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/add_image.py.html
AHELP for CIAO 4.1

add_image

Context: py.crates

Synopsis

Add an image to a crate.

Syntax

add_image(crate, cratedata)

Description

  • crate - input crate
  • cratedata - CrateData object to be added

The add_image command adds an image to the crate. Any existing image in the crate will be replaced. The command returns a "1" if the image is successfully added.

The image is only added to the crate. The write_file ("ahelp write_file") command can be used to save the modified crate to a file.

Example

>>> cd = CrateData()
>>> img = numpy.arange(12).reshape(1,2,6)
>>> cd.load(img, True)
1
>>> cr = IMAGECrate()
>>> add_image(cr, cd)
1
>>> write_file(cr, "newimg.fits")
1

Here we create a FITS image file called newimg.fits which contains a 6 by 2 pixel image containing the values 0 to 11, inclusive. Use dmlist to examine the output file:

unix% dmlist newimg.fits blocks
 
----------------------------------------------------------------------
Dataset: newimg.fits
----------------------------------------------------------------------
 
     Block Name                Type         Dimensions
----------------------------------------------------------------------
Block    1: PRIMARY              Image      Int4(6x2)

The reason for the "dummy" third dimension of 1 in the reshape call is due to the low-level nature of the load call. If this had not been added, then the output would have been a one-dimensional image with 6 pixels, containing the values 0 to 5 inclusive (i.e. the second row would have been ignored).

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.