diff --git a/scripts/Inelastic/Direct/ReductionWrapper.py b/scripts/Inelastic/Direct/ReductionWrapper.py index 804511d4bf6bc2d0a6c6e751a48ed6f2e1e32778..2a8ea37df779c22f709387636914ffa305299379 100644 --- a/scripts/Inelastic/Direct/ReductionWrapper.py +++ b/scripts/Inelastic/Direct/ReductionWrapper.py @@ -251,7 +251,22 @@ class ReductionWrapper(object): return None def evaluate_abs_corrections(self,test_ws,spectra_to_correct): - """ Evaluate absorption corrections from the """ + """ Evaluate absorption corrections from the input workspace + Input: + test_ws -- the workspace to calculate corrections for. + The corrections themselves should be defined by + the following data reduction properties: + propmen.correct_absorption_on = TheShapeOfTheSample -- define sample parameters + propmen.abs_corr_info = {} Dictionary with additional correction parameters + (can be empty) + spectra_to_correct -- list of the spectra to correct absorption for. + If this list is empty, the corrections are calculated for the whole workspace, + which can cause problems for plotting. + + Returns: + corrections -- the workspace containing the absorption corrections + for the spectra, specified in spectra_to_correct variable. + """ n_spectra = test_ws.getNumberHistograms() decrement = len(spectra_to_correct) diff --git a/scripts/test/MariReduction.py b/scripts/test/MariReduction.py index 0c9c71c8b2c9d51fe7ea43d84e5ec8f940d02c66..72a8082ca46f60856266de9acd40f8ad3ea11d9e 100644 --- a/scripts/test/MariReduction.py +++ b/scripts/test/MariReduction.py @@ -75,11 +75,12 @@ class ReduceMARI(ReductionWrapper): # #Two generic algorithms are currently available to # correct for absorption: - # a) AbsorptionCorrections (invoked by 'is_fast':True key of - # abs_corr_info property and by default). + # a) MonteCarloAbsorption (invoked by 'is_mc':True key of abs_corr_info + # property and by default) # and - # b) MonteCarloAbsorption (invoked by 'is_mc':True key of abs_corr_info - # property) + # b) AbsorptionCorrections (invoked by 'is_fast':True key of + # abs_corr_info property). This algorithm has number of optimizations + # for the special shapes cases and need further scientific validations # All other properties, to be provided in the input dictionary of this # property are the non-sample related properties of the @@ -249,15 +250,19 @@ class ReduceMARI(ReductionWrapper): # (or be reduced) if test_ws is None: test_ws = PropertyManager.sample_run.get_workspace() - # Define spectra list to test absorption on + # Define spectra list to test absorption on. Empty list will + # define absorption on the whole workspace. check_spectra = [1,200] # Evaluate corrections on the selected spectra of the workspace and the time to obtain # the corrections on the whole workspace. corrections,time_to_correct_abs = self.evaluate_abs_corrections(test_ws,check_spectra) # When accuracy and speed of the corrections is satisfactory, copy chosen abs_corr_info # properties from above to the advanced_porperties area to run in reduction. - if not mpl is None: - mpl.plotSpectrum(corrections,range(0,len(check_spectra))) + if mpl is not None: + n_spectra = len(check_spectra) + if n_spectra == 0: + n_specra = corrections.getNumberHistograms() + mpl.plotSpectrum(corrections,range(0,n_spectra)) # return corrections diff --git a/scripts/test/ReductionWrapperTest.py b/scripts/test/ReductionWrapperTest.py index 800b73fa1cdc4003f3e333a0ddd3c3120c2dd686..377fd94a020879e97403b918bbc829416f1019fe 100644 --- a/scripts/test/ReductionWrapperTest.py +++ b/scripts/test/ReductionWrapperTest.py @@ -130,8 +130,8 @@ class ReductionWrapperTest(unittest.TestCase): import reduce_vars as rv - self.assertEqual(rv.standard_vars,main_prop) - self.assertEqual(rv.advanced_vars,adv_prop) + self.assertDictEqual(rv.standard_vars,main_prop) + self.assertDictEqual(rv.advanced_vars,adv_prop) self.assertTrue(hasattr(rv,'variable_help')) imp.reload(mr)