ISIS direct reduction script description.

From InelasticDataReduction
Jump to navigation Jump to search

Overview

All ISIS direct inelastic reduction scripts have similar interface and layout, with only parameters different for different instruments. Some parameters change from one cycle and sometimes one experiment to another but most of them are instrument specific and changes only when instrument is modified. Instrument scientists prepare sample Mantid python reduction scripts, which are then automatically distributed to Isiscompute users according to the rules described here.

From the links below one can retrieve resent versions of these scripts and their default reduction parameters stored in XML files, namely:

Instrument Simple reduction script Full reduction script Default reduction parameters User Settings Description file
MARI: template_mari.py MARIReduction_Sample.py MARI_Parameters.xml MARI User settings
MAPS: template_maps.py MAPSReduction_Sample.py MAPS_Parameters.xml MARI User settings
MERLIN: --- MERLINReduction_Sample.py MERLIN_Parameters.xml MERLIN User settings
LET: --- LETReduction_Sample.py LET_Parameters.xml LET User settings

The teplate_instrument_name.py and InstrumentReduction_Sample.py files referenced in column two and three above are processed by MantidConfigurationScript, which replaces the strings, specified in correspondent User Settings Description file (Column 5) and produces simple and full reduction scripts for users.

Simple reduction script created for users who prefer old functional interface used by qtiGenie and Libisis. It highlights only the parameters user needs to change during an experiment and allows users to separate all parameters, necessary to reduce data and user's parameters in different files. User parameters are usually the run number or list of run numbers to process, run number for a white beam vanadium run, energies the user is interested in and energy binning. There are couple of other parameters, directly related to the experiment in progress. These parameters are better described in the script itself.

Simple reduction script is then imports full reduction script, which sets up the parameters specific to a cycle and may be to an experiment. After that the advanced script picks up all other parameter's default values from the appropriate xml file and runs the reduction algorithms itself.

User may work directly with the full reduction script as this one has all necessary parameters which can then be fine tuned for particular runs in the __main__ section of the script as described in the script. In fact, setting up small number of simple parameters in a separate script or setting up all parameters together in one big script is the matter of personal choice between using one big file with all parameters or two files with different sets of parameters.

For instruments, where simple reduction script is present, user can find the iliad function, used by the simple reduction script inside the advanced reduction script.

Reduction Scripts in Depth

This chapter intended for advanced users or instrument scientists who wants to modify reduction scripts and add some new features to them.

ISIS reduction scripts are part of Mantid and located under Mantid installation folder in /scripts/Inelastic/Direct directory (/opt/Mantid/scripts/Inelastic/Direct on Unix, c:\Mantid\scripts\Inelastic\Direct under Windows or see it on the web here)

In Direct folder the following important files can be found:

DirectEnergyConversion.py  -- The python class implementing ISIS direct inelastic reduction workflow. Its most important method is convert_to_energy method,
                              invoked for each  run or sum of runs, and converting data, obtained in experiment into reduced data. All other methods of this
                               class are directly or indirectly called by this method.
PropertyManager.py         -- The python class, responsible for processing user input, Instrument parameter files described above and other properties, attached to 
                              and providing these data to DirectEnergyConversion. This class instantiates four other files: NonIDF_Properties.py, 
                              the input data PropertiesDescriptors.py, RunDescriptor.py and ReductionHelpers.py.

These files contain small classes and functions to helping to process various input parameters, namely

 ReductionHelpers.py  -- file containing range of helper functions and the class, which is automatically instantiated for the Instrument_Parameters.xml
                             fields, which do not need complex behaviour (e.g. load_monitors_with_workspace True or False)
 NonIDF_Properties.py -- file containing classes (Property Descriptors in Python terms) which are not related to the properties found 
                             in  Instrument_Parameters.xml file. (e.g. incident_energy)
 PropertiesDescriptors.py -- file, containing classes related to properties, described in Instrument_Parameters.xml but providing
                                 more complex behaviour for such properties. E.g. DetCalFile class describes detector calibration file det_cal_file 
                                 Instrument_Parameters.xml but contains valiadators, used to check correct file extension and if the calibration file 
                                is present.
 RunDescriptor.py    -- contains one but most important property, related to the reduced and auxiliary experimental data. It's responsible for 
                            conversion between run numbers and file names, loading appropriate files to Mantid to use in reduction, renaming workspaces
                            according to different stages of reduction process, etc.

All these subclasses are instantiated by PropertyManager and PropertyManager is implemented as a singleton so any property instance can be accessed in reduction as:

  prop = PropertyManager.property_name

e.g.

 energy =