sp_validation.masks¶
SPATIAL MASKS.
This module implements the healsparse-backed Mask class and the
spatial-masking helpers (config-driven mask construction, mask statistics,
correlation/confusion matrices) used when building catalogues.
- Author:
Martin Kilbinger
- apply_condition(array, kind, value)[source]¶
Apply Condition.
Evaluate one mask condition (
kind/value, as specified in mask config YAML files) against an array and return a boolean mask. Single shared grammar for the object-selectionMaskclass and the cosmo_inference footprint builder (see issue #181).- Parameters:
array (numpy.ndarray) – input data
kind (str) – operation type, one of “equal”, “not_equal”, “greater”, “greater_equal”, “less”, “less_equal” (alias “smaller_equal”), “range”
value (float or list) – value(s) to be used in mask operation; two-element list for “range”
- Returns:
boolean mask
- Return type:
- class Mask(col_name, label, kind=None, value=0, col_name2=None, dat=None, verbose=False)[source]¶
Bases:
objectMask.
Class to handle masking of catalogues.
- Parameters:
col_name (str) – name of column to use for mask
label (str) – mask label
kind (str) – operation type; see
apply_condition()for the allowed values, plus “not_equal_2bands”, which keeps objects whose value differs fromvalueincol_nameorcol_name2(two-band OR)value (float or list) – value(s) to be used in mask operation
col_name2 (str, optional) – name of second column; required for (and only used by) kind “not_equal_2bands”
dat (numpy.ndarray, optional) – input data, default is None; apply mask if given
verbose (bool, optional) – verbose output if
True; default isFalse
- print_mask_stats(num_obj, masks, mask_combined)[source]¶
Print Mask Stats.
Print mask statistics.
- Parameters:
num_obj
- get_masks_from_config(config, dat, dat_ext, masks_to_apply=None, verbose=False)[source]¶
Get Masks From Config.
Return mask information from yaml config structure.
- Parameters:
config (dict) – config information
dat (numpy.ndarray) – input data
det_ext (numpy.ndarray) – input extended data
masks_to_apply (list, optional) – masks to apply exclusively; if None (default), use all masks
verbose (bool, optional) – verbose output if
True; default isFalse
- Returns:
list – list of masks
dict – list of indices for given mask column name (label)