コード例 #1
0
ファイル: test_algebra.py プロジェクト: sbiquard/fgbuster
 def test_W_dB(self):
     W_dB_analytic = W_dB(self.A, self.A_dB, self.mm.comp_of_dB)
     W_params = W(self.A)
     for i in range(len(self.params)):
         diff_params = [p for p in self.params]
         diff_params[i] = self.DX + diff_params[i]
         diff_A = self.mm.eval(self.nu, *diff_params)
         diff_W = W(diff_A)
         W_dB_numerical = (diff_W - W_params) / self.DX
         aac(W_dB_numerical, W_dB_analytic[i], rtol=1e-3)
コード例 #2
0
    def _get_sys_stat_residuals(self):
        Cl_fgs = self._get_cls_fg()
        i_cmb = self.A.components.index('CMB')
        print('======= ESTIMATION OF STAT AND SYS RESIDUALS =======')

        W_maxL = W(self.A_maxL, invN=self.invN)[i_cmb, :]
        W_dB_maxL = W_dB(self.A_maxL,
                         self.A_dB_maxL,
                         self.A.comp_of_dB,
                         invN=self.invN)[:, i_cmb]
        W_dBdB_maxL = W_dBdB(self.A_maxL,
                             self.A_dB_maxL,
                             self.A_dBdB_maxL,
                             self.A.comp_of_dB,
                             invN=self.invN)[:, :, i_cmb]
        V_maxL = np.einsum('ij,ij...->...', self.res.Sigma, W_dBdB_maxL)

        # Check dimentions
        assert ((self.n_freqs, ) == W_maxL.shape == W_dB_maxL.shape[1:] ==
                W_dBdB_maxL.shape[2:] == V_maxL.shape)
        assert (len(self.res.params) == W_dB_maxL.shape[0] ==
                W_dBdB_maxL.shape[0] == W_dBdB_maxL.shape[1])

        # elementary quantities defined in Stompor, Errard, Poletti (2016)
        Cl_xF = {}
        Cl_xF['yy'] = _utmv(W_maxL, Cl_fgs.T, W_maxL)  # (ell,)
        Cl_xF['YY'] = _mmm(W_dB_maxL, Cl_fgs.T,
                           W_dB_maxL.T)  # (ell, param, param)
        Cl_xF['yz'] = _utmv(W_maxL, Cl_fgs.T, V_maxL)  # (ell,)
        Cl_xF['Yy'] = _mmv(W_dB_maxL, Cl_fgs.T, W_maxL)  # (ell, param)
        Cl_xF['Yz'] = _mmv(W_dB_maxL, Cl_fgs.T, V_maxL)  # (ell, param)

        # bias and statistical foregrounds residuals
        #self.res.noise = Cl_noise
        self.res.bias = Cl_xF['yy'] + 2 * Cl_xF['yz']  # S16, Eq 23
        self.res.stat = np.einsum('ij, lij -> l', self.res.Sigma,
                                  Cl_xF['YY'])  # E11, Eq. 12
        self.res.var = self.res.stat**2 + 2 * np.einsum(
            'li, ij, lj -> l',  # S16, Eq. 28
            Cl_xF['Yy'],
            self.res.Sigma,
            Cl_xF['Yy'])

        return self.res.bias, self.res.stat, self.res.var
コード例 #3
0
ファイル: test_algebra.py プロジェクト: sbiquard/fgbuster
 def test_W_on_d_is_s(self):
     aaae(self.s, _mv(W(self.A), self.d))
コード例 #4
0
ファイル: test_algebra.py プロジェクト: sbiquard/fgbuster
 def W_displaced(i_step, j_step):
     diff_params = [p for p in self.params]
     diff_params[i] = i_step * self.DX + diff_params[i]
     diff_params[j] = j_step * self.DX + diff_params[j]
     diff_A = self.mm.eval(self.nu, *diff_params)
     return W(diff_A, self.invN)