:py:mod:`nifits.backend` ======================== .. py:module:: nifits.backend Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 backend/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: nifits.backend.NIFITSClass nifits.backend.PointCollection nifits.backend.MovingCollection nifits.backend.NI_Backend Functions ~~~~~~~~~ .. autoapisummary:: nifits.backend.col_row_numbers Attributes ~~~~~~~~~~ .. autoapisummary:: nifits.backend.NIFITS_EXTENSIONS nifits.backend.STATIC_EXTENSIONS nifits.backend.NIFITS_EXTENSIONS nifits.backend.STATIC_EXTENSIONS nifits.backend.ModuleType nifits.backend.ArrayLike nifits.backend.mas2rad nifits.backend.rad2mas .. py:data:: NIFITS_EXTENSIONS .. py:data:: STATIC_EXTENSIONS :value: [True, True, True, True, False, False, False, False, False, True, True, False] .. py:data:: NIFITS_EXTENSIONS .. py:data:: STATIC_EXTENSIONS :value: [True, True, True, True, False, False, False, False, False, True, True, False] .. py:class:: NIFITSClass Bases: :py:obj:`object` Class representation of the nifits object. .. py:attribute:: header :type: astropy.io.fits.Header .. py:attribute:: oi_array :type: OI_ARRAY .. py:attribute:: ni_catm :type: NI_CATM .. py:attribute:: ni_fov :type: NI_FOV .. py:attribute:: ni_kmat :type: NI_KMAT .. py:attribute:: oi_wavelength :type: OI_WAVELENGTH .. py:attribute:: oi_target :type: OI_TARGET .. py:attribute:: ni_mod :type: NI_MOD .. py:attribute:: ni_iout :type: NI_IOUT .. py:attribute:: ni_kiout :type: NI_KIOUT .. py:attribute:: ni_kcov :type: NI_KCOV .. py:attribute:: ni_dsamp :type: NI_DSAMP .. py:attribute:: ni_oswavelength :type: NI_OSWAVELENGTH .. py:attribute:: ni_iotags :type: NI_IOTAGS .. py:method:: from_nifits(filename: str) :classmethod: Create the nifits object from the HDU extension of an opened fits file. .. py:method:: 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. :param static_only: (bool) only save the extensions corresponding to static parameters of the model (NI_CATM and NI_FOV). Default: False :param dynamic_only: (bool) only save the dynamic extensions. If true, the hash of the static file should be passed as `static_hash`. Defaultult: False :param static_hash: (str) The hash of the static file. Default: "" .. py:method:: 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. .. py:data:: ModuleType .. py:data:: ArrayLike .. py:data:: mas2rad .. py:data:: rad2mas .. py:class:: PointCollection Bases: :py:obj:`object` A class to hold arrays of coordinates. Handy to compute the transmission map on a large number of points. **Units default to mas.** :param aa: [unit (mas)] (ArrayLike) first coordinate flat array, typically RA. :param 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). .. py:property:: coords Returns a tuple with the ``alpha`` and ``beta`` coordinates in flat arrays. .. py:property:: coords_rad .. py:property:: coords_radial Returns the radial coordinates of points. (rho, theta) ([unit], [rad]). .. py:property:: coords_shaped .. py:attribute:: aa :type: ArrayLike .. py:attribute:: bb :type: ArrayLike .. py:attribute:: unit :type: astropy.units.Unit .. py:method:: __post_init__() .. py:method:: 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) :classmethod: Create a point collection as a uniformly sampled disk. :param radius: [mas] The angular radius of the disk to model :param n: The total number of points to create :param phi_0: [rad] Arbitrary angle to initialiaze pattern :param offset: [mas] An offset of the disk location with respect to the center of the field of view :param md: The numerical module to use as backend :param unit: The unit to use for interactions .. py:method:: from_grid(a_coords: ArrayLike, b_coords: ArrayLike, md: ModuleType = np, unit: astropy.units.Unit = units.mas) :classmethod: Create a point collection as a cartesian grid. :param a_coords: The array of samples along the first axis (typically alpha) :param b_coords: The array of samples along the second axis (typically beta, the second dimension) :param md: Module of choice for the computation :param unit: Units for ``a_coords`` and ``b_coords`` **Handles:** .. py:method:: from_segment(start_coords: ArrayLike, end_coords: ArrayLike, n_samples: int, md: ModuleType = np, unit: astropy.units.Unit = units.mas) :classmethod: Create a point collection as a cartesian grid. :param start_coords: The (a,b) array of the starting point. (typically alpha, beta) :param end_coords: The (a,b) array of the ending point. (typically alpha, beta) :param n_sameples: The number of samples along the line. **Handles:** .. py:method:: from_centered_square_grid(radius, resolution, md: ModuleType = np) :classmethod: Create a centered square cartesian grid object :param radius: The radial extent of the grid. :param resolution: The number of pixels across the width. .. py:method:: 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) .. py:method:: __add__(other) Add together two collection of points. The result inerits properties of the first argument. .. py:method:: transform(matrix, md=np) Produce a linear transform of the coordinates. :param matrix: A transformation matrix (3D) :param md: A module to do the operation .. py:class:: MovingCollection Bases: :py:obj:`object` .. py:property:: coords_rad .. py:property:: coords .. py:property:: coords_radial Returns the radial coordinates of points. (rho, theta) ([unit], [rad]). .. py:property:: coords_shaped .. py:attribute:: series :type: PointCollection .. py:class:: NI_Backend(nifits: nifits.io.oifits.nifits = None, module=np) Bases: :py:obj:`object` A class to produce calculations based on the NIFITS standard. .. py:attribute:: nifits Backend object. Typically created empty. The nifits instrument information are added later with: * ``.add_instrument_definition`` * ``.add_observation_data`` :param nifits: NIFITSClass :param module: A backend module for advanced math. .. py:method:: add_instrument_definition(nifits_instrument: nifits.io.oifits.nifits = None, force: bool = False, verbose: bool = True) Adds the instrument definition to the model. :param nifits_instrument: NIFITS object :param force: ``Bool`` if True, then the existing extensions will be replaced :param verbose: Get more printed information .. py:method:: add_observation_data(nifits_data: nifits.io.oifits.nifits = None, force: bool = False, verbose: bool = True) Adds the observation data to the model. :param nifits_instrument: NIFITS object :param force: ``Bool`` if True, then the existing extensions will be replaced :param verbose: Get more printed information .. py:method:: create_fov_function_all(md=np) Constructs the method to get the chromatic phasor given by injection for all the time series. :param md: A module for the computations Sets up ``self.ni_fov.xy2phasor`` .. py:method:: get_modulation_phasor(md=np) 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. .. py:method:: geometric_phasor(alpha, beta, include_mod=True, md=np) Returns the complex phasor corresponding to the locations of the family of sources :param alpha: The coordinate matched to X in the array geometry :param beta: The coordinate matched to Y in the array geometry :param anarray: The array geometry (n_input, 2) :param include_mod: Include the modulation phasor :returns: A vector of complex phasors .. py:method:: get_Is(xs, md=np) Get intensity from an array of sources. .. py:method:: get_KIs(Iarray: ArrayLike, md: ModuleType = np) Get the prost-processed observable from an array of output intensities. The post-processing matrix K is taken from ``self.nifits.ni_kmat.K`` :param I: (n_frames, n_wl, n_outputs, n_batch) :param md: a python module with a numpy-like interface. :returns: The vector :math:`\boldsymbol{\kappa} = \mathbf{K}\cdot\mathbf{I}` .. py:method:: get_all_outs(alphas, betas, kernels=False, md=np) 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`). :param alphas: ArrayLike [rad] 1D array of coordinates in right ascension :param betas: ArrayLike [rad] 1D array of coordinates in declination :param 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*. :rtype: if ``kernels`` is False .. hint:: **Shape:** (n_frames, n_wl, n_outputs, n_points) .. py:method:: moving_geometric_phasor(alphas, betas, include_mod=True, md=np) 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 .. py:method:: get_moving_outs(alphas, betas, kernels=False, md=np) 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`). :param alphas: ArrayLike [rad] 1D array of coordinates in right ascension :param betas: ArrayLike [rad] 1D array of coordinates in declination :param 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*. :rtype: if ``kernels`` is False .. hint:: **Shape:** (n_frames, n_wl, n_outputs, n_points) .. py:method:: downsample(Is) 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). :param 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) :rtype: Ids Returns .. py:method:: plot_recorded(cmap='viridis', outputs=None, nrows_ncols=None, res_x=1000, res_y=500, interp='nearest') .. py:function:: col_row_numbers(n, col_ceiling=4)