modlmap = enmap.modlmap(shape, wcs) comm = mpi.MPI.COMM_WORLD rank = comm.Get_rank() numcores = comm.Get_size() Njobs = int(narrays * (narrays + 1.) / 2.) num_each, each_tasks = mpi.mpi_distribute(Njobs, numcores) if rank == 0: print("At most ", max(num_each), " tasks...") my_tasks = each_tasks[rank] ainds = [] for aindex1 in range(narrays): for aindex2 in range(aindex1, narrays): ainds.append((aindex1, aindex2)) io.mkdir("data/spectra/%s" % version, comm) for task in my_tasks: aindex1, aindex2 = ainds[task] proot = "data/spectra/%s/%s_%s_" % (version, arrays[aindex1], arrays[aindex2]) print("Noise calc...") scov, _, _, ncov = ncalc( aindex1, aindex2) # raw power spectra in full 2d space before any downsampling enmap.write_map(proot + "signal.fits", scov) enmap.write_map(proot + "noise.fits", ncov) io.plot_img(tutils.tpower(scov), proot + "signal.png") io.plot_img(tutils.tpower(ncov), proot + "noise.png")
parser.add_argument("-n", "--noise", type=float, default=3.0,help="Noise (uK-arcmin).") #parser.add_argument("-f", "--flag", action='store_true',help='A flag.') args = parser.parse_args() # MPI comm = mpi.MPI.COMM_WORLD rank = comm.Get_rank() numcores = comm.Get_size() # Paths PathConfig = io.load_path_config() pout_dir = PathConfig.get("paths","plots")+"qest_hdv_"+str(args.noise)+"_" io.mkdir(pout_dir,comm) # Theory theory_file_root = "../alhazen/data/Aug6_highAcc_CDM" cc = counts.ClusterCosmology(skipCls=True) theory = cosmology.loadTheorySpectraFromCAMB(theory_file_root,unlensedEqualsLensed=False, useTotal=False,TCMB = 2.7255e6,lpad=9000,get_dimensionless=False) # Geometry shape, wcs = maps.rect_geometry(width_arcmin=args.arc,px_res_arcmin=args.pix,pol=False) modlmap = enmap.modlmap(shape,wcs) modrmap = enmap.modrmap(shape,wcs) # Binning bin_edges = np.arange(0.,20.0,args.pix*2)
# Lens grid amin = args.GridMin amax = args.GridMax num_amps = args.GridNum kamps = np.linspace(amin,amax,num_amps) # MPI calculate set up Nsims = num_amps Njobs = Nsims num_each,each_tasks = mpi.mpi_distribute(Njobs,numcores) if rank==0: print ("At most ", max(num_each) , " tasks...") my_tasks = each_tasks[rank] # File I/O io.mkdir(GridName,comm) cov_name = lambda x: GridName+"/cov_"+str(x)+".npy" if rank==0: print("Rank 0 starting ...") for k,my_task in enumerate(my_tasks): kamp = kamps[my_task] kappa_template = lensing.nfw_kappa(kamp*1e15,bmodrmap,cc,overdensity=200.,critical=True,atClusterZ=True) phi,_ = lensing.kappa_to_phi(kappa_template,bmodlmap,return_fphi=True) grad_phi = enmap.grad(phi) pos = posmap + grad_phi alpha_pix = enmap.sky2pix(bshape,bwcs,pos, safe=False) def do_the_thing():