The First Wish - Access to Data

At ISIS and all other neutron scattering centres data is collected in ‘runs’. These are typically periods of time in which the sample is kept in constant conditions. The data for a run is stored in a raw data file, and at ISIS the naming convention is <instrumentxxxx.raw>, where the run number is xxxx. The raw file itself contains one or more time-of-flight spectra and other associated parameters needed for the analysis of the data. This section describes the commands necessary to access data from within Open GENIE. The description that follows is based on the data formats found at ISIS. However, Open GENIE can be modified to read other formats used at other facilities. This section details all the commands used to access data from Open GENIE.

Accessing raw data spectra

One of the major strengths of Open GENIE is the flexibility available in accessing data. The first way of accessing data is based on the old GENIE-V2, where several internal variables control the

  1. current input file,
  2. current output file,
  3. current disk,
  4. current directory,
  5. current instrument,
  6. current file extension

The status of these variables is changed by using the set() command. The show/defaults command gives the input/output defaults, for example

>> show/defaults
Current default disk = AXPLIB$DISK:
Current default directory = [OPENGENIE.GENIE.EXAMPLES.DATA]
Current default instrument = HRP
Current default extension = .RAW
Current default input = AXPLIB$DISK:[OPENGENIE.GENIE.EXAMPLES.DATA]HRP08639.RAW
Current default output =
>>

To read a spectrum or multiple spectra from a raw data file the assign and spectrum() commands can be used. An alternative to this is to use the Get() command. The Get() command is able to read data from either a raw data file, or another of the supported data formats, see Appendix B. However, this assumes that the data items in a file are either named explicitly, or numbered. For example, the data read from a raw data file could be a spectrum or a user name. The most useful parameters, which can be taken from a raw data file are TITL, the run title; USER, the user information; NAME, the instrument name; NDET, the number of detectors; TTHE, the two theta table; NSP1, the total number of spectra; NTC1, the number of time channels; LEN2, L2 for each detector, and each individual spectra file are specified by an associated integer, i.e. specifying 5 would get the fifth spectra from within a file. For example:

# print the user name
# then read in all the spectra in the file,
# finally read every third spectrum from a file
>>printn get("USER", "/usr/local/genie/examples/data/hrp08639.raw")
WIFD/RMI
>>d2 = get(1 : get("NSP1"))
>>spin_up =get(1:50@3)

Note: if a file has been set using the Set/File/Input command then if no file is stipulated it defaults to this file.

To save Open GENIE variables to an intermediate binary file the Put() command is used. These variables may optionally be tagged with a label, which can be used for later reading, or comments may also be added. For example,

# Copy a whole multidimensional spectrum from a raw file into a single item in an intermediate file
>> Set/File/Input "/usr/local/genie/examples/data/irs12839.raw"
>> Set/File/Output "example.in3"
>> Put get(1:20) label = "bigspec" comment = "demo"

which can then be read with

>> Get ("bigspec")

Accessing ASCII files

To read in data from an ASCII file, for example from the file "prs_001.obs", which can be found in the PRISMA directory of the Open GENIE example area

# Read in three data arrays of 30 points (in columns separated by a whitespace)
# and assign to arrays in fields X, Y, and E in the new workspace.
>> handle = Asciifile:Open("/usr/local/genie/examples/prisma/prs_001.obs")
>> wk1=Asciifile:Readfree(Handle, "X,Y,E",$whitespace, 30)
>> printn wk1
Workspace []
(
x = [0.925 0.975 1.02499999999999 1.07499999999999 1.125...] Array(30 )
y = [0.22526098 0.11728537 0.126243569999999 0.144312439999999 0.15559034 ...] Array(30 )
e = [0.009967181499999 0.0043424088 0.004095190999999 0.003976735 0.0038093579 ...] Array(30 )
)
>>

or alternatively

>> Asciifile/Readfree Handle "X,Y,E" $whitespace 30
>> wk1 = Asciifile:data(handle)
>>

The second method enables several different items of data to be accumulated into a workspace before it is returned. For example:

>> Asciifile/Readfree Handle "X1,Y1,E1" $WHITESPACE 4
>> Asciifile/Readfree Handle "X2,Y2,E2" $WHITESPACE 4
>> wk1 = Asciifile:data(Handle)
>> printn wk1
Workspace []
(
x1 = [1.0 1.1 1.2 1.3 ] Array(4 )
y1 = [2.1 2.1 2.2 2.0 ] Array(4 )
e1 = [0.0 0.1 0.2 0.0 ] Array(4 )
x2 = [1.4 1.5 1.6 1.7 ] Array(4 )
y2 = [2.0 2.0 2.0 2.0 ] Array(4 )
e2 = [0.1 0.1 0.2 0.0 ] Array(4 )
)

Note: you can also use the Put/Ascii command to output data to an Asciifile. For full details of these commands and others see Open GENIE reference manual.