diff --git a/Load.py b/Load.py index 40ae72ddb06696b323f368b4720a6a408c3e9984..62ec295c9db1d8ad071b14a16634d352809c0fec 100644 --- a/Load.py +++ b/Load.py @@ -449,3 +449,22 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False, result.attrs['run'] = run result.attrs['runFolder'] = runFolder 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