Package reflectometry :: Package reduction :: Module properties

Module properties

source code

Support for rarely varying instrument configuration parameters.

Instrument configuration parameters will change throughout the lifetime of an instrument. For example, the properties of the beam such as wavelength and wavelength divergence will change when a new monochromator is installed on the instrument. Ideally, all such parameters would be encoded in the data file (this is one goal of the NeXus file format), but this is not the case for all instrument formats available today.

We cannot simply hard code the current value of the instrument parameters in the file reader for the data file format. Such a reader will give bad values for old data files and for new data files after the format has changed. Nor should we burden the user with knowing and entering values for such parameters on their own.

Instead, we provide support for dated values. Each instrument has a table of values and the date the values come into effect. When a file is loaded, the software scans the list of values, extracting all that are in effect on the file date.

As instrument parameters change add additional lines to the configuration file indicating the new value and the date of the change. The order of # the entries does not matter. The timestamp on the file will determine which value will be used.

The format of the entries should be::
default.NAME = (VALUE, 'YYYY-MM-DD') # value after MM/DD/YYYY default.NAME = (VALUE, '') # value at commissioning

[Not implemented] Each data reader has an associated URL which contains the configuration file for the instrument. On file load, the program will fetch dated values from the URL and use them to populate the configuration data for the instrument. This gives control of the instrument parameters to the instrument scientist where it belongs.

Example

The following parameters are needed for the NG71reflectometer:

config = properties.DatedValues()
config.wavelength = (4.76,'')  # in case ICP records the wrong value

# Detector response is uniform below 15000 counts/s.  The efficiency
# curve above 15000 has not been measured.
config.saturation = (numpy.array([[1,15000,0]]),'')

config.detector_distance = (36*25.4, '') # mm
config.psd_width = (20, '') # mm
config.slit1_distance = (-75*25.4, '') # mm
config.slit2_distance = (-14*25.4, '') # mm
config.slit3_distance = (9*25.4, '') # mm
config.slit4_distance = (42*25.4, '') # mm
config.detector_distance = (48*25.4, '2004-02-15')

The defaults are used as follows:

class Data:
     def load(filename):
         data = readheaders(filename)
         self.config = config(str(data.date))
         self.detector.distance = self.config.detector_distance
         ...
Classes
  DatedValuesInstance
  DatedValues
Functions
 
test() source code
Variables
  datepattern = re.compile(r'^(19|20)\d\d-\d\d-\d\d$')