def compute_coupling_coefficients(self, fla1, fla2, flb1=None, flb2=None, lmax=None, n_iter=3, l_toeplitz=-1, l_exact=-1, dl_band=-1): """ Computes coupling coefficients of the Gaussian covariance \ between the power spectra of two pairs of NmtField objects \ (fla1, fla2, flb1 and flb2). Note that you can reuse this \ workspace for the covariance of power spectra between any \ pairs of fields as long as the fields have the same masks \ as those passed to this function, and as long as the binning \ scheme used are also the same. :param NmtField fla1,fla2: fields contributing to the first \ power spectrum whose covariance you want to compute. :param NmtField flb1,flb2: fields contributing to the second \ power spectrum whose covariance you want to compute. If \ None, fla1,fla2 will be used. :param n_iter: number of iterations when computing a_lms. :param l_toeplitz: if a positive number, the Toeplitz approximation \ described in Louis et al. 2020 (arXiv:2010.14344) will be used. \ In that case, this quantity corresponds to ell_toeplitz in Fig. \ 3 of that paper. :param l_exact: if `l_toeplitz>0`, this quantity corresponds to \ ell_exact in Fig. 3 of Louis et al. 2020. Ignored if \ `l_toeplitz<=0`. :param dl_band: if `l_toeplitz>0`, this quantity corresponds to \ Delta ell_band in Fig. 3 of Louis et al. 2020. Ignored if \ `l_toeplitz<=0`. """ if flb1 is None: flb1 = fla1 if flb2 is None: flb2 = fla2 if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None ns = fla1.fl.cs.n_eq if (fla2.fl.cs.n_eq != ns) or (flb1.fl.cs.n_eq != ns) or \ (flb2.fl.cs.n_eq != ns): raise ValueError("Everything should have the same resolution!") if lmax is None: lmax = lib.get_lmax_from_cs_py(fla1.fl.cs) _toeplitz_sanity(l_toeplitz, l_exact, dl_band, lmax, fla1, flb1) self.wsp = lib.covar_workspace_init_py(fla1.fl, fla2.fl, flb1.fl, flb2.fl, lmax, n_iter, l_toeplitz, l_exact, dl_band)
def read_from(self, fname): """ Reads the contents of an NmtCovarianceWorkspace object from a file (encoded using an internal binary format). :param str fname: input file name """ if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None self.wsp = lib.read_covar_workspace(fname)
def read_from(self, fname): """ Reads the contents of an NmtCovarianceWorkspace object \ from a FITS file. :param str fname: input file name """ if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None self.wsp = lib.read_covar_workspace(fname)
def read_from(self, fname, force_spin0_only=False): """ Reads the contents of an NmtCovarianceWorkspace object \ from a FITS file. :param str fname: input file name :param bool force_spin0_only: if `True`, only spin-0 \ combinations will be read and stored. """ if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None self.wsp = lib.read_covar_workspace(fname, int(force_spin0_only))
def compute_coupling_coefficients(self, wa, wb): """ Computes coupling coefficients of the Gaussian covariance between the power spectra computed using wa and wb (two NmtWorkspace objects). :param NmtWorkspace wa,wb: workspaces used to compute the two power spectra whose covariance matrix you want to compute. """ if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None ns = wa.wsp.nside if wa.wsp.nside != wb.wsp.nside: raise ValueError("Everything should have the same resolution!") if (wa.wsp.ncls != 1) or (wb.wsp.ncls != 1): raise ValueError("Gaussian covariances only supported for spin-0 fields") self.wsp = lib.covar_workspace_init_py(wa.wsp, wb.wsp)
def compute_coupling_coefficients(self, fla1, fla2, flb1=None, flb2=None, lmax=None, n_iter=3): """ Computes coupling coefficients of the Gaussian covariance \ between the power spectra of two pairs of NmtField objects \ (fla1, fla2, flb1 and flb2). Note that you can reuse this \ workspace for the covariance of power spectra between any \ pairs of fields as long as the fields have the same masks \ as those passed to this function, and as long as the binning \ scheme used are also the same. :param NmtField fla1,fla2: fields contributing to the first \ power spectrum whose covariance you want to compute. :param NmtField flb1,flb2: fields contributing to the second \ power spectrum whose covariance you want to compute. If \ None, fla1,fla2 will be used. :param n_iter: number of iterations when computing a_lms. """ if flb1 is None: flb1 = fla1 if flb2 is None: flb2 = fla2 if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None ns = fla1.fl.cs.n_eq if (fla2.fl.cs.n_eq != ns) or (flb1.fl.cs.n_eq != ns) or \ (flb2.fl.cs.n_eq != ns): raise ValueError("Everything should have the same resolution!") if lmax is None: lmax = lib.get_lmax_from_cs_py(fla1.fl.cs) self.wsp = lib.covar_workspace_init_py(fla1.fl, fla2.fl, flb1.fl, flb2.fl, lmax, n_iter)
def __del__(self): if self.wsp is not None: lib.covar_workspace_free(self.wsp) self.wsp = None