nifits.backend package¶
Submodules¶
nifits.backend.backend module¶
Backend module¶
This module handles basic computation based on the NIFITS standard for representing the instrument. It reconstructs the model-in-a-kit following the standard.
It offers a limited capability to be powered with computing backends that have a numpy-compatible API.
- class nifits.backend.backend.MovingCollection(series)[source]¶
Bases:
object
- property coords¶
- property coords_rad¶
- property coords_radial¶
Returns the radial coordinates of points. (rho, theta) ([unit], [rad]).
- property coords_shaped¶
-
series:
PointCollection
¶
- class nifits.backend.backend.NI_Backend(nifits=None, module=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[source]¶
Bases:
object
A class to produce calculations based on the NIFITS standard.
- add_instrument_definition(nifits_instrument=None, force=False, verbose=True)[source]¶
Adds the instrument definition to the model.
- Parameters:
nifits_instrument (
nifits
) – NIFITS objectforce (
bool
) –Bool
if True, then the existing extensions will be replacedverbose (
bool
) – Get more printed information
- add_observation_data(nifits_data=None, force=False, verbose=True)[source]¶
Adds the observation data to the model.
- Parameters:
nifits_instrument – NIFITS object
force (
bool
) –Bool
if True, then the existing extensions will be replacedverbose (
bool
) – Get more printed information
- create_fov_function_all(md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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
- 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
- geometric_phasor(alpha, beta, include_mod=True, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[source]¶
Get intensity from an array of sources.
- get_KIs(Iarray, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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 (
ModuleType
) – 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=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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)
- get_modulation_phasor(md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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.
- get_moving_outs(alphas, betas, kernels=False, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[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 geometrybeta
: (n_frames, n_points) The coordinate matched to Y in the array geometryanarray
: The array geometry (n_input, 2)include_mod
: Include the modulation phasor
Returns : A vector of complex phasors
- 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.
- class nifits.backend.backend.PointCollection(aa=None, bb=None, unit=None)[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 (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – [unit (mas)] (ArrayLike) first coordinate flat array, typically RA.bb (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – [unit (mas)] (ArrayLike) second coordinate flat array, typically Dec.
- Constructors:
from_uniform_disk
:from_grid
:from_centered_square
:from_segment
:
- Modificators:
__add__
: basically a concatenationtransform
: Linear transformation in 3D by a matrix
- Handles:
coords
: The array values as first providedcoords_rad
: The array values, converted fromself.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).
-
aa:
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]] = None¶
-
bb:
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]] = None¶
- property coords¶
Returns a tuple with the
alpha
andbeta
coordinates in flat arrays.
- property coords_rad¶
- property coords_radial¶
Returns the radial coordinates of points. (rho, theta) ([unit], [rad]).
- property coords_shaped¶
- classmethod from_centered_square_grid(radius, resolution, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[source]¶
Create a centered square cartesian grid object
- Parameters:
radius – The radial extent of the grid.
resolution – The number of pixels across the width.
- classmethod from_grid(a_coords, b_coords, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>, unit=Unit("mas"))[source]¶
Create a point collection as a cartesian grid.
- Parameters:
a_coords (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The array of samples along the first axis (typically alpha)b_coords (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The array of samples along the second axis (typically beta, the second dimension)md (
ModuleType
) – Module of choice for the computationunit (
Unit
) – Units fora_coords
andb_coords
Handles:
- classmethod from_segment(start_coords, end_coords, n_samples, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>, unit=Unit("mas"))[source]¶
Create a point collection as a cartesian grid.
- Parameters:
start_coords (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The (a,b) array of the starting point. (typically alpha, beta)end_coords (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The (a,b) array of the ending point. (typically alpha, beta)n_sameples – The number of samples along the line.
Handles:
- classmethod from_uniform_disk(radius=None, n=10, phi_0=0.0, offset=array([0., 0.]), md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>, unit=Unit("mas"))[source]¶
Create a point collection as a uniformly sampled disk.
- Parameters:
radius (
float
) – [mas] The angular radius of the disk to modeln (
int
) – The total number of points to createphi_0 (
float
) – [rad] Arbitrary angle to initialiaze patternoffset (
Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – [mas] An offset of the disk location with respect to the center of the field of viewmd (
ModuleType
) – The numerical module to use as backendunit (
Unit
) – The unit to use for interactions
- 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]¶
- transform(matrix, md=<module 'numpy' from '/lhome/romain/miniconda3/envs/aiitec-jax/lib/python3.12/site-packages/numpy/__init__.py'>)[source]¶
Produce a linear transform of the coordinates.
- Parameters:
matrix – A transformation matrix (3D)
md – A module to do the operation
-
unit:
Unit
= None¶