From 903c1a3f51cf9c4a533fecf6b7542e85aabea692 Mon Sep 17 00:00:00 2001 From: Philip Mousley Date: Fri, 10 Jan 2025 10:06:48 +0000 Subject: [PATCH] add in option to save unnormalised intensity --- src/islatu/data.py | 13 +++++++++++++ src/islatu/runner.py | 11 +++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/islatu/data.py b/src/islatu/data.py index 7397c0d..267667d 100644 --- a/src/islatu/data.py +++ b/src/islatu/data.py @@ -81,6 +81,19 @@ def reflectivity_e(self) -> np.array: intensity array. """ return self.intensity_e/np.amax(self.intensity) + @property + def reflectivity_nonorm(self) -> np.array: + """ + Returns the intensity, unnormalised + """ + return self.intensity + + @property + def reflectivity_e_nonorm(self) -> np.array: + """ + Returns the errors on the intensity, unnormalised + """ + return self.intensity_e @property def q_vectors(self) -> np.array: diff --git a/src/islatu/runner.py b/src/islatu/runner.py index 0a95399..62355ed 100644 --- a/src/islatu/runner.py +++ b/src/islatu/runner.py @@ -140,7 +140,7 @@ def __init__(self, software=Software(), input_files=None, data_state=DataState(), parser=io.i07_nxs_parser, crop_function=cropping.crop_to_region, crop_kwargs=None, bkg_function=background.fit_gaussian_1d, bkg_kwargs=None, - dcd_normalisation=None, sample_size=None, beam_width=None,overwrite_transmission=None): + dcd_normalisation=None, sample_size=None, beam_width=None,overwrite_transmission=None,normalisation=True): if input_files is None: input_files = [] self.software = software @@ -155,6 +155,7 @@ def __init__(self, software=Software(), input_files=None, self.sample_size = sample_size self.beam_width = beam_width self.overwrite_transmission=overwrite_transmission + self.normalisation=normalisation class Data: @@ -258,6 +259,9 @@ def setup(self, recipe): self.reduction.bkg_kwargs = recipe['background']['kwargs'] if 'transmission' in keys: self.reduction.overwrite_transmission=recipe['transmission']['values'] + + if 'normalisation' in keys: + self.reduction.normalisation=recipe['normalisation']['maxnorm'] # Populate the setup information if 'setup' in keys: if 'dcd normalisation' in recipe['setup'].keys(): @@ -493,7 +497,10 @@ def i07reduce(run_numbers, yaml_file, directory='/dls/{}/data/{}/{}/', # Prepare the data array. - data = np.array([refl.q_vectors, refl.reflectivity, refl.reflectivity_e]).T + if the_boss.reduction.normalisation==True: + data = np.array([refl.q_vectors, refl.reflectivity, refl.reflectivity_e]).T + elif the_boss.reduction.normalisation==False: + data = np.array([refl.q_vectors, refl.reflectivity_nonorm, refl.reflectivity_e_nonorm]).T debug.log("XRR reduction completed.", unimportance=2) # Work out where to save the file.