Difference between revisions of "Input and Output Functions"
m |
|||
Line 51: | Line 51: | ||
− | * To read and write ASCII files in the format specified by the file or dataset use | + | * To read and write ASCII files in the format (point or histogram) specified by the file or dataset use |
Line 95: | Line 95: | ||
''' >> dataset = getspectrum(rawfile1, spectrum_number) ''' | ''' >> dataset = getspectrum(rawfile1, spectrum_number) ''' | ||
+ | |||
where spectrum_number is the spectrum which is required. | where spectrum_number is the spectrum which is required. | ||
Line 103: | Line 104: | ||
''' >> dataset_2d = getspectra(rawfile1, [start:end]) ''' | ''' >> dataset_2d = getspectra(rawfile1, [start:end]) ''' | ||
+ | |||
where start and end are the initial and final spectrum to include in the dataset_2d. | where start and end are the initial and final spectrum to include in the dataset_2d. | ||
Line 110: | Line 112: | ||
''' example: ''' | ''' example: ''' | ||
− | <pre> >> rawfile1 = IXTraw_file('c:/RAWfiles/HET15958'); | + | <pre>>> rawfile1 = IXTraw_file('c:/RAWfiles/HET15958'); |
>> nsp = geti(rawfile1,'nsp1'); | >> nsp = geti(rawfile1,'nsp1'); | ||
>> d2a = getspectra(rawfile1, [1:nsp]); | >> d2a = getspectra(rawfile1, [1:nsp]); |
Revision as of 12:28, 17 March 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.
Other Formats
Data may be read from other formats including Nexus. IXTrunfile is an object that contains all information about a run. Some of this information may be exported to a dataset for data manipulation and plotting. see the IXTrunfile documentation for further information.