oifits: auxiliary module to read and write oifits files

PyHdust auxiliary module: third-part module for reading/writing OIFITS files.

I made some modifications, but I keep the original README below.

This module is NOT related to the OIFITS Python module provided at http://www.mrao.cam.ac.uk/research/OAS/oi_data/oifits.html It is a (better) alternative.

To open an existing OIFITS file, use the oifits.open(filename) function. This will return an oifits object with the following members (any of which can be empty dictionaries or numpy arrays):

array: a dictionary of interferometric arrays, as defined by the OI_ARRAY tables. The dictionary key is the name of the array (ARRNAME).

target: a numpy array of targets, as defined by the rows of the OI_TARGET table.

wavelength: a dictionary of wavelength tables (OI_WAVELENGTH). The dictionary key is the name of the instrument/settings (INSNAME).

vis, vis2 and t3: numpy arrays of objects containing all the measurement information. Each list member corresponds to a row in an OI_VIS/OI_VIS2/OI_T3 table.

This module makes an ad-hoc, backwards-compatible change to the OIFITS revision 1 standard originally described by Pauls et al., 2005, PASP, 117, 1255. The OI_VIS and OI_VIS2 tables in OIFITS files produced by this file contain two additional columns for the correlated flux, CFLUX and CFLUXERR , which are arrays with a length corresponding to the number of wavelength elements (just as VISAMP/VIS2DATA).

The main purpose of this module is to allow easy access to your OIFITS data within Python, where you can then analyze it in any way you want. As of version 0.3, the module can now be used to create OIFITS files from scratch without serious pain. Be warned, creating an array table from scratch is probably like nailing jelly to a tree. In a future verison this will become easier.

The module also provides a simple mechanism for combining multiple oifits objects, achieved by using the ‘+’ operator on two oifits objects: result = a + b. The result can then be written to a file using result.save(filename).

Many of the parameters and their meanings are not specifically documented here. However, the nomenclature mirrors that of the OIFITS standard, so it is recommended to use this module with the PASP reference above in hand.

Beginning with version 0.3, the OI_VIS/OI_VIS2/OI_T3 classes now use masked arrays for convenience, where the mask is defined via the ‘flag’ member of these classes. Beware of the following subtlety: as before, the array data are accessed via (for example) OI_VIS.visamp; however, OI_VIS.visamp is just a method which constructs (on the fly) a masked array from OI_VIS._visamp, which is where the data are actually stored. This is done transparently, and the data can be accessed and modified transparently via the “visamp” hidden attribute. The same goes for correlated fluxes, differential/closure phases, triple products, etc. See the notes on the individual classes for a list of all the “hidden” attributes.

Example of OIfits merge (same target):

import pyhdust.oifits as oifits
oidata1 = oifits.open('file1.fits')
oidata2 = oifits.open('file2.fits')
oifits.matchtargetbyname = True
merge = oidata1 + oidata2
co-author:Daniel Moser
license:Copyright 2014 Paul Boley
class pyhdust.oifits.AMBER_SPECTRUM(wavelength, interfspec, interfspecerr, spectrum, spectrumerr, eff_wave, eff_band=None)[source]


class pyhdust.oifits.OI_ARRAY(frame, arrxyz, stations=())[source]

Contains all the data for a single OI_ARRAY table. Note the hidden convenience attributes latitude, longitude, and altitude.


Print the array’s center coordinates. If verbosity >= 1, print information about each station.

class pyhdust.oifits.OI_STATION(tel_name=None, sta_name=None, diameter=None, staxyz=[None, None, None])[source]

This class corresponds to a single row (i.e. single station/telescope) of an OI_ARRAY table.

class pyhdust.oifits.OI_T3(timeobs, int_time, t3amp, t3amperr, t3phi, t3phierr, flag, u1coord, v1coord, u2coord, v2coord, wavelength, target, array=None, station=(None, None, None))[source]

Class for storing triple product and closure phase data. To access the data, use the following hidden attributes:

t3amp, t3amperr, t3phi, t3phierr

class pyhdust.oifits.OI_VIS(timeobs, int_time, visamp, visamperr, visphi, visphierr, flag, ucoord, vcoord, wavelength, target, array=None, station=(None, None), cflux=None, cfluxerr=None)[source]

Class for storing visibility amplitude and differential phase data. To access the data, use the following hidden attributes:

visamp, visamperr, visphi, visphierr, flag; and possibly cflux, cfluxerr.

class pyhdust.oifits.OI_VIS2(timeobs, int_time, vis2data, vis2err, flag, ucoord, vcoord, wavelength, target, array=None, station=(None, None))[source]

Class for storing squared visibility amplitude data. To access the data, use the following hidden attributes:

vis2data, vis2err

pyhdust.oifits.getDate(hdu, hdulist)[source]

Get the header value of DATE-OBS from a hdu. If it is not valid, take it from “hdulist[0]”.

DEFINITION: The date of the observation, in the format specified in the FITS Standard. The old date format was ‘yy/mm/dd’ and may be used only for dates from 1900 through 1999. The new Y2K compliant date format is ‘yyyy-mm-dd’ or ‘yyyy-mm-ddTHH:MM:SS[.sss]’.

pyhdust.oifits.open(filename, quiet=False)[source]

Open an OIFITS file.