Chandra X-Ray Observatory (CXC)
Skip to the navigation links
Last modified: December 2011

URL: http://cxc.harvard.edu/ciao/write_pha.html
AHELP for CIAO 4.4

write_pha

Context: crates

Synopsis

Write a PHACrateDataset to a file.

Syntax

write_pha(phadataset, filename [, clobber=False])

Description

  • phadataset - a PHA Crate Dataset
  • filename - name of the file
  • clobber - should an output file be over-written if it already exists (default is False)?

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

Metadata handling

As discussed in ahelp read_file, the Crate and Crate Dataset objects do not retain all the information from the input file, which means that care should be taken when using the output from write_pha() with CIAO tools.

Example

>>> pha = read_pha("pha.fits")
>>> cr = pha.get_crate("SPECTRUM")
>>> pi = get_colvals(cr, "PI")
>>> flag = (pi > 10) & (pi < 700)
>>> cd = CrateData()
>>> cd.name = "QUALITY"
>>> cd.values = 1 * flag
>>> add_col(cr, cd)
>>> write_pha(cds, "no_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, and write out the results to no_qual.fits.

Changes in CIAO 4.4

PHA Dataset

The value returned by read_pha and used by write_pha is a PHA Crate Dataset; in earleir versions it was a Crate.

Error handling

The write_pha routine now raises an error rather than returning an integer.

The clobber argument

A clobber parameter has been added - which defaults to False - to control whether existing files will be overwritten or not.

Bugs

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

contrib
make_image_crate, make_table_crate, scale_image_crate, smooth_image_crate, write_arrays, write_columns
crates
add_col, add_crate, add_key, add_piximg, cratedataset, delete_col, delete_key, delete_piximg, get_crate, is_pha, read_file, read_pha, read_rmf, write_file, write_rmf

Last modified: December 2011
CXC logo

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: cxcweb@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2012. All rights reserved.