예제 #1
0
    def get_noise_photon(self, sampling, scene, out=None):
        """
        Return the photon noise (#det, #sampling).

        """
        nep_photon = self._get_noise_photon_nep(scene)
        return Instrument.get_noise(self, sampling, nep=nep_photon, out=out)
예제 #2
0
    def get_noise_photon(self, sampling, scene, out=None):
        """
        Return the photon noise (#det, #sampling).

        """
        nep_photon = self._get_noise_photon_nep(scene)
        return Instrument.get_noise(self, sampling, nep=nep_photon, out=out)
예제 #3
0
    def get_noise(self, sampling, out=None):
        """
        Return a noisy timeline.

        """
        return Instrument.get_noise(
            self, sampling, sigma=self.detector.sigma,
            fknee=self.detector.fknee, fslope=self.detector.fslope, out=out)
예제 #4
0
    def get_noise_detector(self, sampling, out=None):
        """
        Return the detector noise (#det, #sampling).

        """
        return Instrument.get_noise(
            self, sampling, nep=self.detector.nep, fknee=self.detector.fknee,
            fslope=self.detector.fslope, out=out)
예제 #5
0
    def get_noise_detector(self, sampling, out=None):
        """
        Return the detector noise (#det, #sampling).

        """
        return Instrument.get_noise(
            self, sampling, nep=self.detector.nep, fknee=self.detector.fknee, fslope=self.detector.fslope, out=out
        )
예제 #6
0
    def get_invntt_operator(self, sampling):
        """
        Return the inverse time-time noise correlation matrix as an Operator.

        """
        return Instrument.get_invntt_operator(
            self, sampling, sigma=self.detector.sigma,
            fknee=self.detector.fknee, fslope=self.detector.fslope,
            ncorr=self.detector.ncorr)
예제 #7
0
    def get_invntt_operator(self, sampling):
        """
        Return the inverse time-time noise correlation matrix as an Operator.

        """
        return Instrument.get_invntt_operator(
            self, sampling, fknee=self.detector.fknee,
            fslope=self.detector.fslope, ncorr=self.detector.ncorr,
            nep=self.detector.nep)
def test():
    scene = Scene(1024)
    instrument = Instrument('instrument', PackedTable((32, 32)))
    sampling = Sampling(1000)
    acq = Acquisition(instrument,
                      sampling,
                      scene,
                      nprocs_sampling=max(size // 2, 1))
    print(acq.comm.rank, acq.instrument.detector.comm.rank, '/',
          acq.instrument.detector.comm.size, acq.sampling.comm.rank, '/',
          acq.sampling.comm.size)
예제 #9
0
 def func3(shape):
     instrument = Instrument('', PackedTable(shape))
     acq = MyAcquisition3(instrument, sampling, scene)
     noise = acq.get_noise()
     assert noise.shape == (len(acq.instrument), len(acq.sampling))
     assert_allclose(np.std(noise), sigma, rtol=1e-2)
예제 #10
0
    def __init__(self, d):
        """
        Parameters
        ----------
        calibration : QubicCalibration
            The calibration tree.
        detector_fknee : array-like, optional
            The detector 1/f knee frequency in Hertz.
        detector_fslope : array-like, optional
            The detector 1/f slope index.
        detector_ncorr : int, optional
            The detector 1/f correlation length.
        detector_ngrids : int, optional
            Number of detector grids.
        detector_nep : array-like, optional
            The detector NEP [W/sqrt(Hz)].
        detector_tau : array-like, optional
            The detector time constants in seconds.
        filter_nu : float, optional
            The filter central wavelength, in Hz.
        filter_relative_bandwidth : float, optional
            The filter relative bandwidth Δν/ν.
        polarizer : boolean, optional
            If true, the polarizer grid is present in the optics setup.
        primary_beam : function f(theta [rad], phi [rad]), optional
            The primary beam transmission function.
        secondary_beam : function f(theta [rad], phi [rad]), optional
            The secondary beam transmission function.
        synthbeam_dtype : dtype, optional
            The data type for the synthetic beams (default: float32).
            It is the dtype used to store the values of the pointing matrix.
        synthbeam_kmax : integer, optional
            The diffraction order above which the peaks are ignored.
            For instance, a value of kmax=2 will model the synthetic beam by
            (2 * kmax + 1)**2 = 25 peaks and a value of kmax=0 will only sample
            the central peak.
        synthbeam_fraction: float, optional
            The fraction of significant peaks retained for the computation
            of the synthetic beam.

        """
        if d['nf_sub'] is None and d['MultiBand'] == True:
            raise ValueError, "Error: you want Multiband instrument but you have not specified the number of subband"

        filter_nu = d['filter_nu']
        filter_relative_bandwidth = d['filter_relative_bandwidth']

        detector_fknee = d['detector_fknee']
        detector_fslope = d['detector_fslope']
        detector_ncorr = d['detector_ncorr']
        detector_nep = d['detector_nep']
        detector_ngrids = d['detector_ngrids']
        detector_tau = d['detector_tau']

        polarizer = d['polarizer']
        synthbeam_dtype = np.float32
        synthbeam_fraction = d['synthbeam_fraction']
        synthbeam_kmax = d['synthbeam_kmax']
        synthbeam_peak150_fwhm = np.radians(d['synthbeam_peak150_fwhm'])
        ripples = d['ripples']
        nripples = d['nripples']
        primary_beam = None
        secondary_beam = None

        calibration = QubicCalibration(d)

        self.calibration = calibration
        layout = self._get_detector_layout(detector_ngrids, detector_nep,
                                           detector_fknee, detector_fslope,
                                           detector_ncorr, detector_tau)
        Instrument.__init__(self, layout)
        self.ripples = ripples
        self.nripples = nripples
        self._init_beams(primary_beam, secondary_beam)
        self._init_filter(filter_nu, filter_relative_bandwidth)
        self._init_horns()
        self._init_optics(polarizer)
        self._init_synthbeam(synthbeam_dtype, synthbeam_peak150_fwhm)
        self.synthbeam.fraction = synthbeam_fraction
        self.synthbeam.kmax = synthbeam_kmax
예제 #11
0
    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_nu=150e9,
                 filter_relative_bandwidth=0.25,
                 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.39268176),
                 ripples=False,
                 nripples=0):
        """
        Parameters
        ----------
        calibration : QubicCalibration
            The calibration tree.
        detector_fknee : array-like, optional
            The detector 1/f knee frequency in Hertz.
        detector_fslope : array-like, optional
            The detector 1/f slope index.
        detector_ncorr : int, optional
            The detector 1/f correlation length.
        detector_ngrids : int, optional
            Number of detector grids.
        detector_nep : array-like, optional
            The detector NEP [W/sqrt(Hz)].
        detector_tau : array-like, optional
            The detector time constants in seconds.
        filter_nu : float, optional
            The filter central wavelength, in Hz.
        filter_relative_bandwidth : float, optional
            The filter relative bandwidth Δν/ν.
        polarizer : boolean, optional
            If true, the polarizer grid is present in the optics setup.
        primary_beam : function f(theta [rad], phi [rad]), optional
            The primary beam transmission function.
        secondary_beam : function f(theta [rad], phi [rad]), optional
            The secondary beam transmission function.
        synthbeam_dtype : dtype, optional
            The data type for the synthetic beams (default: float32).
            It is the dtype used to store the values of the pointing matrix.
        synthbeam_kmax : integer, optional
            The diffraction order above which the peaks are ignored.
            For instance, a value of kmax=2 will model the synthetic beam by
            (2 * kmax + 1)**2 = 25 peaks and a value of kmax=0 will only sample
            the central peak.
        synthbeam_fraction: float, optional
            The fraction of significant peaks retained for the computation
            of the synthetic beam.

        """
        if calibration is None:
            calibration = QubicCalibration()
        self.calibration = calibration
        layout = self._get_detector_layout(detector_ngrids, detector_nep,
                                           detector_fknee, detector_fslope,
                                           detector_ncorr, detector_tau)
        Instrument.__init__(self, layout)
        self.ripples = ripples
        self.nripples = nripples
        self._init_beams(primary_beam, secondary_beam)
        self._init_filter(filter_nu, filter_relative_bandwidth)
        self._init_horns()
        self._init_optics(polarizer)
        self._init_synthbeam(synthbeam_dtype, synthbeam_peak150_fwhm)
        self.synthbeam.fraction = synthbeam_fraction
        self.synthbeam.kmax = synthbeam_kmax
예제 #12
0
    def __init__(self, name=None, calibration=None,
                 band=150,
                 detector_sigma=10, detector_fknee=0, detector_fslope=1,
                 detector_ncorr=10, detector_tau=0.01,
                 synthbeam_dtype=np.float32, synthbeam_fraction=0.99,
                 ngrids=2, nside=256, **keywords):
        """
        Parameters
        ----------
        name : str
            Deprecated.
        calibration : QubicCalibration
            The calibration tree.
        band : int or numpy array of two elements
            Frequensies of light in GHz for two focal planes
        detector_tau : array-like
            The detector time constants in seconds.
        detector_sigma : array-like
            The standard deviation of the detector white noise component.
        detector_fknee : array-like
            The detector 1/f knee frequency in Hertz.
        detector_fslope : array-like
            The detector 1/f slope index.
        detector_ncorr : int
            The detector 1/f correlation length.
        nside : int, optional
            Deprecated.
        synthbeam_dtype : dtype, optional
            The data type for the synthetic beams (default: float32).
            It is the dtype used to store the values of the pointing matrix.
        synthbeam_fraction: float, optional
            The fraction of significant peaks retained for the computation
            of the synthetic beam.
        ngrids : int, optional
            Number of detector grids.

        """
        if name is not None:
            skind = ", kind='I'" if 'nopol' in name else ''
            snside = ', nside={0}'.format(nside) if nside is not None else ''
            warn('Please update your code:\nacq = QubicAcquisition(150, sam'
                 'pling{0}{1})\n'.format(skind, snside),
                 QubicDeprecationWarning)
            name = name.replace(' ', '').lower()
            names = 'monochromatic', 'monochromatic,qu', 'monochromatic,nopol'
            if name not in names:
                raise ValueError(
                    "The only modes implemented are {0}.".format(
                        strenum(names, 'and')))
            self._init_deprecated_sky(name, band, nside)

        if calibration is None:
            calibration = QubicCalibration()
        self.calibration = calibration
        layout = self._get_detector_layout(
            ngrids, detector_sigma, detector_fknee, detector_fslope,
            detector_ncorr, detector_tau)
        Instrument.__init__(self, 'QUBIC', layout)
        self._init_primary_beam()
        self._init_optics(**keywords)
        self._init_horns()
        self._init_synthetic_beam(synthbeam_dtype, synthbeam_fraction)
예제 #13
0
def test_pack_unpack():
    layout = PackedTable(4, selection=[True, False, True, True])
    instrument = Instrument("instrument", layout)
    v = [1, 2, 3, 4]
    assert_same(instrument.pack(v), [1, 3, 4])
    assert_same(instrument.unpack([1, 3, 4]), [1, -1, 3, 4])
예제 #14
0
    def __init__(self,
                 todfile,
                 invnttfile,
                 mapmaskfile,
                 convert,
                 ndetectors,
                 missing_value=None,
                 comm=MPI.COMM_WORLD):

        # Get information from files
        nslices, status = tmf.madmap1_nslices(invnttfile, ndetectors)
        if status != 0: raise RuntimeError()
        npixels_per_sample, nsamples, ncorrelations, status = tmf.madmap1_info(\
            todfile, invnttfile, convert, ndetectors, nslices)
        if status != 0: raise RuntimeError()

        m = re.search(r'(?P<filename>.*)\[(?P<extname>\w+)\]$', mapmaskfile)
        if m is None:
            mask = pyfits.open(mapmaskfile)[0].data
        else:
            filename = m.group('filename')
            extname = m.group('extname')
            mask = pyfits.open(filename)[str(extname)].data  #XXX Python3
        if mask is None:
            raise IOError('HDU ' + mapmaskfile + ' has no data.')
        mapmask = np.zeros(mask.shape, dtype=bool)
        if missing_value is None:
            mapmask[mask != 0] = True
        elif np.isnan(missing_value):
            mapmask[np.isnan(mask)] = True
        elif np.isinf(missing_value):
            mapmask[np.isinf(mask)] = True
        else:
            mapmask[mask == missing_value] = True

        # Store instrument information
        self.instrument = Instrument('Unknown', (ndetectors, ), comm=comm)

        # Store observation information
        class MadMap1ObservationInfo(object):
            pass

        self.info = MadMap1ObservationInfo()
        self.info.todfile = todfile
        self.info.invnttfile = invnttfile
        self.info.ncorrelations = ncorrelations
        self.info.npixels_per_sample = npixels_per_sample
        self.info.mapmaskfile = mapmaskfile
        self.info.convert = convert
        self.info.missing_value = missing_value
        self.info.mapmask = mapmask

        # Store slice information
        self.slice = np.recarray(nslices,
                                 dtype=[('start', int), ('stop', int),
                                        ('nsamples_all', int),
                                        ('invnttfile', 'S256')])
        self.slice.nsamples_all = nsamples
        self.slice.start[0] = 0
        self.slice.start[1:] = np.cumsum(nsamples)[:-1]
        self.slice.stop = np.cumsum(nsamples)
        self.slice.nfinesamples = nsamples
        self.slice.invnttfile = [
            invnttfile + '.' + str(i) for i in range(nslices)
        ]

        # Store pointing information
        self.pointing = np.recarray(np.sum(nsamples), [('removed', np.bool_)])
        self.pointing.removed = False

        # Check communicator information
        if self.instrument.comm.size > 1:
            raise NotImplementedError('The parallelisation of the TOD is not ' \
                                      'implemented')
예제 #15
0
def test_pack_unpack():
    layout = PackedTable(4, selection=[True, False, True, True])
    instrument = Instrument('instrument', layout)
    v = [1, 2, 3, 4]
    assert_same(instrument.pack(v), [1, 3, 4])
    assert_same(instrument.unpack([1, 3, 4]), [1, -1, 3, 4])
예제 #16
0
    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_nu=150e9,
        filter_relative_bandwidth=0.25,
        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.39268176),
    ):
        """
        Parameters
        ----------
        calibration : QubicCalibration
            The calibration tree.
        detector_fknee : array-like, optional
            The detector 1/f knee frequency in Hertz.
        detector_fslope : array-like, optional
            The detector 1/f slope index.
        detector_ncorr : int, optional
            The detector 1/f correlation length.
        detector_ngrids : int, optional
            Number of detector grids.
        detector_nep : array-like, optional
            The detector NEP [W/sqrt(Hz)].
        detector_tau : array-like, optional
            The detector time constants in seconds.
        filter_nu : float, optional
            The filter central wavelength, in Hz.
        filter_relative_bandwidth : float, optional
            The filter relative bandwidth Δν/ν.
        polarizer : boolean, optional
            If true, the polarizer grid is present in the optics setup.
        primary_beam : function f(theta [rad], phi [rad]), optional
            The primary beam transmission function.
        secondary_beam : function f(theta [rad], phi [rad]), optional
            The secondary beam transmission function.
        synthbeam_dtype : dtype, optional
            The data type for the synthetic beams (default: float32).
            It is the dtype used to store the values of the pointing matrix.
        synthbeam_kmax : integer, optional
            The diffraction order above which the peaks are ignored.
            For instance, a value of kmax=2 will model the synthetic beam by
            (2 * kmax + 1)**2 = 25 peaks and a value of kmax=0 will only sample
            the central peak.
        synthbeam_fraction: float, optional
            The fraction of significant peaks retained for the computation
            of the synthetic beam.

        """
        if calibration is None:
            calibration = QubicCalibration()
        self.calibration = calibration
        layout = self._get_detector_layout(
            detector_ngrids, detector_nep, detector_fknee, detector_fslope, detector_ncorr, detector_tau
        )
        Instrument.__init__(self, layout)
        self._init_beams(primary_beam, secondary_beam)
        self._init_filter(filter_nu, filter_relative_bandwidth)
        self._init_horns()
        self._init_optics(polarizer)
        self._init_synthbeam(synthbeam_dtype, synthbeam_peak150_fwhm)
        self.synthbeam.fraction = synthbeam_fraction
        self.synthbeam.kmax = synthbeam_kmax