[AstroPy] Documentation or examples for working with UV-FITS files?
adam.g.ginsburg at gmail.com
Fri Dec 20 11:35:40 EST 2013
This should probably be submitted to the NRAO as a feature request
in CASA or a helpdesk ticket; it's probably possible within CASA but
just not well-documented. If we figure out how to do this, we should
probably get the solution posted on casaguides.nrao.edu.
That said, UVFITS files are FITS binary tables. They can be
accesses with astropy.io.fits. For anyone interested in having a
look, there are a lot of nicely reduced UVFITS files available from
https://archive.nrao.edu/cgi-bin/nvas-pos.pl (which can also be
queried via astroquery.readthedocs.org/en/latest/nvas.html).
Here's an example of how you can examine the contents of a UVFITS file:
In : d = fits.open('1.48F27CB_AY0015_1986OCT06_1.uvfits')
In : d
[<astropy.io.fits.hdu.image.PrimaryHDU at 0x10104d510>,
<astropy.io.fits.hdu.table.BinTableHDU at 0x10104dc10>,
<astropy.io.fits.hdu.table.BinTableHDU at 0x101056c90>,
<astropy.io.fits.hdu.table.BinTableHDU at 0x10105a8d0>,
<astropy.io.fits.hdu.table.BinTableHDU at 0x10105f150>,
<astropy.io.fits.hdu.table.BinTableHDU at 0x1010647d0>]
In : [(x,x.data.shape,x.data.dtype.names) for x in d]
[(<astropy.io.fits.hdu.image.PrimaryHDU at 0x10104d510>, (0, 777777701), None),
(<astropy.io.fits.hdu.table.BinTableHDU at 0x10104dc10>,
('FRQSEL', 'IF FREQ', 'CH WIDTH', 'TOTAL BANDWIDTH', 'SIDEBAND')),
(<astropy.io.fits.hdu.table.BinTableHDU at 0x101056c90>,
(<astropy.io.fits.hdu.table.BinTableHDU at 0x10105a8d0>,
(<astropy.io.fits.hdu.table.BinTableHDU at 0x10105f150>,
('TIME1', 'TIME2', 'SOURCE', 'AMPLITUDE', 'RMS', 'WEIGHT', 'CLOSURE')),
(<astropy.io.fits.hdu.table.BinTableHDU at 0x1010647d0>,
('UU---SIN', 'VV---SIN', 'WW---SIN', 'BASELINE', 'DATE', 'VISIBILITIES'))]
The visibilities are in the last header, so you can grab that table
and plot its various contents:
In : uvtable = d[-1].data
In : vis = uvtable['VISIBILITIES']
In : plot(uvtable['UU---SIN'],uvtable['VV---SIN'],',')
Out: [<matplotlib.lines.Line2D at 0x10b4a4ed0>]
In : plot(uvtable['UU---SIN'],vis.reshape([vis.shape,np.product(vis.shape[1:])]),',')
[snipped - there are lots]
Note the last reshaping is because there are lots of axes in
visibilities for polarization and other parameters; I haven't figure
out which headers/keywords describe them, but the information appears
to be there.
This should get you started...
On Fri, Dec 20, 2013 at 5:07 PM, Eric Jensen <ejensen1 at swarthmore.edu> wrote:
> Hi all,
> Can anyone point me to any documentation about UV-FITS files? I'd like to be able to take two UV-FITS files written from CASA (one of observed data and one of a model) and calculate the chi-squared of the data-model comparison in uv space. But I just can't find enough (read: any) documentation of the format to get a sense of how to do this.
> There's some information linked from here: https://safe.nrao.edu/wiki/bin/view/Software/CasaAipsSpwDefinition
> but it's a little hard (for me at least) to parse.
> As far as python implementation, Googling reveals this set of basic routines:
> but no documentation. And CASA has some uv data handling routines, but it doesn't appear to have general arithmetic routines for uv data. So I'd like to try to implement this in python, but I need some docs to help me get started.
> Thanks in advance for any help you can give,
> AstroPy mailing list
> AstroPy at scipy.org
Fellow, European Southern Observatory
More information about the AstroPy