elisa.data.grouping#

Methods for grouping spectrum.

group_const(n: int, c: int) tuple[ndarray, bool][source]#

Group data by containing c channels in each group.

Parameters:
  • n (int) – Number of channels.

  • c (int) – Number of channels in each group.

Returns:

  • flag (ndarray) – Grouping flag.

  • (success: bool) – Whether the scale is met for all grouped channels.

group_min(data: ndarray, n: int) tuple[ndarray, bool][source]#

Group data by containing at least n counts in each channel.

Parameters:
  • data (ndarray) – array_like: Counts array.

  • n (int) – int: Minimum number of counts in each channel after grouping.

Returns:

  • flag (ndarray) – Grouping flag.

  • (success: bool) – Whether the scale is met for all grouped channels.

group_opt(fwhm: ndarray, net_counts: ndarray, bin_counts: ndarray | None = None, n: int | None = None) tuple[ndarray, bool][source]#

Optimal binning of the spectrum data [1].

Parameters:
  • fwhm (ndarray) – FWHM of the channel.

  • net_counts (ndarray) – Net counts of the channel.

  • bin_counts (ndarray | None) – Additional counts to be grouped.

  • n (int | None) – Grouping scale of the bin_counts.

Returns:

  • flag (ndarray) – Grouping flag.

  • (success: bool) – Whether the scale is met for all grouped channels.

References

[1]

Kaastra & Bleeker 2016, A&A 587, A151

significance_lima(n_on: float | ndarray, n_off: float | ndarray, a: float | ndarray) ndarray[source]#

Significance using the formula of Li & Ma 1983.

significance_gv(n: float | ndarray, b: float | ndarray, s: float | ndarray, a: float | ndarray) ndarray[source]#

Significance using the formula of Vianello 2018.

group_optsig_normal(fwhm: ndarray, net_counts: ndarray, counts: ndarray, errors: ndarray, sig: int | float) tuple[ndarray, bool][source]#

Optimal binning with an extra requirement of a minimum significance.

Parameters:
  • fwhm (ndarray) – FWHM of the channel.

  • net_counts (ndarray) – Net counts of the channel.

  • counts (ndarray) – Counts of the channel.

  • errors (ndarray) – Uncertainty of the counts.

  • sig (int | float) – Significance threshold.

Returns:

  • flag (ndarray) – Grouping flag.

  • (success: bool) – Whether the scale is met for all grouped channels.

group_sig_lima(n_on: ndarray, n_off: ndarray, *, spec_exposure: float, back_exposure: float, spec_area: _ScaleGroupData, spec_back: _ScaleGroupData, back_area: _ScaleGroupData, back_back: _ScaleGroupData, sig: float) tuple[ndarray, bool][source]#

Group Poisson source/background data by Li & Ma significance.

The source-to-background ratio is recomputed for every candidate bin from the grouped scale metadata instead of assuming a single constant ratio. Significance grouping always treats the source scales as total-spectrum scales, so NET averaging is not used here.

group_sig_gv(n: ndarray, b: ndarray, s: ndarray, *, spec_exposure: float, back_exposure: float, spec_area: _ScaleGroupData, spec_back: _ScaleGroupData, back_area: _ScaleGroupData, back_back: _ScaleGroupData, sig: float) tuple[ndarray, bool][source]#

Group Poisson data with Gaussian background by GV significance.

The source-to-background ratio is recomputed for every candidate bin from the grouped scale metadata instead of assuming a single constant ratio. Significance grouping always treats the source scales as total-spectrum scales, so NET averaging is not used here.

group_optsig_lima(fwhm: ndarray, net_counts: ndarray, n_on: ndarray, n_off: ndarray, *, spec_exposure: float, back_exposure: float, spec_area: _ScaleGroupData, spec_back: _ScaleGroupData, back_area: _ScaleGroupData, back_back: _ScaleGroupData, sig: float) tuple[ndarray, bool][source]#

Optimally group Poisson source/background data.

group_optsig_gv(fwhm: ndarray, net_counts: ndarray, n: ndarray, b: ndarray, s: ndarray, *, spec_exposure: float, back_exposure: float, spec_area: _ScaleGroupData, spec_back: _ScaleGroupData, back_area: _ScaleGroupData, back_back: _ScaleGroupData, sig: float) tuple[ndarray, bool][source]#

Optimally group Poisson data with Gaussian background.

group_sig_normal(count: ndarray, error: ndarray, sig: int | float) tuple[ndarray, bool][source]#

Group data by limiting the significance is greater than sig.

Parameters:
  • count (ndarray) – Counts array.

  • error (ndarray) – Uncertainty of counts.

  • sig (int | float) – Significance threshold.

Returns:

  • flag (ndarray) – Grouping flag.

  • (success: bool) – Whether the scale is met for all grouped channels.