ISIS Powder Diffraction Scripts - PEARL Reference

Creating PEARL Object

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

Example

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", ...)

Methods

The following methods can be executed on a PEARL object:

For information on creating a PEARL object see: Creating PEARL Object

create_vanadium

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:

Example

# Notice how the filename ends with .yaml
cal_mapping_file = r"C:\path\to\cal_mapping.yaml"

pearl_example.create_vanadium(calibration_mapping_file=cal_mapping_file,
                              do_absorb_corrections=True, long_mode=False,
                              run_in_cycle="100", tt_mode="tt88")

focus

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 parameter may also be optionally set:

Example

# 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)

Calibration Mapping File

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"

Example

1-100:
  label: "1_1"
  offset_file_name: "offset_file.cal"
  empty_run_numbers: "10"
  vanadium_run_numbers: "20"

101-:
  label: "1_2"
  offset_file_name: "offset_file.cal"
  empty_run_numbers: "110"
  vanadium_run_numbers: "120"

Parameters

The following parameters for PEARL are intended for regular use when using the ISIS Powder scripts.

attenuation_file_path

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", ...)

calibration_directory

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", ...)

calibration_mapping_file

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", ...)

config_file

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", ...)

do_absorb_corrections

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, ...)

file_ext

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", ...)

focus_mode

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

All

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.

Groups

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.

Trans

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.

Mods

In mods mode every bank is left as individual workspaces with appropriate names. No additional processing is performed.

Example Input:

pearl_example.focus(focus_mode="all", ...)

long_mode

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, ...)

output_directory

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", ...)

perform_attenuation

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, ...)

run_in_cycle

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, ...)

run_number

Specifies the run number(s) to process when calling the focus method.

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, ...)

tt_mode

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", ...)

user_name

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", ...)

vanadium_normalisation

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, ...)

Advanced Parameters

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.

focused_cropping_values

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, 39990),  # Bank 1
      (20300, 39990),  # Bank 2
      (20300, 39990),  # Bank 3
      (20300, 39990),  # Bank 4
      (20300, 39990),  # Bank 5
      (20300, 39990),  # Bank 6
      (20300, 39990),  # Bank 7
      (20300, 39990),  # Bank 8
      (20300, 39990),  # Bank 9
      (20300, 39990),  # Bank 10
      (20300, 39990),  # Bank 11
      (20300, 39990),  # Bank 12
      (20300, 39990),  # Bank 13
      (20300, 39990)   # Bank 14
    ]

monitor_lambda_crop_range

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)

monitor_integration_range

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)

monitor_mask_regions

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]]

monitor_spectrum_number

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,

monitor_spline_coefficient

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

raw_data_tof_cropping

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, 39995)

spline_coefficient

Determines the spline coefficient to use after processing the vanadium in create_vanadium method. For more details see: SplineBackground

Note that if this value is changed ‘create_vanadium’ will need to be called again.

On PEARL this is set to the following:

spline_coefficient: 60

tt35_grouping_filename

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"

tt70_grouping_filename

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"

tt88_grouping_filename

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"

vanadium_absorb_filename

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"

vanadium_tof_cropping

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, 39993)

Category: Techniques