Chandra X-Ray Observatory
Skip to the navigation links
Last modified: September 2011

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.9


Context: contrib


Scale the pixel values in an IMAGE crate (useful for the ChIPS add_image command)


scale_image_crate(crate, scaling="arcsinh")


This routines applies a scaling function to the pixel values stored in an image crate. It is useful if you want to display the Crate using add_crate or make_figure and want to change the scaling of the data (since, in CIAO 4.4, images are only displayed using a linear scaling).

Scaling routines

Scaling Description
arcsinh or asinh This scales the data using the arcsinh routine to enhance low-level features whilst preserving structure in bright regions.
log Use the natural logarithm.
log10 Use the base-10 logarithm.
sqrt Takes the square root of the pixel values.
square Takes the square of the pixel values.
none Leaves the pixel values unchanged.


This routine modifies the data in the crate; it does not return a modified copy. There is no way to undo the changes made by this routine other than to use read_file() to re-read in the original data.

Loading the routine

The routine can be loaded into a ChIPS or Sherpa session by saying:

from crates_contrib.utils import *

Writing the data out to file

The write_file() command can be used to write the scaled data out to a new file.

Example 1

chips> cr = read_file("img.fits")
chips> scale_image_crate(cr)
chips> add_image(cr)
chips> set_plot_title("arcsinh scaling")
chips> set_image(["interpolation", "bilinear"])

Here we use the default scaling method (arcsinh) to scale the data before displaying it using the ChIPS add_image() command.

Example 2

chips> r = read_file("evt2.fits[energy=500:1500][bin sky=::4]")
chips> g = read_file("evt2.fits[energy=1500:3500][bin sky=::4]")
chips> b = read_file("evt2.fits[energy=3500:700][bin sky=::4]")
chips> scale_image_crate(r)
chips> scale_image_crate(g)
chips> scale_image_crate(b)
chips> add_image(r, g, b)

Here we use the default scaling method (arcsinh) to scale the three channels used to create a "true color" image.

Example 3

chips> cr = read_file("img.fits")
chips> scale_image_crate(cr, "log")
chips> write_file(cr, "img.scaled.fits")

A new file is created - called img.scaled.fits - which contains the natural logarithm of the pixel values.


The dmimgcalc routine is the preferred method to modify image files since using the Crates routines in CIAO 4.4 can lead to the loss of some metadata.


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, smooth_image_crate, write_arrays, write_columns
add_col, add_key, add_piximg, delete_col, delete_key, delete_piximg, read_file, read_pha, read_rmf, write_file, write_pha, write_rmf

Last modified: September 2011
Smithsonian Institute Smithsonian Institute

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