diff --git a/eos/file_reader.py b/eos/file_reader.py index 98cf94a..598647e 100644 --- a/eos/file_reader.py +++ b/eos/file_reader.py @@ -327,6 +327,8 @@ class AmorEventData: # return a new dataset with just events that occured in given time slice if not 'wallTime' in self.data.events.dtype.names: raise ValueError("This dataset is missing a wallTime that is required for time slicing") + # convert from seconds to epoch integer values + start , end = start*1e9, end*1e9 event_filter = self.data.events.wallTime>=start event_filter &= self.data.events.wallTime=start diff --git a/eos/projection.py b/eos/projection.py index 3536eab..e6a7c5b 100644 --- a/eos/projection.py +++ b/eos/projection.py @@ -40,8 +40,10 @@ class ProjectedReflectivity: scale = (self.R[filter_q]/self.dR[filter_q]).sum()/(self.R[filter_q]**2/self.dR[filter_q]).sum() self.scale(scale) logging.info(f' scaling factor = {scale}') + return scale else: logging.warning(' automatic scaling not possible') + return 1.0 def stitch(self, other: 'ProjectedReflectivity'): # find scaling factor between two reflectivities at points both are not zero @@ -56,8 +58,10 @@ class ProjectedReflectivity: scale = (R1**2*R2**2/(dR1**2*dR2**2)).sum() / (R1**3*R2/(dR1**2*dR2**2)).sum() self.scale(scale) logging.info(f' scaling factor = {scale}') + return scale else: logging.warning(' automatic scaling not possible') + return 1.0 def subtract(self, R, dR): # subtract another dataset with same q-points diff --git a/eos/reduction.py b/eos/reduction.py index 8e14e67..3a2a6ec 100644 --- a/eos/reduction.py +++ b/eos/reduction.py @@ -148,11 +148,13 @@ class AmorReduction: if self.reduction_config.timeSlize: - self.read_timeslices(i) + if i>0: + logging.warning(" time slizing should only be used for on set of datafiles, check parameters") + self.analyze_timeslices(i) else: - self.read_unsliced(i) + self.analyze_unsliced(i) - def read_unsliced(self, i): + def analyze_unsliced(self, i): self.monitor = np.sum(self.dataset.data.pulses.monitor) logging.warning(f' monitor = {self.monitor:8.2f} {MONITOR_UNITS[self.experiment_config.monitorType]}') @@ -228,8 +230,7 @@ class AmorReduction: self.datasetsRlt.append(orso_data) j += 1 - def read_timeslices(self, i): - # TODO: warn when using multiple short_codes + def analyze_timeslices(self, i): wallTime_e = np.float64(self.dataset.data.events.wallTime)/1e9 pulseTimeS = np.float64(self.dataset.data.pulses.time)/1e9 interval = self.reduction_config.timeSlize[0] @@ -261,10 +262,14 @@ class AmorReduction: result = proj.project_on_qz() if self.reduction_config.autoscale: - if i==0: - result.autoscale(self.reduction_config.autoscale) + # scale every slice the same + if ti==0: + if i==0: + atscale = result.autoscale(self.reduction_config.autoscale) + else: + atscale = result.stitch(self.last_result) else: - result.stitch(self.last_result) + result.scale(atscale) if self.subtract: if len(result.Q)==len(self.sq_q):