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)
def __init__(self, instrument, sampling, scene, d): 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 = d['synthbeam_peak150_fwhm'] ripples = d['ripples'] nripples = d['nripples'] primary_beam = None secondary_beam = None calibration = QubicCalibration(d) block = d['block'] effective_duration = d['effective_duration'] photon_noise = d['photon_noise'] max_nbytes = d['max_nbytes'] nprocs_instrument = d['nprocs_instrument'] nprocs_sampling = d['nprocs_sampling'] comm = d['comm'] psd = d['psd'] bandwidth = d['bandwidth'] twosided = d['twosided'] sigma = d['sigma'] """ acq = QubicAcquisition(band, sampling, [scene, nprocs_instrument, nprocs_sampling, comm]) acq = QubicAcquisition(instrument, sampling, [scene, nprocs_instrument, nprocs_sampling, comm]) Parameters ---------- band : int The module nominal frequency, in GHz. scene : QubicScene, optional The discretized observed scene (the sky). If not specified, the scene is instantiated using QubicScene(). block : tuple of slices, optional Partition of the samplings. instrument : QubicInstrument, optional The QubicInstrument instance. calibration : QubicCalibration, optional 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_nep : array-like, optional The detector NEP [W/sqrt(Hz)]. detector_ngrids : 1 or 2, optional Number of detector grids. detector_tau : array-like, optional The detector time constants in seconds. effective_duration : float, optional If not None, the noise properties are rescaled so that this acquisition has an effective duration equal to the specified value, in years. filter_relative_bandwidth : float, optional The filter relative bandwidth Δν/ν. polarizer : boolean, optional If true, the polarizer grid is present in the optics setup. photon_noise : boolean, optional If true, the photon noise contribution is included. 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_fraction: float, optional The fraction of significant peaks retained for the computation of the synthetic beam. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int, optional For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int, optional For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm, optional The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling psd : array-like, optional The one-sided or two-sided power spectrum density [signal unit/sqrt Hz]. bandwidth : float, optional The PSD frequency increment [Hz]. twosided : boolean, optional Whether or not the input psd is one-sided (only positive frequencies) or two-sided (positive and negative frequencies). sigma : float Standard deviation of the white noise component. """ Acquisition.__init__(self, instrument, sampling, scene, block=block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm) self.photon_noise = bool(photon_noise) self.effective_duration = effective_duration self.bandwidth = bandwidth self.psd = psd self.twosided = twosided self.sigma = sigma self.detector_fknee = detector_fknee self.detector_fslope = detector_fslope self.detector_ncorr = detector_ncorr
def __init__(self, instrument, sampling, scene, d): """ acq = QubicAcquisition(instrument, sampling, scene, block, max_nbytes, nprocs_instrument, nprocs_sampling, comm) Parameters ---------- instrument : QubicInstrument, optional The QubicInstrument instance. sampling : pointing Pointing obtained with get_pointing(). scene : QubicScene, optional The discretized observed scene (the sky). d : dictionary with lot of parameters: block : tuple of slices, optional Partition of the samplings. effective_duration : float, optional If not None, the noise properties are rescaled so that this acquisition has an effective duration equal to the specified value, in years. photon_noise : boolean, optional If true, the photon noise contribution is included. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int, optional For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int, optional For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm, optional The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling psd : array-like, optional The one-sided or two-sided power spectrum density [signal unit/sqrt Hz]. bandwidth : float, optional The PSD frequency increment [Hz]. twosided : boolean, optional Whether or not the input psd is one-sided (only positive frequencies) or two-sided (positive and negative frequencies). sigma : float Standard deviation of the white noise component. """ block = d['block'] effective_duration = d['effective_duration'] photon_noise = d['photon_noise'] max_nbytes = d['max_nbytes'] nprocs_instrument = d['nprocs_instrument'] nprocs_sampling = d['nprocs_sampling'] comm = d['comm'] psd = d['psd'] bandwidth = d['bandwidth'] twosided = d['twosided'] sigma = d['sigma'] Acquisition.__init__(self, instrument, sampling, scene, block=block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm) self.photon_noise = bool(photon_noise) self.effective_duration = effective_duration self.bandwidth = bandwidth self.psd = psd self.twosided = twosided self.sigma = sigma
def __init__(self, instrument, sampling, scene=None, block=None, calibration=None, detector_nep=4.7e-17, detector_fknee=0, detector_fslope=1, detector_ncorr=10, detector_ngrids=1, detector_tau=0.01, effective_duration=None, filter_relative_bandwidth=0.25, photon_noise=True, polarizer=True, primary_beam=None, secondary_beam=None, synthbeam_dtype=np.float32, synthbeam_fraction=0.99, max_nbytes=None, nprocs_instrument=None, nprocs_sampling=None, comm=None, ripples=False, nripples=0): """ acq = QubicAcquisition(band, sampling, [scene, nprocs_instrument, nprocs_sampling, comm]) acq = QubicAcquisition(instrument, sampling, [scene, nprocs_instrument, nprocs_sampling, comm]) Parameters ---------- band : int The module nominal frequency, in GHz. scene : QubicScene, optional The discretized observed scene (the sky). If not specified, the scene is instantiated using QubicScene(). block : tuple of slices, optional Partition of the samplings. instrument : QubicInstrument, optional The QubicInstrument instance. calibration : QubicCalibration, optional 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_nep : array-like, optional The detector NEP [W/sqrt(Hz)]. detector_ngrids : 1 or 2, optional Number of detector grids. detector_tau : array-like, optional The detector time constants in seconds. effective_duration : float, optional If not None, the noise properties are rescaled so that this acquisition has an effective duration equal to the specified value, in years. filter_relative_bandwidth : float, optional The filter relative bandwidth Δν/ν. polarizer : boolean, optional If true, the polarizer grid is present in the optics setup. photon_noise : boolean, optional If true, the photon noise contribution is included. 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_fraction: float, optional The fraction of significant peaks retained for the computation of the synthetic beam. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int, optional For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int, optional For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm, optional The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling """ if not isinstance(instrument, QubicInstrument): filter_nu = instrument * 1e9 instrument = QubicInstrument( 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, filter_nu=filter_nu, filter_relative_bandwidth=filter_relative_bandwidth, polarizer=polarizer, primary_beam=primary_beam, secondary_beam=secondary_beam, synthbeam_dtype=synthbeam_dtype, synthbeam_fraction=synthbeam_fraction, ripples=ripples, nripples=nripples) if scene is None: scene = QubicScene() Acquisition.__init__( self, instrument, sampling, scene, block=block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm) self.photon_noise = bool(photon_noise) self.effective_duration = effective_duration
def __init__(self, instrument, sampling, scene=None, block=None, calibration=None, detector_nep=4.7e-17, detector_fknee=0, detector_fslope=1, detector_ncorr=10, detector_ngrids=1, detector_tau=0.01, effective_duration=None, filter_relative_bandwidth=0.25, photon_noise=True, polarizer=True, primary_beam=None, secondary_beam=None, synthbeam_dtype=np.float32, synthbeam_fraction=0.99, absolute=False, kind='IQU', nside=256, max_nbytes=None, nprocs_instrument=None, nprocs_sampling=None, comm=None): """ acq = QubicAcquisition(band, sampling, [scene=|absolute=, kind=, nside=], nprocs_instrument=, nprocs_sampling=, comm=) acq = QubicAcquisition(instrument, sampling, [scene=|absolute=, kind=, nside=], nprocs_instrument=, nprocs_sampling=, comm=) Parameters ---------- band : int The module nominal frequency, in GHz. scene : QubicScene, optional The discretized observed scene (the sky). block : tuple of slices, optional Partition of the samplings. absolute : boolean, optional If true, the scene pixel values include the CMB background and the fluctuations in units of Kelvin, otherwise it only represents the fluctuations, in microKelvin. kind : 'I', 'QU' or 'IQU', optional The sky kind: 'I' for intensity-only, 'QU' for Q and U maps, and 'IQU' for intensity plus QU maps. nside : int, optional The Healpix scene's nside. instrument : QubicInstrument, optional The QubicInstrument instance. calibration : QubicCalibration, optional 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_nep : array-like, optional The detector NEP [W/sqrt(Hz)]. detector_ngrids : 1 or 2, optional Number of detector grids. detector_tau : array-like, optional The detector time constants in seconds. effective_duration : float, optional If not None, the noise properties are rescaled so that this acquisition has an effective duration equal to the specified value, in years. filter_relative_bandwidth : float, optional The filter relative bandwidth Δν/ν. polarizer : boolean, optional If true, the polarizer grid is present in the optics setup. photon_noise : boolean, optional If true, the photon noise contribution is included. 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_fraction: float, optional The fraction of significant peaks retained for the computation of the synthetic beam. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int, optional For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int, optional For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm, optional The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling """ if not isinstance(instrument, QubicInstrument): filter_nu = instrument * 1e9 instrument = QubicInstrument( 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, filter_nu=filter_nu, filter_relative_bandwidth=filter_relative_bandwidth, polarizer=polarizer, primary_beam=primary_beam, secondary_beam=secondary_beam, synthbeam_dtype=synthbeam_dtype, synthbeam_fraction=synthbeam_fraction) if scene is None: scene = QubicScene(absolute=absolute, kind=kind, nside=nside) else: attr = 'absolute', 'kind', 'nside' for a in attr: if locals()[a] != getattr(scene, a): raise ValueError( "The attribute '{}' is already specified in the input " "scene.".format(a)) Acquisition.__init__( self, instrument, sampling, scene, block=block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm) self.photon_noise = bool(photon_noise) self.effective_duration = effective_duration
def __init__(self, instrument, sampling, scene=None, block=None, calibration=None, detector_fknee=0, detector_fslope=1, detector_ncorr=10, detector_ngrids=1, detector_nep=4.7e-17, detector_tau=0.01, filter_relative_bandwidth=0.25, polarizer=True, synthbeam_dtype=np.float32, absolute=False, kind='IQU', nside=256, max_nbytes=None, nprocs_instrument=None, nprocs_sampling=None, comm=None): """ acq = SimpleAcquisition(band, sampling, [scene=|absolute=, kind=, nside=], nprocs_instrument=, nprocs_sampling=, comm=) acq = SimpleAcquisition(instrument, sampling, [scene=|absolute=, kind=, nside=], nprocs_instrument=, nprocs_sampling=, comm=) Parameters ---------- band : int The module nominal frequency, in GHz. scene : QubicScene, optional The discretized observed scene (the sky). block : tuple of slices, optional Partition of the samplings. absolute : boolean, optional If true, the scene pixel values include the CMB background and the fluctuations in units of Kelvin, otherwise it only represents the fluctuations, in microKelvin. kind : 'I', 'QU' or 'IQU', optional The sky kind: 'I' for intensity-only, 'QU' for Q and U maps, and 'IQU' for intensity plus QU maps. nside : int, optional The Healpix scene's nside. instrument : SimpleInstrument, optional The SimpleInstrument instance. calibration : QubicCalibration, optional 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_nep : array-like, optional The detector NEP [W/sqrt(Hz)]. detector_ngrids : 1 or 2, optional Number of detector grids. detector_tau : array-like, optional The detector time constants in seconds. filter_relative_bandwidth : float, optional The filter relative bandwidth Δν/ν. polarizer : boolean, optional If true, the polarizer grid is present in the optics setup. 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. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int, optional For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int, optional For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm, optional The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling """ if not isinstance(instrument, SimpleInstrument): filter_nu = band * 1e9 instrument = SimpleInstrument( calibration=calibration, detector_fknee=detector_fknee, detector_fslope=detector_fslope, detector_ncorr=detector_ncorr, detector_ngrids=detector_ngrids, detector_nep=detector_nep, detector_tau=detector_tau, filter_nu=filter_nu, filter_relative_bandwidth=filter_relative_bandwidth, polarizer=polarizer, synthbeam_dtype=synthbeam_dtype) if scene is None: scene = QubicScene(absolute=absolute, kind=kind, nside=nside) Acquisition.__init__( self, instrument, sampling, scene, block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm)
def __init__(self, instrument, sampling, scene=None, block=None, calibration=None, detector_sigma=10, detector_fknee=0, detector_fslope=1, detector_ncorr=10, detector_tau=0.01, ngrids=None, synthbeam_fraction=0.99, kind='IQU', nside=256, max_nbytes=None, nprocs_instrument=None, nprocs_sampling=None, comm=None): """ acq = QubicAcquisition(instrument, sampling, [scene=|kind=, nside=], nprocs_instrument=, nprocs_sampling=, comm=) acq = QubicAcquisition(band, sampling, [scene=|kind=, nside=], nprocs_instrument=, nprocs_sampling=, comm=) Parameters ---------- band : int or two-elements-long numpy array The sky frequency, in GHz. scene : QubicScene, optional The discretized observed scene (the sky). block : tuple of slices, optional Partition of the samplings. kind : 'I', 'QU', 'IQU', optional The sky kind: 'I' for intensity-only, 'QU' for Q and U maps, and 'IQU' for intensity plus QU maps. nside : int, optional The Healpix scene's nside. instrument : QubicInstrument, optional Module name (only 'monochromatic' for now), or a QubicInstrument instance. calibration : QubicCalibration, optional The calibration tree. detector_tau : array-like, optional The detector time constants in seconds. detector_sigma : array-like, optional The standard deviation of the detector white noise component. 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. synthbeam_fraction: float, optional The fraction of significant peaks retained for the computation of the synthetic beam. ngrids : int, optional Number of detector grids. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling """ if scene is None: if isinstance(instrument, QubicInstrument): try: scene = instrument._deprecated_sky except AttributeError: scene = 150 else: scene = instrument if not isinstance(scene, QubicScene): scene = QubicScene(scene, kind=kind, nside=nside) if not isinstance(instrument, QubicInstrument): if ngrids is None: ngrids = 1 if scene.kind == 'I' else 2 instrument = QubicInstrument( calibration=calibration, detector_sigma=detector_sigma, detector_fknee=detector_fknee, detector_fslope=detector_fslope, detector_ncorr=detector_ncorr, detector_tau=detector_tau, synthbeam_fraction=synthbeam_fraction, ngrids=ngrids) Acquisition.__init__( self, instrument, sampling, scene, block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm)
def __init__(self, instrument, sampling, scene=None, block=None, calibration=None, detector_nep=4.7e-17, detector_fknee=0, detector_fslope=1, detector_ncorr=10, detector_ngrids=1, detector_tau=0.01, effective_duration=None, filter_relative_bandwidth=0.25, photon_noise=True, polarizer=True, primary_beam=None, secondary_beam=None, synthbeam_dtype=np.float32, synthbeam_fraction=0.99, max_nbytes=None, nprocs_instrument=None, nprocs_sampling=None, comm=None, ripples=False, nripples=0): """ acq = QubicAcquisition(band, sampling, [scene, nprocs_instrument, nprocs_sampling, comm]) acq = QubicAcquisition(instrument, sampling, [scene, nprocs_instrument, nprocs_sampling, comm]) Parameters ---------- band : int The module nominal frequency, in GHz. scene : QubicScene, optional The discretized observed scene (the sky). If not specified, the scene is instantiated using QubicScene(). block : tuple of slices, optional Partition of the samplings. instrument : QubicInstrument, optional The QubicInstrument instance. calibration : QubicCalibration, optional 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_nep : array-like, optional The detector NEP [W/sqrt(Hz)]. detector_ngrids : 1 or 2, optional Number of detector grids. detector_tau : array-like, optional The detector time constants in seconds. effective_duration : float, optional If not None, the noise properties are rescaled so that this acquisition has an effective duration equal to the specified value, in years. filter_relative_bandwidth : float, optional The filter relative bandwidth Δν/ν. polarizer : boolean, optional If true, the polarizer grid is present in the optics setup. photon_noise : boolean, optional If true, the photon noise contribution is included. 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_fraction: float, optional The fraction of significant peaks retained for the computation of the synthetic beam. max_nbytes : int or None, optional Maximum number of bytes to be allocated for the acquisition's operator. nprocs_instrument : int, optional For a given sampling slice, number of procs dedicated to the instrument. nprocs_sampling : int, optional For a given detector slice, number of procs dedicated to the sampling. comm : mpi4py.MPI.Comm, optional The acquisition's MPI communicator. Note that it is transformed into a 2d cartesian communicator before being stored as the 'comm' attribute. The following relationship must hold: comm.size = nprocs_instrument * nprocs_sampling """ if not isinstance(instrument, QubicInstrument): filter_nu = instrument * 1e9 instrument = QubicInstrument( 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, filter_nu=filter_nu, filter_relative_bandwidth=filter_relative_bandwidth, polarizer=polarizer, primary_beam=primary_beam, secondary_beam=secondary_beam, synthbeam_dtype=synthbeam_dtype, synthbeam_fraction=synthbeam_fraction, ripples=ripples, nripples=nripples) if scene is None: scene = QubicScene() Acquisition.__init__(self, instrument, sampling, scene, block=block, max_nbytes=max_nbytes, nprocs_instrument=nprocs_instrument, nprocs_sampling=nprocs_sampling, comm=comm) self.photon_noise = bool(photon_noise) self.effective_duration = effective_duration