コード例 #1
0
    def compute_coupling_matrix(self,
                                fl1,
                                fl2,
                                bins,
                                is_teb=False,
                                n_iter=3,
                                lmax_mask=-1):
        """
        Computes coupling matrix associated with the cross-power spectrum \
        of two NmtFields and an NmtBin binning scheme. Note that the mode \
        coupling matrix will only contain ells up to the maximum multipole \
        included in the NmtBin bandpowers.

        :param NmtField fl1,fl2: fields to correlate
        :param NmtBin bin: binning scheme
        :param boolean is_teb: if true, all mode-coupling matrices \
            (0-0,0-2,2-2) will be computed at the same time. In this case, \
            fl1 must be a spin-0 field and fl1 must be spin-2.
        :param n_iter: number of iterations when computing a_lms.
        :param lmax_mask: maximum multipole for masks. If smaller than the \
            maximum multipoles of the fields, it will be set to that.
        """
        if self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None
        self.wsp = lib.comp_coupling_matrix(fl1.fl, fl2.fl, bins.bin,
                                            int(is_teb), int(n_iter),
                                            lmax_mask)
コード例 #2
0
    def read_from(self, fname):
        """
        Reads the contents of an NmtWorkspace object from a FITS file.

        :param str fname: input file name
        """
        if self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None
        self.wsp = lib.read_workspace(fname)
コード例 #3
0
    def read_from(self, fname):
        """
        Reads the contents of an NmtWorkspace object from a file (encoded using an internal binary format).

        :param str fname: input file name
        """
        if self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None
        self.wsp = lib.read_workspace(fname)
コード例 #4
0
    def compute_coupling_matrix(self, fl1, fl2, bins):
        """
        Computes coupling matrix associated with the cross-power spectrum of two NmtFields and an NmtBin binning scheme.

        :param NmtField fl1,fl2: fields to correlate
        :param NmtBin bin: binning scheme
        """
        if self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None
        self.wsp = lib.comp_coupling_matrix(fl1.fl, fl2.fl, bins.bin)
コード例 #5
0
ファイル: workspaces.py プロジェクト: DanielLenz/NaMaster
    def compute_coupling_matrix(self, fl1, fl2, bins, is_teb=False):
        """
        Computes coupling matrix associated with the cross-power spectrum of two NmtFields and an NmtBin binning scheme. Note that the mode coupling matrix will only contain ells up to the maximum multipole included in the NmtBin bandpowers.

        :param NmtField fl1,fl2: fields to correlate
        :param NmtBin bin: binning scheme
        :param boolean is_teb: if true, all mode-coupling matrices (0-0,0-2,2-2) will be computed at the same time. In this case, fl1 must be a spin-0 field and fl1 must be spin-2.
        """
        if self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None
        self.wsp = lib.comp_coupling_matrix(fl1.fl, fl2.fl, bins.bin,
                                            int(is_teb))
コード例 #6
0
    def read_from(self, fname, read_unbinned_MCM=True):
        """
        Reads the contents of an NmtWorkspace object from a FITS file.

        :param str fname: input file name
        :param bool read_unbinned_MCM: if False, unbinned mode-coupling \
            matrix will not be read. This can save significant IO time.
        """
        if self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None
        self.wsp = lib.read_workspace(fname, int(read_unbinned_MCM))
        self.has_unbinned = read_unbinned_MCM
コード例 #7
0
    def compute_coupling_matrix(self,
                                fl1,
                                fl2,
                                bins,
                                is_teb=False,
                                n_iter=3,
                                lmax_mask=-1,
                                l_toeplitz=-1,
                                l_exact=-1,
                                dl_band=-1):
        """
        Computes coupling matrix associated with the cross-power spectrum \
        of two NmtFields and an NmtBin binning scheme. Note that the mode \
        coupling matrix will only contain ells up to the maximum multipole \
        included in the NmtBin bandpowers.

        :param NmtField fl1,fl2: fields to correlate
        :param NmtBin bin: binning scheme
        :param boolean is_teb: if true, all mode-coupling matrices \
            (0-0,0-2,2-2) will be computed at the same time. In this case, \
            fl1 must be a spin-0 field and fl1 must be spin-2.
        :param n_iter: number of iterations when computing a_lms.
        :param lmax_mask: maximum multipole for masks. If smaller than the \
            maximum multipoles of the fields, it will be set to that.
        :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 self.wsp is not None:
            lib.workspace_free(self.wsp)
            self.wsp = None

        _toeplitz_sanity(l_toeplitz, l_exact, dl_band, bins.bin.ell_max, fl1,
                         fl2)
        self.wsp = lib.comp_coupling_matrix(fl1.fl, fl2.fl, bins.bin,
                                            int(is_teb), int(n_iter),
                                            lmax_mask, l_toeplitz, l_exact,
                                            dl_band)
コード例 #8
0
 def __del__(self):
     if self.wsp is not None:
         lib.workspace_free(self.wsp)
         self.wsp = None