nifits.backend

Submodules

Package Contents

Classes

NIFITSClass

Class representation of the nifits object.

PointCollection

A class to hold arrays of coordinates. Handy to compute

MovingCollection

NI_Backend

A class to produce calculations based on the NIFITS standard.

Functions

col_row_numbers(n[, col_ceiling])

Attributes

nifits.backend.NIFITS_EXTENSIONS
nifits.backend.STATIC_EXTENSIONS = [True, True, True, True, False, False, False, False, False, True, True, False]
nifits.backend.NIFITS_EXTENSIONS
nifits.backend.STATIC_EXTENSIONS = [True, True, True, True, False, False, False, False, False, True, True, False]
class nifits.backend.NIFITSClass

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)

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)

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()

Check the coherence of the units of and prints the result

NI_IOUT, NI_KCOV, and NI_KIOUT if they exist.

Otherwise, does nothing.

nifits.backend.ModuleType
nifits.backend.ArrayLike
nifits.backend.mas2rad
nifits.backend.rad2mas
class nifits.backend.PointCollection[source]

Bases: object

A class to hold arrays of coordinates. Handy to compute

the transmission map on a large number of points.

Units default to mas.

Parameters:
  • aa – [unit (mas)] (ArrayLike) first coordinate flat array, typically RA.

  • bb – [unit (mas)] (ArrayLike) second coordinate flat array, typically Dec.

Constructors:
  • from_uniform_disk :

  • from_grid :

  • from_centered_square:

  • from_segment :

Modificators:
  • __add__ : basically a concatenation

  • transform : Linear transformation in 3D by a matrix

Handles:
  • coords : The array values as first provided

  • coords_rad : The array values, converted from self.unit into radians.

  • coords_quantity: Return the values as a quantity.

  • coords_radial : Returns the radial coordinates (rho,theta)

  • extent : The [left, right, top, bottom] extent (used for some plots).

property coords

Returns a tuple with the alpha and beta coordinates in flat arrays.

property coords_rad
property coords_radial

Returns the radial coordinates of points. (rho, theta) ([unit], [rad]).

property coords_shaped
aa: ArrayLike
bb: ArrayLike
unit: astropy.units.Unit
__post_init__()[source]
classmethod from_uniform_disk(radius: float = None, n: int = 10, phi_0: float = 0.0, offset: ArrayLike = np.array((0.0, 0.0)), md: ModuleType = np, unit: astropy.units.Unit = units.mas)[source]

Create a point collection as a uniformly sampled disk.

Parameters:
  • radius – [mas] The angular radius of the disk to model

  • n – The total number of points to create

  • phi_0 – [rad] Arbitrary angle to initialiaze pattern

  • offset – [mas] An offset of the disk location with respect to the center of the field of view

  • md – The numerical module to use as backend

  • unit – The unit to use for interactions

classmethod from_grid(a_coords: ArrayLike, b_coords: ArrayLike, md: ModuleType = np, unit: astropy.units.Unit = units.mas)[source]

Create a point collection as a cartesian grid.

Parameters:
  • a_coords – The array of samples along the first axis (typically alpha)

  • b_coords – The array of samples along the second axis (typically beta, the second dimension)

  • md – Module of choice for the computation

  • unit – Units for a_coords and b_coords

Handles:

classmethod from_segment(start_coords: ArrayLike, end_coords: ArrayLike, n_samples: int, md: ModuleType = np, unit: astropy.units.Unit = units.mas)[source]

Create a point collection as a cartesian grid.

Parameters:
  • start_coords – The (a,b) array of the starting point. (typically alpha, beta)

  • end_coords – The (a,b) array of the ending point. (typically alpha, beta)

  • n_sameples – The number of samples along the line.

Handles:

classmethod from_centered_square_grid(radius, resolution, md: ModuleType = np)[source]

Create a centered square cartesian grid object

Parameters:
  • radius – The radial extent of the grid.

  • resolution – The number of pixels across the width.

plot_frame(z=None, frame_index=0, wl_index=0, out_index=0, mycmap=None, marksize_increase=1.0, colorbar=True, xlabel=True, title=True)[source]
__add__(other)[source]

Add together two collection of points.

The result inerits properties of the first argument.

transform(matrix, md=np)[source]

Produce a linear transform of the coordinates.

Parameters:
  • matrix – A transformation matrix (3D)

  • md – A module to do the operation

class nifits.backend.MovingCollection[source]

Bases: object

property coords_rad
property coords
property coords_radial

Returns the radial coordinates of points. (rho, theta) ([unit], [rad]).

property coords_shaped
series: PointCollection
class nifits.backend.NI_Backend(nifits: nifits.io.oifits.nifits = None, module=np)[source]

Bases: object

A class to produce calculations based on the NIFITS standard.

nifits

Backend object. Typically created empty. The nifits instrument information are added later with:

  • .add_instrument_definition

  • .add_observation_data

Parameters:
  • nifits – NIFITSClass

  • module – A backend module for advanced math.

add_instrument_definition(nifits_instrument: nifits.io.oifits.nifits = None, force: bool = False, verbose: bool = True)[source]

Adds the instrument definition to the model.

Parameters:
  • nifits_instrument – NIFITS object

  • forceBool if True, then the existing extensions will be replaced

  • verbose – Get more printed information

add_observation_data(nifits_data: nifits.io.oifits.nifits = None, force: bool = False, verbose: bool = True)[source]

Adds the observation data to the model.

Parameters:
  • nifits_instrument – NIFITS object

  • forceBool if True, then the existing extensions will be replaced

  • verbose – Get more printed information

create_fov_function_all(md=np)[source]

Constructs the method to get the chromatic phasor given by injection for all the time series.

Parameters:

md – A module for the computations

Sets up self.ni_fov.xy2phasor

get_modulation_phasor(md=np)[source]

Computes and returns the modulation phasor [n_wl, n_input]

The modulation phasor includes is computed in units of collected amplitude so that the output of the transmission map in square modulus provides equivalent collecting power in m^2 for each point of the map. This is done to facilitate the usag of the map with models in jansky.

geometric_phasor(alpha, beta, include_mod=True, md=np)[source]

Returns the complex phasor corresponding to the locations of the family of sources

Parameters:
  • alpha – The coordinate matched to X in the array geometry

  • beta – The coordinate matched to Y in the array geometry

  • anarray – The array geometry (n_input, 2)

  • include_mod – Include the modulation phasor

Returns:

A vector of complex phasors

get_Is(xs, md=np)[source]

Get intensity from an array of sources.

get_KIs(Iarray: ArrayLike, md: ModuleType = np)[source]

Get the prost-processed observable from an array of output intensities. The post-processing matrix K is taken from self.nifits.ni_kmat.K

Parameters:
  • I – (n_frames, n_wl, n_outputs, n_batch)

  • md – a python module with a numpy-like interface.

Returns:

The vector \(\boldsymbol{\kappa} = \mathbf{K}\cdot\mathbf{I}\)

get_all_outs(alphas, betas, kernels=False, md=np)[source]

Compute the transmission map for an array of coordinates. The map can be seen as equivalent collecting power expressed in [m^2] for each point sampled so as to facilitate comparison with models in Jansky multiplied by the exposure time of each frame (available in nifits.ni_mod.int_time).

Parameters:
  • alphas – ArrayLike [rad] 1D array of coordinates in right ascension

  • betas – ArrayLike [rad] 1D array of coordinates in declination

  • kernels – (bool) if True, then computes the post-processed observables as per the KMAT matrix.

Returns:

the raw transmission output. if kernels is True: the differential observable.

Return type:

if kernels is False

Hint

Shape: (n_frames, n_wl, n_outputs, n_points)

moving_geometric_phasor(alphas, betas, include_mod=True, md=np)[source]

Returns the complex phasor corresponding to the locations of the family of sources

Parameters:

  • alpha : (n_frames, n_points) The coordinate matched to X in the array geometry

  • beta : (n_frames, n_points) The coordinate matched to Y in the array geometry

  • anarray : The array geometry (n_input, 2)

  • include_mod : Include the modulation phasor

Returns : A vector of complex phasors

get_moving_outs(alphas, betas, kernels=False, md=np)[source]

Compute the transmission map for an array of coordinates. The map can be seen as equivalent collecting power expressed in [m^2] for each point sampled so as to facilitate comparison with models in Jansky multiplied by the exposure time of each frame (available in nifits.ni_mod.int_time).

Parameters:
  • alphas – ArrayLike [rad] 1D array of coordinates in right ascension

  • betas – ArrayLike [rad] 1D array of coordinates in declination

  • kernels – (bool) if True, then computes the post-processed observables as per the KMAT matrix.

Returns:

the raw transmission output. if kernels is True: the differential observable.

Return type:

if kernels is False

Hint

Shape: (n_frames, n_wl, n_outputs, n_points)

downsample(Is)[source]

Downsample flux from the NI_OSWAVELENGTH bins to OI_WAVELENGTH bins. Expected shape is : (n_frames, n_wl, n_outputs, n_points), the method simply applies the NI_DSAMP matrix along the second axis (1).

Parameters:

Is – ArrayLike [flux] input the result computed with the oversampled wavelength channels. (n_frames, n_wlold, n_outputs, n_points)

Returns:

ArrayLike [flux] (n_frames, n_wlnew, n_outputs, n_points)

Return type:

Ids

Returns

plot_recorded(cmap='viridis', outputs=None, nrows_ncols=None, res_x=1000, res_y=500, interp='nearest')[source]
nifits.backend.col_row_numbers(n, col_ceiling=4)[source]