MicroLIA.helper_features
Created on Sat Jun 14 10:05:51 2023
@author: daniel
Module Contents
Functions
|
Inverse-variance weights that are finite and positive. |
|
Weighted value percentiles. |
|
Fraction of points more than 1σ above (sign=+1) or below (sign=−1) the median. |
|
Compute the weighted percentile of a 1D array. |
|
First significant digit (1–9) of absolute values. |
|
Detect duplicate values within a tolerance defined by errors. |
|
Weighted median of data x with weights w. |
|
(p_hi − p_lo) / (95th − 5th) percentile flux ratio, with optional weighting. |
|
Length of the longest consecutive True subsequence. |
|
Stetson normalized residuals (single-band). |
- MicroLIA.helper_features._safe_weights(magerr: numpy.typing.ArrayLike) numpy.ndarray[source]
Inverse-variance weights that are finite and positive.
- Parameters:
magerr (array-like) – Photometric errors.
- Returns:
w – Array of weights (1 / magerr²), with invalid entries set to 0.
- Return type:
ndarray
- MicroLIA.helper_features._weighted_percentiles(x: numpy.typing.ArrayLike, w: numpy.typing.ArrayLike, q: Union[float, Sequence[float], numpy.ndarray]) numpy.ndarray[source]
Weighted value percentiles.
- Parameters:
x (1-D array (already sorted ascending)) –
w (matching 1-D weights (non-negative, same order as x)) –
q (scalar or sequence in [0,1] (e.g. 0.95 or [0.05, 0.4, 0.6, 0.95])) –
- Returns:
percentiles
- Return type:
ndarray
- MicroLIA.helper_features._frac_sigma(mag: numpy.typing.ArrayLike, magerr: numpy.typing.ArrayLike, apply_weights: bool = True, sign: int = 1) float[source]
Fraction of points more than 1σ above (sign=+1) or below (sign=−1) the median.
- MicroLIA.helper_features._weighted_percentile(data: numpy.typing.ArrayLike, weights: numpy.typing.ArrayLike, percentile: float) float[source]
Compute the weighted percentile of a 1D array.
- Parameters:
data (array-like) – Input data values.
weights (array-like) – Non-negative weights associated with each data point. Must be the same length as data.
percentile (float) – Desired percentile in the range [0, 100].
- Returns:
value – The weighted percentile value of the input data.
- Return type:
- MicroLIA.helper_features._first_sig_digit(arr: numpy.typing.ArrayLike) numpy.ndarray[source]
First significant digit (1–9) of absolute values.
- Parameters:
arr (array-like) –
- Returns:
digits – Vectorized output, same shape as input.
- Return type:
int array
- MicroLIA.helper_features._dup_with_tol(values: numpy.typing.ArrayLike, errs: numpy.typing.ArrayLike, tol_factor: float = 2.0) int[source]
Detect duplicate values within a tolerance defined by errors.
- MicroLIA.helper_features._weighted_median(x: numpy.typing.ArrayLike, w: numpy.typing.ArrayLike) float[source]
Weighted median of data x with weights w.
- Parameters:
x (array-like) – Data values.
w (array-like) – Associated weights.
- Returns:
median – Weighted median.
- Return type:
- MicroLIA.helper_features._flux_percentile_ratio(mag: numpy.typing.ArrayLike, magerr: numpy.typing.ArrayLike, p_lo: float, p_hi: float, apply_weights: bool = True) float[source]
(p_hi − p_lo) / (95th − 5th) percentile flux ratio, with optional weighting.
- Parameters:
- Returns:
ratio – Flux percentile ratio.
- Return type:
- MicroLIA.helper_features._longest_true_run(mask: numpy.ndarray) int[source]
Length of the longest consecutive True subsequence.
- Parameters:
mask (1D bool array) –
- Returns:
max_run – Length of the longest run of True values.
- Return type:
- MicroLIA.helper_features._delta(mag: numpy.typing.ArrayLike, magerr: numpy.typing.ArrayLike) numpy.ndarray[source]
Stetson normalized residuals (single-band).
- Parameters:
mag (array-like) – Magnitudes.
magerr (array-like) – Magnitude errors.
- Returns:
delta – Normalized residuals.
- Return type:
ndarray