diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py index 75ca0e0c026b352aeb40c8d8a17cb4580f2260d9..cd78da964cbfd4670e19768c304dc89b6452926d 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py @@ -193,11 +193,30 @@ class TotalScatteringMergedTest(systemtesting.MantidSystemTest): self.assertAlmostEqual(self.pdf_output.dataY(0)[37], 0.7376667, places=3) -def run_total_scattering(run_number, merge_banks, q_lims=None): +class TotalScatteringPdfTypeTest(systemtesting.MantidSystemTest): + + pdf_output = None + + def runTest(self): + setup_mantid_paths() + # Load Focused ws + mantid.LoadNexus(Filename=total_scattering_input_file, OutputWorkspace='98533-Results-TOF-Grp') + q_lims = np.array([2.5, 3, 4, 6, 7, 3.5, 5, 7, 11, 40]).reshape((2, 5)) + self.pdf_output = run_total_scattering('98533', True, q_lims=q_lims, pdf_type="g(r)") + + def validate(self): + # Whilst total scattering is in development, the validation will avoid using reference files as they will have + # to be updated very frequently. In the meantime, the expected peak in the PDF at ~3.9 Angstrom will be checked. + # After rebin this is at X index 37 + self.assertAlmostEqual(self.pdf_output.dataY(0)[37], 1.0152123, places=3) + + +def run_total_scattering(run_number, merge_banks, q_lims=None, pdf_type="G(r)"): pdf_inst_obj = setup_inst_object(mode="PDF") return pdf_inst_obj.create_total_scattering_pdf(run_number=run_number, merge_banks=merge_banks, - q_lims=q_lims) + q_lims=q_lims, + pdf_type=pdf_type) def _gen_required_files(): diff --git a/docs/source/release/v4.3.0/diffraction.rst b/docs/source/release/v4.3.0/diffraction.rst index 04f25c089a719ede44dcebb04b9673ca7e98df45..7f6623e2a3592072c1289ecfac64511c26a25a23 100644 --- a/docs/source/release/v4.3.0/diffraction.rst +++ b/docs/source/release/v4.3.0/diffraction.rst @@ -18,6 +18,7 @@ Powder Diffraction - The create_total_scattering_pdf merging banks now matches spectra to the spectrum with the largest x range. - The create_total_scattering_pdf merging banks no longer matches spectra with scale, it now only matches with offset. +- The polaris create_total_scattering_pdf function can now accept a `pdf_type` argument to set the pdf_output type. - :ref:`HRPDSlabCanAbsorption <algm-HRPDSlabCanAbsorption-v1>` now accepts any thickness parameter and not those in a specified list. Engineering Diffraction diff --git a/docs/source/techniques/ISISPowder-Polaris-v1.rst b/docs/source/techniques/ISISPowder-Polaris-v1.rst index 9db04cec5a81da305330049982ff24007d07eaea..02106230fd4bdc6ce1610099c2e146c1140d2d8b 100644 --- a/docs/source/techniques/ISISPowder-Polaris-v1.rst +++ b/docs/source/techniques/ISISPowder-Polaris-v1.rst @@ -168,10 +168,11 @@ The *create_total_scattering_pdf* method allows a user to create a Pair Distribu from focused POLARIS data, with a view performing further total scattering analysis. With no merging criteria specified, *merge_banks=False* a PDF will be generated for each bank within -the focused_workspace. If run with *merge_banks=True* a PDF will be generated based on the wighted -sum of the detector banks performed using supplied Q limits *q_lims=q_limits*, Q_limits can be in the -form of a numpy array with shape (2, x) where x is the number rof detectors, or a string containing the -directory of an appropriately formatted `.lim` file. +the focused_workspace. The type of PDF output can be set with the keyword argument `pdf_type`, with the +option of `G(r)`, `g(r)`, `RDF(r)` (defaults to `G(r)`). If run with *merge_banks=True* a PDF will be +generated based on the weighted sum of the detector banks performed using supplied Q limits +*q_lims=q_limits*, Q_limits can be in the form of a numpy array with shape (2, x) where x is the number +of detectors, or a string containing the directory of an appropriately formatted `.lim` file. This function applies the placzek self scattering correction from :ref:CalculatePlaczekSelfScattering <algm-CalculatePlaczekSelfScattering> before calculating the PDF diff --git a/scripts/Diffraction/isis_powder/polaris.py b/scripts/Diffraction/isis_powder/polaris.py index 89b7c365a5a77d7c1c6c4df7f7d09e77278ec2c5..c2454457bbad6a7dd3b1b4103f1ee4738c24a365 100644 --- a/scripts/Diffraction/isis_powder/polaris.py +++ b/scripts/Diffraction/isis_powder/polaris.py @@ -10,6 +10,7 @@ import os from isis_powder.routines import absorb_corrections, common, instrument_settings from isis_powder.abstract_inst import AbstractInst from isis_powder.polaris_routines import polaris_advanced_config, polaris_algs, polaris_param_mapping +from mantid.kernel import logger class Polaris(AbstractInst): @@ -51,6 +52,9 @@ class Polaris(AbstractInst): def create_total_scattering_pdf(self, **kwargs): if 'q_lims' not in kwargs: kwargs['q_lims'] = None + if 'pdf_type' not in kwargs or not kwargs['pdf_type'] in ['G(r)', 'g(r)', 'RDF(r)']: + kwargs['pdf_type'] = 'G(r)' + logger.warning('PDF type not specified or is invalid, defaulting to G(r)') self._inst_settings.update_attributes(kwargs=kwargs) # Generate pdf run_details = self._get_run_details(self._inst_settings.run_number) @@ -61,7 +65,8 @@ class Polaris(AbstractInst): merge_banks=self._inst_settings.merge_banks, q_lims=self._inst_settings.q_lims, cal_file_name=cal_file_name, - sample_details=self._sample_details) + sample_details=self._sample_details, + pdf_type=self._inst_settings.pdf_type) return pdf_output def set_sample_details(self, **kwargs): diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py index a7ef6c233a362286f168bf14129b927dac3fb969..f4ba47b085ac54d39100a5707f1c8060b4f9f852 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py @@ -81,7 +81,7 @@ def save_unsplined_vanadium(vanadium_ws, output_path): def generate_ts_pdf(run_number, focus_file_path, merge_banks=False, q_lims=None, cal_file_name=None, - sample_details=None): + sample_details=None, pdf_type="G(r)"): focused_ws = _obtain_focused_run(run_number, focus_file_path) focused_ws = mantid.ConvertUnits(InputWorkspace=focused_ws, Target="MomentumTransfer", EMode='Elastic') @@ -108,11 +108,11 @@ def generate_ts_pdf(run_number, focus_file_path, merge_banks=False, q_lims=None, q_min, q_max = _load_qlims(q_lims) merged_ws = mantid.MatchAndMergeWorkspaces(InputWorkspaces=focused_ws, XMin=q_min, XMax=q_max, CalculateScale=False) - pdf_output = mantid.PDFFourierTransform(Inputworkspace=merged_ws, InputSofQType="S(Q)-1", PDFType="G(r)", + pdf_output = mantid.PDFFourierTransform(Inputworkspace=merged_ws, InputSofQType="S(Q)-1", PDFType=pdf_type, Filter=True) else: pdf_output = mantid.PDFFourierTransform(Inputworkspace='focused_ws', InputSofQType="S(Q)-1", - PDFType="G(r)", Filter=True) + PDFType=pdf_type, Filter=True) pdf_output = mantid.RebinToWorkspace(WorkspaceToRebin=pdf_output, WorkspaceToMatch=pdf_output[4], PreserveEvents=True) common.remove_intermediate_workspace('self_scattering_correction') diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py index 911791606e04cbf712e75ba7d5304b5ec9c9bdb9..7313731c24644f290eb414ed35e39b3cb5629af4 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py @@ -28,6 +28,7 @@ attr_mapping = [ ParamMapEntry(ext_name="mode", int_name="mode", enum_class=POLARIS_CHOPPER_MODES, optional=True), ParamMapEntry(ext_name="multiple_scattering", int_name="multiple_scattering", optional=True), + ParamMapEntry(ext_name="pdf_type", int_name="pdf_type"), ParamMapEntry(ext_name="q_lims", int_name="q_lims"), ParamMapEntry(ext_name="raw_data_cropping_values", int_name="raw_data_crop_values"), ParamMapEntry(ext_name="run_number", int_name="run_number"),