def test_madcap3(): map_lsw2_packed = mapper_ls(tod, projection, invntt=invntt, tol=1.e-7, M=M, callback=callback, criterion=False, profile=profile) if profile: return print 'Elapsed time:', map_lsw2_packed.header['TIME'] assert map_lsw2_packed.header['NITER'] < 50
def func(obs, tod): masking = MaskOperator(tod.mask) proj = obs.get_projection_operator(downsampling=True, npixels_per_sample=6, header=header_ref_global, commin=comm_map) model = masking * proj m = mapper_ls(tod, model, tol=tol, maxiter=maxiter, solver=solver, M=DiagonalOperator(1/cov_ref_global)) check_map_global(m)
def test3(): comm_map = MPI.COMM_WORLD for obs, tod in ((obs1,tod1), (obs2,tod2)): masking = MaskOperator(tod.mask) proj = obs.get_projection_operator(downsampling=True, npixels_per_sample=6, header=header_ref_global, commin=comm_map) model = masking * proj m = mapper_ls(tod, model, tol=tol, maxiter=maxiter, solver=solver, M=DiagonalOperator(1/cov_ref_local)) yield check_map_local, m
profile = None#'test_ls.png' data_dir = os.path.dirname(__file__) + '/data/' # reference map (no communication) comm_tod = MPI.COMM_SELF comm_map = MPI.COMM_SELF obs_ref = PacsObservation(data_dir + 'frames_blue.fits', comm=comm_tod) obs_ref.pointing.chop = 0 tod_ref = obs_ref.get_tod() model_ref = MaskOperator(tod_ref.mask) * \ obs_ref.get_projection_operator(downsampling=True, npixels_per_sample=6, commin=comm_map) map_naive_ref = mapper_naive(tod_ref, model_ref, unit='Jy/arcsec^2') map_ref_global = mapper_ls(tod_ref, model_ref, tol=tol, maxiter=maxiter, solver=solver, M=DiagonalOperator( 1/map_naive_ref.coverage)) cov_ref_global = map_ref_global.coverage mask_ref_global = map_ref_global.coverage == 0 header_ref_global = map_ref_global.header tolocal = MPIDistributionGlobalOperator(map_naive_ref.shape, attrin={'header':header_ref_global}) map_ref_local = tolocal(map_ref_global) cov_ref_local = tolocal(map_ref_global.coverage) mask_ref_local = tolocal(mask_ref_global) def check_map_global(m): assert_all_eq(m.magnitude, map_ref_global.magnitude, mtol) assert_all_eq(m.coverage, cov_ref_global, mtol) def check_map_local(m):
# iterative map, restricting oneself to observed map pixels unpacking = UnpackOperator(projection.get_mask()) old_settings = np.seterr(divide='ignore') M = DiagonalOperator(unpacking.T(1./map_naive.coverage)) np.seterr(**old_settings) #map_iter1 = mapper_ls(tod, model * unpacking, tol=1.e-4, M=M) #if map_iter1.header['NITER'] > 11: # raise TestFailure() # iterative map, taking all map pixels class Callback(): def __init__(self): self.niterations = 0 def __call__(self, x): self.niterations += 1 callback = Callback() #callback=None map_iter2 = mapper_ls(tod, model, tol=tol, maxiter=maxiter, M=DiagonalOperator(masking_map(1./map_naive.coverage)), callback=callback, solver=solver, profile=profile) if profile is None: print 'Elapsed time:', map_iter2.header['TIME'] def test(): assert map_iter2.header['NITER'] <= 10