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 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)
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')
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])