About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2008

URL: http://cxc.harvard.edu/ciao4.1/read_file.py.html
AHELP for CIAO 4.1 read_file Context: py.crates

Synopsis

Read FITS or ASCII data into a crate.

Syntax

read_file(filename)

Description

  • 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.

Example 1

>>> cr = read_file("image.fits")
>>> print 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.

Example 2

>>> cr = read_file("table.fits")
>>> print get_crate_type(cr)
Table

Read a file and create a TABLECrate.

Example 3

>>> phacr = read_file("src.pi")
>>> print(get_crate_type(phacr))
Table
>>> resp = read_file("src.arf")
>>> print(get_crate_type(resp))
Table
>>> resp2 = read_file("src.rmf")
>>> print(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.

Example 4

>>> f = "evt2.fits[energy=500:7000,sky=region(src.reg)][bin sky=::1]"
>>> cr = read_file(f)
>>> s = get_imagevals(cr).sum()
>>> print "Pixel sum=%d" % 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.

Bugs

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

Last modified: December 2008



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-2004. All rights reserved.