In my codes, I usually use the masked array to define masks. An example code can be like:
import healpy as hp
import numpy as np
mask = hp.read_map("mask.fits")
map = hp.read_map("map.fits")
map_masked = hp.ma(map)
map_masked.mask = np.logical_not(mask)
C_l = hp.anafast(map_masked)
There is also the pymaster library in python, which is the implementation of NaMaster library. It is specifically used to compute various power spectra with mapped maps and binning. You define an nmt field object with a list of maps and the mask. Then use various built-in functions to compute various spectra like compute_full_master
. A sample:
import pymaster as nmt
f_0 = nmt.NmtFiels(mask, [map])
b = nmt.NmtBin.from_lmax_linear(lmax, nlb=21)
C_l = nmt.compute_full_master(f_0, f_0, b)
Just note that using the pymaster library is a bit computationally expensive.