From 42842112123e073512531842359d87e50bca86af Mon Sep 17 00:00:00 2001
From: Laurent Mercadier <laurent.mercadier@xfel.eu>
Date: Tue, 22 Oct 2019 12:24:14 +0200
Subject: [PATCH] Adds function to concatenate runs along trainId dimension

---
 Load.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Load.py b/Load.py
index 40ae72d..b3adaeb 100644
--- a/Load.py
+++ b/Load.py
@@ -449,3 +449,20 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False,
     result.attrs['run'] = run
     result.attrs['runFolder'] = runFolder
     return result
+
+def concatenateRuns(runs):
+    """ Concatenate two runs with identical data variables along the trainId dimension
+        Input:
+            runs: (list) the xarray Datasets to concatenate
+        Output:
+            a concatenated xarray Dataset
+    """
+    keys = runs[0].keys()
+    for run in runs[1:]:
+        if 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
-- 
GitLab