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-selection Mask class 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:

numpy.ndarray

correlation_matrix(masks, confidence_level=0.9)[source]
confusion_matrix(prediction, observation)[source]
class Mask(col_name, label, kind=None, value=0, col_name2=None, dat=None, verbose=False)[source]

Bases: object

Mask.

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 from value in col_name or col_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 is False

classmethod from_list(masks, label='combined', verbose=False)[source]
apply(dat)[source]
to_bool(hsp_mask)[source]
classmethod print_strings(coln, lab, num, fnum, f_out=None)[source]
print_stats(num_obj, f_out=None)[source]
get_sign(latex=False)[source]
print_condition(f_out, latex=False)[source]
print_summary(f_out)[source]
create_descr()[source]

Create Descr.

Create description of mask for later use in output file header.

Returns:

description

Return type:

str

add_summary_to_FITS_header(header)[source]
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 is False

Returns:

  • list – list of masks

  • dict – list of indices for given mask column name (label)