Exemple #1
0
def test_healpix_convolution():
    nside = 16
    keywords = {
        'fwhm': np.radians(30),
        'iter': 2,
        'lmax': 8,
        'use_weights': False
    }

    input = np.arange(12 * nside**2)
    op = HealpixConvolutionGaussianOperator(**keywords)

    for i in input, np.repeat(input[:, None], 3, 1):
        expected = np.transpose(hp.smoothing(i.T, verbose=False, **keywords))
        assert_same(op(i), expected)

    if hp.__version__ <= '1.8.6':  # healpy #259
        return

    op = HealpixConvolutionGaussianOperator(pol=False, **keywords)
    input_ = np.arange(12 * nside**2)
    input = np.array([input_, input_, input_]).T
    expected_ = hp.smoothing(input_, verbose=False, **keywords)
    expected = np.array([expected_, expected_, expected_]).T
    assert_same(op(input), expected)
 def get_convolution_transfer_operator(self, **keywords):
     fwhms = self.synthbeam.peak150.fwhm * (150e9 / self.filter.nu)
     fwhm_min = fwhms[-1]
     fwhms_transfer = [np.sqrt(fwhm**2 - fwhm_min**2) for fwhm in fwhms]
     return BlockDiagonalOperator([
         HealpixConvolutionGaussianOperator(fwhm=fwhm, **keywords)
         for fwhm in fwhms_transfer
     ],
                                  new_axisin=0)
    def _get_convolution_peak_operator(nu, synthbeam, **keywords):
        """
        Return an operator that convolves the Healpix sky by the gaussian
        kernel that, if used in conjonction with the peak sampling operator,
        best approximates the synthetic beam.

        """
        fwhm = synthbeam.peak150.fwhm * (150e9 / nu)
        return HealpixConvolutionGaussianOperator(fwhm=fwhm, **keywords)
    def get_convolution_peak_operator(self, **keywords):
        """
        Return an operator that convolves the Healpix sky by the gaussian
        kernel that, if used in conjonction with the peak sampling operator,
        best approximates the synthetic beam.

        """
        fwhms = self.synthbeam.peak150.fwhm * (150e9 / self.filter.nu)
        fwhm_min = fwhms[-1]
        return HealpixConvolutionGaussianOperator(fwhm=fwhm_min, **keywords)
Exemple #5
0
 def get_observation(self, noiseless=False):
     obs = self._true_sky
     if not noiseless:
         obs = obs + self.C(self.get_noise())
     if len(self.scene.shape) == 2:
         for i in range(self.scene.shape[1]):
             obs[~(self.mask), i] = 0.
     else:
         obs[~(self.mask)] = 0.
     return obs
     # XXX neglecting convolution effects...
     HealpixConvolutionGaussianOperator(fwhm=self.fwhm)(obs, obs)
     return obs
Exemple #6
0
    def get_convolution_peak_operator(self, **keywords):
        """
        Return an operator that convolves the Healpix sky by the gaussian
        kernel that, if used in conjonction with the peak sampling operator,
        best approximates the synthetic beam.

        """
        if self.ripples:
            return ConvolutionRippledGaussianOperator(self.filter.nu,
                                                      **keywords)
        fwhm = self.synthbeam.peak150.fwhm * (150e9 / self.filter.nu)
        if 'ripples' in keywords.keys():
            del keywords['ripples']
        return HealpixConvolutionGaussianOperator(fwhm=fwhm, **keywords)
Exemple #7
0
    len(sampling) * sampling.period / (365 * 86400))

maxiter = 1000

x0 = read_map(PATH + 'syn256_pol.fits')

q = MultiQubicInstrument(NPOINTS=NPOINTS,
                         NFREQS=NFREQS,
                         filter_name=filter_name,
                         detector_nep=detector_nep)

C_nf = q.get_convolution_peak_operator()
conv_sky_ = C_nf(x0)

fwhm_t = np.sqrt(q.synthbeam.peak150.fwhm**2 - C_nf.fwhm**2)
C_transf = HealpixConvolutionGaussianOperator(fwhm=fwhm_t)

acq = MultiQubicAcquisition(q, sampling, scene=scene)
acq_planck = PlanckAcquisition(np.int(filter_name / 1e9),
                               scene,
                               true_sky=conv_sky_)
H = acq.get_operator()
COV = acq.get_coverage(H)

conv_sky = C_transf(conv_sky_)

x_rec_fusion = read_map('maps_test/fusion_n{}_N{}_s{}_mi{}.fits'.format(
    NFREQS, NPOINTS, len(sampling), maxiter))

x_rec_qubic = read_map('maps_test/qubic_n{}_N{}_s{}_mi{}.fits'.format(
    NFREQS, NPOINTS, len(sampling), maxiter))
def reconstruction(racenter, deccenter, NPOINTS, NFREQS, filter_name, scene,
                   maxiter, tol, rank, n, start):
    sampling = create_random_pointings([racenter, deccenter], 1000, 10)
    detector_nep = 4.7e-17 * np.sqrt(
        len(sampling) * sampling.period / (365 * 86400))

    #x0 = read_map(PATH + 'syn256_pol.fits')
    x0 = np.zeros((12 * nside**2, 3))
    q = MultiQubicInstrument(NPOINTS=NPOINTS,
                             NFREQS=NFREQS,
                             filter_name=filter_name,
                             detector_nep=detector_nep)

    C_nf = q.get_convolution_peak_operator()
    conv_sky_ = C_nf(x0)

    fwhm_t = np.sqrt(q.synthbeam.peak150.fwhm**2 - C_nf.fwhm**2)
    C_transf = HealpixConvolutionGaussianOperator(fwhm=fwhm_t)

    acq = MultiQubicAcquisition(q, sampling, scene=scene)
    H = acq.get_operator()
    coverage = acq.get_coverage(H)

    acq_planck = MultiPlanckAcquisition(np.int(filter_name / 1e9),
                                        scene,
                                        true_sky=conv_sky_)
    acq_fusion = QubicPlanckAcquisition(acq, acq_planck)

    H = acq_fusion.get_operator()
    y = acq_fusion.get_observation()
    invntt = acq_fusion.get_invntt_operator()

    A = H.T * invntt * H
    b = H.T * invntt * y

    solution_fusion = pcg(A, b, disp=True, maxiter=maxiter, tol=tol)
    x_rec_fusion_ = solution_fusion['x']
    x_rec_fusion = C_transf(x_rec_fusion_)

    #H = acq.get_operator()
    #COV = acq.get_coverage(H)
    #y = acq.get_observation(conv_sky_)
    #invntt = acq.get_invntt_operator()

    # A = H.T * invntt * H
    # b = H.T * invntt * y

    # solution_qubic = pcg(A, b, disp=True, maxiter=maxiter, tol=tol)
    # x_rec_qubic_ = solution_qubic['x']
    # x_rec_qubic = C_transf(x_rec_qubic_)

    # conv_sky = C_transf(conv_sky_)

    path = '/home/fincardona/Qubic/map_making/maps/montecarlo'
    if rank == 0:
        hp.write_map(
            '%s/fusion_n{}_N{}_s{}_mi{}_niter{}.fits'.format(
                NFREQS, NPOINTS, len(sampling), maxiter, n + start) % path,
            x_rec_fusion.T)
        #hp.write_map('maps_test/qubic_n{}_N{}_s{}_mi{}.fits'.format(
        #    NFREQS, NPOINTS, len(sampling), maxiter), x_rec_qubic.T)
    gc.collect()
    return coverage, sampling, path
Exemple #9
0
def test_healpix_convolution_morph():
    op = HealpixConvolutionGaussianOperator(fwhm=0)
    assert_is_type(op, IdentityOperator)
    op = HealpixConvolutionGaussianOperator(sigma=0)
    assert_is_type(op, IdentityOperator)