virgil.oifits
Read and write OIFITS files with astropy.io.fits alone. This is the
maintained OIFITS path; OIData uses read_oifits whenever it
is given a file path or an opened HDUList (including pyoifits objects).
The reader supports:
- several wavelength channels (every baseline × channel becomes one sample);
- several
OI_VIS2/OI_VIS/OI_T3tables and epochs, matched byARRNAME,INSNAME(or anotherINSNAMEof the same array with identical wavelengths), station indices andMJD; FLAGcolumns and non-finite values, which are left out of the observables;- several targets, chosen with
target=; - absolute phases from
OI_VISVISPHIwhen there is noOI_T3.
Closure-phase triangles (a, b, c) find their baselines (a, b), (b, c)
and (a, c) in the visibility table with the same ARRNAME and INSNAME, or
else in one of the same array with identical wavelengths (the standard does
not require T3 and V² tables to share an INSNAME; station numbers belong to
an array, so another ARRNAME is never used). A baseline stored reversed is used as the conjugate. A
baseline stored in neither orientation (some MIRC-X and ESO phase-3 files omit
a baseline's V²) is placed at the OI_T3 row's own (u, v) as a flagged
sample, with one warning per file giving the number of such legs.
Functions
Read and write OIFITS files using only astropy.io.fits.
read_oifits turns an OIFITS file (a path or
any astropy HDUList) into the record that
virgil.oidata.OIData is built from, and
write_oifits writes an OIData or a dictionary
of tables to an OIFITS2 file. Each (baseline, wavelength) sample is one element of the flat
u, v and wavel arrays; closure phases index into them. See
OIFITS files for the details.
read_oifits(source, target=None, insname=None, frame_mjd='mean', extras=(), bandwidth=False)
Read an OIFITS file into the record OIData(source) is built from.
Prefers OI_VIS2 over amplitudes and OI_T3 over absolute phases; see
OIFITS files for the tables read and how closure
phases are matched.
Source: Pauls et al. (2005), references;
Duvert et al. (2015), references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str, os.PathLike, astropy.io.fits.HDUList, or a list of them
|
A path or an opened file. A list is read in order and concatenated. |
required |
target
|
str or int
|
Target to keep, by name or |
None
|
insname
|
str or sequence of str
|
Keep only tables with this |
None
|
frame_mjd
|
(mean, row)
|
Give every sample of a frame the frame's mean |
"mean"
|
extras
|
sequence of str
|
Any of |
()
|
bandwidth
|
bool
|
Also return each sample's |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Flat per-sample |
Raises:
| Type | Description |
|---|---|
ValueError
|
For several targets or instruments without |
write_oifits(data, filename, overwrite=True)
Write an OIData or a dictionary of OIFITS tables to an OIFITS2 file.
An OIData is written as OI_VIS2 with OI_T3 or OI_VIS phases, and
read back by read_oifits to the same
observables, errors, flags, frames, wavelengths and (u, v), and the times
if any (else MJD 0). Wavelengths are float32 (relative error 6e-8); frames
at one MJD get distinct TIMEs so they stay apart; closure phases
without station indices get placeholder stations (STAPLACE). A
dictionary of tables (columns as in
writing OIFITS, upper-case OIFITS names) has
phases in degrees.
Source: Duvert et al. (2015), references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
OIData or dict
|
V² with closure or absolute phases, or a mapping of table name to a
dict of columns ( |
required |
filename
|
str or PathLike
|
Output path. Missing parent directories are created. |
required |
overwrite
|
bool
|
Replace an existing file (default True). |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
The path written. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
KeyError
|
If a dictionary lacks |
OSError
|
If the file exists and |
build_hdulist(tables)
Build the OIFITS2 HDUList that :func:write_oifits writes.
Useful for adding non-standard columns or keywords before writing.