nifits.io.oifits

A module for reading/writing NIFITS files and handling the data.

To open an existing NIFITS file, use nifits.from_nifits constructor.

To save an NIFITS object to a file, use nifits.to_nifits method.

A summary of the information in the oifits object can be obtained by using the info() method:

> import oifits > oifitsobj = oifits.open(‘foo.fits’) > oifitsobj.info()

For further information, contact R. Laugier

Module Contents

Classes

OI_STATION

This class corresponds to a single row (i.e. single

NI_CATM

Contains the complex amplitude transfer matrix CATM of the instrument.

NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

NI_EXTENSION_ARRAY

Generic class for NIFITS array extensions

NI_EXTENSION_CPX_ARRAY

Generic class for NIFITS array extensions.

OI_ARRAY

NI_EXTENSION Generic class for NIFITS extensions

OI_WAVELENGTH

NI_EXTENSION Generic class for NIFITS extensions

NI_OSWAVELENGTH

NI_EXTENSION Generic class for NIFITS extensions

OI_TARGET

OI_TARGET definition.

NI_CATM

Contains the complex amplitude transfer matrix CATM of the instrument.

NI_IOUT

NI_EXTENSION Generic class for NIFITS extensions

NI_KIOUT

NI_EXTENSION Generic class for NIFITS extensions

NI_KCOV

Generic class for NIFITS array extensions

NI_KMAT

Generic class for NIFITS array extensions

NI_DSAMP

Generic class for NIFITS array extensions

NI_IOTAGS

Contains information on the inputs and outputs.

NI_MOD

Contains input modulation vector for the given observation. The format

NI_FOV

NI_EXTENSION Generic class for NIFITS extensions

nifits

Class representation of the nifits object.

Functions

check_item(func)

A decorator for the fits.Header.__getitem__.

_plurals(count)

array_eq(a, b)

Test whether all the elements of two arrays are equal.

_isnone(x)

Convenience hack for checking if x is none; needed because numpy

_notnone(x)

Convenience hack for checking if x is not none; needed because numpy

nulfunc(self, *args, **kwargs)

create_basic_fov_data(D, offset, lamb, n)

A convenience function to help define the FOV function and data model

getclass(classname)

Attributes

nifits.io.oifits.Table[source]
nifits.io.oifits.ArrayLike
nifits.io.oifits.__version__ = '0.0.6'
nifits.io.oifits.__standard_version__ = '0.4'
nifits.io.oifits._mjdzero
nifits.io.oifits.matchtargetbyname = False
nifits.io.oifits.matchstationbyname = False
nifits.io.oifits.refdate
nifits.io.oifits.check_item(func)[source]

A decorator for the fits.Header.__getitem__. This is here to save from compatibility issues with files of standard version <= 0.2 while warning that that this version will

nifits.io.oifits._plurals(count)[source]
nifits.io.oifits.array_eq(a: ArrayLike, b: ArrayLike)[source]

Test whether all the elements of two arrays are equal.

Parameters:
  • a – one input.

  • b – another input.

nifits.io.oifits._isnone(x)[source]

Convenience hack for checking if x is none; needed because numpy arrays will, at some point, return arrays for x == None.

nifits.io.oifits._notnone(x)[source]

Convenience hack for checking if x is not none; needed because numpy arrays will, at some point, return arrays for x != None.

class nifits.io.oifits.OI_STATION(tel_name=None, sta_name=None, diameter=None, staxyz=[None, None, None], fov=None, fovtype=None, revision=1)[source]

Bases: object

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

__eq__(other)[source]

Return self==value.

__ne__(other)[source]

Return self!=value.

__repr__()[source]

Return repr(self).

class nifits.io.oifits.NI_CATM[source]

Bases: object

Contains the complex amplitude transfer matrix CATM of the instrument. The CATM is a complex matrix representing the transformation from the each of the complex amplitude of electric field from the inputs to the outputs of the instrument. The dimensions are (n_ch, n_out, n_in) where n_ch represents the spectral channels.

It is expected that

\(\textbf{n}_{out} = \textbf{M}_{CATM}.\textbf{m}_{mod} \circ \textbf{x}_{in}\) with \(\textbf{m}_{mod}\) containded in NI_MOD.

Mcatm: ArrayLike
header: astropy.io.fits.Header
classmethod from_hdu(hdu: type(fits.hdu.ImageHDU))[source]

Create the NI_CATM object from the HDU extension of an opened fits file.

to_hdu()[source]

Returns and hdu object to save into fits

nifits.io.oifits.nulfunc(self, *args, **kwargs)[source]
nifits.io.oifits.NI_OITAG_DEFAULT_HEADER
nifits.io.oifits.NI_MOD_DEFAULT_HEADER
nifits.io.oifits.NI_FOV_DEFAULT_HEADER

Obtaining the goecentric location of observatories. (unchecked) `python from astroplan import Observer import astropy.coordinates as coords myobs = Observer.at_site("CHARA") print([acoord.value for acoord in myobs.location.to_geocentric()]) ` VLTI: 1946404.3410388362, -5467644.290798524, -2642728.2014442487 CHARA: -2484228.6029109913, -4660044.467216573, 3567867.961141405

nifits.io.oifits.OI_ARRAY_DEFAULT_VLTI_HEADER
nifits.io.oifits.OI_ARRAY_DEFAULT_CHARA_HEADER
class nifits.io.oifits.NI_EXTENSION[source]

Bases: object

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

data_table: Table
header: astropy.io.fits.Header
unit: astropy.units.Unit
classmethod from_hdu(hdu: type(fits.hdu.TableHDU))[source]

Create the data object from the HDU extension of an opened fits file.

Parameters:

hdu – TableHDU object containing the relevant data

to_hdu()[source]

Returns and hdu object to save into fits

__len__()[source]
class nifits.io.oifits.NI_EXTENSION_ARRAY[source]

Bases: NI_EXTENSION

Generic class for NIFITS array extensions

Parameters:
  • data_array – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property shape
data_array: ArrayLike
header: astropy.io.fits.Header
unit: astropy.units.Unit
classmethod from_hdu(hdu: type(fits.hdu.ImageHDU))[source]

Create the data object from the HDU extension of an opened fits file.

to_hdu()[source]

Returns and hdu object to save into fits

Note

This also updates the header if dimension changes

__len__()[source]
class nifits.io.oifits.NI_EXTENSION_CPX_ARRAY[source]

Bases: NI_EXTENSION

Generic class for NIFITS array extensions.

The array is kept locally as complex valued, but it is stored to and loaded from a real-valued array with an extra first dimension of length 2 for (real, imaginary) parts.

property shape
data_array: ArrayLike
header: astropy.io.fits.Header
classmethod from_hdu(hdu: type(fits.hdu.ImageHDU))[source]

Create the data object from the HDU extension of an opened fits file.

to_hdu()[source]

Returns and hdu object to save into fits

Note

This also updates the header if dimension changes

__len__()[source]
class nifits.io.oifits.OI_ARRAY[source]

Bases: NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

__doc__
name = 'OI_ARRAY'
class nifits.io.oifits.OI_WAVELENGTH[source]

Bases: NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property lambs
property dlambs
property nus
property dnus
__doc__
name = 'OI_WAVELENGTH'
class nifits.io.oifits.NI_OSWAVELENGTH[source]

Bases: NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property lambs
property dlambs
property nus
property dnus
__doc__
name = 'OI_WAVELENGTH'
class nifits.io.oifits.OI_TARGET[source]

Bases: NI_EXTENSION

OI_TARGET definition.

name = 'OI_TARGET'
classmethod from_scratch()[source]

Creates the OI_TARGET object with an empty table.

**Returns:

OI_TARGET: object with an empty table.

Use add_target() to finish the job.

add_target(target_id=0, target='MyTarget', raep0=0.0, decep0=0.0, equinox=0.0, ra_err=0.0, dec_err=0.0, sysvel=0.0, veltyp='', veldef='', pmra=0.0, pmdec=0.0, pmra_err=0.0, pmdec_err=0.0, parallax=0.0, para_err=0.0, spectyp='', category='')[source]

Use this method to add a row to the table of targets

Parameters:
  • target_id (param) – (default: 0)

  • target – (default: “MyTarget”)

  • raep0 – (default: 0.)

  • decep0 – (default: 0.)

  • equinox – (default: 0.)

  • ra_err – (default: 0.)

  • dec_err – (default: 0.)

  • sysvel – (default: 0.)

  • veltyp – (default: “”)

  • veldef – (default: “”)

  • pmra – (default: 0.)

  • pmdec – (default: 0.)

  • pmra_err – (default: 0.)

  • pmdec_err – (default: 0.)

  • parallax – (default: 0.)

  • para_err – (default: 0.)

  • spectyp – (default: “”)

  • category – (default: “”)

class nifits.io.oifits.NI_CATM[source]

Bases: NI_EXTENSION_CPX_ARRAY

Generic class for NIFITS array extensions.

The array is kept locally as complex valued, but it is stored to and loaded from a real-valued array with an extra first dimension of length 2 for (real, imaginary) parts.

property M
__doc__
name = 'NI_CATM'
class nifits.io.oifits.NI_IOUT[source]

Bases: NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property iout
__doc__
name = 'NI_IOUT'
set_unit(new_unit, comment=None)[source]
class nifits.io.oifits.NI_KIOUT[source]

Bases: NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property kiout
property shape
__doc__
unit: astropy.units.Unit
name = 'NI_KIOUT'
set_unit(new_unit, comment=None)[source]
class nifits.io.oifits.NI_KCOV[source]

Bases: NI_EXTENSION_ARRAY

Generic class for NIFITS array extensions

Parameters:
  • data_array – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property kcov
__doc__
unit: astropy.units.Unit
name = 'NI_KCOV'
set_unit(new_unit, comment=None)[source]
class nifits.io.oifits.NI_KMAT[source]

Bases: NI_EXTENSION_ARRAY

Generic class for NIFITS array extensions

Parameters:
  • data_array – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property K
__doc__
name = 'NI_KMAT'
class nifits.io.oifits.NI_DSAMP[source]

Bases: NI_EXTENSION_ARRAY

Generic class for NIFITS array extensions

Parameters:
  • data_array – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

property D
__doc__
name = 'NI_DSAMP'
class nifits.io.oifits.NI_IOTAGS[source]

Bases: NI_EXTENSION

Contains information on the inputs and outputs.

property outbright

The flags of bright outputs

property outdark

The flags of dark outputs

property outbright

The flags of photometric outputs

property outpola

The polarization of outputs.

property inpola

The polarization of inputs.

data_table: Table
header: astropy.io.fits.Header
name = 'NI_MOD'
class nifits.io.oifits.NI_MOD[source]

Bases: NI_EXTENSION

Contains input modulation vector for the given observation. The format is a complex phasor representing the alteration applied by the instrument to the light at its inputs. Either an intended modulation, or an estimated instrumental error. the dimenstions are (n_ch, n_in)

The effects modeled in NI_MOD must cumulate with some that may be modeled in NI_CATM. It is recommended to include in CATM the static effects and in NI_MOD any affect that may vary throughout the observµng run.

\(n_a \times \lambda\)

information.

Item

format

unit

comment

APP_INDEX

int

NA

Indices of subaperture (starts at 0)

TARGET_ID

int

d

Index of target in OI_TARGET

TIME

float

s

Backwards compatibility

MJD

float

day

INT_TIME

float

s

Exposure time

MOD_PHAS

n_{wl},n_a float

Complex phasor of modulation for all collectors

APPXY

n_a,2 float

m

Projected location of subapertures in the plane orthogonal to the line of sight and oriented as ( \alpha, \delta)

ARRCOL

n_a float

\mathrm{m}^2

Collecting area of the subaperture

FOV_INDEX

n_a int

NA

The entry of the NI_FOV to use for this subaperture.

property n_series
property all_phasors
property appxy

Shape n_frames x n_a x 2

abstract property dateobs

Get the dateobs from the weighted mean of the observation time from each of the observation times given in the rows of NI_MOD table.

property arrcol

The collecting area of the telescopes

property int_time

Conveniently retrieve the integration time.

data_table: Table
header: astropy.io.fits.Header
name = 'NI_MOD'
nifits.io.oifits.create_basic_fov_data(D, offset, lamb, n)[source]

A convenience function to help define the FOV function and data model

class nifits.io.oifits.NI_FOV[source]

Bases: NI_EXTENSION

NI_EXTENSION Generic class for NIFITS extensions

Inherited methods:

  • from_hdu: Creates the object from an astropy.io.fits.TableHDU object

  • to_hdu : Returns the TableHDU from itself.

Parameters:
  • data_table – [ArrayLike] The data to stored

  • header – [fits.Header] A fits header (optional)

  • unit – [astropy.units.Unit] Units of the data stored (mandatory of NI_IOUT, NI_KIOUT and NI_KCOV)

__doc__
name = 'NI_FOV'
classmethod simple_from_header(header=None, lamb=None, n=0)[source]

Constructor for a simple NIFITS NI_FOV object with chromatic gaussian profile and no offset.

Parameters:

header – (astropy.io.fits.Header) Header containing the required information such as NIFITS FOV_TELDIAM and NIFITS FOV_TELDIAM_UNIT which are used to create the gaussian profiles of radius \(\lambda/D\)

get_fov_function(lamb: ArrayLike, n: int)[source]

Returns the function to get the chromatic phasor given by injection for a the index n of the time series

This method will move to the backend

Parameters:
  • lamb – The array of wavelength bins [m]

  • n – The index of the time series to compute for

nifits.io.oifits.TEST_BACKUP = True
nifits.io.oifits.NIFITS_EXTENSIONS
nifits.io.oifits.NIFITS_KEYWORDS = []
nifits.io.oifits.STATIC_EXTENSIONS = [True, True, True, True, False, False, False, False, False, True, True, False]
nifits.io.oifits.getclass(classname)[source]
nifits.io.oifits.H_PREFIX = 'HIERARCH NIFITS '
class nifits.io.oifits.nifits[source]

Bases: object

Class representation of the nifits object.

header: astropy.io.fits.Header
oi_array: OI_ARRAY
ni_catm: NI_CATM
ni_fov: NI_FOV
ni_kmat: NI_KMAT
oi_wavelength: OI_WAVELENGTH
oi_target: OI_TARGET
ni_mod: NI_MOD
ni_iout: NI_IOUT
ni_kiout: NI_KIOUT
ni_kcov: NI_KCOV
ni_dsamp: NI_DSAMP
ni_oswavelength: NI_OSWAVELENGTH
ni_iotags: NI_IOTAGS
classmethod from_nifits(filename: str)[source]

Create the nifits object from the HDU extension of an opened fits file.

to_nifits(filename: str = '', static_only: bool = False, dynamic_only: bool = False, static_hash: str = '', writefile: bool = True, overwrite: bool = False)[source]

Write the extension objects to a nifits file.

Parameters:
  • static_only – (bool) only save the extensions corresponding to static parameters of the model (NI_CATM and NI_FOV). Default: False

  • dynamic_only – (bool) only save the dynamic extensions. If true, the hash of the static file should be passed as static_hash. Defaultult: False

  • static_hash – (str) The hash of the static file. Default: “”

check_unit_coherence()[source]

Check the coherence of the units of and prints the result

NI_IOUT, NI_KCOV, and NI_KIOUT if they exist.

Otherwise, does nothing.