nraonrao
 
 NRAO Home > CASA > CasaDocument
image.tofits - Function

1.1.1 Convert the image to a FITS file
Description

This function converts the image into a FITS file.

If the image has a rest frequency associated with it, it will always write velocity information into the FITS file. By default the frequency information will be primary as it is better defined than velocity information. If you select velocity=T then by default the velocity is written in the optical convention, but if optical=F it will use the radio convention instead.

The FITS definition demands equal increment pixels. Therefore, if you write velocity information as primary and use the optical velocity definition, the increment is computed at the spectral reference pixel. If the bandwidth is large, this may incur non-negligible coordinate calculation errors far from the reference pixel.

By default the image is written as a floating point FITS file (bitpix= -32). Under rare circumstances you might want to save space and write it as scaled 16 bit integers (bitpix = 16). You can have tofits calculate the scaling factors by using the default minpix and maxpix. If you set minpix and maxpix, values outside of that range will be truncated. This can be useful if all of the FITS images dynamic range is being used by a few high or low values and you are not interested in preserving those values exactly. Besides the factor of two space savings you get by using 16 instead of 32 bits, integer images usually also compress well (for example, with the standard GNU software facility gzip).

If the specified region-of-interest extends beyond the image, it is truncated.

The output mask is the combination (logical OR) of the default input pixel mask (if any) and the OTF mask.

Sometimes it is useful to drop axes of length one (degenerate axes) because not all FITS readers can handle them. Use the dropdeg argument if you want to do this.

Arguments





Inputs

outfile

FITS file name. Default is input name + ’.fits’

allowed:

string

Default:

velocity

prefer velocity (rather than frequency) as primary spectral axis?

allowed:

bool

Default:

false

optical

use the optical (rather than radio) velocity convention?

allowed:

bool

Default:

true

bitpix

Bits per pixel, -32 (floating point) or 16 (integer)

allowed:

int

Default:

-32

minpix

Minimum pixel value for BITPIX=16, Default is to autoscale if minpix ¿ maxpix.

allowed:

double

Default:

1

maxpix

Maximum pixel value for BITPIX=16, Default is to autoscale if maxpix ¡ minpix.

allowed:

double

Default:

-1

region

The region of interest. Default is whole image.

allowed:

any

Default:

record

mask

OTF mask, Boolean LEL expression or mask region Default is none.

allowed:

any

Default:

variant

overwrite

Overwrite (unprompted) pre-existing output file?

allowed:

bool

Default:

false

dropdeg

Drop degenerate axes?

allowed:

bool

Default:

false

deglast

Put degenerate axes last in header?

allowed:

bool

Default:

false

async

Run asynchronously?

allowed:

bool

Default:

false

Returns
bool

Example

"""  
#  
print "\t----\t tofits Ex 1 \t----"  
ia.maketestimage()  
ok = ia.tofits(’MYFILE.FITS’,overwrite=true)  
                       # write FITS image file  
ok = ia.tofits(’MYFILE2.FITS’, bitpix=16, overwrite=true)  
                       # Write as scaled 16 bit integers  
ia.close()  
#  
"""

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.