NaMaster
Data Structures | Macros | Typedefs | Functions
namaster.h File Reference

Go to the source code of this file.

Data Structures

struct  nmt_binning_scheme_flat
 Flat-sky bandpowers. More...
 
struct  nmt_binning_scheme
 Full-sky bandpowers. More...
 
struct  nmt_k_function
 Flat-sky Fourier-space function. More...
 
struct  nmt_flatsky_info
 Flat-sky information. More...
 
struct  nmt_field_flat
 Flat-sky field. More...
 
struct  nmt_curvedsky_info
 Curved-sky information. More...
 
struct  nmt_field
 Full-sky field. More...
 
struct  nmt_workspace_flat
 Flat-sky mode-coupling matrix. More...
 
struct  nmt_workspace
 Full-sky mode-coupling matrix. More...
 
struct  nmt_master_calculator
 
struct  nmt_covar_workspace_flat
 Flat-sky Gaussian covariance matrix. More...
 
struct  nmt_covar_workspace
 Full-sky Gaussian covariance matrix. More...
 

Macros

#define NMT_MAX(a, b)   (((a)>(b)) ? (a) : (b))
 
#define NMT_MIN(a, b)   (((a)<(b)) ? (a) : (b))
 

Typedefs

typedef double flouble
 
typedef double complex fcomplex
 

Functions

nmt_binning_scheme_flatnmt_bins_flat_constant (int nlb, flouble lmax)
 nmt_binning_scheme_flat constructor for constant bandpowers More...
 
nmt_binning_scheme_flatnmt_bins_flat_create (int nell, flouble *l0, flouble *lf)
 nmt_binning_scheme_flat generic constructor. More...
 
void nmt_bins_flat_free (nmt_binning_scheme_flat *bin)
 nmt_binning_scheme_flat destructor More...
 
void nmt_bin_cls_flat (nmt_binning_scheme_flat *bin, int nl, flouble *larr, flouble **cls_in, flouble **cls_out, int ncls)
 Returns average of input power spectrum into bandpowers. More...
 
void nmt_unbin_cls_flat (nmt_binning_scheme_flat *bin, flouble **cls_in, int nl, flouble *larr, flouble **cls_out, int ncls)
 Returns binned power spectra interpolated into an given set of multipoles. More...
 
void nmt_ell_eff_flat (nmt_binning_scheme_flat *bin, flouble *larr)
 Returns effective multipoles. More...
 
int nmt_bins_flat_search_fast (nmt_binning_scheme_flat *bin, flouble l, int il)
 Fast bin-searching routine for flat-sky bandpowers. More...
 
nmt_binning_schemenmt_bins_constant (int nlb, int lmax, int is_l2)
 nmt_binning_scheme constructor for constant bandpowers. More...
 
nmt_binning_schemenmt_bins_create (int nell, int *bpws, int *ells, flouble *weights, flouble *f_ell, int lmax)
 nmt_binning_scheme generic constructor. More...
 
nmt_binning_schemenmt_bins_read (char *fname, int lmax)
 nmt_binning_scheme constructor from file More...
 
void nmt_bins_free (nmt_binning_scheme *bin)
 nmt_binning_scheme destructor More...
 
void nmt_bin_cls (nmt_binning_scheme *bin, flouble **cls_in, flouble **cls_out, int ncls)
 Returns average of input power spectrum into bandpowers. More...
 
void nmt_unbin_cls (nmt_binning_scheme *bin, flouble **cls_in, flouble **cls_out, int ncls)
 Returns binned power spectra interpolated into output multipoles. More...
 
void nmt_ell_eff (nmt_binning_scheme *bin, flouble *larr)
 Returns effective multipoles. More...
 
nmt_k_functionnmt_k_function_alloc (int nk, flouble *karr, flouble *farr, flouble y0, flouble yf, int is_const)
 nmt_k_function creator. More...
 
void nmt_k_function_free (nmt_k_function *f)
 nmt_k_function destructor More...
 
flouble nmt_k_function_eval (nmt_k_function *f, flouble k, gsl_interp_accel *intacc)
 nmt_k_function evaluator. More...
 
nmt_flatsky_infonmt_flatsky_info_alloc (int nx, int ny, flouble lx, flouble ly)
 nmt_flatsky_info constructor More...
 
void nmt_flatsky_info_free (nmt_flatsky_info *fs)
 nmt_flatsky_info destructor. More...
 
void nmt_field_flat_free (nmt_field_flat *fl)
 nmt_field_flat destructor More...
 
nmt_field_flatnmt_field_flat_alloc (int nx, int ny, flouble lx, flouble ly, flouble *mask, int spin, flouble **maps, int ntemp, flouble ***temp, int nl_beam, flouble *l_beam, flouble *beam, int pure_e, int pure_b, double tol_pinv, int masked_input, int is_lite, int mask_only)
 nmt_field_flat constructor More...
 
flouble ** nmt_synfast_flat (int nx, int ny, flouble lx, flouble ly, int nfields, int *spin_arr, int nl_beam, flouble *l_beam, flouble **beam_fields, int nl_cell, flouble *l_cell, flouble **cell_fields, int seed)
 Gaussian realizations of flat-sky fields. More...
 
void nmt_purify_flat (nmt_field_flat *fl, flouble *mask, fcomplex **walm0, flouble **maps_in, flouble **maps_out, fcomplex **alms)
 E- or B-mode purifies a given pair of flat-sky (Q,U) maps. More...
 
nmt_curvedsky_infonmt_curvedsky_info_copy (nmt_curvedsky_info *cs_in)
 Makes a copy of a nmt_curvedsky_info structure. More...
 
nmt_curvedsky_infonmt_curvedsky_info_alloc (int is_healpix, long nside, int lmax_sht, int nx0, int ny0, flouble Dtheta, flouble Dphi, flouble phi0, flouble theta0)
 nmt_curvedsky_info creator More...
 
int nmt_diff_curvedsky_info (nmt_curvedsky_info *c1, nmt_curvedsky_info *c2)
 Compare two nmt_curvedsky_info structs. More...
 
floublenmt_extend_CAR_map (nmt_curvedsky_info *cs, flouble *map_in)
 Extend CAR map to cover the full circle. More...
 
void nmt_field_free (nmt_field *fl)
 nmt_field destructor. More...
 
nmt_fieldnmt_field_alloc_sph (nmt_curvedsky_info *cs, flouble *mask, int spin, flouble **maps, int ntemp, flouble ***temp, flouble *beam, int pure_e, int pure_b, int n_iter_mask_purify, double tol_pinv, int niter, int masked_input, int is_lite, int mask_only)
 nmt_field constructor More...
 
nmt_fieldnmt_field_read (int is_healpix, char *fname_mask, char *fname_maps, char *fname_temp, char *fname_beam, int spin, int pure_e, int pure_b, int n_iter_mask_purify, double tol_pinv, int niter)
 nmt_field constructor from file. More...
 
flouble ** nmt_synfast_sph (nmt_curvedsky_info *cs, int nfields, int *spin_arr, int lmax, flouble **cells, flouble **beam_fields, int seed)
 Gaussian realizations of full-sky fields. More...
 
void nmt_purify (nmt_field *fl, flouble *mask, fcomplex **walm0, flouble **maps_in, flouble **maps_out, fcomplex **alms, int niter)
 E- or B-mode purifies a given pair of full-sky (Q,U) maps. More...
 
void nmt_apodize_mask (long nside, flouble *mask_in, flouble *mask_out, flouble aposize, char *apotype)
 Apodize full-sky mask. More...
 
void nmt_apodize_mask_flat (int nx, int ny, flouble lx, flouble ly, flouble *mask_in, flouble *mask_out, flouble aposize, char *apotype)
 Apodize flat-sky mask. More...
 
void nmt_workspace_flat_free (nmt_workspace_flat *w)
 nmt_workspace_flat destructor More...
 
nmt_workspace_flatnmt_compute_coupling_matrix_flat (nmt_field_flat *fl1, nmt_field_flat *fl2, nmt_binning_scheme_flat *bin, flouble lmn_x, flouble lmx_x, flouble lmn_y, flouble lmx_y, int is_teb)
 Computes mode-coupling matrix. More...
 
void nmt_compute_deprojection_bias_flat (nmt_field_flat *fl1, nmt_field_flat *fl2, nmt_binning_scheme_flat *bin, flouble lmn_x, flouble lmx_x, flouble lmn_y, flouble lmx_y, int nl_prop, flouble *l_prop, flouble **cl_proposal, flouble **cl_bias)
 Computes deprojection bias. More...
 
void nmt_couple_cl_l_flat_fast (nmt_workspace_flat *w, int nl, flouble *larr, flouble **cl_in, flouble **cl_out)
 Mode-couples an input power spectrum. More...
 
void nmt_couple_cl_l_flat_quick (nmt_workspace_flat *w, int nl, flouble *larr, flouble **cl_in, flouble **cl_out)
 Mode-couples an input power spectrum. More...
 
void nmt_decouple_cl_l_flat (nmt_workspace_flat *w, flouble **cl_in, flouble **cl_noise_in, flouble **cl_bias, flouble **cl_out)
 Inverts mode-coupling matrix. More...
 
void nmt_compute_coupled_cell_flat (nmt_field_flat *fl1, nmt_field_flat *fl2, nmt_binning_scheme_flat *bin, flouble **cl_out, flouble lmn_x, flouble lmx_x, flouble lmn_y, flouble lmx_y)
 Coupled pseudo-CL. More...
 
nmt_workspace_flatnmt_compute_power_spectra_flat (nmt_field_flat *fl1, nmt_field_flat *fl2, nmt_binning_scheme_flat *bin, flouble lmn_x, flouble lmx_x, flouble lmn_y, flouble lmx_y, nmt_workspace_flat *w0, flouble **cl_noise, int nl_prop, flouble *l_prop, flouble **cl_prop, flouble **cl_out)
 Computes pseudo-CL specrum. More...
 
nmt_master_calculatornmt_compute_master_coefficients (int lmax, int lmax_mask, int npcl, flouble **pcl_masks, int s1, int s2, int pure_e1, int pure_b1, int pure_e2, int pure_b2, int do_teb, int l_toeplitz, int l_exact, int dl_band)
 
void nmt_master_calculator_free (nmt_master_calculator *c)
 
nmt_workspacenmt_compute_coupling_matrix (nmt_field *fl1, nmt_field *fl2, nmt_binning_scheme *bin, int is_teb, int niter, int lmax_mask, int l_toeplitz, int l_exact, int dl_band)
 Computes mode-coupling matrix. More...
 
void nmt_update_coupling_matrix (nmt_workspace *w, int n_rows, double *new_matrix)
 Updates the mode coupling matrix with a new one.Saves nmt_workspace structure to file. More...
 
void nmt_workspace_update_binning (nmt_workspace *w, nmt_binning_scheme *bin)
 Updates the binning scheme associated to this workspace. More...
 
void nmt_workspace_update_beams (nmt_workspace *w, int nl1, double *b1, int nl2, double *b2)
 Updates the beams associated to this workspace. More...
 
void nmt_workspace_free (nmt_workspace *w)
 nmt_workspace destructor More...
 
void nmt_compute_deprojection_bias (nmt_field *fl1, nmt_field *fl2, flouble **cl_proposal, flouble **cl_bias, int niter)
 Computes deprojection bias. More...
 
void nmt_compute_uncorr_noise_deprojection_bias (nmt_field *fl1, flouble *map_var, flouble **cl_bias, int niter)
 Noise bias from uncorrelated noise map. More...
 
void nmt_couple_cl_l (nmt_workspace *w, flouble **cl_in, flouble **cl_out)
 Mode-couples an input power spectrum. More...
 
void nmt_decouple_cl_l (nmt_workspace *w, flouble **cl_in, flouble **cl_noise_in, flouble **cl_bias, flouble **cl_out)
 Inverts mode-coupling matrix. More...
 
void nmt_compute_bandpower_windows (nmt_workspace *w, double *bpw_win_out)
 Returns the bandpower window functions for this workspace. More...
 
void nmt_compute_coupled_cell (nmt_field *fl1, nmt_field *fl2, flouble **cl_out)
 Coupled pseudo-CL. More...
 
nmt_workspacenmt_compute_power_spectra (nmt_field *fl1, nmt_field *fl2, nmt_binning_scheme *bin, nmt_workspace *w0, flouble **cl_noise, flouble **cl_proposal, flouble **cl_out, int niter, int lmax_mask, int l_toeplitz, int l_exact, int dl_band)
 Computes pseudo-CL specrum. More...
 
void nmt_covar_workspace_flat_free (nmt_covar_workspace_flat *cw)
 nmt_covar_workspace_flat destructor. More...
 
nmt_covar_workspace_flatnmt_covar_workspace_flat_init (nmt_field_flat *fla1, nmt_field_flat *fla2, nmt_binning_scheme_flat *ba, nmt_field_flat *flb1, nmt_field_flat *flb2, nmt_binning_scheme_flat *bb)
 nmt_covar_workspace_flat constructor More...
 
void nmt_compute_gaussian_covariance_flat (nmt_covar_workspace_flat *cw, int spin_a, int spin_b, int spin_c, int spin_d, nmt_workspace_flat *wa, nmt_workspace_flat *wb, int nl, flouble *larr, flouble **clac, flouble **clad, flouble **clbc, flouble **clbd, flouble *covar_out)
 Compute flat-sky Gaussian covariance matrix. More...
 
void nmt_covar_workspace_free (nmt_covar_workspace *cw)
 nmt_covar_workspace destructor. More...
 
nmt_covar_workspacenmt_covar_workspace_init (nmt_field *fla1, nmt_field *fla2, nmt_field *flb1, nmt_field *flb2, int lmax, int niter, int l_toeplitz, int l_exact, int dl_band)
 nmt_covar_workspace constructor More...
 
void nmt_compute_gaussian_covariance (nmt_covar_workspace *cw, int spin_a, int spin_b, int spin_c, int spin_d, nmt_workspace *wa, nmt_workspace *wb, flouble **clac, flouble **clad, flouble **clbc, flouble **clbd, flouble *covar_out)
 Compute full-sky Gaussian covariance matrix. More...
 
void nmt_compute_gaussian_covariance_coupled (nmt_covar_workspace *cw, int spin_a, int spin_b, int spin_c, int spin_d, nmt_workspace *wa, nmt_workspace *wb, flouble **clac, flouble **clad, flouble **clbc, flouble **clbd, flouble *covar_out)
 Compute full-sky Gaussian covariance matrix. More...
 
void nmt_workspace_write_fits (nmt_workspace *w, char *fname)
 Saves nmt_workspace structure to file. More...
 
nmt_workspacenmt_workspace_read_fits (char *fname)
 Builds nmt_workspace structure from file. More...
 
nmt_workspace_flatnmt_workspace_flat_read_fits (char *fname)
 Builds nmt_workspace_flat structure from file. More...
 
void nmt_workspace_flat_write_fits (nmt_workspace_flat *w, char *fname)
 Saves nmt_workspace_flat structure to file. More...
 
void nmt_covar_workspace_write_fits (nmt_covar_workspace *cw, char *fname)
 Saves nmt_covar_workspace structure to file. More...
 
nmt_covar_workspacenmt_covar_workspace_read_fits (char *fname)
 Builds nmt_covar_workspace structure from file. More...
 
void nmt_covar_workspace_flat_write_fits (nmt_covar_workspace_flat *cw, char *fname)
 Saves nmt_covar_workspace_flat structure to file. More...
 
nmt_covar_workspace_flatnmt_covar_workspace_flat_read_fits (char *fname)
 Builds nmt_covar_workspace_flat structure from file. More...
 

Macro Definition Documentation

#define NMT_MAX (   a,
 
)    (((a)>(b)) ? (a) : (b))
#define NMT_MIN (   a,
 
)    (((a)<(b)) ? (a) : (b))

Typedef Documentation

typedef double complex fcomplex
typedef double flouble

Function Documentation

void nmt_apodize_mask ( long  nside,
flouble mask_in,
flouble mask_out,
flouble  aposize,
char *  apotype 
)

Apodize full-sky mask.

Produces apodized version of a full-sky mask for a number of apodization schemes.

Parameters
nsideHEALPix resolution parameter.
mask_inInput mask to be apodized.
mask_outOutput apodized mask.
aposizeApodization scale (in degrees).
apotypeString defining the apodization procedure. Three values allowed: 'C1', 'C2' and 'Smooth'. These correspond to:
  • apotype = "C1". All pixels are multiplied by a factor $f$, given by:

    \[ f=\left\{ \begin{array}{cc} x-\sin(2\pi x)/(2\pi) & x<1\\ 1 & {\rm otherwise} \end{array} \right., \]

    where $x=\sqrt{(1-\cos\theta)/(1-\cos(\theta_*))}$, $\theta_*$ is the apodization scale and $\theta$ is the angular separation between a pixel and the nearest masked pixel (i.e. where the mask takes a zero value).
  • apotype = "C2". The same as the C1 case, but the function in this case is:

    \[ f=\left\{ \begin{array}{cc} \frac{1}{2}\left[1-\cos(\pi x)\right] & x<1\\ 1 & {\rm otherwise} \end{array} \right., \]

  • apotype = "Smooth". This apodization is carried out in three steps:
    1. All pixels within a disc of radius $2.5\theta_*$ of a masked pixel are masked.
    2. The resulting map is smooth with a Gaussian window function with standard deviation $\sigma=\theta_*$.
    3. One final pass is made through all pixels to ensure that all originally masked pixels are still masked after the smoothing operation.
void nmt_apodize_mask_flat ( int  nx,
int  ny,
flouble  lx,
flouble  ly,
flouble mask_in,
flouble mask_out,
flouble  aposize,
char *  apotype 
)

Apodize flat-sky mask.

Produces apodized version of a flat-sky mask for a number of apodization schemes.

Parameters
nxNumber of grid points in the x dimension
nyNumber of grid points in the y dimension
lxLength of the x dimension (in steradians)
lyLength of the y dimension (in steradians)
mask_inInput mask to be apodized.
mask_outOutput apodized mask.
aposizeApodization scale (in degrees).
apotypeString defining the apodization procedure. See definitions of nmt_apodize_mask().
void nmt_bin_cls ( nmt_binning_scheme bin,
flouble **  cls_in,
flouble **  cls_out,
int  ncls 
)

Returns average of input power spectrum into bandpowers.

Parameters
binnmt_binning_scheme structure defining the bandpowers.
cls_inArray of ncls input power spectra. They should be defined in all ells that go into any bandpower defined by bin.
cls_outArray of ncls averaged output power spectra. Should be allocated to the number of bandpowers defined bin.
nclsNumber of input/output power spectra.
void nmt_bin_cls_flat ( nmt_binning_scheme_flat bin,
int  nl,
flouble larr,
flouble **  cls_in,
flouble **  cls_out,
int  ncls 
)

Returns average of input power spectrum into bandpowers.

Parameters
binnmt_binning_scheme_flat structure defining the bandpowers.
nlNumber of elements in the input power spectra.
larrArray containing the nl multipoles at which the input power spectrum is defined.
cls_inArray of ncls input power spectra.
cls_outArray of ncls averaged output power spectra. Should be allocated to the number of bandpowers defined bin.
nclsNumber of input/output power spectra.
nmt_binning_scheme* nmt_bins_constant ( int  nlb,
int  lmax,
int  is_l2 
)

nmt_binning_scheme constructor for constant bandpowers.

nmt_binning_scheme constructor for bandpowers with constant width nlb, from ell = 2 to ell = lmax.

Parameters
nlbConstant band width
lmaxMaximum multipole
is_l2If not zero, will assume l*(l+1)/2pi weighting
Returns
Allocated binning structure.
nmt_binning_scheme* nmt_bins_create ( int  nell,
int *  bpws,
int *  ells,
flouble weights,
flouble f_ell,
int  lmax 
)

nmt_binning_scheme generic constructor.

Parameters
nellNumber of elements in all subsequent arrays.
bpwsArray of bandpower indices.
ellsArray of multipole values. This function collects all multipoles into their associated bandpowers.
weightsArray of weights associated to each multipole. Weights are normalized to 1 within each bandpower.
f_ellArray of ell-dependent prefactor (e.g. l*(l+1)/2pi is a typical choice). Pass NULL if you don't want any prefactor. normalized to 1 within each bandpower.
lmaxMaximum multipole to consider.
Returns
Allocated binning structure.
nmt_binning_scheme_flat* nmt_bins_flat_constant ( int  nlb,
flouble  lmax 
)

nmt_binning_scheme_flat constructor for constant bandpowers

nmt_binning_scheme_flat constructor for bandpowers with constant width nlb, from ell = 2 to ell = lmax.

Parameters
nlbConstant band width
lmaxMaximum multipole
Returns
Allocated binning structure.
nmt_binning_scheme_flat* nmt_bins_flat_create ( int  nell,
flouble l0,
flouble lf 
)

nmt_binning_scheme_flat generic constructor.

Parameters
nellNumber of bandpowers
l0Lower edge of all bandpowers (should be allocated to nell elements).
lfLower edge of all bandpowers (should be allocated to nell elements).
Returns
Allocated binning structure.
void nmt_bins_flat_free ( nmt_binning_scheme_flat bin)
int nmt_bins_flat_search_fast ( nmt_binning_scheme_flat bin,
flouble  l,
int  il 
)

Fast bin-searching routine for flat-sky bandpowers.

Returns the bandpower index in which a given ell falls. The functions is designed to be fast if a good guess for the bandpower index is supplied. A typical use would be to iterate over ell values and pass, as a guess index, the index found in the previous iteration.

Parameters
binnmt_binning_scheme_flat structure defining the bandpowers.
lMultipole for which you want the bandpower index.
ilGuessed bandpower index.
Returns
Bandpower index.
void nmt_bins_free ( nmt_binning_scheme bin)

nmt_binning_scheme destructor

nmt_binning_scheme* nmt_bins_read ( char *  fname,
int  lmax 
)

nmt_binning_scheme constructor from file

Builds a nmt_binning_scheme structure from an ASCII file.

Parameters
fnamePath to file containing information to build bandpowers. The file should contain three columns, corresponding to: bandpower index, multipole and weight (in this order). See definition of nmt_bins_create().
lmaxMaximum multipole to be considered.
Returns
Allocated binning structure.
void nmt_compute_bandpower_windows ( nmt_workspace w,
double *  bpw_win_out 
)

Returns the bandpower window functions for this workspace.

This function returns, in a flattened array, the bandpower window functions associated with the mode-coupling matrix stored in this workspace. The effect of the PCL estimator on the unbinned theory prediction can be fully accounted for by convolving it with these window functions.

Parameters
wnmt_workspace containing the mode-coupling matrix.
bpw_win_outoutput 1D array allocated to the right size (n_cls * n_bpw * n_cls * (lmax+1)).
void nmt_compute_coupled_cell ( nmt_field fl1,
nmt_field fl2,
flouble **  cl_out 
)

Coupled pseudo-CL.

Computes the pseudo-CL power spectrum of two fields without accounting for the mode-coupling matrix. This is essentially equivalent to running HEALPix's 'anafast' on the purified and contaminant-deprojected input fields. See notes about power spectrum ordering in the main page of this documentation.

Parameters
fl1nmt_field structure defining the first field to correlate.
fl2nmt_field structure defining the second field to correlate.
cl_outOuptput power spectrum. Should be allocated to shape [ncls][lmax+1], where ncls is the appropriate number of power spectra (e.g. 4=2*2 for two spin-2 fields).
void nmt_compute_coupled_cell_flat ( nmt_field_flat fl1,
nmt_field_flat fl2,
nmt_binning_scheme_flat bin,
flouble **  cl_out,
flouble  lmn_x,
flouble  lmx_x,
flouble  lmn_y,
flouble  lmx_y 
)

Coupled pseudo-CL.

Computes the pseudo-CL power spectrum of two fields without accounting for the mode-coupling matrix. See notes about power spectrum ordering in the main page of this documentation.

Parameters
fl1nmt_field_flat structure defining the first field to correlate.
fl2nmt_field_flat structure defining the second field to correlate.
binnmt_binning_scheme_flat defining the power spectrum bandpowers.
lmn_xLower end of the range of multipoles in the x direction that should be masked.
lmx_xUpper end of the range of multipoles in the x direction that should be masked. if lmx_x < lmn_x, no Fourier-space masked is performed.
lmn_ySame as lmn_x for the y direction.
lmx_ySame as lmx_x for the y direction.
cl_outOuptput power spectrum. Should be allocated to shape [ncls][nbpw], where ncls is the appropriate number of power spectra (e.g. 4=2*2 for two spin-2 fields), and nbpw is the number of bandpowers defined by bin.
nmt_workspace* nmt_compute_coupling_matrix ( nmt_field fl1,
nmt_field fl2,
nmt_binning_scheme bin,
int  is_teb,
int  niter,
int  lmax_mask,
int  l_toeplitz,
int  l_exact,
int  dl_band 
)

Computes mode-coupling matrix.

Computes MCM for a given pair of full-sky fields.

Parameters
fl1nmt_field structure defining the first field to correlate.
fl2nmt_field structure defining the second field to correlate.
binnmt_binning_scheme defining the power spectrum bandpowers.
is_tebif !=0, all mode-coupling matrices (0-0,0-2,2-2) will be computed at the same time.
niternumber of iterations when computing alms.
lmax_maskmaximum multipole to which the masks should be resolved. If smaller than the maximum multipole of fl1/fl2, it will be set to that.
Returns
Newly allocated nmt_workspace structure containing the mode-coupling matrix.
nmt_workspace_flat* nmt_compute_coupling_matrix_flat ( nmt_field_flat fl1,
nmt_field_flat fl2,
nmt_binning_scheme_flat bin,
flouble  lmn_x,
flouble  lmx_x,
flouble  lmn_y,
flouble  lmx_y,
int  is_teb 
)

Computes mode-coupling matrix.

Computes MCM for a given pair of flat-sky fields.

Parameters
fl1nmt_field_flat structure defining the first field to correlate.
fl2nmt_field_flat structure defining the second field to correlate.
binnmt_binning_scheme_flat defining the power spectrum bandpowers.
lmn_xLower end of the range of multipoles in the x direction that should be masked.
lmx_xUpper end of the range of multipoles in the x direction that should be masked. if lmx_x < lmn_x, no Fourier-space masked is performed.
lmn_ySame as lmn_x for the y direction.
lmx_ySame as lmx_x for the y direction.
is_tebif !=0, all mode-coupling matrices (0-0,0-2,2-2) will be computed at the same time.
void nmt_compute_deprojection_bias ( nmt_field fl1,
nmt_field fl2,
flouble **  cl_proposal,
flouble **  cl_bias,
int  niter 
)

Computes deprojection bias.

Computes contaminant deprojection bias for a pair of fields. See notes about power spectrum ordering in the main page of this documentation.

Parameters
fl1nmt_field structure defining the first field to correlate.
fl2nmt_field structure defining the second field to correlate.
cl_proposalProposed power spectrum. Should have shape [ncls][lmax+1], where ncls is the appropriate number of power spectra given the spins of the input fields (e.g. ncls = 2*2 = 4 if both fields have spin=2).
cl_biasOuptput deprojection bias. Should be allocated to shape [ncls][lmax+1], where ncls is defined above.
niternumber of iterations when computing alms.
void nmt_compute_deprojection_bias_flat ( nmt_field_flat fl1,
nmt_field_flat fl2,
nmt_binning_scheme_flat bin,
flouble  lmn_x,
flouble  lmx_x,
flouble  lmn_y,
flouble  lmx_y,
int  nl_prop,
flouble l_prop,
flouble **  cl_proposal,
flouble **  cl_bias 
)

Computes deprojection bias.

Computes contaminant deprojection bias for a pair of fields. See notes about power spectrum ordering in the main page of this documentation.

Parameters
fl1nmt_field_flat structure defining the first field to correlate.
fl2nmt_field_flat structure defining the second field to correlate.
binnmt_binning_scheme_flat defining the power spectrum bandpowers.
lmn_xLower end of the range of multipoles in the x direction that should be masked.
lmx_xUpper end of the range of multipoles in the x direction that should be masked. if lmx_x < lmn_x, no Fourier-space masked is performed.
lmn_ySame as lmn_x for the y direction.
lmx_ySame as lmx_x for the y direction.
nl_propNumber of multipoles over which the proposed power spectrum is defined.
l_propArray of multipoles over which the proposed power spectrum is defined.
cl_proposalProposed power spectrum. Should have shape [ncls][nl_prop], where ncls is the appropriate number of power spectra given the spins of the input fields (e.g. ncls = 2*2 = 4 if both fields have spin=2).
cl_biasOuptput deprojection bias. Should be allocated to shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers defined by bin.
void nmt_compute_gaussian_covariance ( nmt_covar_workspace cw,
int  spin_a,
int  spin_b,
int  spin_c,
int  spin_d,
nmt_workspace wa,
nmt_workspace wb,
flouble **  clac,
flouble **  clad,
flouble **  clbc,
flouble **  clbd,
flouble covar_out 
)

Compute full-sky Gaussian covariance matrix.

Computes the covariance matrix for two sets of power spectra given input predicted spectra and a nmt_covar_workspace structure.

Parameters
cwnmt_covar_workspace structure containing the information necessary to compute the covariance matrix.
spin_afield a spin.
spin_bfield b spin.
spin_cfield c spin.
spin_dfield d spin.
wanmt_workspace structure containing the mode-coupling matrix for the first power spectra.
wbnmt_workspace structure containing the mode-coupling matrix for the second power spectra.
clacCross-power spectra between field 1 in the first set and field 1 in the second set (ac) All power spectra should be defined for all ell < lmax.
cladCross-power spectra between field 1 in the first set and field 2 in the second set (ad)
clbcCross-power spectra between field 2 in the first set and field 1 in the second set (bc)
clbdCross-power spectra between field 2 in the first set and field 2 in the second set (bd)
covar_outflattened covariance matrix. Should be allocated to shape [ncls_1 * nbpw_1 * ncls_2 * nbpw_2], where nbpw_X and ncls_X are the number of bandpowers and different power spectra in the X-th set of fields.
void nmt_compute_gaussian_covariance_coupled ( nmt_covar_workspace cw,
int  spin_a,
int  spin_b,
int  spin_c,
int  spin_d,
nmt_workspace wa,
nmt_workspace wb,
flouble **  clac,
flouble **  clad,
flouble **  clbc,
flouble **  clbd,
flouble covar_out 
)

Compute full-sky Gaussian covariance matrix.

Computes the covariance matrix for two sets of power spectra given input predicted spectra and a nmt_covar_workspace structure. Calculation done for the mode-coupled pseudo-Cls.

Parameters
cwnmt_covar_workspace structure containing the information necessary to compute the covariance matrix.
spin_afield a spin.
spin_bfield b spin.
spin_cfield c spin.
spin_dfield d spin.
wanmt_workspace structure containing the mode-coupling matrix for the first power spectra.
wbnmt_workspace structure containing the mode-coupling matrix for the second power spectra.
clacCross-power spectra between field 1 in the first set and field 1 in the second set (ac) All power spectra should be defined for all ell < lmax.
cladCross-power spectra between field 1 in the first set and field 2 in the second set (ad)
clbcCross-power spectra between field 2 in the first set and field 1 in the second set (bc)
clbdCross-power spectra between field 2 in the first set and field 2 in the second set (bd)
covar_outflattened covariance matrix. Should be allocated to shape [ncls_1 * nbpw_1 * ncls_2 * nbpw_2], where nbpw_X and ncls_X are the number of bandpowers and different power spectra in the X-th set of fields.
void nmt_compute_gaussian_covariance_flat ( nmt_covar_workspace_flat cw,
int  spin_a,
int  spin_b,
int  spin_c,
int  spin_d,
nmt_workspace_flat wa,
nmt_workspace_flat wb,
int  nl,
flouble larr,
flouble **  clac,
flouble **  clad,
flouble **  clbc,
flouble **  clbd,
flouble covar_out 
)

Compute flat-sky Gaussian covariance matrix.

Computes the covariance matrix for two sets of power spectra given input predicted spectra and two nmt_covar_workspace_flat structures.

Parameters
cwnmt_covar_workspace_flat structure containing the information necessary to compute the covariance matrix.
spin_afield a spin.
spin_bfield b spin.
spin_cfield c spin.
spin_dfield d spin.
wanmt_workspace_flat structure containing the mode-coupling matrix for the first power spectra (between fields a and b).
wbnmt_workspace_flat structure containing the mode-coupling matrix for the second power spectra (between fields c and d).
nlNumber of multipoles in which input power spectra are computed.
larrArray of multipoles in which input power spectra are computed.
clacCross-power spectra between field 1 in the first set and field 1 in the second set (ac)
cladCross-power spectra between field 1 in the first set and field 2 in the second set (ad)
clbcCross-power spectra between field 2 in the first set and field 1 in the second set (bc)
clbdCross-power spectra between field 2 in the first set and field 2 in the second set (bd)
covar_outflattened covariance matrix. Should be allocated to shape [ncls_1 * nbpw_1 * ncls_2 * nbpw_2], where nbpw_X and ncls_X are the number of bandpowers and different power spectra in the X-th set of fields.
nmt_master_calculator* nmt_compute_master_coefficients ( int  lmax,
int  lmax_mask,
int  npcl,
flouble **  pcl_masks,
int  s1,
int  s2,
int  pure_e1,
int  pure_b1,
int  pure_e2,
int  pure_b2,
int  do_teb,
int  l_toeplitz,
int  l_exact,
int  dl_band 
)
nmt_workspace* nmt_compute_power_spectra ( nmt_field fl1,
nmt_field fl2,
nmt_binning_scheme bin,
nmt_workspace w0,
flouble **  cl_noise,
flouble **  cl_proposal,
flouble **  cl_out,
int  niter,
int  lmax_mask,
int  l_toeplitz,
int  l_exact,
int  dl_band 
)

Computes pseudo-CL specrum.

Wrapper function containing all the steps to compute a power spectrum. For performance reasons, the blind use of this function is discouraged against a smarter combination of nmt_workspace structures and nmt_compute_coupled_cell(). See notes about power spectrum ordering in the main page of this documentation.

Parameters
fl1nmt_field structure defining the first field to correlate.
fl2nmt_field structure defining the second field to correlate.
binnmt_binning_scheme defining the power spectrum bandpowers.
w0nmt_workspace structure containing the mode-coupling matrix. If NULL, a new computation of the MCM will be carried out and stored in the output nmt_workspace. Otherwise, w0 will be used and returned by this function.
cl_proposalProposed power spectrum. Should have shape [ncls][lmax+1], where ncls is the appropriate number of power spectra given the spins of the input fields (e.g. ncls = 2*2 = 4 if both fields have spin=2).
cl_noiseNoise bias (same shape as cl_prop).
cl_outOuptput power spectrum. Should be allocated to shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers defined by bin.
niternumber of iterations when computing alms.
lmax_maskmaximum multipole to which the masks should be resolved. If smaller than the maximum multipole of fl1/fl2, it will be set to that.
Returns
Newly allocated nmt_workspace structure containing the mode-coupling matrix if w0 is NULL (will return w0 otherwise).
nmt_workspace_flat* nmt_compute_power_spectra_flat ( nmt_field_flat fl1,
nmt_field_flat fl2,
nmt_binning_scheme_flat bin,
flouble  lmn_x,
flouble  lmx_x,
flouble  lmn_y,
flouble  lmx_y,
nmt_workspace_flat w0,
flouble **  cl_noise,
int  nl_prop,
flouble l_prop,
flouble **  cl_prop,
flouble **  cl_out 
)

Computes pseudo-CL specrum.

Wrapper function containing all the steps to compute a power spectrum. For performance reasons, the blind use of this function is discouraged against a smarter combination of nmt_workspace_flat structures and nmt_compute_coupled_cell_flat(). See notes about power spectrum ordering in the main page of this documentation.

Parameters
fl1nmt_field_flat structure defining the first field to correlate.
fl2nmt_field_flat structure defining the second field to correlate.
binnmt_binning_scheme_flat defining the power spectrum bandpowers.
lmn_xLower end of the range of multipoles in the x direction that should be masked.
lmx_xUpper end of the range of multipoles in the x direction that should be masked. if lmx_x < lmn_x, no Fourier-space masked is performed.
lmn_ySame as lmn_x for the y direction.
lmx_ySame as lmx_x for the y direction.
w0nmt_workspace_flat structure containing the mode-coupling matrix. If NULL, a new computation of the MCM will be carried out and stored in the output nmt_workspace_flat. Otherwise, w0 will be used and returned by this function.
nl_propNumber of multipoles over which the proposed power spectrum is defined.
l_propArray of multipoles over which the proposed power spectrum is defined.
cl_propProposed power spectrum. Should have shape [ncls][nl_prop], where ncls is the appropriate number of power spectra given the spins of the input fields (e.g. ncls = 2*2 = 4 if both fields have spin=2).
cl_noiseNoise bias. Should have shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers defined by bin.
cl_outOuptput power spectrum. Should be allocated to shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers defined by bin.
Returns
Newly allocated nmt_workspace_flat structure containing the mode-coupling matrix if w0 is NULL (will return w0 otherwise).
void nmt_compute_uncorr_noise_deprojection_bias ( nmt_field fl1,
flouble map_var,
flouble **  cl_bias,
int  niter 
)

Noise bias from uncorrelated noise map.

Computes deprojection bias due to an source of uncorrelated noise given an input noise variance map. See companion paper for more details.

Parameters
fl1nmt_field structure defining the properties of the field for which this noise bias applies.
map_varNoise variance map (should contain per-pixel noise variance).
cl_biasOuptput noise bias. Should be allocated to shape [ncls][lmax+1], where ncls is the appropriate number of power spectra given the spins of the input fields (e.g. ncls = 2*2 = 4 if both fields have spin=2).
niternumber of iterations when computing alms.
void nmt_couple_cl_l ( nmt_workspace w,
flouble **  cl_in,
flouble **  cl_out 
)

Mode-couples an input power spectrum.

This function applies the effects of the mode-coupling the pseudo-CL estimator for a given input power spectrum. This function should be used in conjunction with nmt_decouple_cl_l() to compute the theory prediction of the pseudo-CL estimator. See notes about power spectrum ordering in the main page of this documentation.

Parameters
wnmt_workspace structure containing the mode-coupling matrix
cl_inArray of input power spectra. Should have shape [ncls][lmax+1], where ncls is the appropriate number of power spectra given the fields being correlated (e.g. ncls=4=2*2 for two spin-2 fields).
cl_outArray of output power spectra. Should have shape [ncls][lmax+1], where ncls is defined above.
void nmt_couple_cl_l_flat_fast ( nmt_workspace_flat w,
int  nl,
flouble larr,
flouble **  cl_in,
flouble **  cl_out 
)

Mode-couples an input power spectrum.

This function applies the effects of the mode-coupling the pseudo-CL estimator for a given input power spectrum. This function should be used in conjunction with nmt_decouple_cl_l_flat() to compute the theory prediction of the pseudo-CL estimator. See the scientific documentation or the companion paper for further details on how this is done in particular for the flat-sky approximation. See notes about power spectrum ordering in the main page of this documentation.

Parameters
wnmt_workspace_flat structure containing the mode-coupling matrix
nlNumber of multipoles on which the input power spectrum is defined.
larrArray of multipoles on which the input power spectrum is defined.
cl_inArray of input power spectra. Should have shape [ncls][nl], where ncls is the appropriate number of power spectra given the fields being correlated (e.g. ncls=4=2*2 for two spin-2 fields.
cl_outArray of output power spectra. Should have shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers used to define w.
void nmt_couple_cl_l_flat_quick ( nmt_workspace_flat w,
int  nl,
flouble larr,
flouble **  cl_in,
flouble **  cl_out 
)

Mode-couples an input power spectrum.

Faster (but less accurate) version of nmt_couple_cl_l_flat_fast().

Parameters
wnmt_workspace_flat structure containing the mode-coupling matrix
nlNumber of multipoles on which the input power spectrum is defined.
larrArray of multipoles on which the input power spectrum is defined.
cl_inArray of input power spectra. Should have shape [ncls][nl], where ncls is the appropriate number of power spectra given the fields being correlated (e.g. ncls=4=2*2 for two spin-2 fields.
cl_outArray of output power spectra. Should have shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers used to define w.
void nmt_covar_workspace_flat_free ( nmt_covar_workspace_flat cw)
nmt_covar_workspace_flat* nmt_covar_workspace_flat_init ( nmt_field_flat fla1,
nmt_field_flat fla2,
nmt_binning_scheme_flat ba,
nmt_field_flat flb1,
nmt_field_flat flb2,
nmt_binning_scheme_flat bb 
)

nmt_covar_workspace_flat constructor

Builds an nmt_covar_workspace_flat structure from two nmt_workspace_flat structures, corresponding to the two sets of power spectra for which the covariance is required.

Parameters
fla1nmt_field_field for the first field going into the first (a-th) power spectrum.
fla2nmt_field_field for the second field going into the first (a-th) power spectrum.
flb1nmt_field_field for the first field going into the second (b-th) power spectrum.
flb2nmt_field_field for the second field going into the second (b-th) power spectrum.
banmt_binning_scheme_flat used for the first power spectrum.
bbnmt_binning_scheme_flat used for the second power spectrum.
nmt_covar_workspace_flat* nmt_covar_workspace_flat_read_fits ( char *  fname)

Builds nmt_covar_workspace_flat structure from file.

The input file uses the FITS standard. In combination with nmt_covar_workspace_flat_write_fits(), this can be used to save the information contained in a given workspace and reuse it for future covariance matrix computations. The same workspace can be used on any pair of power spectra between fields with the same masks.

Parameters
fnamePath to input file.
void nmt_covar_workspace_flat_write_fits ( nmt_covar_workspace_flat cw,
char *  fname 
)

Saves nmt_covar_workspace_flat structure to file.

The output file uses the FITS standard. In combination with nmt_covar_workspace_flat_read_fits(), this can be used to save the information contained in a given workspace and reuse it for future covariance matrix computations. The same workspace can be used on any pair of power spectra between fields with the same masks.

Parameters
cwnmt_covar_workspace_flat to be saved.
fnamePath to output file.
void nmt_covar_workspace_free ( nmt_covar_workspace cw)

nmt_covar_workspace destructor.

nmt_covar_workspace* nmt_covar_workspace_init ( nmt_field fla1,
nmt_field fla2,
nmt_field flb1,
nmt_field flb2,
int  lmax,
int  niter,
int  l_toeplitz,
int  l_exact,
int  dl_band 
)

nmt_covar_workspace constructor

Builds an nmt_covar_workspace structure from two pairs of nmt_field structures, corresponding to the two sets of power spectra for which the covariance is required.

Parameters
fla1nmt_field for the first field going into the first (a-th) power spectrum.
fla2nmt_field for the second field going into the first (a-th) power spectrum.
flb1nmt_field for the first field going into the second (b-th) power spectrum.
flb2nmt_field for the second field going into the second (b-th) power spectrum.
lmaxmaximum multipole up to which the coupling coefficients will be calculated.
niternumber of iterations when computing alms.
nmt_covar_workspace* nmt_covar_workspace_read_fits ( char *  fname)

Builds nmt_covar_workspace structure from file.

The input file uses the FITS standard. In combination with nmt_covar_workspace_write_fits(), this can be used to save the information contained in a given workspace and reuse it for future covariance matrix computations. The same workspace can be used on any pair of power spectra between fields with the same masks.

Parameters
fnamePath to input file.
void nmt_covar_workspace_write_fits ( nmt_covar_workspace cw,
char *  fname 
)

Saves nmt_covar_workspace structure to file.

The output file uses the FITS standard. In combination with nmt_covar_workspace_read_fits(), this can be used to save the information contained in a given workspace and reuse it for future covariance matrix computations. The same workspace can be used on any pair of power spectra between fields with the same masks.

Parameters
cwnmt_covar_workspace to be saved.
fnamePath to output file.
nmt_curvedsky_info* nmt_curvedsky_info_alloc ( int  is_healpix,
long  nside,
int  lmax_sht,
int  nx0,
int  ny0,
flouble  Dtheta,
flouble  Dphi,
flouble  phi0,
flouble  theta0 
)

nmt_curvedsky_info creator

If generating a Clenshaw-Curtis grid, then Dtheta and Dphi must be (close to) exact divisor of pi and 2pi respectively. Likewise, theta0 must be an integer multiple of Dtheta, and the number of pixels in the theta direction must be such that the map actually fits on the sphere (i.e. theta0-(ny-1)*Dtheta >=0).

Parameters
is_healpixis this HEALPix pixelization.
nsideif is_healpix, this should be the HEALPix Nside parameter.
lmax_shtmaximum multipole up to which spherical harmonic transforms will be computed.
nx0number of pixels in the phi direction.
ny0number of pixels in the theta direction.
Dthetapixel size in the theta direction. In radians. Must be positive.
Dphipixel size in the phi direction. In radians, must be positive.
theta0colatitude of the last ring in the map. In radians.
phi0minimum azimuth covered by the map. In radians.
Returns
nmt_curvedsky_info struct.
nmt_curvedsky_info* nmt_curvedsky_info_copy ( nmt_curvedsky_info cs_in)

Makes a copy of a nmt_curvedsky_info structure.

Parameters
cs_ininput structure to be copied.
Returns
copy of input nmt_curvedsky_info structure.
void nmt_decouple_cl_l ( nmt_workspace w,
flouble **  cl_in,
flouble **  cl_noise_in,
flouble **  cl_bias,
flouble **  cl_out 
)

Inverts mode-coupling matrix.

Multiplies coupled power spectra by inverse mode-coupling matrix. See notes about power spectrum ordering in the main page of this documentation.

Parameters
wnmt_workspace containing the mode-coupling matrix.
cl_inInput coupled power spectra. Should have shape [ncls][lmax+1], where ncls is the appropriate number of power spectra given the fields used to define w (e.g. 4=2*2 for two spin-2 fields).
cl_noise_inNoise bias (same shape as cl_in).
cl_biasDeprojection bias (same shape as cl_in, see nmt_compute_deprojection_bias()).
cl_outMode-decoupled power spectrum. Should have shape [ncls][nbpw], where ncls is defined above and nbpw is the number of bandpowers used to define w.
void nmt_decouple_cl_l_flat ( nmt_workspace_flat w,
flouble **  cl_in,
flouble **  cl_noise_in,
flouble **  cl_bias,
flouble **  cl_out 
)

Inverts mode-coupling matrix.

Multiplies coupled power spectra by inverse mode-coupling matrix. See notes about power spectrum ordering in the main page of this documentation.

Parameters
wnmt_workspace_flat containing the mode-coupling matrix.
cl_inInput coupled power spectra. Should have shape [ncls][nbpw], where ncls is the appropriate number of power spectra given the fields used to define w (e.g. 4=2*2 for two spin-2 fields) and nbpw is the number of bandpowers used when defining w.
cl_noise_inNoise bias (same shape as cl_in).
cl_biasDeprojection bias (same shape as cl_in, see nmt_compute_deprojection_bias_flat()).
cl_outMode-decoupled power spectrum (same shape as cl_in).
int nmt_diff_curvedsky_info ( nmt_curvedsky_info c1,
nmt_curvedsky_info c2 
)

Compare two nmt_curvedsky_info structs.

Returns
true (!=0) if both structs are equivalent, and false (0) if they aren't.
void nmt_ell_eff ( nmt_binning_scheme bin,
flouble larr 
)

Returns effective multipoles.

Return the weighted average multipole values within each bandpower defined by bin.

Parameters
binnmt_binning_scheme structure defining the bandpowers.
larrOutput array containing the effective multipole in each bandpower. Should be preallocated to the correct number of bandpowers.
void nmt_ell_eff_flat ( nmt_binning_scheme_flat bin,
flouble larr 
)

Returns effective multipoles.

Returns the mid point of each bandpower defined in bin.

Parameters
binnmt_binning_scheme_flat structure defining the bandpowers.
larrOutput array containing mid-points of the bandpowers. Should be preallocated to the correct number of bandpowers.
flouble* nmt_extend_CAR_map ( nmt_curvedsky_info cs,
flouble map_in 
)

Extend CAR map to cover the full circle.

CAR maps only cover a particular part of the sky, but the SHT routines need as input maps that are complete in the azimuth direction. This routine takes in a raw CAR map with its corresponding nmt_curvedsky_info and returns the phi-complete map (with zeros in all pixels outside the original map). If the input map is in HEALPix, this routine just returns a copy of it.

Parameters
cscurved sky geometry info.
map_ininput incomplete map.
Returns
phi-complete map.
nmt_field* nmt_field_alloc_sph ( nmt_curvedsky_info cs,
flouble mask,
int  spin,
flouble **  maps,
int  ntemp,
flouble ***  temp,
flouble beam,
int  pure_e,
int  pure_b,
int  n_iter_mask_purify,
double  tol_pinv,
int  niter,
int  masked_input,
int  is_lite,
int  mask_only 
)

nmt_field constructor

Builds an nmt_field structure from input maps and resolution parameters.

Parameters
cscurved sky geometry info.
maskField's mask.
spinField's spin.
mapsObserved field values BEFORE multiplying by the mask (this is irrelevant for binary masks).
ntempNumber of contaminant templates affecting this field.
tempContaminant template maps (again, NOT multiplied by the mask).
beamHarmonic coefficients of the beam (defined for all multipoles up to the maximum multipole sampled by the map). Pass a NULL pointer if you don't want any beam.
pure_eSet to >0 if you want purified E-modes.
pure_bSet to >0 if you want purified B-modes.
n_iter_mask_purifyE/B purification requires a number of harmonic-space operations on an appropriately apodized mask. This parameter sets the number of iterations requested to compute the spherical harmonic transform of the field's mask. Higher values will produce more accurate results (at the cost of computational time).
tol_pinvContaminant deprojection requires the inversion of the template covariance matrix. This could be ill-defined if some templates are linearly related. In this case we use a pseudo-inverse that accounts for this possibility in a consistent way. Effectively this is a singular-value decomposition. All eigenvalues that are smaller than tol_pinv the largest eigenvalue will be discarded.
niternumber of iterations when computing alms (for all transforms other than the mask's).
masked_inputif not 0, input maps and templates have already been masked. This is not advisable if using purification.
is_liteif not 0, only the map alms and the mask will be stored. You can then use this field to compute the standard pseudo-C_ell with deprojection and purification, but you won't be able to compute the deprojection bias or examine any maps.
mask_onlyif not 0, this field will only store a mask and a beam. You will be able to use it to compute the PCL and covariance mode coupling matrices, but that's it (no actual power spectra, deprojection biases etc.).
nmt_field_flat* nmt_field_flat_alloc ( int  nx,
int  ny,
flouble  lx,
flouble  ly,
flouble mask,
int  spin,
flouble **  maps,
int  ntemp,
flouble ***  temp,
int  nl_beam,
flouble l_beam,
flouble beam,
int  pure_e,
int  pure_b,
double  tol_pinv,
int  masked_input,
int  is_lite,
int  mask_only 
)

nmt_field_flat constructor

Builds an nmt_field_flat structure from input maps and patch parameters.

Parameters
nxNumber of grid points in the x dimension.
nyNumber of grid points in the y dimension.
lxLength of the x dimension (in steradians).
lyLength of the y dimension (in steradians).
maskField's mask (an array of nx * ny values).
spinField's spin.
mapsObserved field values BEFORE multiplying by the mask (this is irrelevant for binary masks).
ntempNumber of contaminant templates affecting this field.
tempContaminant template maps (again, NOT multiplied by the mask).
nl_beamNumber of multipole values defining this field's beam.
l_beamMultipole values at which this field's beam is defined.
beamBeam values at ell = l_beam. Pass a NULL pointer if you don't want any beam (nl_beam and l_beam will be ignored).
pure_eSet to >0 if you want purified E-modes.
pure_bSet to >0 if you want purified B-modes.
tol_pinvContaminant deprojection requires the inversion of the template covariance matrix. This could be ill-defined if some templates are linearly related. In this case we use a pseudo-inverse that accounts for this possibility in a consistent way. Effectively this is a singular-value decomposition. All eigenvalues that are smaller than tol_pinv the largest eigenvalue will be discarded.
masked_inputif not 0, input maps and templates have already been masked. This is not advisable if using purification.
is_liteif not 0, only the map alms and the mask will be stored. You can then use this field to compute the standard pseudo-C_ell with deprojection and purification, but you won't be able to compute the deprojection bias or examine any maps.
mask_onlyif not 0, this field will only store a mask and a beam. You will be able to use it to compute the PCL and covariance mode coupling matrices, but that's it (no actual power spectra, deprojection biases etc.).
void nmt_field_flat_free ( nmt_field_flat fl)

nmt_field_flat destructor

void nmt_field_free ( nmt_field fl)

nmt_field destructor.

nmt_field* nmt_field_read ( int  is_healpix,
char *  fname_mask,
char *  fname_maps,
char *  fname_temp,
char *  fname_beam,
int  spin,
int  pure_e,
int  pure_b,
int  n_iter_mask_purify,
double  tol_pinv,
int  niter 
)

nmt_field constructor from file.

Builds an nmt_field structure from data written in files.

Parameters
is_healpixis the map stored in healpix format?
fname_maskPath to FITS file containing the field's mask (single HEALPix map).
spinField's spin.
fname_mapsPath to FITS file containing the field's observed maps (1(2) maps if spin=0(!=0)).
fname_tempPath to FITS file containing the field's contaminant templates. If spin > 0, the file should contain an even number of files. Each consecutive pair of maps will be interpreted as the Q and U components of a given contaminant. Pass "none" if you don't want any contaminants.
fname_beamPath to ASCII file containing the field's beam. The file should contain two columns: l (multipole) and b_l (beam SHT at that multipole). Pass "none if you don't want a beam.
pure_e>0 if you want E-mode purification.
pure_b>0 if you want B-mode purification.
n_iter_mask_purifyE/B purification requires a number of harmonic-space operations on an appropriately apodized mask. This parameter sets the number of iterations requested to compute the spherical harmonic transform of the field's mask. Higher values will produce more accurate results (at the cost of computational time).
tol_pinvContaminant deprojection requires the inversion of the template covariance matrix. This could be ill-defined if some templates are linearly related. In this case we use a pseudo-inverse that accounts for this possibility in a consistent way. Effectively this is a singular-value decomposition. All eigenvalues that are smaller than tol_pinv the largest eigenvalue will be discarded.
niternumber of iterations when computing alms (other than the mask's).
nmt_flatsky_info* nmt_flatsky_info_alloc ( int  nx,
int  ny,
flouble  lx,
flouble  ly 
)

nmt_flatsky_info constructor

Builds nmt_flatsky_info from patch dimensions.

Parameters
nxNumber of grid points in the x dimension
nyNumber of grid points in the y dimension
lxLength of the x dimension (in steradians)
lyLength of the y dimension (in steradians)
Returns
Allocated nmt_flatsky_info structure.
void nmt_flatsky_info_free ( nmt_flatsky_info fs)

nmt_flatsky_info destructor.

nmt_k_function* nmt_k_function_alloc ( int  nk,
flouble karr,
flouble farr,
flouble  y0,
flouble  yf,
int  is_const 
)

nmt_k_function creator.

Parameters
nkNumber of elements in input arrays.
karrk-values at which the input function is sampled.
farrFunction values at k = karr.
y0Constant function value below interpolation range.
yfConstant function value above interpolation range.
is_constIf non-zero, will create a constant function. In this case all previous arguments other than y0 are ignored and the function will take this value for all k.
flouble nmt_k_function_eval ( nmt_k_function f,
flouble  k,
gsl_interp_accel *  intacc 
)

nmt_k_function evaluator.

Returns value of function at k.

Parameters
fnmt_k_function to evaluate.
kValue of k for which you want f(k).
intaccGSL interpolation accelerator. If you don't want any, just pass a NULL pointer.
void nmt_k_function_free ( nmt_k_function f)

nmt_k_function destructor

void nmt_master_calculator_free ( nmt_master_calculator c)
void nmt_purify ( nmt_field fl,
flouble mask,
fcomplex **  walm0,
flouble **  maps_in,
flouble **  maps_out,
fcomplex **  alms,
int  niter 
)

E- or B-mode purifies a given pair of full-sky (Q,U) maps.

This function is mostly used internally by NaMaster, and its standalone use is discouraged.

Parameters
flnmt_field containing information about what should be purified.
maskSky mask (should be appropriately apodized - see scientific documentation).
walm0Spherical harmonic transform of the mask.
maps_inMaps to be purified (should NOT be mask-multiplied).
maps_outOutput purified maps.
almsSpherical harmonic transform of the output purified maps.
niternumber of iterations when computing alms.
void nmt_purify_flat ( nmt_field_flat fl,
flouble mask,
fcomplex **  walm0,
flouble **  maps_in,
flouble **  maps_out,
fcomplex **  alms 
)

E- or B-mode purifies a given pair of flat-sky (Q,U) maps.

This function is mostly used internally by NaMaster, and its standalone use is discouraged.

Parameters
flnmt_field_flat containing information about what should be purified.
maskSky mask (should be appropriately apodized - see scientific documentation).
walm0Fourier transform of the mask.
maps_inMaps to be purified (should NOT be mask-multiplied).
maps_outOutput purified maps.
almsFourier transform of the output purified maps.
flouble** nmt_synfast_flat ( int  nx,
int  ny,
flouble  lx,
flouble  ly,
int  nfields,
int *  spin_arr,
int  nl_beam,
flouble l_beam,
flouble **  beam_fields,
int  nl_cell,
flouble l_cell,
flouble **  cell_fields,
int  seed 
)

Gaussian realizations of flat-sky fields.

Generates a Gaussian realization of an arbitrary list of possibly-correlated fields with different spins.

Parameters
nxNumber of grid points in the x dimension.
nyNumber of grid points in the y dimension.
lxLength of the x dimension (in steradians).
lyLength of the y dimension (in steradians).
nfieldsNumber of fields to generate.
spin_arrArray (size nfields) containing the spins of the fields to be generated.
nl_beamNumber of multipoles at which the field beams are defined.
l_beamArray of multipoles at which the field beams are defined.
beam_fieldsArray of beams (one per field).
nl_cellNumber of multipole values at which the input power spectra are provided.
l_cellArray of multipole values at which the input power spectra are provided.
cell_fieldsArray of input power spectra. Shape should be [n_cls][nl_cell], where n_cls is the number of power spectra needed to define all the fields. This should be n_cls = n_maps * (n_maps + 1) / 2, where n_maps is the total number of maps required (1 for each spin-0 field, 2 for each spin-2 field). Power spectra must be provided only for the upper-triangular part in row-major order (e.g. if n_maps is 3, there will be 6 power spectra ordered as [1-1,1-2,1-3,2-2,2-3,3-3].
seedSeed for this particular realization.
Returns
Gaussian realization.
flouble** nmt_synfast_sph ( nmt_curvedsky_info cs,
int  nfields,
int *  spin_arr,
int  lmax,
flouble **  cells,
flouble **  beam_fields,
int  seed 
)

Gaussian realizations of full-sky fields.

Generates a Gaussian realization of an arbitrary list of possibly-correlated fields with different spins.

Parameters
cscurved sky geometry info.
lmaxMaximum multipole used.
nfieldsNumber of fields to generate.
spin_arrArray (size nfields) containing the spins of the fields to be generated.
beam_fieldsArray of beams (one per field). Must be defined at all ell <= lmax.
cellsArray of input power spectra (defined at all ell <= lmax). Shape should be [n_cls][lmax+1], where n_cls is the number of power spectra needed to define all the fields. This should be n_cls = n_maps * (n_maps + 1) / 2, where n_maps is the total number of maps required (1 for each spin-0 field, 2 for each spin-2 field). Power spectra must be provided only for the upper-triangular part in row-major order (e.g. if n_maps is 3, there will be 6 power spectra ordered as [1-1,1-2,1-3,2-2,2-3,3-3].
seedSeed for this particular realization.
Returns
Gaussian realization.
void nmt_unbin_cls ( nmt_binning_scheme bin,
flouble **  cls_in,
flouble **  cls_out,
int  ncls 
)

Returns binned power spectra interpolated into output multipoles.

Top-hat interpolation is used (i.e. a given ell is associated with the binned power spectrum value at the bandpower that ell corresponds to).

Parameters
binnmt_binning_scheme structure defining the bandpowers.
cls_inArray of ncls input power spectra. Must have the same number of elements as bandpowers defined by bin.
cls_outArray of ncls interpolated output power spectra.
nclsNumber of input/output power spectra.
void nmt_unbin_cls_flat ( nmt_binning_scheme_flat bin,
flouble **  cls_in,
int  nl,
flouble larr,
flouble **  cls_out,
int  ncls 
)

Returns binned power spectra interpolated into an given set of multipoles.

Nearest-neighbours interpolation is used.

Parameters
binnmt_binning_scheme_flat structure defining the bandpowers.
cls_inArray of ncls input power spectra. Must have the same number of elements as bandpowers defined by bin.
nlNumber of elements in the output power spectra.
larrArray containing the nl multipoles at which the output power spectrum are requested.
cls_outArray of ncls interpolated output power spectra.
nclsNumber of input/output power spectra.
void nmt_update_coupling_matrix ( nmt_workspace w,
int  n_rows,
double *  new_matrix 
)

Updates the mode coupling matrix with a new one.Saves nmt_workspace structure to file.

The new matrix must be provided as a single 1D array of size n_rows $^2$. Here n_rows=n_cls * n_ell is the size of the flattened power spectra, where n_cls is the number of power spectra (1, 2 or 4 for spin0-0, spin0-2 and spin2-2 correlations) and n_ells=lmax+1 (by default lmax=3*nside-1 for HEALPix, and pi/dx for CAR (where dx is the minimum angular pixel size)). The ordering of the power spectra should be such that the l-th element of the i-th power spectrum is stored with index l * n_cls + i.

Parameters
wnmt_workspace to be updated.
n_rowssize of the flattened power spectra.
new_matrixnew mode-coupling matrix (flattened).
void nmt_workspace_flat_free ( nmt_workspace_flat w)

nmt_workspace_flat destructor

nmt_workspace_flat* nmt_workspace_flat_read_fits ( char *  fname)

Builds nmt_workspace_flat structure from file.

The input file uses the FITS standard. In combination with nmt_workspace_flat_write_fits(), this can be used to save the information contained in a given workspace and reuse it for future power spectrum computations. The same workspace can be used on any pair of fields with the same masks.

Parameters
fnamePath to input file.
void nmt_workspace_flat_write_fits ( nmt_workspace_flat w,
char *  fname 
)

Saves nmt_workspace_flat structure to file.

The output file uses the FITS standard. In combination with nmt_workspace_flat_read_fits(), this can be used to save the information contained in a given workspace and reuse it for future power spectrum computations. The same workspace can be used on any pair of fields with the same masks.

Parameters
wnmt_workspace_flat to be saved.
fnamePath to output file.
void nmt_workspace_free ( nmt_workspace w)

nmt_workspace destructor

nmt_workspace* nmt_workspace_read_fits ( char *  fname)

Builds nmt_workspace structure from file.

The input file uses the FITS standard. In combination with nmt_workspace_write_fits(), this can be used to save the information contained in a given workspace and reuse it for future power spectrum computations. The same workspace can be used on any pair of fields with the same masks.

Parameters
fnamePath to input file.
void nmt_workspace_update_beams ( nmt_workspace w,
int  nl1,
double *  b1,
int  nl2,
double *  b2 
)

Updates the beams associated to this workspace.

Also recomputes the binned MCM and its inverse

Parameters
wworkspace.
nl1Number of elements of b1.
b1First field's beam (harmonic space). One element per multipole.
nl2Number of elements of b1.
b2Second field's beam (harmonic space). One element per multipole.
void nmt_workspace_update_binning ( nmt_workspace w,
nmt_binning_scheme bin 
)

Updates the binning scheme associated to this workspace.

Also rebins the MCM and re-inverts it.

Parameters
wnmt_workspace to be updated.
binnew nmt_binning_scheme.
void nmt_workspace_write_fits ( nmt_workspace w,
char *  fname 
)

Saves nmt_workspace structure to file.

The output file uses the FITS standard. In combination with nmt_workspace_read_fits(), this can be used to save the information contained in a given workspace and reuse it for future power spectrum computations. The same workspace can be used on any pair of fields with the same masks.

Parameters
wnmt_workspace to be saved.
fnamePath to output file.