Difference between revisions of "Homer and mgenie style functions"

From LIBISIS
Jump to navigation Jump to search
Line 3: Line 3:
 
All the population routines descirbed here use the [[IXTdata_source]] object.  The [[IXTdata_source]] object is used to define source files for the population of an [[IXTrunfile]] object. Different source files can be added to the [[IXTdata_source]] object with their own special commands:
 
All the population routines descirbed here use the [[IXTdata_source]] object.  The [[IXTdata_source]] object is used to define source files for the population of an [[IXTrunfile]] object. Different source files can be added to the [[IXTdata_source]] object with their own special commands:
  
*rawfiles: [add_rawfile]
+
*rawfiles: [[add_rawfile]]
*monitor map files: [add_monmap]
+
*monitor map files: [[add_monmap]]
*monitor mask files: [add_monmask]
+
*monitor mask files: [[add_monmask]]
*detector map files: [add_detmap]
+
*detector map files: [[add_detmap]]
*detector mask files: [add_detmask]
+
*detector mask files: [[add_detmask]]
  
 
It is <b>necessary</b> to define the type of instrument you are using in the [[IXTdata_source]] object, of course only <b>one</b> instrument can be defined for population to work as you would expect. This affects how the IXTrunfile is populated, and the current options are as follows
 
It is <b>necessary</b> to define the type of instrument you are using in the [[IXTdata_source]] object, of course only <b>one</b> instrument can be defined for population to work as you would expect. This affects how the IXTrunfile is populated, and the current options are as follows
  
*chopper instruments: [add_chopinst]
+
*chopper instruments: [[add_chopinst]]
*diffraction instruments: [add_diffinst]
+
*diffraction instruments: [[add_diffinst]]
  
 
== IXTmap and IXTmask files ==
 
== IXTmap and IXTmask files ==
Line 18: Line 18:
 
Different instruments generally have their own map files associated with them, but it is also possible to create [[IXTmap and IXTmask from the matlab command line]]
 
Different instruments generally have their own map files associated with them, but it is also possible to create [[IXTmap and IXTmask from the matlab command line]]
  
==  Populating [IXTrunfile] ==
+
==  Populating [[IXTrunfile]] ==
  
There are three standard ways to populate an [IXTrunfile] object, all require an [IXTdata_source] object which has had the type of instrument defined in it ie. chopper or diffraction instrument. As well as simply loading data from a raw file the data can generally be optionally masked/mapped/rebinned using an argument to the population function as a keyword with an associated parameter (eg. a map/mask file, rebin parameters etc.)
+
There are three standard ways to populate an [[IXTrunfile]] object, all require an [[IXTdata_source]] object which has had the type of instrument defined in it ie. chopper or diffraction instrument. As well as simply loading data from a raw file the data can generally be optionally masked/mapped/rebinned using an argument to the population function as a keyword with an associated parameter (eg. a map/mask file, rebin parameters etc.)
  
 
If a map/mask/raw file is provided as a command line argument, then it will override any specification already defined in the [IXTdata_source] object.
 
If a map/mask/raw file is provided as a command line argument, then it will override any specification already defined in the [IXTdata_source] object.
  
If no map files are defined, either on the command line or in the [IXTdata_source] object then a 1:1 mapping with _all_ spectra will be created by default. If no mask files are defined then all spectra will be included in the workspaces.
+
If no map files are defined, either on the command line or in the [[IXTdata_source]] object then a 1:1 mapping with _all_ spectra will be created by default. If no mask files are defined then all spectra will be included in the workspaces.
  
 
The standard construction for these population routines is as follows.
 
The standard construction for these population routines is as follows.
Line 41: Line 41:
 
* keywords are ''always'' character strings and each keyword '''must''' be followed by a parameter
 
* keywords are ''always'' character strings and each keyword '''must''' be followed by a parameter
 
* values can take any appropriate type
 
* values can take any appropriate type
* map files have a designated [Map File Format]
+
* map files have a designated [[Map File Format]]
* mask files have a designated [Mask File Format]
+
* mask files have a designated [[Mask File Format]]
  
  
 
=== mon ===
 
=== mon ===
  
This function populates an [IXTrunfile] object with the raw time-of-flight data for the monitors in the runfile.mon_data [IXTdata] object only. It will optionally accept the keywords in the following table:
+
This function populates an [[IXTrunfile]] object with the raw time-of-flight data for the monitors in the runfile.mon_data [IXTdata] object only. It will optionally accept the keywords in the following table:
  
 
{| border ="1" cellpadding="2"
 
{| border ="1" cellpadding="2"
Line 77: Line 77:
 
=== spec ===
 
=== spec ===
  
This function populates an [IXTrunfile] object with the raw time-of-flight data for the detectors in the runfile.det_data [IXTdata] object only. It will optionally accept the keywords in the following table:
+
This function populates an [[IXTrunfile]] object with the raw time-of-flight data for the detectors in the runfile.det_data [IXTdata] object only. It will optionally accept the keywords in the following table:
  
 
{| border ="1" cellpadding="2"
 
{| border ="1" cellpadding="2"
Line 112: Line 112:
  
  
This function populates an [IXTrunfile] object with the raw time-of-flight data for the detectors in the runfile.det_data [IXTdata] object only. It will optionally accept the keywords in the following table:
+
This function populates an [[IXTrunfile]] object with the raw time-of-flight data for the detectors in the runfile.det_data [IXTdata] object only. It will optionally accept the keywords in the following table:
  
 
{| border ="1" cellpadding="2"
 
{| border ="1" cellpadding="2"

Revision as of 10:17, 30 January 2008

Preparing the [IXTdata_source]

All the population routines descirbed here use the IXTdata_source object. The IXTdata_source object is used to define source files for the population of an IXTrunfile object. Different source files can be added to the IXTdata_source object with their own special commands:

It is necessary to define the type of instrument you are using in the IXTdata_source object, of course only one instrument can be defined for population to work as you would expect. This affects how the IXTrunfile is populated, and the current options are as follows

IXTmap and IXTmask files

Different instruments generally have their own map files associated with them, but it is also possible to create IXTmap and IXTmask from the matlab command line

Populating IXTrunfile

There are three standard ways to populate an IXTrunfile object, all require an IXTdata_source object which has had the type of instrument defined in it ie. chopper or diffraction instrument. As well as simply loading data from a raw file the data can generally be optionally masked/mapped/rebinned using an argument to the population function as a keyword with an associated parameter (eg. a map/mask file, rebin parameters etc.)

If a map/mask/raw file is provided as a command line argument, then it will override any specification already defined in the [IXTdata_source] object.

If no map files are defined, either on the command line or in the IXTdata_source object then a 1:1 mapping with _all_ spectra will be created by default. If no mask files are defined then all spectra will be included in the workspaces.

The standard construction for these population routines is as follows.

>> RF=pop_fun(DSO,  run_no, 'keyword_1', parameter_1,..., 'keyword_N',parameter_N)

For any of these functions to run properly the matlab environment must be prepared by calling the instrument setup scripts.


  • RF is an IXTrunfile object
  • DSO is an IXTdata_source object which contains an instrument type definition
  • pop_fun can be either _mon,spec,pop_full,homer_
  • raw file specification does not use a keyword, it is built up from the standard instrument abbreviation (eg. HRP, MAR, SRF etc.) and the run number automatically according to which setup file has been run. If this has not been run then the script will fail and tell you
  • keywords are always character strings and each keyword must be followed by a parameter
  • values can take any appropriate type
  • map files have a designated Map File Format
  • mask files have a designated Mask File Format


mon

This function populates an IXTrunfile object with the raw time-of-flight data for the monitors in the runfile.mon_data [IXTdata] object only. It will optionally accept the keywords in the following table:

Keyword arguments for mon function
Keyword Parameter Type Brief Description
'period' numeric specifies period default:1, if = 0 then spectra can be defined from more than one period
'mon_map' 'string' specifies a map file, supplied parameter is defines the location of the monitor map file
'mon_mask' 'string' specifies a mask file, supplied parameter is defines the location of the monitor mask file
'm_rebin' [xlo,dx,xhi] or [x_1,dx_1,x_2,dx_2,...,x_n,dx_n,x_n+1] rebin parameters are defined according to the numerical array inputs of [rebin_x],[rebin] for single datasets

An example sequence of commands is shown below.

>> run_no= '12345' % run number
>> monitor_mask_file = 'X:\MASKFILES\MON.MASK'
>> monitor_map_file = 'X:\MAPFILES\MON.MAP'
>> rebin_parameters = [1000,100,20000]
>> runfile = mon(dso,run_no,'mon_map',monitor_map_file,'mon_mask',monitor_mask_file,'m_rebin',rebin_parameters)


spec

This function populates an IXTrunfile object with the raw time-of-flight data for the detectors in the runfile.det_data [IXTdata] object only. It will optionally accept the keywords in the following table:

Keyword arguments for spec function
Keyword Parameter Type Brief Description
'period' numeric specifies period default:1, if = 0 then spectra can be defined from more than one period
'det_map' 'string' specifies a map file, supplied parameter is defines the location of the detector map file
'det_mask' 'string' specifies a mask file, supplied parameter is defines the location of the detector mask file
'd_rebin' [xlo,dx,xhi] or [x_1,dx_1,x_2,dx_2,...,x_n,dx_n,x_n+1] specifies rebinning of data, rebin parameters are defined according to the *numerical* array inputs of [rebin_x],[rebin] for single datasets
'd_int' [xlo,xhi] specifies limits for integration of the dataset between two limits, 'd_int' *cannot* be supplied with 'd_rebin'
'background' [xlo,xhi] specifies a background subtraction, the supplied parameter is a numerical array defining the background integration range in time-of-flight

An example sequence of commands is shown below.

>> run_no= '54321' % run number
>> detector_mask_file = 'X:\MASKFILES\DET.MASK'
>> detector_map_file = 'X:\MAPFILES\DET.MAP'
>> rebin_parameters = [1000,100,20000]
>> bgrd =[12000,18000]
>> runfile = spec(dso,run_no,'det_map',detector_map_file,'det_mask',detector_mask_file,'d_rebin',rebin_parameters)

pop_full

This function populates an IXTrunfile object with the raw time-of-flight data for the detectors in the runfile.det_data [IXTdata] object only. It will optionally accept the keywords in the following table:

Keyword arguments for pop_full function
Keyword Parameter Type Brief Description
'period' numeric specifies period default:1, if = 0 then spectra can be defined from more than one period
'mon_map' 'string' specifies a monitor map file, supplied parameter is defines the location of the monitor map file
'mon_mask' 'string' specifies a monitor mask file, supplied parameter is defines the location of the monitor mask file
'm_rebin' [xlo,dx,xhi] or [x_1,dx_1,x_2,dx_2,...,x_n,dx_n,x_n+1] specifies rebinning of monitor data, rebin parameters are defined according to the *numerical* array inputs of [rebin_x],[rebin] for single datasets
'det_map' 'string' specifies a detector map file, supplied parameter is defines the location of the detector map file
'det_mask' 'string' specifies a detector mask file, supplied parameter is defines the location of the detector mask file
'd_rebin' [xlo,dx,xhi] or [x_1,dx_1,x_2,dx_2,...,x_n,dx_n,x_n+1] specifies rebinning of detector data, rebin parameters are defined according to the *numerical* array inputs of [rebin_x],[rebin] for single datasets
'd_int' [xlo,xhi] specifies limits for integration of the dataset between two limits, 'd_int' *cannot* be supplied with 'd_rebin'
'background' [xlo,xhi] specifies a background subtraction, the supplied parameter is a numerical array defining the background integration range in time-of-flight

An example sequence of commands is shown below.

>> run_no= '54321' % run number
>> monitor_mask_file = 'X:\MASKFILES\MON.MASK'
>> monitor_map_file = 'X:\MAPFILES\MON.MAP'
>> mon_rebin_parameters = [1000,100,20000]
>> detector_mask_file = 'X:\MASKFILES\DET.MASK'
>> detector_map_file = 'X:\MAPFILES\DET.MAP'
>> det_rebin_parameters = [1000,100,20000]
>> bgrd = [12000,18000]
>> runfile = pop_full(dso,run_no,'mon_map',monitor_map_file,'mon_mask',monitor_mask_file,'m_rebin',mon_rebin_parameters, ...
                                      'det_map',detector_map_file,'det_mask',detector_mask_file,'d_rebin',det_rebin_parameters)


homer

The homer command is a special version of the populate command in which extra normalisation keywords can be supplied with a fixed set of associated parameters.

Keyword arguments for homer function
Keyword Parameter Type Brief Description
'period' numeric specifies period default:1, if = 0 then spectra can be defined from more than one period
'mon_map' 'string' specifies a monitor map file, supplied parameter is defines the location of the monitor map file
'mon_mask' 'string' specifies a monitor mask file, supplied parameter is defines the location of the monitor mask file
'm_rebin' [xlo,dx,xhi] or [x_1,dx_1,x_2,dx_2,...,x_n,dx_n,x_n+1] specifies rebinning of monitor data, rebin parameters are defined according to the *numerical* array inputs of [rebin_x],[rebin] for single datasets
'det_map' 'string' specifies a detector map file, supplied parameter is defines the location of the detector map file
'det_mask' 'string' specifies a detector mask file, supplied parameter is defines the location of the detector mask file
'd_rebin' [xlo,dx,xhi] or [x_1,dx_1,x_2,dx_2,...,x_n,dx_n,x_n+1] specifies rebinning of detector data, rebin parameters are defined according to the numerical array inputs of [rebin_x],[rebin] for single datasets. 'd_rebin' cannot be supplied with 'd_int'
'background' [xlo,xhi] specifies a background subtraction, the supplied parameter is a numerical array defining the background integration range in time-of-flight
'ei' real defines estimate of incident energy (meV)
'white' specifies treatment as a white beam
'fixei' real specifies a known incident energy, so that ei determination is not necessary
'normalisation' integer value specifies workspace number of monitor used in normalisation [default 1]
'uahr' specifies normalisation by microamp hours, 'range' keyword cannot be specified if this parameter is defined
'range' [xlo,xhi] specifies range of integration for normalisation, using monitor workspace defined by 'normalisation' and declared in the units defined in 'mon_units'
'peak' specifies to use the area determined by peak search in the monitor defined by 'normalisation' close to the value of either 'ei' or 'fixei', only valid if 'ei' numeric, not if 'white'
'mon_units' [units code] specifies output units of monitor data
'det_units' [units code] specifies output units of detector data
'd_int' [xlo,xhi] specifies limits for integration of the dataset between two limits, if 'det_units' has been supplied then integration will take place after units conversion, 'd_int' cannot be supplied with 'd_rebin'
'scale' real specifies units of normalisation ie per 1e6 counts or per 1000uAhrs [default 1]
'solid' [IXTrunfile] Specifies a solid angle correction, the supplied parameter *must* be a white beam [IXTrunfile] object which has been integrated for every spectrum (i suppose one could also just provide a run number....)
'corr' logical Specifies detector efficiency correction and kf/ki correction will be applied [default false]


see also: [Creating Datasets], [Arrays of Datasets], [Mathematical Functions and Operators], [Other Matlab Utilities], [Input and Output Functions], [Dataset Manipulation and Conversion Functions]