lezargus.library.container.functionality.broadcast module

lezargus.library.container.functionality.broadcast module#

Functions to properly broadcast one Lezargus container into another.

Sometimes operations are needed to be performed between two dimensions of data structures. We have functions here which serve to convert from one structure to another based on some broadcasting pattern. We properly handle the internal conversions (such as the flags, mask, wavelength, etc) as well based on the input template structure broadcasting to.

lezargus.library.container.functionality.broadcast.broadcast_spectrum_to_cube(input_spectrum: hint.LezargusSpectrum, shape: tuple, location: tuple | hint.NDArray | str, fill_value: float = 0, fill_uncertainty: float = 0) hint.LezargusCube[source]#

Make a LezargusCube from a LezargusSpectrum.

A LezargusCube is made from a LezargusSpectrum, with its overall shape being defined. The location of where to broadcast the spectrum to the cube is also custom as well.

Parameters:
  • input_spectrum (LezargusSpectrum) – The input spectrum which will be broadcasted to fit the input template cube.

  • shape (tuple) – The defined shape of the new cube. Either a two element tuple defining the spatial axes or a full three element tuple.

  • location (tuple | ndarray | str) –

    The spatial location of where the spectrum is broadcast too. A single location is specified by a two element tuple. If a 2D array, all parts where True the spectrum is applied. If a string, instead we use the following instructions:

    • ”center” : The spectrum is broadcast at the center, or close to it for the case of even edge shapes.

    • ”full” : The spectrum is broadcast across the entire spatial area.

  • fill_value (float, default = 0) – For the cube where there the spectrum is not being broadcast (i.e. outside the specified locations), we fill it with this data value.

  • fill_uncertainty (float, default = 0) – Similar to py:param:fill_value, but for the uncertainty part of the cube.

Returns:

broadcast_cube – The LezargusCube after the spectrum was uniformly broadcast spatially. Any header information came from first the spectrum then the cube.

Return type:

LezargusCube