Skip to the navigation links
Last modified: December 2009

URL: http://cxc-newtest.cfa.harvard.edu/ciao4.2/copy_piximgvals.sl.html
AHELP for CIAO 4.2

copy_piximgvals

Context: sl.crates

Synopsis

Copy the image values from a crate.

Syntax

copy_piximgvals(crate);

Description

  • crate - input IMAGECrate

The copy_piximgvals command retrieves an array of the values of the specified image within the crate. The data values are copied into an array and that array is returned.

Example

slshgt; variable img = read_file("image.fits");
slshgt; variable vals_cpy = copy_piximgvals(img);
slshgt; print(vals_cpy);
0 0 0 0 0 0 0 0 0 0 0 0 0 6 4 6 4 7 3 9 6 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 4 7 3 4 5 9 2 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 4 12 6 5 5 8 5 5 4 5 6 1 0 0 0 0 0 0 0 0 0
...
slshgt; vals_cpy[0,0] = 99;
slshgt; print(vals_cpy);
99 0 0 0 0 0 0 0 0 0 0 0 0 6 4 6 4 7 3 9 6 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 4 7 3 4 5 9 2 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 4 12 6 5 5 8 5 5 4 5 6 1 0 0 0 0 0 0 0 0 0
...

Use copy_piximgvals to get the values of the image "image.fits" and print them to the screen. Change the first value to "99", then print the array again.

Should I use copy_piximgvals or get_piximgvals?

The copy_piximgvals routine was added to Crates in CIAO 4.2. It appears similar to get_piximgvals, so why was it added? The return value from get_piximgvals reflects the contents of the Crate, so that changes to the return value also change the crate, whereas copy_piximgvals returns a copy of this data.

It is generally going to be safer to use copy_piximgvals rather than get_piximgvals unless:

  • you do want to be able to change values in the crate for either future processing or to write out to disk
  • you have read in a large file and do not want to waste memory by creating another copy of the array

If the image being read in is a virtual one then the data is always going to be copied, so in this particular case there is no difference between copy_piximgvals and get_piximgvals.

Bugs

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

See Also

sl.crates
add_piximg, delete_piximg, get_piximg, get_piximg_shape, get_piximgvals, set_piximgvals

Last modified: December 2009