NRAO Home > CASA > CASA Toolkit Reference Manual
image.newimagefromarray - Function

1.1.1 Construct a CASA image from an array


Description

This function converts an array of any size into a CASA image file.

If outfile is given, the image is written to the specified disk file. If outfile is unset, the on-the-fly Image tool returned by this function is associated with a temporary image. This temporary image may be in memory or on disk, depending on its size. When you destroy the on-the-fly Image tool (with the done function) this temporary image is deleted.

At present, no matter what type the pixels array is, a real-valued image will be written (the input pixels will be converted to Float). In the future, Complex images will be supported.

The Coordinate System, provided as a record describing a Coordsys tool (via coordsys.torecord(), for instance) is optional. If you provide it, it must be dimensionally consistent with the pixels array you give (see also coordsys).

If you don’t provide the Coordinate System (unset), a default Coordinate System is made for you. If linear=F (the default) then it is a standard RA/DEC/Stokes/Spectral Coordinate System depending exactly upon the shape of the pixels array (Stokes axis must be no longer than 4 pixels and you may find the spectral axis coming out before the Stokes axis if say, shape=[64,64,32,4]). Extra dimensions are given linear coordinates. If linear=T then you get a linear Coordinate System.

Arguments





Inputs

outfile

Output image file name. Default is unset.

allowed:

string

Default:

pixels

A numeric array is required.

allowed:

any

Default:

variant

csys

Coordinate System. Default is unset.

allowed:

record

Default:

linear

Make a linear Coordinate System if csys not given

allowed:

bool

Default:

false

overwrite

Overwrite (unprompted) pre-existing output file?

allowed:

bool

Default:

false

log

Write image creation messages to logger

allowed:

bool

Default:

true

Returns
image

Example

 
 
"""  
#  
print "\t----\t newimagefromarray Ex 1 \t----"  
im1=ia.newimagefromarray(outfile=’test.data’,  
                         pixels=ia.makearray(0, [64, 64, 4, 128]),  
                         overwrite=true)  
cs1 = im1.coordsys(axes=[0,1])  
im1.done()  
im2 = ia.newimagefromarray(pixels=ia.makearray(1.0, [32, 64]),  
                           csys=cs1.torecord())  
cs1.done()  
im2.done()  
#  
"""  
 
 
The first example creates a zero-filled \imagefile\ named {\sff  
test.data} which is of shape [64,64,4,128].  If you examine the header  
with {\stff ia.summary()} you will see the default  
RA/DEC/Stokes/Frequency coordinate information.  In the second  
example, a Coordinate System describing the first two axes of the  
image {\sff test.data} is created and used to create a 2D image  
temporary image.  
 

__________________________________________________________________


More information about CASA may be found at the CASA web page

Copyright 2016 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search