NRAO Home > CASA > CASA Toolkit Reference Manual
ms.tofits - Function

1.3.1 Convert a measurement set to a uvfits file


Description

This function writes a uvfits file that contains the data in the measurement set associated with this tool. The fits file is always written in floating point format and the data are always stored in the primary array of the fits file.

IMPORTANT NOTE: In general, some of the data averaging features of this method have never worked properly. In general, users should run mstransform to select and average data prior to running tofits(). The associated input parameters are slowly being deprecated and removed.

If the measurement set has been imaged or calibrated in CASA, it may contain additional data columns. You need to select ONE of these columns to be written to the fits file. The possible options are:

observed
This is the raw data as collected by the telescope. All interferometric measurement sets must contain this column. A synonym for ’observed’ is ’data’.
corrected
This is the calibrated data. A synonym for ’corrected’ is ’corrected_data’.
model
This is the visibilites that would be measured using the current model of the sky. A synonym for ’model’ is ’model_data’.

The parsing of these strings is case insensitive. If any other option is specified then the observed data will be written.

By default a single-source uvfits file is written, but if the measurement set contains more than one field or if you set the multisource argument to True a multi-source uvfits file will be written. Because of limitations in the uvfits format you have to ensure that the data shape is fixed for all the data you intend to write to one fits file. See the general description of this tool for how you can select data to meet this condition.

The combinespw argument is used to control whether data from different spectral windows will be written as different entries in the fits FQ (frequency) table or combined as different IF’s within one entry in the FQ table. You should normally only set this to True if you know that the data from different spectral windows were observed simultaneously, and the data in the measurement set can be equally divided between all the spectral windows (i.e. each window should have the same width). Use of this switch is recommended for data to be processed in classic AIPS and difmap (if possible, e.g., standard dual IF observations).

The padwithflags argument is only relevant if combinespw is True. If true, it will fill in data that is ’missing’ with flags to fit the IF structure. This is appropriate if the MS had a few frequency-dependent flags applied, and was then time-averaged by split. If the spectral windows were observed at different times, padwithflags=True will add a large number of flags, making the output file significantly longer. It does not yet support spectral windows with different widths.

The fits GC (gain curve) and TY (system temperature) tables can be optionally written by setting the writesyscal argument to True. This is a rather WSRT-specific operation at the moment and may not work correctly for measurement sets from other telescopes.

The width argument is for channel averaging while outputing the data to the fits file. The default values of 1 will copy the channels of the input as is. The start channel number is the first channel of the spw expression. The number of output channels is determined by spw expression and the width. The width is the number of channels of the input data to make 1 channel of the output data.

One may overwrite the specified output file if it exists by specifying overwrite=True.

NOTE ON WEIGHTS

If the MS has no WEIGHT_SPECTRUM column, or if it does, but that column does not contain any data, ms.tofits() will compute the associated weight it writes to the uvfits file by taking the associated WEIGHT column value in the MS and dividing it by the number of channels associated with the spectral window of that visibility.

Arguments





Inputs

fitsfile

Name of the new uvfits file

allowed:

string

Default:

column

Data column to write, see above for options

allowed:

string

Default:

corrected

field

Field ids (0-based) or fieldnames to split out

allowed:

any

Default:

variant

spw

Spectral windows to split

allowed:

any

Default:

variant

width

DEPRECATED. Use mstransform to select and average data prior to running tofits().

allowed:

int

Default:

1

baseline

Antenna names or Antenna indices to select

allowed:

any

Default:

variant

time

Limit data selected to be within a given time range. Syntax is the defined in the msselection link

allowed:

string

Default:

scan

Limit data selected on scan numbers. Syntax is the defined in the msselection link

allowed:

any

Default:

variant

uvrange

Limit data selected on uv distance. Syntax is the defined in the msselection link

allowed:

any

Default:

variant

taql

For the TAQL experts, flexible data selection using the TAQL syntax

allowed:

string

Default:

writesyscal

Write GC and TY tables

allowed:

bool

Default:

false

multisource

Write in multisource format

allowed:

bool

Default:

false

combinespw

Export spectral windows as IFs

allowed:

bool

Default:

false

writestation

Write station name instead of antenna name

allowed:

bool

Default:

false

padwithflags

If combinespw==True, pad data with flags to fit IFs

allowed:

bool

Default:

false

overwrite

Overwrite output file if it exists?

allowed:

bool

Default:

false

Returns
bool

Example

 
 
 
      ms.open(’3C273XC1.MS’)  
      ms.tofits(’3C273XC1.fits’, column=’DATA’);  
      ms.done()  
 
     This example writes  the observed data of a measurement set to a  
     uvfits file.  
 
 
      ms.open(’big.ms’)  
      ms.tofits(’part.fits’, column=’CORRECTED’, field=[0,1], spw=[2]);  
      ms.done()  
 
     This example writes part (the first 2 fields and the third spectral  
     window) of the corrected data to the fits file.  
 
 

__________________________________________________________________


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