diff --git a/docs/source/api/python/techniques/ISISPowder-Polaris-v1.rst b/docs/source/api/python/techniques/ISISPowder-Polaris-v1.rst index a5fe1220cd0c364d82857a296f21e50c9e88a846..f2da7a50869fd6582f85c2a9aa31f00289ff3978 100644 --- a/docs/source/api/python/techniques/ISISPowder-Polaris-v1.rst +++ b/docs/source/api/python/techniques/ISISPowder-Polaris-v1.rst @@ -70,7 +70,7 @@ the user enables and will spline the resulting workspace(s) for later focusing. On POLARIS the following parameters are required when executing *create_vanadium*: - :ref:`calibration_mapping_file_polaris_isis-powder-diffraction-ref` -- :ref:`chopper_on_polaris_isis-powder-diffraction-ref` +- :ref:`mode_polaris_isis-powder-diffraction-ref` - :ref:`do_absorb_corrections_polaris_isis-powder-diffraction-ref` - :ref:`first_cycle_run_no_polaris_isis-powder-diffraction-ref` @@ -89,7 +89,7 @@ Example cal_mapping_file = r"C:\path\to\cal_mapping.yaml" polaris_example.create_vanadium(calibration_mapping_file=cal_mapping_file, - chopper_on=True, do_absorb_corrections=True, + mode="PDF", do_absorb_corrections=True, first_cycle_run_no=100, multiple_scattering=False) .. _focus_polaris_isis-powder-diffraction-ref: @@ -102,7 +102,7 @@ focuses and optionally applies corrections if the user has requested them. On POLARIS the following parameters are required when executing *focus*: - :ref:`calibration_mapping_file_polaris_isis-powder-diffraction-ref` -- :ref:`chopper_on_polaris_isis-powder-diffraction-ref` +- :ref:`mode_polaris_isis-powder-diffraction-ref` - :ref:`do_absorb_corrections_polaris_isis-powder-diffraction-ref` - :ref:`do_van_normalisation_polaris_isis-powder-diffraction-ref` - :ref:`input_mode_polaris_isis-powder-diffraction-ref` @@ -133,7 +133,7 @@ Example cal_mapping_file = r"C:\path\to\cal_mapping.yaml" polaris_example.focus(calibration_mapping_file=cal_mapping_file, - chopper_on=True, do_absorb_corrections=False, + mode="Rietveld", do_absorb_corrections=False, file_ext=".s01", input_mode="Individual", run_number="100-110") @@ -184,10 +184,10 @@ substituting the below values for appropriate values: 1-100: label: "1_1" offset_file_name: "offset_file.cal" - chopper_off: + PDF: vanadium_run_numbers: "10" empty_run_numbers: "20" - chopper_on: + Rietveld: vanadium_run_numbers: "30" empty_run_numbers: "40" @@ -202,20 +202,20 @@ Example 1-100: label: "1_1" offset_file_name: "offset_file.cal" - chopper_off: + PDF: vanadium_run_numbers: "10" empty_run_numbers: "20" - chopper_on: + Rietveld: vanadium_run_numbers: "30" empty_run_numbers: "40" 101-: label: "1_2" offset_file_name: "offset_file.cal" - chopper_off: + PDF: vanadium_run_numbers: "110" empty_run_numbers: "120" - chopper_on: + Rietveld: vanadium_run_numbers: "130" empty_run_numbers: "140" @@ -263,11 +263,11 @@ Example Input: # Notice the filename always ends in .yaml polaris_example = Polaris(calibration_mapping_file=r"C:\path\to\file\calibration_mapping.yaml", ...) -.. _chopper_on_polaris_isis-powder-diffraction-ref: +.. _mode_polaris_isis-powder-diffraction-ref: -chopper_on +mode ^^^^^^^^^^ -The chopper state to use in the +The current chopper mode to use in the :ref:`create_vanadium_polaris_isis-powder-diffraction-ref` and :ref:`focus_polaris_isis-powder-diffraction-ref` method. This determines which vanadium and empty run numbers @@ -275,13 +275,15 @@ to use whilst processing. Accepted values are: **True** or **False** +*Note: This parameter is not case sensitive* + Example Input: .. code-block:: python - polaris_example.create_vanadium(chopper_on=True, ...) + polaris_example.create_vanadium(mode="PDF", ...) # Or - polaris.focus(chopper_on=False, ...) + polaris_example.focus(mode="Rietveld", ...) .. _config_file_polaris_isis-powder-diffraction-ref: diff --git a/docs/source/api/python/techniques/ISISPowder-Tutorials.rst b/docs/source/api/python/techniques/ISISPowder-Tutorials.rst index f5eb6f20f605c96951bcfb9dbd051dd1f6fb2092..bad9ae6ebdcc7586923affe061506697f89c4113 100644 --- a/docs/source/api/python/techniques/ISISPowder-Tutorials.rst +++ b/docs/source/api/python/techniques/ISISPowder-Tutorials.rst @@ -211,7 +211,7 @@ found for each individual instrument in the reference document: How objects hold state in ISIS Powder ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Additionally as the objects hold state we can set a parameter -anywhere. For example on Polaris that have a *chopper_on* indicates +anywhere. For example on Polaris the *mode* indicates the chopper state for this/these run(s). This can either be set when we create the object like this: @@ -219,7 +219,7 @@ when we create the object like this: from isis_powder import Polaris - a_pol_obj = Polaris(chopper_on=True, ....) + a_pol_obj = Polaris(mode="PDF", ....) a_pol_obj.create_vanadium(...) Or set whilst calling a method like this: @@ -229,7 +229,7 @@ Or set whilst calling a method like this: from isis_powder import Polaris a_pol_obj = Polaris(...) - a_pol_obj.create_vanadium(chopper_on=True, ...) + a_pol_obj.create_vanadium(mode="PDF", ...) Both of the above are equivalent. Additionally if we change the value the scripts will warn us. This can be demonstrated with the following @@ -239,14 +239,14 @@ example: from isis_powder import Polaris - a_pol_obj = Polaris(chopper_on=True, ...) + a_pol_obj = Polaris(mode="PDF", ...) # The following line will warn us we changed the chopper - # status from True to False. It will also remain False - # from now on - a_pol_obj.create_vanadium(chopper_on=False, ...) + # status from PDF to Rietveld. It will also remain + # in Rietveld mode from now on till we change it again + a_pol_obj.create_vanadium(mode="Rietveld", ...) - # Chopper_on is still False on the following line + # Mode is still Rietveld on the following line a_pol_obj.create_vanadium(...) For these reasons it is recommended to create multiple objects @@ -256,13 +256,13 @@ when you need to switch between different settings within a script: from isis_powder import Polaris - pol_chopper_on = Polaris(chopper_on=True, ...) - pol_chopper_off = Polaris(chopper_on=False, ...) + pol_PDF = Polaris(mode="PDF", ...) + pol_Rietveld = Polaris(mode="Rietveld", ...) - # Runs with chopper on: - pol_chopper_on.create_vanadium(...) - # Runs with chopper off: - pol_chopper_off.create_vanadium(...) + # Runs with the chopper set to PDF mode: + pol_PDF.create_vanadium(...) + # Runs with the chopper set to Rietveld mode: + pol_Rietveld.create_vanadium(...) .. _creating_first_vanadium_run_isis-powder-diffraction-ref: @@ -287,12 +287,12 @@ For Polaris we require the following parameters in addition to the parameters discussed to create the object (see :ref:`creating_inst_object_isis-powder-diffraction-ref`): -- *chopper_on* - Indicates what the chopper state was for this run +- *do_absorb_corrections* - Indicates whether to account for absorption when processing + the vanadium data. It is recommended to have this set to *True* - *first_cycle_run_no* - Used to determine which cycle to create a vanadium for. For example on a cycle with runs 100-120 this value can be any value from 100-120 (e.g. 111) -- *do_absorb_corrections* - Indicates whether to account for absorption when processing - the vanadium data. It is recommended to have this set to *True* +- *mode* - Indicates what the chopper state was for this run - *multiple_scattering* - Indicates whether to account for the effects of multiple scattering. For the tutorial it is highly **recommended to set this to False** as it will increase the script run time from seconds to 10-30 minutes. @@ -309,9 +309,9 @@ the correct cycle is selected for the *first_cycle_run_no* input. # This should be set from the previous tutorial. a_pol_obj = Polaris(....) - a_pol_obj.create_vanadium(chopper_on=False, - first_cycle_run_no=98533, + a_pol_obj.create_vanadium(first_cycle_run_no=98533, do_absorb_corrections=True, + mode="Rietveld", multiple_scattering=False) Executing the above should now successfully process the vanadium run, @@ -349,23 +349,24 @@ instrument reference document: To focus the Si sample included in the ISIS data set we require the following parameters: -- *chopper_on* - Indicates what the chopper state was for this run +- *do_absorb_corrections* - This will be covered in a later tutorial + it determines whether to perform sample absorption corrections on + instruments which support this correction. For this tutorial please + ensure it is set to *False* +- *do_van_normalisation* - Determines whether to divide the data + set by the processed vanadium splines. This should be set to + *True*. - *input_mode* - Some instruments will not have this (in which case the data will always be summed). Acceptable values are **Individual** or **Summed**. When set to individual each run will be loaded and processed separately, in summed all runs specified will be summed. +- *mode* - Indicates what the chopper state was for this run ("Rietveld") - *run_number* - The run number or range of run numbers. This can either be a string or integer (plain number). For example *"100-105, 107, 109-111"* will process 100, 101, 102..., 105, 107, 109, 110, 111. -- *do_absorb_corrections* - This will be covered in a later tutorial - it determines whether to perform sample absorption corrections on - instruments which support this correction. For this tutorial please - ensure it is set to *False* -- *do_van_normalisation* - Determines whether to divide the data - set by the processed vanadium splines. This should be set to - *True*. + For this tutorial the run number will be 98533, and *input_mode* will not affect the result as it is a single run. Additionally in @@ -377,8 +378,8 @@ the example data you could focus 98534 (YAG sample) too. # This should be set from the previous tutorial. a_pol_obj = Polaris(....) - a_pol_obj.focus(chopper_on=False, - input_mode="Individual", run_number=98533, + a_pol_obj.focus(input_mode="Individual", run_number=98533, + mode="Rietveld", do_absorb_corrections=False, do_van_normalisation=True) diff --git a/scripts/Diffraction/isis_powder/polaris_routines/Examples/polaris_cycle_map_example.yaml b/scripts/Diffraction/isis_powder/polaris_routines/Examples/polaris_cycle_map_example.yaml index 6225c8c613f0351ea556aa417d9190f77b4a0f8e..66773019ab2ea484b4946d5622e316b36bf1ccf8 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/Examples/polaris_cycle_map_example.yaml +++ b/scripts/Diffraction/isis_powder/polaris_routines/Examples/polaris_cycle_map_example.yaml @@ -5,11 +5,11 @@ 78334-82415: offset_file_name : "offsets_2011_cycle111b.cal" label : "15_2" - chopper_on: + PDF: vanadium_run_numbers : "78338" empty_run_numbers : "78339" - chopper_off: + Rietveld: vanadium_run_numbers : "78338" empty_run_numbers : "78339" @@ -18,6 +18,6 @@ # Calibration run offset_file_name : "cycle_16_5_silicon_all_spectra.cal" label : "17_1" - chopper_off: + Rietveld: vanadium_run_numbers : "98532" empty_run_numbers : "98531" diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py index 1281eafe1d8121aaf3ec258f486ccb5af51ddeb3..463ad022e689d379068898463ba8171e391eb363 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py @@ -19,40 +19,31 @@ def calculate_van_absorb_corrections(ws_to_correct, multiple_scattering): def get_run_details(run_number_string, inst_settings, is_vanadium_run): - # Get the chopper mode as vanadium and empty run numbers depend on different modes - chopper_config_callable = CustomFuncForRunDetails().\ - add_to_func_chain(user_function=RunDetailsWrappedCommonFuncs.get_cal_mapping_dict, - run_number_string=run_number_string, inst_settings=inst_settings).\ - add_to_func_chain(user_function=polaris_get_chopper_config, inst_settings=inst_settings) + cal_mapping_callable = CustomFuncForRunDetails().add_to_func_chain( + user_function=RunDetailsWrappedCommonFuncs.get_cal_mapping_dict, run_number_string=run_number_string, + inst_settings=inst_settings + ).add_to_func_chain(user_function=polaris_get_chopper_config, inst_settings=inst_settings) - # Then use the results to set the empty and vanadium runs - err_message = "this must be under the relevant chopper_on / chopper_off section." + # Get empty and vanadium + err_message = "this must be under the relevant Rietveld or PDF mode." - empty_runs_callable = chopper_config_callable.add_to_func_chain( - RunDetailsWrappedCommonFuncs.cal_dictionary_key_helper, - key="empty_run_numbers", append_to_error_message=err_message) - - vanadium_runs_callable = chopper_config_callable.add_to_func_chain( - RunDetailsWrappedCommonFuncs.cal_dictionary_key_helper, key="vanadium_run_numbers", + empty_run_callable = cal_mapping_callable.add_to_func_chain( + user_function=RunDetailsWrappedCommonFuncs.cal_dictionary_key_helper, key="empty_run_numbers", append_to_error_message=err_message) - run_details = create_run_details_object(run_number_string=run_number_string, inst_settings=inst_settings, - empty_run_call=empty_runs_callable, is_vanadium_run=is_vanadium_run, - vanadium_run_call=vanadium_runs_callable) + vanadium_run_callable = cal_mapping_callable.add_to_func_chain( + user_function=RunDetailsWrappedCommonFuncs.cal_dictionary_key_helper, key="vanadium_run_numbers", + append_to_error_message=err_message) - return run_details + return create_run_details_object(run_number_string=run_number_string, inst_settings=inst_settings, + is_vanadium_run=is_vanadium_run, empty_run_call=empty_run_callable, + vanadium_run_call=vanadium_run_callable) def polaris_get_chopper_config(forwarded_value, inst_settings): - # The previous result is a cal_mapping + # Forwarded value should be a cal mapping cal_mapping = forwarded_value - - if inst_settings.chopper_on: - chopper_config = common.cal_map_dictionary_key_helper(cal_mapping, "chopper_on") - else: - chopper_config = common.cal_map_dictionary_key_helper(cal_mapping, "chopper_off") - - return chopper_config + return common.cal_map_dictionary_key_helper(cal_mapping, inst_settings.mode) def process_vanadium_for_focusing(bank_spectra, mask_path, spline_number): diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py new file mode 100644 index 0000000000000000000000000000000000000000..67125b1aca3c3de6723e41ec2d042cda5b541959 --- /dev/null +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py @@ -0,0 +1,7 @@ +from __future__ import (absolute_import, division, print_function) + + +class POLARIS_CHOPPER_MODES(object): + enum_friendly_name = "Polaris chopper modes" + PDF = "PDF" + Rietveld = "Rietveld" 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 829a95b2885a72a895bc51994040e6f712a6b188..8bafc9756e75a42560bfc6bf59090efa6ccb3baa 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py @@ -2,13 +2,14 @@ from __future__ import (absolute_import, division, print_function) from isis_powder.routines.param_map_entry import ParamMapEntry from isis_powder.routines.common_enums import INPUT_BATCHING +from isis_powder.polaris_routines.polaris_enums import POLARIS_CHOPPER_MODES # Maps friendly user name (ext_name) -> script name (int_name) attr_mapping = \ [ ParamMapEntry(ext_name="calibration_directory", int_name="calibration_dir"), ParamMapEntry(ext_name="calibration_mapping_file", int_name="cal_mapping_path"), - ParamMapEntry(ext_name="chopper_on", int_name="chopper_on"), + ParamMapEntry(ext_name="config_file", int_name="config_file"), ParamMapEntry(ext_name="do_absorb_corrections", int_name="do_absorb_corrections"), ParamMapEntry(ext_name="do_van_normalisation", int_name="do_van_normalisation"), @@ -19,6 +20,7 @@ attr_mapping = \ ParamMapEntry(ext_name="grouping_file_name", int_name="grouping_file_name"), ParamMapEntry(ext_name="input_mode", int_name="input_mode", enum_class=INPUT_BATCHING), ParamMapEntry(ext_name="masking_file_name", int_name="masking_file_name"), + ParamMapEntry(ext_name="mode", int_name="mode", enum_class=POLARIS_CHOPPER_MODES), ParamMapEntry(ext_name="multiple_scattering", int_name="multiple_scattering"), ParamMapEntry(ext_name="raw_data_cropping_values", int_name="raw_data_crop_values"), ParamMapEntry(ext_name="run_number", int_name="run_number"),