Last modified: December 2018

Jump to: Description · Example · Bugs · See Also

AHELP for CIAO 4.16


Context: crates


Write a PHACrateDataset to a file.


write_pha(pha, filename, clobber=False)


Argument Description
pha The PHACrateDataset object to write out.
filename The output file name. To change the format from FITS add a kernel specifier as described in 'ahelp dmopt' and 'ahelp dmascii'.
clobber Set to True if the output file already exists and you wish to over-write it, since the default behavior is to raise an IOError in this case.

The write_pha command creates an output file for the input PHACrateDataset.


>>> pha = read_pha("pha.fits")
>>> cr = pha.get_crate("SPECTRUM")
>>> pi = get_colvals(cr, "PI")
>>> flag = (pi > 10) & (pi < 700)
>>> cd = CrateData()
>>> = "QUALITY"
>>> cd.values = 1 * flag
>>> add_col(cr, cd)
>>> write_pha(pha, "pha_qual.fits", clobber=True)

Here we add a QUALITY column to the SPECTRUM block; setting rows to 1 for those PI bins greater than 10 and less than 700, otherwise 0. The resulting file - including all the blocks in pha.fits - is written out to pha_qual.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_pha, read_dataset, read_file, read_pha, read_rmf, write_dataset, write_file, write_rmf