def __init__(self, version, qid=None, model="act_mr3", cmb_type='LensedUnabberatedCMB', dobeam=True, add_foregrounds=True, apply_window=True, max_cached=1,extract_region = None,extract_region_shape = None,extract_region_wcs = None): """ version: The version identifier for the filename of covsqrts on disk model: The name of an implemented soapack datamodel extract_region: An optional map whose footprint on to which the sims are extracted extract_region_shape: Instead of passing a map for extract_region, one can pass its shape and wcs extract_region_wcs: Instead of passing a map for extract_region, one can pass its shape and wcs max_cached: The maximum number of cached sim/or alms """ self.qid = qid self.noise_gen = noise.NoiseGen(qid=qid,version=version,model=model,ncache=max_cached,verbose=False) self.signal_gen = signal.SignalGen(cmb_type=cmb_type, dobeam=dobeam, add_foregrounds=add_foregrounds, apply_window=apply_window, max_cached=max_cached, model=model) self.default_geometries = {} self.model = model if (extract_region is not None) or (extract_region_shape is not None): self._refoot = True if (extract_region is not None): assert extract_region_shape is None assert extract_region_wcs is None extract_region_shape, extract_region_wcs = extract_region.shape, extract_region.wcs assert extract_region_wcs is not None self._eshape, self._ewcs = extract_region_shape, extract_region_wcs else: self._refoot = False
def get_default_geometry(version, season, patch, array, freq, model='act_mr3'): noise_gen = noise.NoiseGen(version=version, model=model, ncache=1, verbose=False) oshape, owcs = noise_gen.load_covsqrt(season, patch, array, coadd=True, mask_patch=None, get_geometry=True) return (oshape, owcs)
# Get data model dm = sints.models[args.model](region=mask) # Get a NoiseGen model if args.extract_mask is not None: emask = sints.get_act_mr3_crosslinked_mask(mask_patch, version=args.extract_mask, kind=args.mask_kind, season=season, array=array + "_f150") eshape, ewcs = emask.shape, emask.wcs else: emask = mask ngen = noise.NoiseGen(qid=qid, version=version, model=args.model, extract_region=emask, ncache=1, verbose=True) # Get split data splits = enmap.enmap([dm.get_splits(q) for q in qid]) nsplits = dm.ainfo(args.qid, 'nsplits') # Get inverse variance map ivars = enmap.enmap([dm.get_ivars(q) for q in qid]) modlmap = splits.modlmap() if calc_covsqrt: flatstring = "un" if args.do_only_filter_noise else ""
# Generate each ACT and Planck sim and store kdiffs,kcoadd in memory set_id = args.set_id bandpasses = not(args.effective_freq) gconfig = io.config_from_yaml("input/data.yml") mask = sints.get_act_mr3_crosslinked_mask(args.region, version=args.mask_version, kind='binary_apod') shape,wcs = mask.shape,mask.wcs Ny,Nx = shape modlmap = enmap.modlmap(shape,wcs) ngen = {} ngen['act_mr3'] = actnoise.NoiseGen(args.sim_version,model="act_mr3",extract_region=mask,ncache=0,verbose=True) ngen['planck_hybrid'] = actnoise.NoiseGen(args.sim_version,model="planck_hybrid",extract_region=mask,ncache=0,verbose=True) arrays = args.arrays.split(',') narrays = len(arrays) nsims = args.nsims jsim = pipeline.JointSim(arrays,args.fg_res_version+"_"+args.region, bandpassed=bandpasses,no_act_color_correction=args.no_act_color_correction, ccor_exp=args.ccor_exp) comm,rank,my_tasks = mpi.distribute(nsims) for task in my_tasks: sim_index = task + args.start_index
kind="binary_apod", season=season, array=args.array + "_f150", pad=args.mask_pad) # print(mask.shape) mask = mask[400:-400, 5000:-5000] mask *= enmap.apod(mask, 400) # print(mask.shape) noise.plot(pout + "_mask", mask, grid=True) dm = sints.models[model](region=mask) # Get a NoiseGen model emask = mask ngen = noise.NoiseGen(version=version, model=model, extract_region=emask, ncache=1, verbose=True) # Get arrays from array splits = dm.get_splits(season=season, patch=patch, arrays=dm.array_freqs[args.array], srcfree=True) ivars = dm.get_splits_ivar(season=season, patch=patch, arrays=dm.array_freqs[args.array]) noise.plot(pout + "_splits", splits) noise.plot(pout + "_ivars", ivars)
parser.add_argument("--mask-pad", type=int, default=None, help='Mask additional padding. No padding is applied to the extracted mask if any specified.') parser.add_argument("--extract-mask", type=str, default=None, help='Make sims on the big mask but do all the analysis on an extract of this version.') parser.add_argument("--binary-percentile", type=float, default=10.,help='Binary percentile for sim masking.') parser.add_argument("--season", type=str,help='Season') parser.add_argument("--array", type=str,help='Array') parser.add_argument("--patch", type=str,help='Patch') args = parser.parse_args() mask_patch = args.patch if args.mask_patch is None else args.mask_patch with bench.show("region"): if args.extract_mask is not None: region_map = sints.get_act_mr3_crosslinked_mask(mask_patch, version=args.extract_mask, kind=args.mask_kind, season=args.season) else: region_map = None with bench.show("ngen init"): ngen = noise.NoiseGen(args.version,extract_region=region_map,ncache=1) with bench.show("make a sim"): ngen.generate_sim(season=args.season,patch=args.patch,array=args.array,seed=1) with bench.show("make another sim"): ngen.generate_sim(season=args.season,patch=args.patch,array=args.array,seed=2)