Difference between revisions of "Input and Output Functions"
m (→Other Formats) |
m |
||
Line 94: | Line 94: | ||
− | where spectrum_number is the spectrum which is required. | + | where '''spectrum_number''' is the spectrum which is required. |
Line 117: | Line 117: | ||
* Other information is contained in the rawfile, see [[IXTraw_file]] documentation for more information. | * Other information is contained in the rawfile, see [[IXTraw_file]] documentation for more information. | ||
+ | |||
+ | |||
+ | ==Slices, Cuts and Masks== | ||
+ | |||
+ | A slice from Horace or mslice can be read into a Libisis [[IXTdataset_2d]] object using the command | ||
+ | |||
+ | <pre>>>w = read_slice(filename) | ||
+ | w = read_slice</pre> | ||
+ | |||
+ | * '''filename''' is a string containing the location of the .slc file | ||
+ | * If filename is not given then a prompt will ask the user to locate the file | ||
+ | * Output is an [[IXTdataset_2d]], with as much information taken from the slice as possible, otherwise fields are blank. | ||
+ | |||
+ | |||
+ | Similarly, a Mask or a cut from Horace / mslice can be read into Libisis [[IXTdataset_1d]] objects using the commands | ||
+ | |||
+ | <pre>>>w = read_cut(filename) | ||
+ | >> w = read_mask(filename)</pre> | ||
+ | |||
+ | * '''filename''' is a string containing the location of the .cut or .msk file | ||
+ | * If filename is not given then a prompt will ask the user to locate the file | ||
+ | * Output is an [[IXTdataset_1d]], with as much information taken from the cut / mask as possible, otherwise fields are blank. | ||
+ | |||
+ | |||
+ | == Nexus Files== | ||
+ | |||
+ | [[NeXus]] files can be read using the read_nxs command | ||
+ | |||
+ | <pre>>>w = read_nxs(filename, IXTobject, entry) | ||
+ | |||
+ | *'''filename''' is a string showing the location of the .nxs file | ||
+ | *'''IXTobject''' is the object that the dta is being read into (i.e. [[IXTrunfile]], [[IXTdataset_2d]] | ||
+ | *'''entry''' is a string, the top level directory to read the object from (i.e. 'runfile'), by ''default'' it is 'object' | ||
+ | * '''w''' will be of the same object type as IXTobject (i.e. [[IXTrunfile]]) | ||
+ | |||
+ | |||
+ | '''''Example:''''' | ||
+ | |||
+ | |||
+ | <tt>wout = read_nxs('C:/nexusfiles/maps1020.nxs', IXTrunfile, 'runfile')</tt> | ||
+ | |||
+ | |||
+ | reads the data from the runfile top directory into the wout object that will be an [[IXTrunfile]] object. | ||
+ | |||
== Other Formats == | == Other Formats == | ||
− | |||
− | |||
− | [[Homer_and_mgenie_style_functions| Homer]] | + | Data can be read from other formats or in other ways, such as using [[Homer_and_mgenie_style_functions| Homer]] to populate an [[IXTrunfile]] object. |
Revision as of 15:36, 1 April 2008
ASCII Files
- IXTdataset_1d objects may be stored in ASCII files.
- These files may contain x and y data or x, s, error data in a 2 or 3 column format.
- Column 1 will be x values, column 2 will be s values and if available column 3 will be error values, if not available then error is assumed to be 0.
- Any information at the start or end of the file that is not in a 2 or 3 column format is ignored (for instance, header information may be stored here).
- Columns may be separated by commas, tabs, or spaces.
- ASCII files may contain point or histogram data, the x column in histogram data will have one more value than the s and e columns.
- The following files would all be acceptable ASCII files
title = plots1 xaxis = wavelength yaxis = signal 490.2 30000 491.2 31923 492.2 40000
Represents a three point dataset with 0 error.
title = plots1 xaxis = wavelength yaxis = signal 490.2 30000 300 491.2 31923 300 492.2 40000 250 493.2
Represents a 3 column histogram dataset with error data.
490.2,30000,300 491.2,31923,300 492.2,40000,250 493.2
Will represent the same 3 column histogram dataset with error data.
- When files are written by libisis a header is written at the top of the file with the following information
name = dataset name title = dataset title signal_units = dataset s axis label x_units = dataset x axis label x_distribution = 1 x1 s1 e1 x2 s2 e2 ...
where the header information is taken from the dataset being written.
- To read and write ASCII files in the format (point or histogram) specified by the file or dataset use
>> read_ascii('filename') >> write_ascii(dataset,'filename')
if no filename is given then the user will be prompted to locate the file.
Point Data
One can force the written or read ASCII file to be in the form of point data by using the commands
>>read_points('filename') write_points(dataset, 'filename')
Histogram Data
One can force the written or read ASCII file to be in the form of histogram data by using the commands
>> read_hist('filename') >> write_hist(dataset, 'filename')
RAW Files
RAW files come directly from instruments and can also be read into Libisis. Data can then be extracted from the RAW file to form an IXTdataset_1d or an IXTdataset_2d object.
- To read in a rawfile (in the form of an IXTraw_file object) use the command
>> rawfile1 = IXTraw_file('filename')
- To read data into an IXTdataset_1d object use the command
>> dataset = getspectrum(rawfile1, spectrum_number)
where spectrum_number is the spectrum which is required.
- to read multiple runs into an IXTdataset_2d object use the command
>> dataset_2d = getspectra(rawfile1, [start:end])
where start and end are the initial and final spectrum to include in the dataset_2d.
EXAMPLE:
>> rawfile1 = IXTraw_file('c:/RAWfiles/HET15958'); >> nsp = geti(rawfile1,'nsp1'); >> d2a = getspectra(rawfile1, [1:nsp]); >> d1a = getspectrum(rawfile1, 25);
this will load all spectra from the HET15958 raw file contained in the folder c:/RAWfiles into an IXTdataset_2d object called d2a and load spectrum 25 into an IXTdataset_1d object name d1a.
- Other information is contained in the rawfile, see IXTraw_file documentation for more information.
Slices, Cuts and Masks
A slice from Horace or mslice can be read into a Libisis IXTdataset_2d object using the command
>>w = read_slice(filename) w = read_slice
- filename is a string containing the location of the .slc file
- If filename is not given then a prompt will ask the user to locate the file
- Output is an IXTdataset_2d, with as much information taken from the slice as possible, otherwise fields are blank.
Similarly, a Mask or a cut from Horace / mslice can be read into Libisis IXTdataset_1d objects using the commands
>>w = read_cut(filename) >> w = read_mask(filename)
- filename is a string containing the location of the .cut or .msk file
- If filename is not given then a prompt will ask the user to locate the file
- Output is an IXTdataset_1d, with as much information taken from the cut / mask as possible, otherwise fields are blank.
Nexus Files
NeXus files can be read using the read_nxs command
>>w = read_nxs(filename, IXTobject, entry) *filename is a string showing the location of the .nxs file *IXTobject is the object that the dta is being read into (i.e. IXTrunfile, IXTdataset_2d *entry is a string, the top level directory to read the object from (i.e. 'runfile'), by default it is 'object' * w will be of the same object type as IXTobject (i.e. IXTrunfile) Example: wout = read_nxs('C:/nexusfiles/maps1020.nxs', IXTrunfile, 'runfile') reads the data from the runfile top directory into the wout object that will be an IXTrunfile object.Other Formats
Data can be read from other formats or in other ways, such as using Homer to populate an IXTrunfile object.