Skip to content
Snippets Groups Projects
Commit 5ec7d187 authored by Loïc Le Guyader's avatar Loïc Le Guyader
Browse files

Merge branch 'combine_runs' into 'master'

Adds function to concatenate runs along trainId dimension

See merge request SCS/ToolBox!50
parents a2f524ed e5a2d407
No related branches found
No related tags found
No related merge requests found
...@@ -449,3 +449,22 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False, ...@@ -449,3 +449,22 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False,
result.attrs['run'] = run result.attrs['run'] = run
result.attrs['runFolder'] = runFolder result.attrs['runFolder'] = runFolder
return result return result
def concatenateRuns(runs):
""" Concatenate a list of two runs with identical data variables along the
trainId dimension.
Input:
runs: (list) the xarray Datasets to concatenate
Output:
a concatenated xarray Dataset
"""
keys = sorted(runs[0].keys())
for run in runs[1:]:
if sorted(run.keys()) != keys:
print('data fields between different runs are not identical. Cannot combine runs.')
return
result = xr.concat(runs, dim='trainId')
result = result.sortby(result.trainId)
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment