From e651b64b9cc2d823041fa1463a666b1e9eeaff9d Mon Sep 17 00:00:00 2001 From: jochenstahn Date: Wed, 11 Sep 2024 18:22:39 +0200 Subject: [PATCH] introduced underillumination option --- libeos/command_line.py | 8 ++++---- libeos/options.py | 4 ++-- libeos/reduction.py | 14 +++++++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libeos/command_line.py b/libeos/command_line.py index d92f788..22152f7 100644 --- a/libeos/command_line.py +++ b/libeos/command_line.py @@ -24,9 +24,9 @@ def commandLineArgs(): default = Defaults.normalisationFileIdentifier, nargs = '+', help = "file number(s) of normalisation measurement") - #input_data.add_argument("-nm", "--normalisationMethod", - # default = Defaults.normalisationMethod, - # help = "normalisation method: overillumination, underillumination, direct_beam") + input_data.add_argument("-nm", "--normalisationMethod", + default = Defaults.normalisationMethod, + help = "normalisation method: [o]verillumination, [u]nderillumination, [d]irect_beam") input_data.add_argument("--raw", type = str, default = Defaults.raw, @@ -198,7 +198,7 @@ def command_line_options(): scale = clas.scale, subtract = clas.subtract, normalisationFileIdentifier = clas.normalisationFileIdentifier, - #normalisationMethod = clas.normalisationMethod, + normalisationMethod = clas.normalisationMethod, timeSlize = clas.timeSlize, ) output_config = OutputConfig( diff --git a/libeos/options.py b/libeos/options.py index daf9a67..943fec8 100644 --- a/libeos/options.py +++ b/libeos/options.py @@ -12,7 +12,7 @@ class Defaults: raw = ['.', './raw', '../raw', '../../raw'] year = datetime.now().year normalisationFileIdentifier = [] - #normalisationMethod = 'overillumination' + normalisationMethod = 'o' # subtract outputName = "fromEOS" outputFormat = ['Rqz.ort'] @@ -60,6 +60,7 @@ class ExperimentConfig: @dataclass class ReductionConfig: + normalisationMethod: str qResolution: float qzRange: Tuple[float, float] thetaRange: Tuple[float, float] @@ -71,7 +72,6 @@ class ReductionConfig: autoscale: Optional[Tuple[bool, bool]] = None subtract: Optional[str] = None normalisationFileIdentifier: Optional[list] = None - #normalisationMethod: str timeSlize: Optional[list] = None @dataclass diff --git a/libeos/reduction.py b/libeos/reduction.py index dee7ddb..6025b78 100644 --- a/libeos/reduction.py +++ b/libeos/reduction.py @@ -408,7 +408,19 @@ class AmorReduction: int_lz = np.where(mask_lz, int_lz, np.nan) thetaF_lz = np.where(mask_lz, alphaF_lz, np.nan) - ref_lz = (int_lz * np.absolute(thetaN_lz)) / (norm_lz * np.absolute(thetaF_lz)) * self.normMonitor + print(self.reduction_config.normalisationMethod) + if self.reduction_config.normalisationMethod == 'o': + logging.debug(' assuming an overilluminated sample and correcting for the angle of incidence') + ref_lz = (int_lz * np.absolute(thetaN_lz)) / (norm_lz * np.absolute(thetaF_lz)) * self.normMonitor + elif self.reduction_config.normalisationMethod == 'u': + logging.debug(' assuming an underilluminated sample and ignoring the angle of incidence') + ref_lz = (int_lz / norm_lz) * self.normMonitor + elif self.reduction_config.normalisationMethod == 'u': + logging.debug(' assuming direct beam for normalisation an underilluminated sample and ignoring the angle of incidence') + ref_lz = (int_lz / norm_lz) * self.normMonitor + else: + logging.debug('unknown normalisation method! Use [u], [o] or [d]') + ref_lz = (int_lz * np.absolute(thetaN_lz)) / (norm_lz * np.absolute(thetaF_lz)) * self.normMonitor err_lz = ref_lz * np.sqrt( 1/(int_lz+.1) + 1/norm_lz ) res_lz = np.ones((np.shape(lamda_l[:-1])[0], np.shape(alphaF_z)[0])) * 0.022**2