Importing Data from MIRIAD: Difference between revisions

From CASA Guides
Jump to navigationJump to search
No edit summary
No edit summary
Line 29: Line 29:


If you need to apply an update for the antenna positions, or linelength corrections, you should do these before exporting to FITS.
If you need to apply an update for the antenna positions, or linelength corrections, you should do these before exporting to FITS.


To update antenna positions:
To update antenna positions:
Line 36: Line 37:
uvedit vis=$PROJECT.vis out=$PROJECT.ant apfile=$ANTPOS
uvedit vis=$PROJECT.vis out=$PROJECT.ant apfile=$ANTPOS
</source>
</source>


To apply linelength corrections:
To apply linelength corrections:
Line 57: Line 59:
Now you should be ready to write out your CARMA UV data.  You will need to write out each spectral window as a separate FITS file, and then concatenate them back together within CASA.  In your shell script, just use a "foreach" loop.
Now you should be ready to write out your CARMA UV data.  You will need to write out each spectral window as a separate FITS file, and then concatenate them back together within CASA.  In your shell script, just use a "foreach" loop.


In this example, I am writing out the upper sideband windows only (windows 4,5, and 6):
In this example, I am writing out the upper sideband windows only (windows 4,5, and 6).  This loop produces one file for each spectral window, including data from all sources observed with that window.


#####
# Write out windows of individual sidebands to export to CASA for
# testing--all sources in same file for common window
#####


<source lang="bash">
<source lang="bash">
Line 72: Line 70:


== Constructing the CASA Measurement Set (MS) ==
== Constructing the CASA Measurement Set (MS) ==
If you have more than a couple spectral windows to import, I'd recommend using a little python to assemble the list of files for you, rather than having to tediously type out the whole list by hand. The following lines of code will produce an array of filenames that you can give CASA as an input for the "importuvfits" command:
<source lang="python">
# in python
from glob import glob as filesearch
import os
fitsdir='fits/'
msdir='./'
proj='c0437'
catfile=msdir+proj+'.ms'
inlist = sorted(filesearch(fitsdir+'*.fits'))
</source>
In the same python script, you can now use the following "for" loop to read each of the individual FITS files into an MS of the same name (e.g., for a FITS file named "c0437.4.fits", produce an MS called "c0437.4.ms" .)
<source lang="python">
# in python
for item in inlist:
    infile=item.split('/')[-1]
    outfile=infile.replace('.fits','.ms')
    importuvfits(fitsfile=item, vis=msdir+outfile)
</source>
Lastly, concatenate the individual spectral windows MS directories into one big MS containing all spectral windows, for all sources:
<source lang="python">
# in python
files = sorted(filesearch('*.ms'))
concat(vis=files,concatvis=catfile,freqtol="",dirtol="1arcsec",async=False)
</source>
== A final check ==
Of course, if you'd like to see whether or not "concat" produced something sensible, just run a "listobs" to make sure things look all right:
<source lang="python">
# in python
listobs(vis=catfile)
</source>





Revision as of 16:02, 23 November 2009


A filler routine is currently being developed to convert native MIRIAD format data into a CASA measurement set, but it has not yet been completed. The following steps describe how to use FITS format files to transfer CARMA data into CASA, and should still be useful even after the filler is operational. At that time, a description of how to use the CARMA filler routine will be added to this page.

This page assumes you have MIRIAD already installed. All MIRIAD commands are given in their shell-script (csh) form, assuming that a number of variables have been defined at the top of your script.

For this example, the following items would be defined at the beginning of the csh shell script:

# in csh script

#!/bin/csh
# FILE = name of original MIRIAD-format file
set FILE="../c0437.1E_115NGC694.1.miriad"
# PROJECT = base file name for processed data files
set PROJECT="c0437"
# ANTPOS = the location of the file which contains updates to the CARMA antenna positions
set ANTPOS="../antpos.090613"

Preparing MIRIAD data for export to FITS

To minimize the data you are transferring over, select only the astronomically useful data:

# in csh script
uvcat vis=$FILE  select='-source(NOISE),-auto' out=$PROJECT.vis

If you need to apply an update for the antenna positions, or linelength corrections, you should do these before exporting to FITS.


To update antenna positions:

# in csh script
uvedit vis=$PROJECT.vis out=$PROJECT.ant apfile=$ANTPOS


To apply linelength corrections:

# in csh script
linecal vis=$PROJECT.ant
uvcat vis=$PROJECT.ant out=$PROJECT.lc

Currently, MIRIAD writes out the identity of the array as identified by Antenna 1, which is a formerly-OVRO antenna. Thus, without correction, the dataset will identify the array as OVRO rather than CARMA, which means that CASA will make the same mistake. To fix this problem, simply do a small header edit:

# in csh script
puthd in=$PROJECT.lc/telescop value=CARMA


Writing out the FITS files

Now you should be ready to write out your CARMA UV data. You will need to write out each spectral window as a separate FITS file, and then concatenate them back together within CASA. In your shell script, just use a "foreach" loop.

In this example, I am writing out the upper sideband windows only (windows 4,5, and 6). This loop produces one file for each spectral window, including data from all sources observed with that window.


# in csh script
foreach i (4 5 6)
    fits in=$PROJECT.lc op=uvout select="win($i)" out="./fits/$PROJECT.$i.fits"
end

Constructing the CASA Measurement Set (MS)

If you have more than a couple spectral windows to import, I'd recommend using a little python to assemble the list of files for you, rather than having to tediously type out the whole list by hand. The following lines of code will produce an array of filenames that you can give CASA as an input for the "importuvfits" command:

# in python
from glob import glob as filesearch
import os

fitsdir='fits/'
msdir='./'
proj='c0437'
catfile=msdir+proj+'.ms'

inlist = sorted(filesearch(fitsdir+'*.fits'))

In the same python script, you can now use the following "for" loop to read each of the individual FITS files into an MS of the same name (e.g., for a FITS file named "c0437.4.fits", produce an MS called "c0437.4.ms" .)

# in python
for item in inlist:
    infile=item.split('/')[-1]
    outfile=infile.replace('.fits','.ms')
    importuvfits(fitsfile=item, vis=msdir+outfile)

Lastly, concatenate the individual spectral windows MS directories into one big MS containing all spectral windows, for all sources:

# in python
files = sorted(filesearch('*.ms'))
concat(vis=files,concatvis=catfile,freqtol="",dirtol="1arcsec",async=False)

A final check

Of course, if you'd like to see whether or not "concat" produced something sensible, just run a "listobs" to make sure things look all right:

# in python
listobs(vis=catfile)



--Mthornle 19:05, 23 November 2009 (UTC)