Get the pixel values from an image crate.
|crate||The image crate.|
The get_piximgvals command returns an array of values from the input image crate.
The get_piximg command returns a CrateData object for the image, which is useful if you are interested in the metadata associated with it.
>>> cr = read_file("image.fits") >>> vals = get_piximgvals(cr) >>> print(vals.shape) (201, 201) >>> print(vals.sum()) 6696
The get_piximgvals() call returns a numpy array which contains the pixel values.
Should I use copy_piximgvals or get_piximgvals?
The copy_piximgvals routine is similar to get_piximgvals, so when should you use it? 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.
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.