Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
ToolBox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Kluyver
ToolBox
Commits
66969e22
Commit
66969e22
authored
5 years ago
by
Laurent Mercadier
Browse files
Options
Downloads
Patches
Plain Diff
Concatenate: simplifies sorting and add attrs of each run
parent
61e4a8d5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Load.py
+10
-6
10 additions, 6 deletions
Load.py
with
10 additions
and
6 deletions
Load.py
+
10
−
6
View file @
66969e22
...
@@ -453,7 +453,7 @@ def load(fields, runNB, proposalNB, subFolder='raw', display=False, validate=Fal
...
@@ -453,7 +453,7 @@ def load(fields, runNB, proposalNB, subFolder='raw', display=False, validate=Fal
return
result
return
result
def
concatenateRuns
(
runs
):
def
concatenateRuns
(
runs
):
"""
C
oncatenate a list of
two
runs with identical data variables along the
"""
Sorts and c
oncatenate a list of runs with identical data variables along the
trainId dimension.
trainId dimension.
Input:
Input:
...
@@ -461,12 +461,16 @@ def concatenateRuns(runs):
...
@@ -461,12 +461,16 @@ def concatenateRuns(runs):
Output:
Output:
a concatenated xarray Dataset
a concatenated xarray Dataset
"""
"""
keys
=
sorted
(
runs
[
0
].
keys
())
firstTid
=
{
i
:
int
(
run
.
trainId
[
0
].
values
)
for
i
,
run
in
enumerate
(
runs
)}
for
run
in
runs
[
1
:]:
orderedDict
=
dict
(
sorted
(
firstTid
.
items
(),
key
=
lambda
t
:
t
[
1
]))
if
sorted
(
run
.
keys
())
!=
keys
:
orderedRuns
=
[
runs
[
i
]
for
i
in
orderedDict
]
keys
=
orderedRuns
[
0
].
keys
()
for
run
in
orderedRuns
[
1
:]:
if
run
.
keys
()
!=
keys
:
print
(
'
data fields between different runs are not identical. Cannot combine runs.
'
)
print
(
'
data fields between different runs are not identical. Cannot combine runs.
'
)
return
return
result
=
xr
.
concat
(
runs
,
dim
=
'
trainId
'
)
result
=
xr
.
concat
(
orderedRuns
,
dim
=
'
trainId
'
)
result
=
result
.
sortby
(
result
.
trainId
)
result
.
attrs
[
'
run
'
]
=
[
run
.
attrs
[
'
run
'
]
for
run
in
orderedRuns
]
result
.
attrs
[
'
runFolder
'
]
=
[
run
.
attrs
[
'
runFolder
'
]
for
run
in
orderedRuns
]
return
result
return
result
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment