Table of Contents
This method assumes you are familiar with the concept of objects in Python. If not more details can be read here: A quick introduction to objects
To create a PEARL object the following parameters are required:
Optionally a configuration file may be specified if one exists using the following parameter:
See Using configuration files on YAML configuration files for more details
from isis_powder import Pearl
calibration_dir = r"C:\path\to\calibration_dir"
output_dir = r"C:\path\to\output_dir"
pearl_example = Pearl(calibration_directory=calibration_dir,
output_directory=output_dir,
user_name="Mantid")
# Optionally we could provide a configuration file like so
# Notice how the file name ends with .yaml
config_file_path = r"C:\path\to\config_file.yaml
pearl_example = Pearl(config_file=config_file_path,
user_name="Mantid", ...)
The following methods can be executed on a PEARL object:
For information on creating a PEARL object see: Creating PEARL Object
The create_vanadium method allows a user to process a vanadium run. Whilst processing the vanadium run the scripts can apply any corrections the user enables and will spline the resulting workspace(s) for later focusing.
On PEARL the following parameters are required when executing create_vanadium:
The focus method processes the user specified run(s). It aligns, focuses and optionally applies corrections if the user has requested them.
On PEARL the following parameters are required when executing focus:
The following parameter is required if perform_attenuation is set to True
The following parameters may also be optionally set:
# Notice how the filename ends with .yaml
cal_mapping_file = r"C:\path\to\cal_mapping.yaml"
attenuation_path = r"C:\path\to\attenuation_file"
pearl_example.focus(calibration_mapping_file=cal_mapping_file,
focus_mode="all", long_mode=True,
perform_attenuation=True,
attenuation_file_path=attenuation_path,
run_number="100-110", tt_mode="tt88",
vanadium_normalisation=True)
The create_cal method creates the offset calibration file for PEARL scripts. The following parameters are required:
The PEARL object does not behave as described in How objects hold state in ISIS Powder. For PEARL, any settings given in the constructor for the PEARL object, either explicitly or via a config file, are taken as defaults. If these are overridden in a call to either focus, create_vanadium or create_cal, then these settings only apply to that line, and are reverted to the defaults when the line has finished executing.
The calibration mapping file holds the mapping between run numbers, current label, offset filename and the empty and vanadium numbers.
For more details on the calibration mapping file see: Cycle mapping files
The layout on PEARL should look as follows substituting the example values included for appropriate values:
1-100:
label: "1_1"
offset_file_name: "offset_file.cal"
empty_run_numbers: "10"
vanadium_run_numbers: "20"
The following parameters for PEARL are intended for regular use when using the ISIS Powder scripts.
Required if generate_absorb_corrections is set to True.
The full path to save generated absorption corrects file to.
Note: The path to the file must include the file extension
Example Input:
pearl_example.focus(generate_absorb_corrections=True,
absorb_corrections_out_filename=r"C:\PEARL\pearl_absorb_sphere_17_2.nxs"...)
Required if perform_attenuation is set to True
The full path to the attenuation file to use within the focus method.
The workspace will be attenuated with the specified file if the focus_mode is set to all or trans. For more details see PearlMCAbsorption
Note: The path to the file must include the file extension
Example Input:
pearl_example(attenuation_file_path=r"C:\path\to\attenuation_file.out", ...)
This parameter should be the full path to the calibration folder. Within the folder the following should be present:
The script will also save out vanadium splines into the relevant label folder which are subsequently loaded and used within the focus method.
Example Input:
pearl_example = Pearl(calibration_directory=r"C:\path\to\calibration_dir", ...)
This parameter gives the full path to the YAML file containing the calibration mapping. For more details on this file see: Calibration Mapping File
Note: This should be the full path to the file including extension
Example Input:
# Notice the filename always ends in .yaml
pearl_example = Pearl(calibration_mapping_file=r"C:\path\to\file\calibration_mapping.yaml", ...)
The full path to the YAML configuration file. This file is described in detail here: Using configuration files It is recommended to set this parameter at object creation instead of on a method as it will warn if any parameters are overridden in the scripting window.
Note: This should be the full path to the file including extension
Example Input:
# Notice the filename always ends in .yaml
pearl_example = Pearl(config_file=r"C:\path\to\file\configuration.yaml", ...)
Indicates whether to perform vanadium absorption corrections when calling create_vanadium. If set to True the vanadium absorption file (described here: vanadium_absorb_filename) will be loaded and the vanadium sample will be divided by the pre-calculated absorption corrections.
Accepted values are: True or False
Example Input:
pearl_example.create_vanadium(do_absorb_corrections=True, ...)
Optional
Specifies a file extension to use when using the focus method.
This should be used to process partial runs. When processing full runs (i.e. completed runs) it should not be specified as Mantid will automatically determine the best extension to use.
Note: A leading dot (.) is not required but is preferred for readability
Example Input:
pearl_example.focus(file_ext=".s01", ...)
Determines how the banks are grouped when using the focus method. Each mode is further described below.
Accepted values are: All, Groups, Mods and Trans
In all mode banks 1-9 (inclusive) are summed into a single spectra then scaled down to 1/9 of their original values.
The workspace is also attenuated if perform_attenuation is set to True.
Workspaces containing banks 10-14 are left as separate workspaces with appropriate names.
In groups mode banks 1+2+3, 4+5+6, 7+8+9 are summed into three (3) separate workspaces. Each workspace is scaled down to a 1/3 of original scale.
The workspaces containing banks 4-9 (inclusive) are then added into a separate workspace and scaled down to 1/2 original scale.
Banks 10-14 are left as separate workspaces with appropriate names.
In trans mode banks 1-9 (inclusive) are summed into a single spectra then scaled down to 1/9 original scale.
The workspace is also attenuated if perform_attenuation is set to True.
All banks are also output as individual workspaces with appropriate names with no additional processing applied.
Determines the TOF window to process data in. This affects both the create_vanadium and focus methods.
As this affects the vanadium spline used the create_vanadium method will need to be called once for each long_mode value (True and/or False) if the user intends to use a different mode. This will create a spline for the relevant mode which is automatically used when focusing.
When long_mode is False the TOF window processed is between 0-20,000 μs
When long_mode is True the TOF window processed is between 0-40,000 μs
This also affects the Advanced Parameters used. More detail can be found for each individual parameter listed under the advanced parameters section.
Accepted values are: True or False
Example Input:
pearl_example.create_vanadium(long_mode=False, ...)
# Or
pearl_example.focus(long_mode=True, ...)
Specifies the path to the output directory to save resulting files into. The script will automatically create a folder with the label determined from the calibration_mapping_file and within that create another folder for the current user_name.
Within this folder processed data will be saved out in several formats.
Example Input:
pearl_example = Pearl(output_directory=r"C:\path\to\output_dir", ...)
Indicates whether to perform attenuation corrections whilst running focus. For more details of the corrections performed see: PearlMCAbsorption
If this is set to True attenuation_file_path must be set too.
Note: This correction will only be performed if ‘focus_mode’ is in All or Trans. See: focus_mode for more details.
Accepted values are: True or False
Example Input:
pearl_example.focus(perform_attenuation=True, ...)
Indicates a run from the current cycle to use when calling create_vanadium. This does not have the be the first run of the cycle or the run number corresponding to the vanadium. However it must be in the correct cycle according to the Calibration Mapping File.
Example Input:
# In this example assume we mean a cycle with run numbers 100-200
pearl_example.create_vanadium(run_in_cycle=100, ...)
Specifies the run number(s) to process when calling the focus and create_cal methods.
This parameter accepts a single value or a range of values with the following syntax:
- : Indicates a range of runs inclusive (e.g. 1-10 would process 1, 2, 3....8, 9, 10)
, : Indicates a gap between runs (e.g. 1, 3, 5, 7 would process run numbers 1, 3, 5, 7)
These can be combined like so: 1-3, 5, 8-10 would process run numbers 1, 2, 3, 5, 8, 9, 10.
On Pearl any ranges of runs indicates the runs will be summed before any additional processing takes place. For example a run input of 1, 3, 5 will sum runs 1, 3 and 5 together before proceeding to focus them.
Example Input:
# Sum and process run numbers 1, 3, 5, 6, 7
pearl_example.focus(run_number="1, 3, 5-7", ...)
# Or just a single run
pearl_example.focus(run_number=100, ...)
Optional
This parameter specifies a suffix to append the names of output files during a focus.
Example Input:
pearl_example.focus(suffix="-corr", ...)
Specifies the detectors to be considered from the grouping files. This is used in the create_vanadium and focus methods.
For more details of the grouping file which is selected between see the following:
Accepted values are: tt35, tt70 and tt80
When calling create_vanadium all can be used to implicitly process all of the supported values indicated above.
Example Input:
pearl_example.create_vanadium(tt_mode="all", ...)
# Or
pearl_example.focus(tt_mode="tt35", ...)
Specifies the name of the current user when creating a new PEARL object. This is only used when saving data to sort data into respective user folders. See output_directory for more details.
Example Input:
pearl_example = Pearl(user_name="Mantid", ...)
Indicates whether to divide the focused workspace within focus mode with a previously generated vanadium spline.
This requires a vanadium to have been previously created with the create_vanadium method
Accepted values are: True or False
Example Input:
pearl_example.focus(vanadium_normalisation=True, ...)
Warning
These values are not intended to be changed and should reflect optimal defaults for the instrument. For more details please read: Instrument advanced properties
This section is mainly intended to act as reference of the current settings distributed with Mantid
All values changed in the advanced configuration file requires the user to restart Mantid for the new values to take effect. Please read Instrument advanced properties before proceeding to change values within the advanced configuration file.
The rebin parameters to use in the first rebin operation in create_cal. On PEARL this is set to the following:
# Long mode OFF:
create_cal_rebin_1_params: "100,-0.0006,19950"
# Long mode ON:
create_cal_rebin_1_params: "20300,-0.0006,39990"
The rebin parameters to use in the second rebin operation in create_cal. On PEARL this is set to the following:
create_cal_rebin_2_params: "1.8,0.002,2.1"
The Workspace Index of the spectra to correlate all other spectra against in the cross-correlation step of create_cal. On PEARL this is set to the following:
cross_corr_reference_spectra: 20
The workspace index of the last member of the range of spectra to cross-correlate against in create_cal. On PEARL this is set to the following:
cross_corr_ws_index_max: 1063
The workspace index of the first member of the range of spectra to cross-correlate against in create_cal. On PEARL this is set to the following:
cross_corr_ws_index_min: 9
The ending point of the region to be cross correlated in create_cal. On PEARL this is set to the following:
cross_corr_x_max: 2.1
The starting point of the region to be cross correlated in create_cal. On PEARL this is set to the following:
cross_corr_x_min: 1.8
Indicates a list of TOF values to crop the focused workspace which was created by focus on a bank by bank basis.
This parameter is a list of bank cropping values with one list entry per bank. The values must have a smaller TOF window than the vanadium_tof_cropping
Note: The value passed with the long_mode parameter determines the set of values used.
On PEARL this is set to the following TOF windows:
# Long mode OFF:
focused_cropping_values: [
(1500, 19900), # Bank 1
(1500, 19900), # Bank 2
(1500, 19900), # Bank 3
(1500, 19900), # Bank 4
(1500, 19900), # Bank 5
(1500, 19900), # Bank 6
(1500, 19900), # Bank 7
(1500, 19900), # Bank 8
(1500, 19900), # Bank 9
(1500, 19900), # Bank 10
(1500, 19900), # Bank 11
(1500, 19900), # Bank 12
(1500, 19900), # Bank 13
(1500, 19900) # Bank 14
]
# Long mode ON:
focused_cropping_values: [
(20300, 38830), # Bank 1
(20300, 38830), # Bank 2
(20300, 38830), # Bank 3
(20300, 38830), # Bank 4
(20300, 38830), # Bank 5
(20300, 38830), # Bank 6
(20300, 38830), # Bank 7
(20300, 38830), # Bank 8
(20300, 38830), # Bank 9
(20300, 38830), # Bank 10
(20300, 38830), # Bank 11
(20300, 38830), # Bank 12
(20300, 38830), # Bank 13
(20300, 38830) # Bank 14
]
Indicates whether to generate the absorption corrections, instead of reading them from a file. Allowed values are: True and False. If set to True, absorb_corrections_out_filename must also be set. On PEARL this is set to the following:
generate_absorb_corrections: False
Center of reference peak in d-space for GetDetectorOffsets in create_cal. On PEARL this is set to the following:
get_det_offsets_d_ref: 1.912795
Step size used to bin d-spacing data in GetDetectorOffsets when running create_cal. On PEARL this is set to the following:
get_det_offsets_step: 0.002
Maximum of CrossCorrelation data to search for peak, usually negative, in create_cal. On PEARL this is set to the following:
get_det_offsets_x_max: -200
Minimum of CrossCorrelation data to search for peak, usually negative, in create_cal. On PEARL this is set to the following:
get_det_offsets_x_min: -200
The range in dSpacing to crop a monitor spectra to when generating a spline of the current to the target. This is should be stored as a tuple of both values (lower and upper bound).
Note: The value passed with the long_mode parameter determines the set of values used.
On PEARL this is set to the following:
# Long mode OFF:
monitor_lambda_crop_range: (0.03, 6.00)
# Long mode ON:
monitor_lambda_crop_range: (5.9, 12.0)
The maximum and minimum values for a bin whilst integrating the monitor spectra. Any values that fall outside of this range will not be considered. This should be stored as a tuple of both values (lower and upper bound). See: Integration for more details.
Note: The value passed with the long_mode parameter determines the set of values used.
On PEARL this is set to the following:
# Long mode OFF:
monitor_integration_range: (0.6, 5.0)
# Long mode ON:
monitor_integration_range: (6, 10)
The masks applied to monitor spectra when normalising a workspace.
On PEARL this is set to the following:
monitor_mask_regions: [[3.45, 2.96, 2.1, 1.73],
[3.7, 3.2, 2.26, 1.98]]
The workspace spectrum number that represents a monitor which can be used to calculate current.
On PEARL this is set to the following:
monitor_spectrum_number: 1,
Determines the spline coefficient to use whilst processing the monitor spectra to normalise by current. For more details see: SplineBackground
On PEARL this is set to the following:
monitor_spline_coefficient: 20
Determines the TOF window to crop all spectra down to before any processing in the create_vanadium and focus methods.
This helps remove negative counts where at very low TOF the empty counts can exceed the captured neutron counts of the run to process. It also is used to crop to the correct TOF window depending on the value of the long_mode parameter.
Note: The value passed with the long_mode parameter determines the set of values used.
On PEARL this is set to the following:
# Long mode OFF:
raw_data_tof_cropping: (0, 19995)
# Long mode ON:
raw_data_tof_cropping: (20280, 39000)
Determines the spline coefficient to use after processing the vanadium in create_vanadium method. For more details see: SplineBackground This value is lower on long-mode to deal with the increased noise.
Note that if this value is changed ‘create_vanadium’ will need to be called again.
On PEARL this is set to the following:
# Long mode OFF:
spline_coefficient: 60
# Long mode ON:
spline_coefficient: 5
Provides the option to disable subtracting empty instrument runs from the run being focused. This is useful for focusing empties, as subtracting an empty from itself, or subtracting the previous cycle’s empty from this cycle’s, creates meaningless data. Set to False to disable empty subtraction.
On PEARL this is set to the following:
subtract_empty_instrument: True
Determines the name of the grouping cal file which is located within top level of the calibration_directory if tt_mode is set to tt35
The grouping file determines the detector ID to bank mapping to use whilst focusing the spectra into banks.
On PEARL this is set to the following:
tt35_grouping_filename: "pearl_group_12_1_TT35.cal"
Determines the name of the grouping cal file which is located within top level of the calibration_directory if tt_mode is set to tt70
The grouping file determines the detector ID to bank mapping to use whilst focusing the spectra into banks.
On PEARL this is set to the following:
tt70_grouping_filename: "pearl_group_12_1_TT70.cal"
Determines the name of the grouping cal file which is located within top level of the calibration_directory if tt_mode is set to tt88
The grouping file determines the detector ID to bank mapping to use whilst focusing the spectra into banks.
On PEARL this is set to the following:
tt88_grouping_filename: "pearl_group_12_1_TT88.cal"
Determines the name of the precalculated vanadium absorption correction values to apply when running create_vanadium.
This file must be located within the top level of the calibration_directory directory.
On PEARL this is set to the following:
vanadium_absorb_filename: "pearl_absorp_sphere_10mm_newinst2_long.nxs"
A template for the filename of the generated NeXus file.
A template for the filename of the generated GSAS file.
The subdirectory of the output directory where the .dat files are saved
A template for the filename of the generated TOF XYE file.
A template for the filename of the generated dSpacing XYE file.
Determines the TOF window to crop all banks to within the create_vanadium method. This is applied after focusing and before a spline is taken.
It is used to remove low counts at the start and end of the vanadium run to produce a spline which better matches the data.
This parameter is stored as a tuple of both values (lower and upper bound). The values must have a larger TOF window than the focused_cropping_values and a smaller window than raw_data_tof_cropping.
Note: The value passed with the long_mode parameter determines the set of values used.
On PEARL this is set to the following:
# Long mode OFF:
vanadium_tof_cropping: (1400, 19990)
# Long mode ON:
vanadium_tof_cropping: (20295, 39000)
Category: Techniques