cobi.simulation.Mask

class Mask(libdir, nside, select, apo_scale=0.0, apo_method='C2', gal_cut=0, verbose=True)[source]

Sky mask generator and manager for CMB analysis.

This class creates and handles various types of sky masks including survey footprints (LAT/SAT), galactic plane cuts, point source masks, and CO line emission masks. Supports apodization for optimal power spectrum estimation.

Parameters:
  • libdir (str) – Directory for caching mask files.

  • nside (int) – HEALPix resolution parameter.

  • select (str) – Mask type selector. Can combine multiple masks with ‘+’: - ‘lat’: LAT survey footprint - ‘sat’: SAT survey footprint - ‘co’: CO line emission mask - ‘ps’: Point source mask - ‘gal’: Galactic plane mask Example: ‘lat+gal+ps’ combines LAT, galactic, and point source masks.

  • apo_scale (float, default 0.0) – Apodization scale in degrees. If 0, no apodization applied.

  • apo_method ({'C1', 'C2', 'Gaussian'}, default 'C2') – Apodization method compatible with NaMaster.

  • gal_cut (float, int, or str, default 0) – Galactic cut specification: - float < 1: f_sky fraction (e.g., 0.4 for 40% sky) - int > 1: percentage (e.g., 40 for 40% sky) - str: direct percentage ‘40’, ‘60’, ‘70’, ‘80’, ‘90’ Only used when ‘gal’ or ‘GAL’ in select.

  • verbose (bool, default True) – Enable logging output.

nside

HEALPix resolution.

Type:

int

mask

The combined mask array (values 0-1).

Type:

ndarray

select

Mask type identifier.

Type:

str

apo_scale

Apodization scale in degrees.

Type:

float

fsky

Sky fraction (computed from mask).

Type:

float

get_mask()

Returns the mask array.

Examples

Create LAT mask with galactic cut:

mask = Mask(
    libdir='./masks',
    nside=512,
    select='lat+gal',
    gal_cut=20,  # 20% sky
    apo_scale=1.0,
    apo_method='C2'
)

mask_array = mask.mask
print(f"Sky fraction: {mask.fsky:.3f}")

Simple point source mask:

ps_mask = Mask(
    libdir='./masks',
    nside=512,
    select='ps',
    apo_scale=0.5
)

Combined mask for full analysis:

full_mask = Mask(
    libdir='./masks',
    nside=512,
    select='lat+gal+ps+co',
    gal_cut=40,
    apo_scale=1.0
)

Notes

  • Masks are cached to disk for efficient reuse

  • Apodization reduces mode-coupling in power spectra

  • Multiple masks are combined via multiplication

  • Compatible with NaMaster (pymaster) workflows

__init__(libdir, nside, select, apo_scale=0.0, apo_method='C2', gal_cut=0, verbose=True)[source]

Initializes the Mask class for handling and generating sky masks.

Parameters: nside (int): HEALPix resolution parameter. libdir (Optional[str], optional): Directory where the mask may be saved or loaded from. Defaults to None.

Parameters:
Return type:

None

Methods

__init__(libdir, nside, select[, apo_scale, ...])

Initializes the Mask class for handling and generating sky masks.

__init__(libdir, nside, select, apo_scale=0.0, apo_method='C2', gal_cut=0, verbose=True)[source]

Initializes the Mask class for handling and generating sky masks.

Parameters: nside (int): HEALPix resolution parameter. libdir (Optional[str], optional): Directory where the mask may be saved or loaded from. Defaults to None.

Parameters:
Return type:

None

__load_mask_healper__()[source]

Loads a mask from a file.

Returns: np.ndarray: The mask array.

Return type:

numpy.ndarray

__load_mask__()[source]

Loads a mask from a file.

Returns: np.ndarray: The mask array.

Return type:

numpy.ndarray

__calc_fsky__(mask=None)[source]

Calculates the fraction of sky covered by the mask.

Returns: float: The fraction of sky covered by the mask.

Return type:

float