module documentation

Quick tool for spectrally rebinning a FITS file, convolves a triangular function of bin_width with the input data and samples it every bin_step.

NOTE: Supersampling is not done in any special way, so if that is desired, set bin_width to the distance between two datapoints and bin_step to the supersampling length. This will not preserve the sum, but it should work when interpolation is required.

Class ResponseFunction Undocumented
Class SquareResponseFunction Undocumented
Class TriangularResponseFunction Undocumented
Function array_const_boundary Return the values on an arry such that any indices that are "to the left" return the first entry in the axis, and any that are "to the right" return the last entry in the axis.
Function exec_with_args Undocumented
Function go Thin wrapper around run() to accept string inputs. As long as the names of the arguments to this function are the same as the names expected from the command line we can do this programatically
Function indices_const_boundary Give a tuple with N entries indices like ((i_00,i_01,i_02,...,i_0M_0),(i_10,i_11,...,i_1M_1),...,(...,i_NM_N)), where N is the number of entries in shape which is like (s_0, s_1, ..., s_N), and M_0, M_1,...
Function lin_interp Given data defined at old_points along axis, linearly interpolate at new_points subject to boundary_conditions. Works on N-dimensional arrays, but only over one axis at a time.
Function overlap_add_convolve Performs convolution over axis of data by the overlap-and-add method with response_1d. Is generally faster for large data and small response_1d. The shape of the output array depends on the mode:
Function parse_args Undocumented
Function plot_rebin_response_function Undocumented
Function rebin_hdu_over_axis_with_response_function Undocumented
Function run Undocumented
Constant DEBUG_PIXEL Undocumented
Variable named_spectral_binning_parameters Undocumented
Variable _lgr Undocumented
def array_const_boundary(a: np.ndarray, indices: tuple[Sequence[int]]) -> np.ndarray:

Return the values on an arry such that any indices that are "to the left" return the first entry in the axis, and any that are "to the right" return the last entry in the axis.

def exec_with_args(argv):

Undocumented

def go(fits_spec, output_path=None, spectral_unit_in_meters=None, rebin_operation=None, output_unit=None, rebin_preset=None, rebin_params=None):

Thin wrapper around run() to accept string inputs. As long as the names of the arguments to this function are the same as the names expected from the command line we can do this programatically

def indices_const_boundary(indices: tuple[Sequence[int]], shape: tuple[int]) -> tuple[int]:

Give a tuple with N entries indices like ((i_00,i_01,i_02,...,i_0M_0),(i_10,i_11,...,i_1M_1),...,(...,i_NM_N)), where N is the number of entries in shape which is like (s_0, s_1, ..., s_N), and M_0, M_1, ..., M_N are the number of indices present for each axis.

Alter the indices so if i_nm < 0, i_nm=0. And if i_nm >= s_n, i_nm=s_n-1. I.e., indices "to the left" are set to the first entry in the axis, and indices "to the right" are set to the last entry in the axis.

def lin_interp(new_points: np.ndarray[[N]], old_points: np.ndarray[[M]], data: np.ndarray[[..., M, ...]], axis: int, boundary_conditions: Literal['constant'] | Literal['reflect'] | Literal['periodic'] | Literal['extrapolate'] = 'constant') -> np.ndarray:

Given data defined at old_points along axis, linearly interpolate at new_points subject to boundary_conditions. Works on N-dimensional arrays, but only over one axis at a time.

def overlap_add_convolve(data: np.ndarray[[..., M, ...]], response_1d: np.ndarray[[N]], axis: int, mode: Literal['same'] | Literal['full'] | Literal['valid'] = 'same') -> np.ndarray[[..., L, ...]]:

Performs convolution over axis of data by the overlap-and-add method with response_1d. Is generally faster for large data and small response_1d. The shape of the output array depends on the mode:

mode | output shape --------|----------------- 'same' | [...,'M',...] 'full' | [...,'M+2N',...] 'valid' | [...,'M-2N',...]

def parse_args(argv):

Undocumented

def plot_rebin_response_function(data_hdu, axis, spectral_unit_in_meters, new_spec_ax, new_data):

Undocumented

def rebin_hdu_over_axis_with_response_function(data_hdu, axis, response_function: ResponseFunction, bin_start: float | None = None, bin_step: float = 1e-09, axis_unit_conversion_factors: tuple[float, ...] = (1), plot: bool = True) -> tuple[np.ndarray, np.ndarray]:

Undocumented

def run(fits_spec: aph.fits.specifier.FitsSpecifier, output_path: Path | str, bin_step: float = 1e-09, bin_width: float = 2e-09, operation: Literal['sum'] | Literal['mean'] | Literal['mean_err'] = 'mean', spectral_unit_in_meters: float = 1, response_function_class: Literal[SquareResponseFunction] | Literal[TriangularResponseFunction] = TriangularResponseFunction, output_unit: u.Unit | None = None, plot: bool = False) -> tuple[np.ndarray, np.ndarray]:

Undocumented

DEBUG_PIXEL: tuple[int, ...] =

Undocumented

Value
(161, 168)
named_spectral_binning_parameters =

Undocumented

_lgr =

Undocumented