From 19f1c6e6e8d45602adaa9316cf798be8d111513d Mon Sep 17 00:00:00 2001
From: BenVK <BenVanKuiken@gmail.com>
Date: Fri, 8 Sep 2023 15:35:26 +0200
Subject: [PATCH] Added flag to from_run method to discard first frame for
 proper normalization

---
 src/toolbox_scs/detectors/hrixs.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py
index 2ee5802..698da4a 100644
--- a/src/toolbox_scs/detectors/hrixs.py
+++ b/src/toolbox_scs/detectors/hrixs.py
@@ -266,10 +266,14 @@ class hRIXS:
                       'bins', 'method', 'fields')
         return {param: getattr(self, param.upper()) for param in params}
 
-    def from_run(self, runNB, proposal=None, extra_fields=()):
+    def from_run(self, runNB, proposal=None, extra_fields=(), drop_first=False):
         """load a run
 
         Load the run `runNB`. A thin wrapper around `toolbox.load`.
+        Parameters
+        ----------
+            drop_first: bool
+                if True, the first image in the run is removed from the dataset.
 
         Example
         -------
@@ -284,7 +288,8 @@ class hRIXS:
             proposal = self.PROPOSAL
         run, data = tb.load(proposal, runNB=runNB,
                             fields=self.FIELDS + list(extra_fields))
-
+        if drop_first is True:
+            data = data.isel(trainId=slice(1, None))
         return data
 
     def load_dark(self, runNB, proposal=None):
-- 
GitLab