Beispiel #1
0
def get_coverage_onedet(idetector=231, angspeed=1., delta_az=15., angspeed_psi=0., maxpsi=15., nsweeps_el=100, duration=24, ts=1., decrange=2., decspeed=2., recenter=False):
    print('##### Getting Coverage for: ') 
    print('## idetector = '+str(idetector))
    print('## duration = '+str(duration))
    print('## ts = '+str(ts))
    print('## recenter = '+str(recenter))
    print('## angspeed = '+str(angspeed))
    print('## delta_az = '+str(delta_az))
    print('## nsweeps_el = '+str(nsweeps_el))
    print('## decrange = '+str(decrange))
    print('## decspeed = '+str(decspeed))
    print('## angspeed_psi = '+str(angspeed_psi))
    print('## maxpsi = '+str(maxpsi))
    print('##########################')
    nside = 256
    racenter = 0.0
    deccenter = -57.0
    pointing = pointings_modbyJC.create_sweeping_pointings(
        [racenter, deccenter], duration, ts, angspeed, delta_az, nsweeps_el,
        angspeed_psi, maxpsi, decrange=decrange, decspeed=decspeed, recenter=recenter)
    pointing.angle_hwp = np.random.random_integers(0, 7, pointing.size) * 22.5
    ntimes = len(pointing)

    # get instrument model with only one detector
    instrument = QubicInstrument('monochromatic')
    mask_packed = np.ones(len(instrument.detector.packed), bool)
    mask_packed[idetector] = False
    mask_unpacked = instrument.unpack(mask_packed)
    instrument = QubicInstrument('monochromatic', removed=mask_unpacked)
    
    obs = QubicAcquisition(instrument, pointing)
    convolution = obs.get_convolution_peak_operator()
    projection = obs.get_projection_peak_operator(kmax=0)
    coverage = projection.pT1()
    return coverage
Beispiel #2
0
def test_polarizer():
    sampling = QubicSampling(0, 0, 0)
    scene = QubicScene(150, kind='I')
    instruments = [
        QubicInstrument(polarizer=False, detector_ngrids=2),
        QubicInstrument(polarizer=True, detector_ngrids=2),
        QubicInstrument(polarizer=False),
        QubicInstrument(polarizer=True),
        QubicInstrument(polarizer=False, detector_ngrids=2)[:992],
        QubicInstrument(polarizer=True, detector_ngrids=2)[:992]
    ]

    n = len(instruments[0])
    expecteds = [
        np.r_[np.ones(n // 2), np.zeros(n // 2)],
        np.full(n, 0.5),
        np.ones(n // 2),
        np.full(n // 2, 0.5),
        np.ones(n // 2),
        np.full(n // 2, 0.5)
    ]

    def func(instrument, expected):
        op = instrument.get_polarizer_operator(sampling, scene)
        sky = np.ones((len(instrument), 1))
        assert_equal(op(sky).ravel(), expected)

    for instrument, expected in zip(instruments, expecteds):
        yield func, instrument, expected
Beispiel #3
0
def test():
    kinds = 'I', 'IQU'
    instrument = QubicInstrument(synthbeam_dtype=float)[:400]
    np.random.seed(0)
    sampling = create_random_pointings([0, 90], 30, 5)
    skies = np.ones(12 * 256**2), np.ones((12 * 256**2, 3))

    def func(sampling, kind, sky, ref1, ref2, ref3, ref4, ref5, ref6):
        nprocs_instrument = max(size // 2, 1)
        acq = QubicAcquisition(instrument,
                               sampling,
                               kind=kind,
                               nprocs_instrument=nprocs_instrument)
        assert_equal(acq.comm.size, size)
        assert_equal(acq.instrument.detector.comm.size, nprocs_instrument)
        assert_equal(acq.sampling.comm.size, size / nprocs_instrument)
        H = acq.get_operator()
        invntt = acq.get_invntt_operator()
        tod = H(sky)
        #actual1 = acq.unpack(H(sky))
        #assert_same(actual1, ref1, atol=20)
        actual2 = H.T(invntt(tod))
        assert_same(actual2, ref2, atol=20)
        actual2 = (H.T * invntt * H)(sky)
        assert_same(actual2, ref2, atol=20)
        actual3, actual4 = tod2map_all(acq, tod, disp=False, maxiter=2)
        assert_same(actual3, ref3, atol=20)
        assert_same(actual4, ref4, atol=20)
        #actual5, actual6 = tod2map_each(acq, tod, disp=False)
        #assert_same(actual5, ref5, atol=1000)
        #assert_same(actual6, ref6)

    for kind, sky in zip(kinds, skies):
        acq = QubicAcquisition(instrument,
                               sampling,
                               kind=kind,
                               comm=MPI.COMM_SELF)
        assert_equal(acq.comm.size, 1)
        H = acq.get_operator()
        invntt = acq.get_invntt_operator()
        tod = H(sky)
        ref1 = acq.unpack(tod)
        ref2 = H.T(invntt(tod))
        ref3, ref4 = tod2map_all(acq, tod, disp=False, maxiter=2)
        ref5, ref6 = None, None  #tod2map_each(acq, tod, disp=False)
        yield (func, sampling, kind, sky, ref1, ref2, ref3, ref4, ref5, ref6)
Beispiel #4
0
def test():
    instrument = QubicInstrument()[:10]
    sampling = create_random_pointings([0, 90], 30, 5)
    nside = 64
    scenes = QubicScene(nside, kind='I'), QubicScene(nside)

    def func(scene, max_nbytes, ref1, ref2, ref3, ref4, ref5, ref6):
        acq = QubicAcquisition(instrument,
                               sampling,
                               scene,
                               max_nbytes=max_nbytes)
        sky = np.ones(scene.shape)
        H = acq.get_operator()
        actual1 = H(sky)
        assert_same(actual1, ref1, atol=10)
        actual2 = H.T(actual1)
        assert_same(actual2, ref2, atol=10)
        actual2 = (H.T * H)(sky)
        assert_same(actual2, ref2, atol=10)
        actual3, actual4 = tod2map_all(acq, ref1, disp=False)
        assert_same(actual3, ref3, atol=10000)
        assert_same(actual4, ref4)
        actual5, actual6 = tod2map_each(acq, ref1, disp=False)
        assert_same(actual5, ref5, atol=1000)
        assert_same(actual6, ref6)

    for scene in scenes:
        acq = QubicAcquisition(instrument, sampling, scene)
        sky = np.ones(scene.shape)
        nbytes_per_sampling = acq.get_operator_nbytes() // len(acq.sampling)
        H = acq.get_operator()
        ref1 = H(sky)
        ref2 = H.T(ref1)
        ref3, ref4 = tod2map_all(acq, ref1, disp=False)
        ref5, ref6 = tod2map_each(acq, ref1, disp=False)
        for max_sampling in 10, 29, 30:
            max_nbytes = None if max_sampling is None \
                              else max_sampling * nbytes_per_sampling
            yield (func, scene, max_nbytes, ref1, ref2, ref3, ref4, ref5, ref6)
Beispiel #5
0
center = equ2gal(racenter, deccenter)
maxiter = 1000

nside = 1024

sampling = create_random_pointings([racenter, deccenter], 5000, 5)
scene = QubicScene(nside, kind='I')

#sky = read_map(PATH + 'syn256_pol.fits')[:,0]
sky = np.zeros(12*nside**2)
ip0=hp.ang2pix(nside, np.radians(90.-center[1]), np.radians(center[0]))
v0 = np.array(hp.pix2vec(nside, ip0))
sky[ip0] = 1000
#hp.gnomview(sky, rot=center, reso=5, xsize=800)

instrument = QubicInstrument(filter_nu=150e9,
                            detector_nep=1e-30)

acq_qubic = QubicAcquisition(instrument, sampling, scene, effective_duration=1, photon_noise=False)

coverage = acq_qubic.get_coverage()
observed = coverage > 0.01 * np.max(coverage)
H = acq_qubic.get_operator()
invntt = acq_qubic.get_invntt_operator()
y, sky_convolved = acq_qubic.get_observation(sky, convolution=True)

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

tol = 5e-6
solution_qubic = pcg(A, b, disp=True, maxiter=maxiter, tol=tol)
Beispiel #6
0
from __future__ import division
import numpy as np
from pyoperators.utils import settingerr
from pyoperators.utils.testing import assert_equal, assert_same, assert_is_type
from pysimulators import BeamGaussian, BeamUniformHalfSpace, FitsArray
from qubic import (create_random_pointings, QubicAcquisition, QubicInstrument,
                   QubicSampling, QubicScene)

q = QubicInstrument()
s = create_random_pointings([0, 90], 5, 10.)


def test_detector_indexing():
    expected = FitsArray('test/data/detector_indexing.fits')
    assert_same(q.detector.index, expected)


def test_beams():
    assert_is_type(q.primary_beam, BeamGaussian)
    assert_is_type(q.secondary_beam, BeamGaussian)
    a = QubicAcquisition(150,
                         s,
                         primary_beam=BeamUniformHalfSpace(),
                         secondary_beam=BeamUniformHalfSpace())
    assert_is_type(a.instrument.primary_beam, BeamUniformHalfSpace)
    assert_is_type(a.instrument.secondary_beam, BeamUniformHalfSpace)


def test_primary_beam():
    def primary_beam(theta, phi):
        import numpy as np
    os.system('\cp ' + path + '/TD_CalQubic_HornArray_v4.fits ' + path +
              '/CalQubic_HornArray_v5.fits')
    os.system('\cp ' + path + '/TD_CalQubic_DetArray_v3.fits ' + path +
              '/CalQubic_DetArray_v4.fits')
else:
    print('First Instrument')
    os.system('rm -f ' + path + '/CalQubic_HornArray_v5.fits')
    os.system('rm -f ' + path + '/CalQubic_DetArray_v4.fits')

###### Monochromatic Instrument #####################################################################
nside = 256
scene = QubicScene(nside)

from qubic import QubicInstrument

instTD = QubicInstrument(filter_nu=150e9)

############ Visualizing the Horns and detectors ################################
clf()
subplot(1, 2, 1)
instTD.detector.plot()
xx, yy, zz = instTD.detector.center.T
index_det = instTD.detector.index
for i in range(len(instTD.detector)):
    text(xx[i] - 0.0012,
         yy[i],
         '{}'.format(index_det[i]),
         fontsize=6,
         color='r')
subplot(1, 2, 2)
instTD.horn.plot()
Beispiel #8
0
SOURCE_POWER = 1  # [W]
SOURCE_THETA = np.radians(3)  # [rad]
SOURCE_PHI = np.radians(45)  # [rad]

NPOINT_FOCAL_PLANE = 512**2  # number of detector plane sampling points

NSIDE = 512

#primary_beam = MyBeam(alternative_beam, fwhm1, fwhm2, x0_1, x0_2, weight1, weight2, NSIDE)
#secondary_beam = MyBeam(alternative_beam, fwhm1, fwhm2, x0_1, x0_2, weight1, weight2, NSIDE, backward=True)

#qubic = MyQubicInstrument(
#    primary_beam=primary_beam, secondary_beam=secondary_beam,
#    detector_ngrids=1, filter_nu=NU)

qubic = QubicInstrument(detector_ngrids=1, filter_nu=NU)

qubic.horn.open[:] = False
#qubic.horn.open[10] = True
#qubic.horn.open[14] = True
qubic.horn.open[78] = True
qubic.horn.open[82] = True
qubic.horn.plot(facecolor_closed='white', facecolor_open='red')

FOCAL_PLANE_LIMITS = (np.nanmin(qubic.detector.vertex[..., 0]),
                      np.nanmax(qubic.detector.vertex[..., 0]))  # [m]
# to check energy conservation (unrealistic detector plane):
#FOCAL_PLANE_LIMITS = (-4, 4) # [m]
#FOCAL_PLANE_LIMITS = (-0.2, 0.2) # [m]

#################
# read the input map
x0 = qubic.io.read_map(qubic.data.PATH + 'syn256_pol.fits', field='I_STOKES')

# let's take the galactic north pole as the center of the observation field
center_gal = 0, 90
center = gal2equ(center_gal[0], center_gal[1])

# sampling model
np.random.seed(0)
sampling = create_random_pointings(center, 1000, 10)

# scene model
scene = QubicScene(hp.npix2nside(x0.size), kind='I')

# instrument model
instrument = QubicInstrument(filter_nu=150e9)

# acquisition model
acq = QubicAcquisition(instrument, sampling, scene)
x0_convolved = acq.get_convolution_peak_operator()(x0)
H = acq.get_operator()
coverage = H.T(np.ones(H.shapeout))
mask = coverage > 0

# restrict the scene to the observed pixels
acq_restricted = acq[..., mask]
H_restricted = acq_restricted.get_operator()
x0_restricted = x0[mask]
y = H_restricted(x0_restricted)
invntt = acq_restricted.get_invntt_operator()
Beispiel #10
0
ang = 20            # degrees
##################################################################################


############## True Pointing #####################################################
pointing = create_random_pointings([racenter, deccenter], duration*3600/ts, ang, period=ts)
hwp_angles = np.random.random_integers(0, 7, len(pointing)) * 11.25 
pointing.pitch = 0
pointing.angle_hwp = hwp_angles
npoints = len(pointing)
##################################################################################


############# Instrument with Alternative Primary Beam ###########################
inst = QubicInstrument(detector_tau=0.0001,
                    detector_sigma=noise,
                    detector_fknee=0.,
                    detector_fslope=1)
if hornprofile != 0:
    pb = AltPrimaryBeam(14,hornprofile)
    inst.primary_beam=pb
##################################################################################


############## Input maps ########################################################
# x0 = None
# if rank == 0:
#     print('Rank '+str(rank)+' is Running Synfast')
#     x0 = np.array(hp.synfast(spectra[1:],nside,fwhm=0,pixwin=True,new=True)).T

# x0 = MPI.COMM_WORLD.bcast(x0)
# x0_noI = x0.copy()
    def __init__(self,
                 calibration=None,
                 detector_fknee=0,
                 detector_fslope=1,
                 detector_ncorr=10,
                 detector_nep=4.7e-17,
                 detector_ngrids=1,
                 detector_tau=0.01,
                 filter_name=150e9,
                 filter_nu=None,
                 filter_relative_bandwidth=None,
                 polarizer=True,
                 primary_beam=None,
                 secondary_beam=None,
                 synthbeam_dtype=np.float32,
                 synthbeam_fraction=0.99,
                 synthbeam_kmax=8,
                 synthbeam_peak150_fwhm=np.radians(0.3859879),
                 NPOINTS=1,
                 detector_points=None,
                 NFREQS=1):
        """
        The QubicInstrument class. It represents the instrument setup.

        The exact values of synthbeam_peak150_fwhm are:
        
        mask degrees    mean             sigma             TEST
        
        30      [[[  3.85987922e-01   5.82749218e-06]      energy
                  [  3.79987384e-01   1.30462933e-03]]     residuals
        
        60       [[  3.85987936e-01   5.82815020e-06]      energy
                  [  3.79986166e-01   1.30518810e-03]]]    residuals

        Parameters
        ----------
        NPOINTS : integer in the range: [n**2 for n integer], optional
            Takes into account the spatial extension of the bolometers. It is
            the focal plane number of points inside each detector.
        detector_points : array-like, optional
            Grid of points on the focal plane. They must be conteined inside 
            the detectors. The shape must be: (ndetectors, NPOINTS, 3). If 
            None it will be considered a squared grid of NPOINTS points.
        filter_name : float, optional
            The central wavelength of the band, in Hz: 150e9 or 220e9
        NFREQS : integer, optional
            Takes into account the polychromaticity of the bandwidth. It is 
            the bandwidth number of frequencies. 
        frequencies : array-like, optional
            Grid of frequencies for the bandwidth. If None it will be 
            considered a non-linear grid of NFREQS frequencies.
        relative_bandwidths : array-like, optional
            The relative bandwidths for each frequency of the bandwidth.
        """
        QubicInstrument.__init__(self,
                                 calibration=calibration,
                                 detector_fknee=detector_fknee,
                                 detector_fslope=detector_fslope,
                                 detector_ncorr=detector_ncorr,
                                 detector_nep=detector_nep,
                                 detector_ngrids=detector_ngrids,
                                 detector_tau=detector_tau,
                                 polarizer=polarizer,
                                 filter_nu=filter_name,
                                 filter_relative_bandwidth=0.25,
                                 primary_beam=primary_beam,
                                 secondary_beam=secondary_beam,
                                 synthbeam_dtype=synthbeam_dtype,
                                 synthbeam_fraction=synthbeam_fraction,
                                 synthbeam_kmax=synthbeam_kmax,
                                 synthbeam_peak150_fwhm=synthbeam_peak150_fwhm)

        self.filter.name = filter_name
        if filter_nu is None and filter_relative_bandwidth is None:
            self.filter.NFREQS = NFREQS
            self.filter.nu = self.quadratic_grid4freqs()
            self.filter.relative_bandwidth = self.weights() / self.filter.nu
        elif fiter_nu is None and filter_relative_bandwidths is not None:
            raise ValueError("Invalid frequencies or bandwidths")
        elif filter_nu is not None and filter_relative_bandwidths is None:
            raise ValueError("Invalid frequencies or bandwidths")
        else:
            self.filter.NFREQS = len(filter_nu)
            self.filter.nu = filter_nu
            self.filter.relative_bandwidth = filter_relative_bandwidths
        self.filter.bandwidth = (self.filter.nu *
                                 self.filter.relative_bandwidth)
        if detector_points is None:
            self.detector.NPOINTS = NPOINTS
            side = np.sqrt(self.detector.area)
            self.detector.points = self.shift_grid4pos(self.detector.NPOINTS,
                                                       side,
                                                       self.detector.center)
        elif len(detector_points.shape) != 3:
            raise ValueError("The shape must be: (ndetectors, NPOINTS, 3)")
        else:
            self.detector.NPOINTS = detector_points.shape[1]
            self.detector.points = detector_points
    def __init__(
            self, calibration=None, detector_fknee=0, detector_fslope=1,
            detector_ncorr=10, detector_nep=4.7e-17, detector_ngrids=1,
            detector_tau=0.01, filter_name=150e9, filter_nu=None,
            filter_relative_bandwidth=None, polarizer=True,
            primary_beam=None, secondary_beam=None,
            synthbeam_dtype=np.float32, synthbeam_fraction=0.99,
            synthbeam_kmax=8, synthbeam_peak150_fwhm=np.radians(0.3859879), 
            NPOINTS=1, detector_points=None, NFREQS=1):
        """
        The QubicInstrument class. It represents the instrument setup.

        The exact values of synthbeam_peak150_fwhm are:
        
        mask degrees    mean             sigma             TEST
        
        30      [[[  3.85987922e-01   5.82749218e-06]      energy
                  [  3.79987384e-01   1.30462933e-03]]     residuals
        
        60       [[  3.85987936e-01   5.82815020e-06]      energy
                  [  3.79986166e-01   1.30518810e-03]]]    residuals

        Parameters
        ----------
        NPOINTS : integer in the range: [n**2 for n integer], optional
            Takes into account the spatial extension of the bolometers. It is
            the focal plane number of points inside each detector.
        detector_points : array-like, optional
            Grid of points on the focal plane. They must be conteined inside 
            the detectors. The shape must be: (ndetectors, NPOINTS, 3). If 
            None it will be considered a squared grid of NPOINTS points.
        filter_name : float, optional
            The central wavelength of the band, in Hz: 150e9 or 220e9
        NFREQS : integer, optional
            Takes into account the polychromaticity of the bandwidth. It is 
            the bandwidth number of frequencies. 
        frequencies : array-like, optional
            Grid of frequencies for the bandwidth. If None it will be 
            considered a non-linear grid of NFREQS frequencies.
        relative_bandwidths : array-like, optional
            The relative bandwidths for each frequency of the bandwidth.
        """
        QubicInstrument.__init__(
            self, calibration=calibration, detector_fknee=detector_fknee, 
            detector_fslope=detector_fslope, detector_ncorr=detector_ncorr, 
            detector_nep=detector_nep, detector_ngrids=detector_ngrids,
            detector_tau=detector_tau, polarizer=polarizer, 
            filter_nu=filter_name, filter_relative_bandwidth=0.25,
            primary_beam=primary_beam, secondary_beam=secondary_beam, 
            synthbeam_dtype=synthbeam_dtype, 
            synthbeam_fraction=synthbeam_fraction, 
            synthbeam_kmax=synthbeam_kmax, 
            synthbeam_peak150_fwhm=synthbeam_peak150_fwhm)

        self.filter.name = filter_name
        if filter_nu is None and filter_relative_bandwidth is None:
            self.filter.NFREQS = NFREQS
            self.filter.nu = self.quadratic_grid4freqs()
            self.filter.relative_bandwidth = self.weights() / self.filter.nu
        elif fiter_nu is None and filter_relative_bandwidths is not None:
            raise ValueError("Invalid frequencies or bandwidths")
        elif filter_nu is not None and filter_relative_bandwidths is None:
            raise ValueError("Invalid frequencies or bandwidths")
        else:
            self.filter.NFREQS = len(filter_nu)
            self.filter.nu = filter_nu
            self.filter.relative_bandwidth = filter_relative_bandwidths
        self.filter.bandwidth = (
            self.filter.nu * self.filter.relative_bandwidth)
        if detector_points is None:
            self.detector.NPOINTS = NPOINTS
            side = np.sqrt(self.detector.area)
            self.detector.points = self.shift_grid4pos(
                self.detector.NPOINTS, side, self.detector.center)
        elif len(detector_points.shape) != 3:
                raise ValueError(
                    "The shape must be: (ndetectors, NPOINTS, 3)")
        else:
            self.detector.NPOINTS = detector_points.shape[1]
            self.detector.points = detector_points
Beispiel #13
0
ptg = [1., 0, 180]
ptg2 = [1., 1, 180]
pta = np.asarray(ptg)
pta2 = np.asarray(ptg2)
ptgs = ptg, [ptg], [ptg, ptg], [[ptg, ptg], [ptg2, ptg2, ptg2]], \
       pta, [pta], [pta, pta], [[pta, pta], [pta2, pta2, pta2]], \
       np.asarray([pta]), np.asarray([pta, pta]), [np.asarray([pta, pta])], \
       [np.asarray([pta, pta]), np.asarray([pta2, pta2, pta2])]
block_n = [[1], [1], [2], [2, 3], [1], [1], [2], [2, 3], [1], [2], [2], [2, 3],
           [2, 3]]
caltree = QubicCalibration(detarray='CalQubic_DetArray_v1.fits')
selection = np.zeros((32, 32), dtype=bool)
selection[30:, 30:] = True
qubic = QubicInstrument(calibration=caltree,
                        filter_nu=160e9,
                        synthbeam_fraction=0.99)
qubic = qubic[qubic.pack(selection)]


@skiptest
def test_pointing():
    def func(p, n):
        p = np.asarray(p)
        smp = QubicSampling(azimuth=p[..., 0],
                            elevation=p[..., 1],
                            pitch=p[..., 2])
        acq = QubicAcquisition(qubic, smp)
        assert_equal(acq.block.n, n)
        assert_equal(len(acq.pointing), sum(n))
Beispiel #14
0
plot(azel[0]*np.pi/180,90-azel[1],'.')
fig.suptitle('Azimuth Elevation')

fig2=figure()
plot(pointings[:,2])
xlabel('Pitch angle')

fig=figure()
plot(pointings[:,1],90-pointings[:,0],',')
xlabel('ra')
ylabel('dec')
mp.show()

map_orig = hp.read_map('/Volumes/Data/Qubic/qubic_v1/syn256.fits')

q = QubicInstrument()
C = q.get_convolution_peak_operator()
P = q.get_projection_peak_operator(pointings, kmax=kmax)
H = P * C

### TOD
tod = H(map_orig)
ndet,npix=tod.shape
#ikeep=511
    #for i in arange(ndet):
    #if i != ikeep:
#    tod[i,:]=0


### noise
white_noise_sig=30
Beispiel #15
0
from __future__ import division

import matplotlib.pyplot as mp
import numpy as np
from pyoperators import MaskOperator
from pysimulators import create_fitsheader, SceneGrid
from qubic import QubicInstrument

NU = 150e9                   # [Hz]

SOURCE_THETA = np.radians(0) # [rad]
SOURCE_PHI = np.radians(0)   # [rad]

NPOINT_FOCAL_PLANE = 512**2  # number of detector plane sampling points

qubic = QubicInstrument(filter_nu=NU)

# example for a baseline selection:
#qubic.horn.open[:] = False
#qubic.horn.open[0] = True
#qubic.horn.open[14] = True

FOCAL_PLANE_LIMITS = (np.nanmin(qubic.detector.vertex[..., 0]),
                      np.nanmax(qubic.detector.vertex[..., 0]))  # [m]

# to check energy conservation (unrealistic detector plane):
FOCAL_PLANE_LIMITS = (-0.2, 0.2) # [m]


#################
# FOCAL PLANE
Beispiel #16
0
from pyquad import pyquad

from pyoperators import pcg, DiagonalOperator, UnpackOperator
from pysimulators import ProjectionInMemoryOperator
from qubic import QubicConfiguration, QubicInstrument, create_random_pointings

path = os.path.dirname("/Users/hamilton/idl/pro/Qubic/People/pierre/qubic/script/script_ga.py")

nside = 256
input_map = np.zeros(12 * nside ** 2)
input_map[0] = 1

#### QUBIC Instrument
kmax = 2
qubic = QubicInstrument("monochromatic,nopol", nside=nside)
pointings = create_random_pointings(1, 20)
pointings[0, :] = [0.1, 0, 0]


#### configure observation
obs = QubicConfiguration(qubic, pointings)
C = obs.get_convolution_peak_operator()
P = obs.get_projection_peak_operator(kmax=kmax)
H = P * C

# Produce the Time-Ordered data
tod = H(input_map)

plot(tod)
corner = qubic.pack(qubic.detector.corner).view(float).reshape((-1, 4, 2))
Beispiel #17
0
angspeed_psi = 0.1  # deg/sec
maxpsi = 45.        # deg
nsweeps_el = 300
duration = 24       # hours
ts = 0.1            # seconds

# get the sampling model
np.random.seed(0)
sampling = create_sweeping_pointings(
    [racenter, deccenter], duration, ts, angspeed, delta_az, nsweeps_el,
    angspeed_psi, maxpsi)
scene = QubicScene(nside)

# get the instrument model with only one detector
idetector = 0
instrument = QubicInstrument()[idetector]

# get the acquisition model from the instrument, sampling and scene models
acq = QubicAcquisition(instrument, sampling, scene)

# get noiseless timeline
x0 = qubic.io.read_map(qubic.data.PATH + 'syn256_pol.fits')
y, x0_convolved = acq.get_observation(x0, convolution=True, noiseless=True)

# inversion through Preconditioned Conjugate Gradient
x, coverage = tod2map_all(acq, y, disp=True, tol=1e-3,
                          coverage_threshold=0)
mask = coverage > 0


# some display
Beispiel #18
0
angspeed_psi = 0
maxpsi = 15.
nsweeps_el = int(120*angspeed)
duration = 24   # hours
ts = 0.1         # seconds
decrange=0
decspeed=0
pointing = pointings_modbyJC.create_sweeping_pointings(
    [racenter, deccenter], duration, ts, angspeed, delta_az, nsweeps_el,
    angspeed_psi, maxpsi, decrange=decrange, decspeed=decspeed,recenter=True)
pointing.angle_hwp = np.random.random_integers(0, 7, pointing.size) * 22.5
ntimes = len(pointing)

# get instrument model with only one detector
idetector = 231
instrument = QubicInstrument('monochromatic')
instrument.plot()
mask_packed = np.ones(len(instrument.detector.packed), bool)
mask_packed[idetector] = False
mask_unpacked = instrument.unpack(mask_packed)
instrument = QubicInstrument('monochromatic', removed=mask_unpacked)

obs = QubicAcquisition(instrument, pointing)
convolution = obs.get_convolution_peak_operator()
projection = obs.get_projection_peak_operator(kmax=0)
hwp = obs.get_hwp_operator()
polarizer = obs.get_polarizer_operator()
coverage = projection.pT1()
mask = coverage > 0
projection.restrict(mask)
pack = PackOperator(mask, broadcast='rightward')
Beispiel #19
0
mp.plot(lll, np.sqrt(abs(spectra[4])*(lll*(lll+1))/(2*np.pi)),label='$C_\ell^{TE}$')
mp.plot(lll,np.sqrt(spectra[2]*(lll*(lll+1))/(2*np.pi)),label='$C_\ell^{EE}$')
mp.plot(lll,np.sqrt(spectra[3]*(lll*(lll+1))/(2*np.pi)),label='$C_\ell^{BB}$')
mp.yscale('log')
mp.xlim(0,lmaxcamb+1)
#ylim(0.0001,100)
mp.xlabel('$\ell$')
mp.ylabel('$\sqrt{\ell(\ell+1)C_\ell/(2\pi)}$'+'    '+'$[\mu K]$ ')
mp.legend(loc='lower right',frameon=False)



########## Qubic Instrument
NET150 = (220+314)/2*sqrt(2)*sqrt(2)  ### Average between witner and summer
NET220 = (520+906)/2*sqrt(2)*sqrt(2)  ### Average between witner and summer
inst = QubicInstrument()


############# Shifting horns quarters
def shift_inst(shift):
	inst = QubicInstrument()
	matback = np.array([[np.cos(np.radians(-inst.horn.angle)), -np.sin(np.radians(-inst.horn.angle))],[np.sin(np.radians(-inst.horn.angle)), np.cos(np.radians(-inst.horn.angle))]])
	matfwd = matback = np.array([[np.cos(np.radians(inst.horn.angle)), -np.sin(np.radians(inst.horn.angle))],[np.sin(np.radians(inst.horn.angle)), np.cos(np.radians(inst.horn.angle))]])
	xyrot = np.dot(matback, inst.horn.center[:,:2].T).T
	xplus = xyrot[:,0] > 0
	xyrot[xplus,0] += shift/2
	xyrot[~xplus,0] += -shift/2
	yplus = xyrot[:,1] > 0
	xyrot[yplus,1] += shift/2
	xyrot[~yplus,1] += -shift/2
	#stop