def make_lagfields(nc, seed, bs=1536, T=40, B=2, simpath=sc_simpath, outpath=sc_outpath, Rsm=0): fname = get_filename(nc, seed, T=T, B=B) spath = simpath + fname opath = outpath + fname try: os.makedirs(opath) except: pass pm = ParticleMesh(BoxSize=bs, Nmesh=[nc, nc, nc], dtype='f4') rank = pm.comm.rank lin = BigFileMesh(spath + '/linear', 'LinearDensityK').paint() lin -= lin.cmean() print(rank, 'lin field read') header = '1,b1,b2,bg,bk' names = header.split(',') lag_fields = tools.getlagfields( pm, lin, R=Rsm) # use the linear field at the desired redshift print(rank, 'lag field created') for i, ff in enumerate(lag_fields): x = FieldMesh(ff) x.save(opath + 'lag', dataset=names[i], mode='real')
pm = ParticleMesh(BoxSize=bs, Nmesh=[nc, nc, nc], dtype='f4') rank = pm.comm.rank #grid = pm.mesh_coordinates()*bs/nc lin = BigFileMesh(lpath+ '/linear', 'LinearDensityK').paint() lin -= lin.cmean() print(rank, 'lin field read') header = '1,b1,b2,bg,bk' names = header.split(',') lag_fields = tools.getlagfields(pm, lin, R=Rsm) # use the linear field at the desired redshift print(rank, 'lag field created') for i, ff in enumerate(lag_fields): x = FieldMesh(ff) x.save(lpath + 'lag', dataset=names[i], mode='real') ### dyn = BigFileCatalog(dpath + '/fastpm_%0.4f/1'%aa) print(rank, 'files read') # fpos = dyn['Position'].compute() idd = dyn['ID'].compute() attrs = dyn.attrs grid = tools.getqfromid(idd, attrs, nc) print(rank, 'grid computed')
rank = pm.comm.rank #grid = pm.mesh_coordinates()*bs/nc lin = BigFileMesh(lpath + '/linear', 'LinearDensityK').paint() lin -= lin.cmean() print(rank, 'lin field read') header = '1,b1,b2,bg,bk' names = header.split(',') lag_fields = tools.getlagfields( pm, lin, R=Rsm) # use the linear field at the desired redshift print(rank, 'lag field created') for i, ff in enumerate(lag_fields): x = FieldMesh(ff) x.save(lpath + 'lag', dataset=names[i], mode='real') ## ### ## dyn = BigFileCatalog(dpath + '/fastpm_%0.4f/1'%aa) ## ## print(rank, 'files read') ## ## # ## fpos = dyn['Position'].compute() ## idd = dyn['ID'].compute() ## attrs = dyn.attrs ## ## grid = tools.getqfromid(idd, attrs, nc) ## print(rank, 'grid computed') ## ### cat = ArrayCatalog({'ID': idd, 'InitPosition': grid, 'Position' : fpos}, BoxSize=pm.BoxSize, Nmesh=pm.Nmesh)
#pm = ParticleMesh(BoxSize=bs, Nmesh=[nc, nc, nc], dtype='f4') #rank = pm.comm.rank dyn = BigFileCatalog(dpath + '/fastpm_%0.4f/1' % aa) # fpos = dyn['Position'].compute() idd = dyn['ID'].compute() attrs = dyn.attrs grid = tools.getqfromid(idd, attrs, nc) print('grid computed') del dyn, idd header = '1,b1,b2,bg,bk' names = header.split(',') for i in range(len(names)): ff = BigFileMesh(lpath + '/lag', names[i]).paint() pm = ff.pm rank = pm.comm.rank glay, play = pm.decompose(grid), pm.decompose(fpos) wts = ff.readout(grid, layout=glay, resampler='nearest') print(rank, ' got weights') x = FieldMesh(pm.paint(fpos, mass=wts, layout=play)) x.save(lpath + 'eul-z%03d-R%d' % (zz * 100, Rsm), dataset=names[i], mode='real') del pm, ff, wts, x