|AHELP for CIAO 4.2||
Read FITS or ASCII data into a crate.
- filename - name of the input file; FITS or ASCII format
The read_file command loads the specified file into the appropriate crate, either a TABLECrate or an IMAGECrate. The input file may be in FITS or ASCII format.
The read_pha, read_arf, and read_rmf routines can be used when the type of the dataset is known.
Users familiar with the CIAO Data Model should note that:
- Crates reads one extension of the input file, not the whole dataset. The file that is written out will only contain the block which was read.
- Crates does not retain the data subspace of the file.
- Crates does not retain HISTORY or COMMENT blocks from the input file.
slsh> cr = read_file("image.fits"); slsh> get_crate_type(cr); Image
A file is read into the crate "cr", then the get_crate_type command is used to confirm it is an IMAGECrate.
slsh> cr = read_file("table.fits"); slsh> get_crate_type(cr); Table
Read a file and create a TABLECrate.
slsh> phacr = read_file("src.pi"); slsh> get_crate_type(phacr); Table slsh> resp = read_file("src.arf"); slsh> get_crate_type(resp); Table slsh> resp2 = read_file("src.arf"); slsh> get_crate_type(resp2); Table
Using the read_file command to read a PHA, ARF, or RMF file reads it in as a TABLECrate. The read_pha, read_arf, and read_rmf routines should be used to create a PHACrate, ARFCrate, or RMFCrate.
slsh> f = "evt2.fits[energy=500:7000,sky=region(src.reg)][bin sky=::1]"; slsh> cr = read_file(f); slsh> s = sum (get_piximgvals (cr)); slsh> message ("Pixel sum=$s"$); Pixel sum=2361
File names can include CIAO Data Model filtering and binning commands (e.g. see "ahelp dm"). In this case an energy and spatial filter are applied to an event file before being binned into an image. The pixel values are read in and then summed up.
>>> a=read_file("myfile.dat"); >>> print(get_col_names(a)); >>> s=get_colvals(a,"col1");
The read_file command is used to read the contents of the ASCII file myfile.dat into the TABLEcrate "a", which is then input to the get_col_names command to print the column names read from the file. The get_colvals command is used to store the "col1" data array to the variable "s".
>>> a = read_file("myfile.dat[opt colnames=none]");
In this case, the ASCII kernel option 'opt colnames=none' tells the read_file command to skip the header information when reading the contents of the ASCII file myfile.dat into the TABLEcrate "a" (see "ahelp dmascii" for more information).
See the bug pages on the CIAO website for an up-to-date listing of known bugs.