          Read all contents of a file.

read_dataset(filename)

Argument
Description
filename
Name of the file; it can include CIAO Data Model syntax such as filters and binning values

The read_dataset command loads the specified file and returns a cratedataset object, which can be used to access the various blocks in the file.

In the following example three images have been combined into a single file with the dmappend command:

% dmappend broad_flux.img,broad_thresh.img,broad_thresh.expmap broad.img

The full dataset can be loaded intp Python with read_dataset:

>>> ds = read_dataset("broad.img")

The contents can be accessed, such as accessing the data from the second block:

>>> print(ds) Crate Dataset: File Name: broad.img Read-Write Mode: rw Number of Crates: 3 1) Crate Type: <IMAGECrate> Crate Name: PFLUX_IMAGE

2) Crate Type: <IMAGECrate> Crate Name: EVENTS_IMAGE

3) Crate Type: <IMAGECrate> Crate Name: EXPMAP

>>> cr = ds.get_crate('EVENTS_IMAGE') >>> print(cr) Crate Type: <IMAGECrate> Crate Name: EVENTS_IMAGE Image Axes: ['sky', 'EQPOS']

>>> ds = read_dataset('clus.rmf')
>>> rmf = read_rmf('clus.rmf')

The read_dataset routine can read in the separate blocks in a RMF file. The read_rmf routine should be preferred for this task.

>>> print(ds) Crate Dataset: File Name: clus.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: 1070

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

and

>>> print(rmf) RMF Crate Dataset: File Name: clus.rmf Read-Write Mode: r Number of Crates: 3 1) Crate Type: <IMAGECrate> Crate Name: PRIMARY

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

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

Changes in CIAO 4.13

The read_dataset routine is now exported from the pycrates module. In earlier versions of CIAO it was only availabe from the pycrates.hlui module.

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

December 2020