From a70f9cd79bcf9347314e01f0aff235677b3c3fe5 Mon Sep 17 00:00:00 2001
From: Laurent Mercadier <laurent.mercadier@xfel.eu>
Date: Mon, 15 Jul 2024 13:30:21 +0200
Subject: [PATCH] Keep using subFolder in load function

---
 src/toolbox_scs/load.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/toolbox_scs/load.py b/src/toolbox_scs/load.py
index 3aa0c0d..ee7b3f7 100644
--- a/src/toolbox_scs/load.py
+++ b/src/toolbox_scs/load.py
@@ -39,6 +39,7 @@ log = logging.getLogger(__name__)
 
 def load(proposalNB=None, runNB=None,
          fields=None,
+         subFolder='all',
          display=False,
          validate=False,
          subset=None,
@@ -66,6 +67,10 @@ def load(proposalNB=None, runNB=None,
         {"extra": {'source': 'SCS_CDIFFT_MAG/SUPPLY/CURRENT',
                    'key': 'actual_current.value',
                    'dim': None}}
+    subFolder: str
+        'raw', 'proc' (processed) or 'all' (both 'raw' and 'proc') to access
+        data from either or both of those folders. If 'all' is used, sources
+        present in 'proc' overwrite those in 'raw'. The default is 'raw'.
     display: bool
         whether to show the run.info or not
     validate: bool
@@ -93,6 +98,7 @@ def load(proposalNB=None, runNB=None,
     bunchPattern: str
         bunch pattern used to extract the Fast ADC pulses.
         A string or a dict as in::
+
         {'FFT_PD2': 'sase3', 'ILH_I0': 'scs_ppl'}
 
         Ignored if extract_digitizers=False.
@@ -113,8 +119,9 @@ def load(proposalNB=None, runNB=None,
     >>> run, data = tb.load(2212, 208, ['SCS_SA3', 'MCP2apd', 'nrj'])
 
     """
-    runFolder = find_run_path(proposalNB, runNB, 'raw')
-    run = ed.open_run(proposalNB, runNB, data='all', parallelize=parallelize)
+    run = ed.open_run(proposalNB, runNB, data=subFolder, parallelize=parallelize)
+    subFolder = 'raw' if subFolder == 'all' else subFolder
+    runFolder = find_run_path(proposalNB, runNB, subFolder)
     if subset is not None:
         run = run.select_trains(subset)
     if fields is None:
-- 
GitLab