RoboLowess

class gdt.core.background.binned.RoboLowess(counts, tstart, tstop, exposure, *, first_pass_chan_range=None)[source]

Bases: object

Background fitting using LOWESS with iterative sigma-clipping.

Parameters:
  • counts (np.ndarray) – Count array, shape (num_times, num_channels)

  • tstart (np.ndarray) – Time bin start edges, shape (num_times,)

  • tstop (np.ndarray) – Time bin stop edges, shape (num_times,)

  • exposure (np.ndarray) – Exposure of each bin, shape (num_times,)

  • first_pass_chan_range (tuple, optional) – (chan_min, chan_max) for Pass 1

Attributes Summary

dof

The degrees-of-freedom for each channel

statistic

The fit chi-squared statistic for each channel

statistic_name

'chisq'

Methods Summary

fit([win_size, min_frac, max_frac, ...])

Fit background model using two-pass LOWESS with sigma-clipping.

interpolate(tstart, tstop[, exposure, ...])

Interpolate the background model at given bin edges.

Attributes Documentation

dof

The degrees-of-freedom for each channel

Type:

(np.array)

statistic

The fit chi-squared statistic for each channel

Type:

(np.array)

statistic_name

‘chisq’

Type:

(str)

Methods Documentation

fit(win_size=None, min_frac=0.4, max_frac=0.95, spline_bc_type='clamped', lowess_iter=5, refit_after_clipping=True)[source]

Fit background model using two-pass LOWESS with sigma-clipping.

Parameters:
  • win_size (float, optional) – Absolute smoothing window in seconds. Converted internally to a LOWESS fraction via frac = win_size / data_range. If not provided, the fraction is auto-computed from the data.

  • min_frac (float) – Minimum window fraction (default 0.4)

  • max_frac (float) – Maximum window fraction (default 0.95)

  • spline_bc_type (str) – Spline boundary condition (default ‘clamped’)

  • lowess_iter (int) – LOWESS robustness iterations (default 5)

  • refit_after_clipping (bool) – If True, runs a final LOWESS fit on the retained background bins after iterative clipping. For high-time-resolution TTE data, such as 64 ms TTE binning, set to False to skip this final refit.

Returns:

(np.ndarray, np.ndarray, list)

Removed bin times, interpolated

background at removed times, iteration diagnostics

interpolate(tstart, tstop, exposure=None, channel_range=None)[source]

Interpolate the background model at given bin edges.

Parameters:
  • tstart (np.ndarray) – Bin start edges.

  • tstop (np.ndarray) – Bin stop edges.

  • channel_range (tuple, optional) – (chan_min, chan_max) inclusive.

Returns:

(np.ndarray, np.ndarray) – The interpolated model value and model uncertainty in each bin with shape (num_bins, num_channels).