Last modified: December 2015

AHELP for CIAO 4.15


Context: crates


Load an RMF file into a RMFCrateDataset.


read_rmf(filename, mode='r')


Argument Description
filename Name of the file; it can include CIAO Data Model syntax such as filters and binning values
mode Should the mode be opened for read-only ('r', the default), or for read-write access ('rw').

The read_rmf command loads the specified RMF file into a RMFCrateDataset.


>>> cds = read_rmf("rmf.fits")
>>> print(cds)

The output of the print command is:

   RMF Crate Dataset:
     File Name:         meg_1.rmf
     Read-Write Mode:   rw
     Number of Crates:  3
       1)     Crate Type:        <IMAGECrate>
   Crate Name:        PRIMARY

       2)     Crate Type:        <TABLECrate>
   Crate Name:        MATRIX
   Ncols:             6
   Nrows:             8192

       3)     Crate Type:        <TABLECrate>
   Crate Name:        EBOUNDS
   Ncols:             3
   Nrows:             8192

In this example the RMF is from a grating observation and was obtained from TGCat.

The mode argument

When a file is read in, the write permission is checked against the mode argument and, if it does not match (if mode='rw' but the user does not have write permission, or the file is a gzipped file) then a warning is displayed and the mode is set to 'r'.

When is the mode argument used?

The mode argument is only relevant if you call the write method of the crate with no arguments; that is if you say

>>> cr = read_file('tbl.dat', mode='rw')
UserWarning: File 'tbl.dat' does not have write permission. Changing to
read-only mode.
>>> cr.write()
IOError: File is not writeable.

It is not used if you want to write to a new file or one that is not write protected. That is, you can read in a file in read-only mode, change its contents, and write it out to a new file:

>>> cr = read_file('img.fits', mode='r')
>>> ivals = cr.get_image().values
>>> ivals += 1
>>> cr.write('modified.fits')


See the bug pages on the CIAO website for an up-to-date listing of known bugs.

Refer to the CIAO bug pages for an up-to-date listing of known issues.

See Also

make_image_crate, make_table_crate, scale_image_crate, smooth_image_crate, write_arrays, write_columns
add_col, add_crate, add_key, add_piximg, cratedataset, delete_col, delete_key, delete_piximg, get_crate, is_rmf, read_file, read_pha, write_file, write_pha, write_rmf