3 API Reference¶
See 2 Usage for how to use these functions for common tasks.
3.1 qe – Quadratic Estimators¶

symlens.qe.
A_l
(shape, wcs, feed_dict, estimator, XY, xmask=None, ymask=None, field_names=None, kmask=None)[source]¶ Returns the normalization corresponding to a predefined modecoupling estimator.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 estimator (str) – The name of a predefined modecoupling estimator. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.
Returns: Al – The 2D normalization for the estimator.
Return type: (Ny,Nx) ndarray

symlens.qe.
A_l_custom
(shape, wcs, feed_dict, f, F, xmask=None, ymask=None, groups=None, kmask=None)[source]¶ Returns the 2D normalization corresponding to a custom modecoupling estimator.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 f (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response. See the Usage guide for details. If this is specified, the argument F is required, and the arguments estimator, XY and field_names are ignored.  F (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the estimator filter. See the Usage guide for details.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  xname (str,optional) – The name of the key in feed_dict where the X map in the XY quadratic estimator is stored. Defaults to X_l1.
 yname (str,optional) – The name of the key in feed_dict where the Y map in the XY quadratic estimator is stored. Defaults to Y_l2.
 groups (list,optional) – Group all terms in the normalization calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: Al – The 2D normalization for the estimator.
Return type: (Ny,Nx) ndarray

symlens.qe.
N_l
(shape, wcs, feed_dict, estimator, XY, xmask=None, ymask=None, Al=None, field_names=None, kmask=None, power_name='t')[source]¶ Returns the 2D noise corresponding to a predefined modecoupling estimator NOT assuming that it is optimal. This involves 2 integrals, unless a precalculated normalization Al is provided, in which case only 1 integral needs to be evaluated.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 estimator (str) – The name of a predefined modecoupling estimator. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 Al ((Ny,Nx) ndarray, optional) – Precalculated normalization for the estimator. Reduces the number of integrals calculated to 1 if provided, else calculates 2 integrals.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.
Returns: Nl – The 2D noise for the estimator.
Return type: (Ny,Nx) ndarray

symlens.qe.
N_l_cross
(shape, wcs, feed_dict, alpha_estimator, alpha_XY, beta_estimator, beta_XY, xmask=None, ymask=None, Aalpha=None, Abeta=None, field_names_alpha=None, field_names_beta=None, kmask=None, skip_filter_field_names=False, power_name='t')[source]¶ Returns the 2D crosscovariance between two predefined modecoupling estimators. This involves 3 integrals, unless precalculated normalizations Al are provided.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 alpha_estimator (str) – The name of the first predefined modecoupling estimator. If this is provided, the argument XY is required and the arguments f, F, and groups are ignored. e.g. “hu_ok”, “hdv” and “shear”.
 beta_estimator (str,optional) – The name of the second predefined modecoupling estimator. If this is provided, the argument XY is required and the arguments f, F, and groups are ignored. e.g. “hu_ok”, “hdv” and “shear”.
 alpha_XY (str,optional) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 beta_XY (str,optional) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 Aalpha ((Ny,Nx) ndarray, optional) – Precalculated normalization for the first estimator. This is calculated if not provided
 Abeta ((Ny,Nx) ndarray, optional) – Precalculated normalization for the second estimator. This is calculated if not provided
 field_names_alpha (2 element list, optional) – Providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  field_names_beta (2 element list, optional) – As above, but for the second beta estimator.
Returns: Nl – The requested 2D crosscovariance.
Return type: (Ny,Nx) ndarray

symlens.qe.
N_l_cross_custom
(shape, wcs, feed_dict, alpha_XY, beta_XY, Falpha, Fbeta, Fbeta_rev, xmask=None, ymask=None, field_names_alpha=None, field_names_beta=None, falpha=None, fbeta=None, Aalpha=None, Abeta=None, groups=None, kmask=None, power_name='t')[source]¶ Returns the 2D crosscovariance between two custom modecoupling estimators. This involves 3 integrals, unless precalculated normalizations Al are provided.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 alpha_XY (str) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 beta_XY (str) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 falpha (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response for the first estimator alpha. See the Usage guide for details.  fbeta (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response for the second estimator beta. See the Usage guide for details.  Falpha (
sympy.core.symbol.Symbol
) – A sympy expression containing the first alpha estimator filter. See the Usage guide for details.  Fbeta (
sympy.core.symbol.Symbol
) – A sympy expression containing the second beta estimator filter. See the Usage guide for details.  Fbeta_rev (
sympy.core.symbol.Symbol
) – Same as above but with l1 and l2 swapped.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names_alpha (2 element list, optional) – Providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  field_names_beta (2 element list, optional) – As above, but for the second beta estimator.
 groups (list,optional) – Group all terms in the normalization calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
 Aalpha ((Ny,Nx) ndarray, optional) – Precalculated normalization for the first estimator. This is calculated if not provided
 Abeta ((Ny,Nx) ndarray, optional) – Precalculated normalization for the second estimator. This is calculated if not provided
Returns: Nl – The requested 2D crosscovariance.
Return type: (Ny,Nx) ndarray

symlens.qe.
N_l_optimal
(shape, wcs, feed_dict, estimator, XY, xmask=None, ymask=None, field_names=None, kmask=None)[source]¶ Returns the 2D noise corresponding to a predefined modecoupling estimator but assuming that it is optimal, i.e. Nl = A_L L^2 / 4
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 estimator (str) – The name of a predefined modecoupling estimator. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.
Returns: Nl – The 2D noise for the estimator.
Return type: (Ny,Nx) ndarray

symlens.qe.
N_l_optimal_custom
(shape, wcs, feed_dict, f, F, xmask=None, ymask=None, groups=None, kmask=None)[source]¶ Returns the 2D noise corresponding to a custom modecoupling estimator but assuming that it is optimal, i.e. Nl = A_L L^2 / 4
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 f (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response. See the Usage guide for details. If this is specified, the argument F is required, and the arguments estimator, XY and field_names are ignored.  F (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the estimator filter. See the Usage guide for details.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 xname (str,optional) – The name of the key in feed_dict where the X map in the XY quadratic estimator is stored. Defaults to X_l1.
 yname (str,optional) – The name of the key in feed_dict where the Y map in the XY quadratic estimator is stored. Defaults to Y_l2.
 groups (list,optional) – Group all terms in the normalization calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: Nl – The 2D noise for the estimator.
Return type: (Ny,Nx) ndarray

class
symlens.qe.
QE
(shape, wcs, feed_dict, estimator=None, XY=None, f=None, F=None, xmask=None, ymask=None, field_names=None, groups=None, kmask=None)[source]¶ Construct a quadratic estimator such that the normalization is precalculated and reused.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below).
 estimator (str,optional) – The name of a predefined modecoupling estimator. If this is provided, the argument XY is required and the arguments f, F, and groups are ignored. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str,optional) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 f (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response. See the Usage guide for details. If this is specified, the argument F is required, and the arguments estimator, XY and field_names are ignored.  F (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the estimator filter. See the Usage guide for details.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  groups (list,optional) – Group all terms in the normalization such that they have common factors of the provided list of expressions to reduce the number of FFTs.

reconstruct
(feed_dict, xname='X_l1', yname='Y_l2', groups=None, physical_units=True)[source]¶ Returns a normalized reconstruction corresponding to the initialized modecoupling estimator.
Parameters:  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 xname (str,optional) – The name of the key in feed_dict where the X map in the XY quadratic estimator is stored. Defaults to X_l1.
 yname (str,optional) – The name of the key in feed_dict where the Y map in the XY quadratic estimator is stored. Defaults to Y_l2.
 groups (list,optional) – Group all terms in the reconstruction calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: krecon – The normalized Fourier space reconstruction in physical units (not pixel units).
Return type: (Ny,Nx) ndarray

symlens.qe.
RDN0_analytic
(shape, wcs, feed_dict, alpha_estimator, alpha_XY, beta_estimator, beta_XY, split_estimator=False, Aalpha=None, Abeta=None, xmask=None, ymask=None, kmask=None, field_names_alpha=None, field_names_beta=None, skip_filter_field_names=False)[source]¶ Often lovingly called the `dumb’ N0 by ACT lensers, this is the analytic expression for the realizationdependependent N0 correction when the noise is isotropic and no mask is present.
feed_dict should have dC_T_T, etc. the realized total data power spectrum. tC_T_T, etc. should be the total coadd power spectrum used in filters uC_T_T, etc. the usual theory spectra for the CMB signal. nC_T_T etc. should be the expected total theory power spectrum But if split_estimator is true: dC_T_T, etc. should be the realized crosspower average. nC_T_T etc. should be the expected crosspower, which is usually nC without the instrument noise.

symlens.qe.
RDN0_analytic_generic
(shape, wcs, feed_dict, alpha_XY, beta_XY, Falpha, Fbeta, Fbeta_rev, falpha=None, fbeta=None, Aalpha=None, Abeta=None, xmask=None, ymask=None, kmask=None, field_names_alpha=None, field_names_beta=None, split_estimator=False, groups=None)[source]¶ Often lovingly called the `dumb’ N0 by ACT lensers, this is the analytic expression for the realizationdependependent N0 correction when the noise is isotropic and no mask is present.
feed_dict should have dC_T_T, etc. the realized total data power spectrum. tC_T_T, etc. should be the total coadd power spectrum used in filters uC_T_T, etc. the usual theory spectra for the CMB signal. nC_T_T etc. should be the expected total theory power spectrum But if split_estimator is true: dC_T_T, etc. should be the realized crosspower average. nC_T_T etc. should be the expected crosspower, which is usually nC without the instrument noise.

symlens.qe.
cross_integral_custom
(shape, wcs, feed_dict, alpha_XY, beta_XY, Falpha, Fbeta, Fbeta_rev, xmask=None, ymask=None, field_names_alpha=None, field_names_beta=None, groups=None, power_name='t')[source]¶ Calculates the integral
where alpha_XY = “ab” beta_XY = “cd”
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 alpha_XY (str) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 beta_XY (str) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 Falpha (
sympy.core.symbol.Symbol
) – A sympy expression containing the first alpha estimator filter. See the Usage guide for details.  Fbeta (
sympy.core.symbol.Symbol
) – A sympy expression containing the second beta estimator filter. See the Usage guide for details.  Fbeta_rev (
sympy.core.symbol.Symbol
) – Same as above but with l1 and l2 swapped.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names_alpha (2 element list, optional) – Providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  field_names_beta (2 element list, optional) – As above, but for the second beta estimator.
 groups (list,optional) – Group all terms in the normalization calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: integral – Returns the integral described above.
Return type: (Ny,Nx) ndarray

symlens.qe.
generic_cross_integral
(shape, wcs, feed_dict, alpha_XY, beta_XY, Falpha, Fbeta, Fbeta_rev, Dexpr1, Dexpr2, xmask=None, ymask=None, field_names_alpha=None, field_names_beta=None, groups=None)[source]¶ Calculates the integral
where alpha_XY = “ab” beta_XY = “cd”
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 alpha_XY (str) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 beta_XY (str) – The XY pair for the first estimator. Typical examples include “TT” and “EB”.
 Falpha (
sympy.core.symbol.Symbol
) – A sympy expression containing the first alpha estimator filter. See the Usage guide for details.  Fbeta (
sympy.core.symbol.Symbol
) – A sympy expression containing the second beta estimator filter. See the Usage guide for details.  Fbeta_rev (
sympy.core.symbol.Symbol
) – Same as above but with l1 and l2 swapped.  Dexpr1 (
sympy.core.symbol.Symbol
) – A sympy expression entering in the generic integral.  Dexpr2 (
sympy.core.symbol.Symbol
) – A second sympy expression entering in the generic integral.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names_alpha (2 element list, optional) – Providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  field_names_beta (2 element list, optional) – As above, but for the second beta estimator.
 groups (list,optional) – Group all terms in the normalization calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: integral – Returns the integral described above.
Return type: (Ny,Nx) ndarray

symlens.qe.
generic_noise_expression
(cross_integral, shape, wcs, feed_dict, falpha, fbeta, Falpha, Fbeta, xmask=None, ymask=None, kmask=None, Aalpha=None, Abeta=None)[source]¶ returns (1/4) A_alpha * A_beta * cross_integral

symlens.qe.
get_mc_expressions
(estimator, XY, field_names=None, estimator_to_harden='hu_ok')[source]¶ Predefined mode coupling expressions. Returns f(l1,l2), F(l1,l2), F(l2,l1). If a list field_names is provided containing two strings, then “total power” spectra are customized to potentially be different and feed_dict will need to have more values.
Parameters:  estimator (str) – The name of a predefined modecoupling estimator. If this is provided, the argument XY is required and the arguments f, F, and groups are ignored. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more general noise correlations.
Returns:  f (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response. See the Usage guide for details.  F (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the estimator filter.  Fr (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the estimator filter but with l1 and l2 swapped.

symlens.qe.
lensing_response_f
(XY, rev=False, curl=False)[source]¶ Returns the modecoupling response f(l1,l2) for CMB lensing.
Parameters:  XY (str) – The XY pair for the requested estimator. This must belong to one of TT, EE, TE, ET, EB or TB.
 rev (boolean, optional) – Whether to swap l1 and l2. Defaults to False.
Returns: f – A sympy expression containing the modecoupling response. See the Usage guide for details.
Return type: sympy.core.symbol.Symbol
, optional

symlens.qe.
reconstruct
(shape, wcs, feed_dict, estimator=None, XY=None, f=None, F=None, xmask=None, ymask=None, field_names=None, norm_groups=None, est_groups=None, xname='X_l1', yname='Y_l2', kmask=None, physical_units=True)[source]¶ Returns a normalized reconstruction corresponding to specified modecoupling estimator.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 estimator (str,optional) – The name of a predefined modecoupling estimator. If this is provided, the argument XY is required and the arguments f, F, and groups are ignored. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str,optional) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 f (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the modecoupling response. See the Usage guide for details. If this is specified, the argument F is required, and the arguments estimator, XY and field_names are ignored.  F (
sympy.core.symbol.Symbol
, optional) – A sympy expression containing the estimator filter. See the Usage guide for details.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  norm_groups (list,optional) – Group all terms in the normalization such that they have common factors of the provided list of expressions to reduce the number of FFTs.
 xname (str,optional) – The name of the key in feed_dict where the X map in the XY quadratic estimator is stored. Defaults to X_l1.
 yname (str,optional) – The name of the key in feed_dict where the Y map in the XY quadratic estimator is stored. Defaults to Y_l2.
 est_groups (list,optional) – Group all terms in the reconstruction calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: krecon – The normalized Fourier space reconstruction in physical units (not pixel units).
Return type: (Ny,Nx) ndarray
See also
QE()
 A class with which the slow normalization can be precalculated and repeated estimation can be performed on similar datasets.

symlens.qe.
rotation_response_f
(XY, rev=False)[source]¶ Returns the modecoupling response f(l1,l2) for CMB rotation.
Parameters:  XY (str) – The XY pair for the requested estimator. This must belong to one of EE, TE, ET, EB or TB.
 rev (boolean, optional) – Whether to swap l1 and l2. Defaults to False.
Returns: f – A sympy expression containing the modecoupling response. See the Usage guide for details.
Return type: sympy.core.symbol.Symbol

symlens.qe.
unnormalized_quadratic_estimator
(shape, wcs, feed_dict, estimator, XY, xname='X_l1', yname='Y_l2', field_names=None, xmask=None, ymask=None, physical_units=True)[source]¶ Returns a normalized reconstruction corresponding to specified predefined modecoupling estimator.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 estimator (str,optional) – The name of a predefined modecoupling estimator. If this is provided, the argument XY is required and the arguments f, F, and groups are ignored. e.g. “hu_ok”, “hdv” and “shear”.
 XY (str,optional) – The XY pair for the requested estimator. Typical examples include “TT” and “EB”.
 xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 field_names (2 element list, optional) – When a predefined modecoupling estimator is used, providing a list field_names
modifies the total power spectra variable names that feed_dict expects.
Typically, names like “tC_T_T” and “tC_T_E” are expected. But if field_names
is [“E1”,”E2”] for example, variable names like
tC_E1_T_E1_T
,tC_E2_T_E2_T
,tC_E1_T_E2_T
,tC_E2_T_E1_T
are expected to be present in feed_dict. This allows for more custom noise correlations.  xname (str,optional) – The name of the key in feed_dict where the X map in the XY quadratic estimator is stored. Defaults to X_l1.
 yname (str,optional) – The name of the key in feed_dict where the Y map in the XY quadratic estimator is stored. Defaults to Y_l2.
Returns: krecon – The normalized Fourier space reconstruction in physical units (not pixel units).
Return type: (Ny,Nx) ndarray
See also
reconstruct()
 Get the properly normalized quadratic estimator reconstruction.
QE()
 A class with which the slow normalization can be precalculated and repeated estimation can be performed on similar datasets.

symlens.qe.
unnormalized_quadratic_estimator_custom
(shape, wcs, feed_dict, F, xname='X_l1', yname='Y_l2', xmask=None, ymask=None, groups=None, physical_units=True)[source]¶ Returns a normalized reconstruction corresponding to a custom modecoupling estimator.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays used in the normalization and reconstruction calculation. When using predefined modecoupling estimators, typical keys that must be present are ‘uC_X_Y’ and ‘tC_X_Y’, where X and Y depend on the requested estimator XY (see below). This feed_dict must also contain the keys with name xname and yname (see below), which contain the 2D maps X and Y for the data from which the quadratic estimate is constructed.
 F (
sympy.core.symbol.Symbol
) – A sympy expression containing the estimator filter. See the Usage guide for details.  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 xname (str,optional) – The name of the key in feed_dict where the X map in the XY quadratic estimator is stored. Defaults to X_l1.
 yname (str,optional) – The name of the key in feed_dict where the Y map in the XY quadratic estimator is stored. Defaults to Y_l2.
 groups (list,optional) – Group all terms in the reconstruction calclulation such that they have common factors of the provided list of expressions to reduce the number of FFTs.
Returns: krecon – The normalized Fourier space reconstruction in physical units (not pixel units).
Return type: (Ny,Nx) ndarray
See also
QE()
 A class with which the slow normalization can be precalculated and repeated estimation can be performed on similar datasets.
3.2 factorize – Core utilties for factorization and integration¶

symlens.factorize.
factorize_2d_convolution_integral
(expr, l1funcs=None, l2funcs=None, groups=None, validate=True)[source]¶ Reduce a sympy expression of variables l1x,l1y,l2x,l2y,l1,l2 into a sum of products of factors that depend only on vec(l1) and vec(l2) and neither, each. If the expression appeared as the integrand in an integral over vec(l1), where vec(l2) = vec(L)  vec(l1) then this reduction allows one to evaluate the integral as a function of vec(L) using FFTs instead of as a convolution.
Parameters:  expr (
sympy.core.symbol.Symbol
) – The full Sympy expression to reduce to sum of products of functions of l1 and l2.  l1funcs (list) – List of symbols that are functions of l1
 l2funcs (list) – List of symbols that are functions of l2
 groups (list,optional) – Group all terms such that they have common factors of the provided list of expressions to reduce the number of FFTs.
 validate (boolean,optional) – Whether to check that the final expression and the original agree. Defaults to True.
Returns:  terms
 unique_l1s
 unique_l2s
 ogroups
 ogroup_weights
 ogroup_symbols
 expr (

symlens.factorize.
integrate
(shape, wcs, feed_dict, expr, xmask=None, ymask=None, cache=True, validate=True, groups=None, physical_units=True)[source]¶ Integrate an arbitrary expression after factorizing it.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  feed_dict (dict) – Mapping from names of custom symbols to numpy arrays.
 expr (
sympy.core.symbol.Symbol
) – A sympy expression containing recognized symbols (see docs)  xmask ((Ny,Nx) ndarray,optional) – Fourier space 2D mask for the l1 part of the integral. Defaults to ones.
 ymask ((Ny,Nx) ndarray, optional) – Fourier space 2D mask for the l2 part of the integral. Defaults to ones.
 cache (boolean, optional) – Whether to store in memory and reuse repeated terms. Defaults to true.
 validate (boolean,optional) – Whether to check that the final expression and the original agree. Defaults to True.
 groups (list,optional) – Group all terms such that they have common factors of the provided list of expressions to reduce the number of FFTs.
 physical_units (boolean,optional) – Whether the input is in pixel units or not.
Returns: result – The numerical result of the integration of the expression after factorization.
Return type: (Ny,Nx) ndarray
3.3 utils  General utilities¶

symlens.utils.
evaluate
(symbolic_term, feed_dict)[source]¶ Convert a symbolic term into a numerical result by using values for the symbols from a dictionary.
symbolic_term: sympy expression feed_dict: dictionary mapping names of symbols to numpy arrays

symlens.utils.
gauss_beam
(ells, fwhm)[source]¶ Return a Gaussian beam transfer function for the given ells.
Parameters:  ells (ndarray) – Any numpy array containing the multipoles at which the beam transfer function is requested.
 fwhm (float) – The beam FWHM in arcminutes.
Returns: output – An array of the same shape as ells containing the Gaussian beam transfer function for those multipoles.
Return type: ndarray

symlens.utils.
interp
(x, y, bounds_error=False, fill_value=0.0, **kwargs)[source]¶ Return a function that interpolates (x,y). This wraps around scipy.interpolate.interp1d but by defaulting to zero filling outside bounds.
Docstring copied from scipy. Interpolate a 1D function. x and y are arrays of values used to approximate some function f:
y = f(x)
. This class returns a function whose call method uses interpolation to find the value of new points. Note that calling interp1d with NaNs present in input values results in undefined behaviour. :param x: A 1D array of real values. :type x: (N,) array_like :param y: A ND array of real values. The length of y along the interpolationaxis must be equal to the length of x.Parameters:  kind (str or int, optional) – Specifies the kind of interpolation as a string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘previous’, ‘next’, where ‘zero’, ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of zeroth, first, second or third order; ‘previous’ and ‘next’ simply return the previous or next value of the point) or as an integer specifying the order of the spline interpolator to use. Default is ‘linear’.
 axis (int, optional) – Specifies the axis of y along which to interpolate. Interpolation defaults to the last axis of y.
 copy (bool, optional) – If True, the class makes internal copies of x and y. If False, references to x and y are used. The default is to copy.
 bounds_error (bool, optional) – If True, a ValueError is raised any time interpolation is attempted on a value outside of the range of x (where extrapolation is necessary). If False, out of bounds values are assigned fill_value. False by default.
 fill_value (arraylike or (arraylike, array_like) or "extrapolate", optional) –
 if a ndarray (or float), this value will be used to fill in for requested points outside of the data range. If not provided, then the default is zero. The arraylike must broadcast properly to the dimensions of the noninterpolation axes.
 If a twoelement tuple, then the first element is used as a
fill value for
x_new < x[0]
and the second element is used forx_new > x[1]
. Anything that is not a 2element tuple (e.g., list or ndarray, regardless of shape) is taken to be a single arraylike argument meant to be used for both bounds asbelow, above = fill_value, fill_value
. .. versionadded:: 0.17.0  If “extrapolate”, then points outside the data range will be extrapolated. .. versionadded:: 0.17.0
 assume_sorted (bool, optional) – If False, values of x can be in any order and they are sorted first. If True, x has to be an array of monotonically increasing values.

symlens.utils.
__call__
()¶
See also
splrep()
,splev()
UnivariateSpline()
 An objectoriented wrapper of the FITPACK routines.
interp2d()
 2D interpolation
Examples
>>> import matplotlib.pyplot as plt >>> from scipy import interpolate >>> x = np.arange(0, 10) >>> y = np.exp(x/3.0) >>> f = interpolate.interp1d(x, y) >>> xnew = np.arange(0, 9, 0.1) >>> ynew = f(xnew) # use interpolation function returned by `interp1d` >>> plt.plot(x, y, 'o', xnew, ynew, '') >>> plt.show()

symlens.utils.
mask_kspace
(shape, wcs, lxcut=None, lycut=None, lmin=None, lmax=None)[source]¶ Produce a Fourier space mask.
Parameters:  shape (tuple) – The shape of the array for the geometry of the footprint. Typically (…,Ny,Nx) for Ny pixels in the ydirection and Nx in the xdirection.
 wcs (
astropy.wcs.wcs.WCS
) – The wcs object completing the specification of the geometry of the footprint.  lxcut (int, optional) – The width of a band in number of Fourier pixels to be masked in the lx direction. Default is no masking in this band.
 lycut (int, optional) – The width of a band in number of Fourier pixels to be masked in the ly direction. Default is no masking in this band.
 lmin (int, optional) – The radial distance in Fourier space below which all Fourier pixels are masked. Default is no masking.
 lmax (int, optional) – The radial distance in Fourier space above which all Fourier pixels are masked. Default is no masking.
Returns: output – A 2D array containing the Fourier space mask.
Return type: (Ny,Nx) ndarray