hispecdrp.primitives.ramp_fitting.utils

Functions

bitwise_or_reduce(arr)

get_mid_delta_times(times, dq_raw)

Parallelized wrapper for get_mid_delta_times_ramp to apply on a 3D DQ array.

get_mid_delta_times_ramp(times, dq_raw)

Compute the mid time of the exposure accounting for the DQ flags: DO_NOT_USE, SATURATED, or JUMP_DET.

get_ramp_chunks(dq_raw)

Returns (starts, ends) arrays of indices of dtype int64.

mean_numba_if_not_zero(arr)

seconds_to_mjd_offset(seconds)

Convert a time offset in seconds to fractional days (MJD units).

bitwise_or_reduce(arr)[source]
get_mid_delta_times(times, dq_raw)[source]

Parallelized wrapper for get_mid_delta_times_ramp to apply on a 3D DQ array. Loops over the 2nd and 3rd dimensions (y, x) and applies get_mid_delta_times to each pixel.

Parameters:
  • times (np.ndarray) – 1D array of read times (length N_reads).

  • dq_raw (np.ndarray) – 3D array of DQ flags uint8 with shape (N_reads, Ny, Nx).

Returns:

mid_time_map (np.ndarray) – 2D array (Ny, Nx) of mid times for each pixel.

get_mid_delta_times_ramp(times, dq_raw)[source]

Compute the mid time of the exposure accounting for the DQ flags: DO_NOT_USE, SATURATED, or JUMP_DET.

Parameters:
  • times (np.ndarray) – 1D array of read times (length n_reads).

  • dq_raw (np.ndarray uint8) – 1D array of data quality flags (length n_reads).

Returns:

mid_delta_time (float) – Mid-exposure offset from the first read, in seconds (not MJD days).

get_ramp_chunks(dq_raw)[source]

Returns (starts, ends) arrays of indices of dtype int64. Drops everything at and after the first SATURATED index. Keeps the JUMP_DET read but splits before it (i.e., previous chunk ends at i-1, next chunk starts at i). Excludes DO_NOT_USE reads entirely (may split).

Notes

Does NOT filter out single-read chunks; wrapper does that.

Parameters:

dq_raw (np.ndarray uint8) – 1D array of data quality flags (length n_reads).

Returns:
  • starts (np.ndarray int32) – 1D array of starting indices of valid ramp chunks.

  • ends (np.ndarray int32) – 1D array of ending indices (exclusive) of valid ramp chunks.

mean_numba_if_not_zero(arr)[source]
seconds_to_mjd_offset(seconds)[source]

Convert a time offset in seconds to fractional days (MJD units).