nraonrao
 
 NRAO Home > CASA > CasaDocument
image.fromarray - 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 Image tool is associated with a temporary image. This temporary image may be in memory or on disk, depending on its size. When you close the Image tool with the close 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 Coordsys tool(converted to a record) 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

Numeric array

allowed:

any

Default:

variant

csys

Coordinate System. Default is unset.

allowed:

any

Default:

record

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
bool

Example

"""  
#  
print "\t----\t fromarray Ex 1 \t----"  
ia.fromarray(outfile=’test.data’, pixels=ia.makearray(0, [64, 64, 4, 128]),  
             overwrite=true)  
mycs = ia.coordsys(axes=[0,1])  
ia.close()  
ia.fromarray(pixels=ia.makearray(1.0, [32, 64]), csys=mycs.torecord())  
mycs.done()  
ia.close()  
#  
"""

The first example creates a zero-filled image file named test.data which is of shape [64,64,4,128]. If you examine the header with 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 test.data is created and used to create a 2D temporary image.

Please send any comments or questions about CASA or AIPS++ to aips2-requests@nrao.edu

Copyright © 2007 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

Updated daily during alpha development.