#########################################

#Set parameters here
##
cfname = sys.argv[1]
upsample = bool(float(sys.argv[2]))
with open(cfname, 'r') as ymlfile:
    cfg = yaml.load(ymlfile)
for i in cfg['basep'].keys():
    locals()[i] = cfg['basep'][i]
zz = 1 / aa - 1

if upsample: ncd = nc * 2
else: ncd = nc

truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(ncd, ncd, ncd), dtype='f8')
comm = truth_pm.comm
rank = comm.rank
kmin, angle = cfg['mods']['kmin'], cfg['mods']['angle']
h1model = HImodels.ModelA(aa)
if angle is None:
    angle = numpy.round(
        mapnoise.wedge(zz, att=cfg['mods']['wopt'], angle=True), 0)
if rank == 0:
    print(angle)
try:
    spread
except:
    spread = 1.

if numd <= 0: num = -1
Example #2
0
#cosmo = Planck15.clone(Omega_cdm = 0.2685, h = 0.6711, Omega_b = 0.049)
cosmodef = {'omegam': 0.309167, 'h': 0.677, 'omegab': 0.048}
cosmo = Cosmology.from_dict(cosmodef)

#########################################

#Set parameters here
##
cfname = sys.argv[1]
with open(cfname, 'r') as ymlfile:
    cfg = yaml.load(ymlfile)
for i in cfg['basep'].keys():
    locals()[i] = cfg['basep'][i]
zz = 1 / aa - 1

truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
comm = truth_pm.comm
rank = comm.rank
kmin, angle = cfg['mods']['kmin'], cfg['mods']['angle']
h1model = HImodels.ModelA(aa)
if angle is None:
    angle = numpy.round(
        mapnoise.wedge(zz, att=cfg['mods']['wopt'], angle=True), 0)
if rank == 0:
    print(angle)
try:
    spread
except:
    spread = 1.

if numd <= 0: num = -1
Example #3
0
from nbodykit.algorithms.fof import FOF
from nbodykit.lab import KDDensity, BigFileMesh, BigFileCatalog, ArrayCatalog
import os, json
##
#Import the relevant map and objective function relevant to reconstruction
from cosmo4d.lab import mapbias as map
from cosmo4d.lab import objectives
from cosmo4d.lab import mapnoise
from cosmo4d.lab import dg
from solve import solve

##################################################################################

#Set parameters here
bs, nc = 256., 64
truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f4')
nsteps = 5
aa = 1.0000
B = 1

noisevar = 0.01
smooth = None
seed = 999

## Basic bookkeeping. Creating folders and paths to save files
ofolder = '/global/cscratch1/sd/chmodi/fm_eor/bias/'
prefix = 'test'
fname = 's%d_%s' % (seed, prefix)
optfolder = ofolder + 'opt_%s/' % fname
if truth_pm.comm.rank == 0: print('Output Folder is %s' % optfolder)
Example #4
0
from abopt.algs.lbfgs import scalar as scalar_diag

from nbodykit.cosmology import Planck15, EHPower, Cosmology
from nbodykit.algorithms.fof import FOF
from nbodykit.lab import KDDensity, BigFileMesh, BigFileCatalog, ArrayCatalog
import os, json
from solve import solve

objfunc = objectives.SmoothedObjective
#########################################

#Set parameters here
bs, nc = 400., 128
seed = 100
truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
comm = truth_pm.comm
rank = comm.rank
nsteps = 5
zz = 0
aa = 1 / (1 + zz)
B = 1
iseed = 999
smoothings = [0, 0.5, 1., 2., 4.]

noisevar = 0.01
smooth = None

#
mainfolder = '/global/cscratch1/sd/chmodi/cosmo4d/'
dfolder = mainfolder + '/data/z%02d/L%04d_N%04d_S%04d_%dstep/' % (zz, bs, nc,
Example #5
0
#########################################
###
###CHECK FRESHRUN, INFOLDER

cfname = sys.argv[1]

with open(cfname, 'r') as ymlfile:
    cfg = yaml.load(ymlfile)

#open up dictionaries
for i in cfg.keys():
    locals()[i] = cfg[i]
for i in basep.keys():
    locals()[i] = basep[i]
#Mesh
pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
rank = truth_pm.comm.rank

#########################################
#Folder and file names
ofolder = scratch + 'output/version2/L%04d_N%04d_%02dstep-fof/lhd_S%04d/n%02d/' % (
    bs, nc, nsteps, seed, numd * 1e4)
#hofolder = scratch + 'output/L%04d_N%04d_%02dstep-fof/'%(bs, nc, nsteps) + foldersp['hofolder']%(fine, seed)
hofolder = project + 'data/L%04d_N%04d_S%04d_%02dstep/' % (bs, int(
    nc * fine), seed, nfsteps)

#This needs to be updated!
if zz:
    ofolder = ofolder + 'z%02d/' % (zz * 10)
    hofolder = hofolder[:-1] + '_z%02d/' % (zz * 10)
Example #6
0
import sys, os, json, yaml
from solve import solve
from getbiasparams import getbias, eval_bfit

#########################################

#Set parameters here
##
cfname = sys.argv[1]
with open(cfname, 'r') as ymlfile:
    cfg = yaml.load(ymlfile)
for i in cfg['basep'].keys():
    locals()[i] = cfg['basep'][i]
zz = 1 / aa - 1

truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f4')
comm = truth_pm.comm
rank = comm.rank

if numd <= 0: num = -1
else: num = int(bs**3 * numd)
if rank == 0: print('Number of objects : ', num)

objfunc = getattr(objectives, cfg['mods']['objective'])
map = getattr(lab, cfg['mods']['map'])

#
proj3058 = '/project/projectdirs/m3058/chmodi/cosmo4d/'
proj3035 = '/project/projectdirs/m3035/chmodi/cosmo4d/'
dfolder = proj3035 + 'data/z00/L%04d_N%04d_S%04d_%02dstep/' % (bs, int(nc),
                                                               seed, 5)
#Set parameters here
##
cfname = sys.argv[1]
with open(cfname, 'r') as ymlfile: cfg = yaml.load(ymlfile)
for i in cfg['basep'].keys(): locals()[i] = cfg['basep'][i]
kmin, angle = cfg['mods']['kmin'], cfg['mods']['angle']
h1model = HImodels.ModelA(aa)
zz = 1/aa-1
if angle is None:
    angle = numpy.round(mapnoise.wedge(zz, att=cfg['mods']['wopt'], angle=True), 0)
if rank == 0: 
    print(angle)
try: spread
except : spread = 1.

truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
comm = truth_pm.comm
rank = comm.rank

if numd <= 0: num = -1
else: num = int(bs**3 * numd)
if rank == 0: print('Number of objects : ', num)

objfunc = getattr(objectives, cfg['mods']['objective'])
map = getattr(lab, cfg['mods']['map'])

#
proj = '/project/projectdirs/cosmosim/lbl/chmodi/cosmo4d/'
if ray: dfolder = '/global/cscratch1/sd/chmodi/m3127/cm_lowres/%dstepT-B%d/%d-%d-9100/'%(nsteps, B, bs, nc)
else: dfolder = '/global/cscratch1/sd/chmodi/m3127/cm_lowres/%dstepT-B%d/%d-%d-9100-fixed/'%(nsteps, B, bs, nc)
Example #8
0
for i in cfg['basep'].keys():
    locals()[i] = cfg['basep'][i]
kmin, angle = cfg['mods']['kmin'], cfg['mods']['angle']
h1model = HImodels.ModelA(aa)
zz = 1 / aa - 1
if angle is None:
    angle = numpy.round(
        mapnoise.wedge(zz, att=cfg['mods']['wopt'], angle=True), 0)
if rank == 0:
    print(angle)
try:
    spread
except:
    spread = 1.

truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
comm = truth_pm.comm
rank = comm.rank
nc2 = nc * 2

if numd <= 0: num = -1
else: num = int(bs**3 * numd)
if rank == 0: print('Number of objects : ', num)

objfunc = getattr(objectives, cfg['mods']['objective'])
map = getattr(lab, cfg['mods']['map'])

#
proj = '/project/projectdirs/m3058/chmodi/m3127/'
#proj = '/project/projectdirs/cosmosim/lbl/chmodi/cosmo4d/'
if ray:
Example #9
0
###CHECK FRESHRUN, INFOLDER

cfname = sys.argv[1]

with open(cfname, 'r') as ymlfile:
    cfg = yaml.load(ymlfile)

#open up dictionaries
for i in cfg.keys():
    locals()[i] = cfg[i]
for i in basep.keys():
    locals()[i] = basep[i]
Mdown = [float(i) for i in Mdown]

#Mesh
truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
rank = truth_pm.comm.rank

if mods['objective'].find('Smoothed') == 0:
    objfunc = getattr(objectives, mods['objective'])
    if rank == 0: print('Objective = %s' % mods['objective'][len('Smoothed'):])
    #objfunc = objectives.SmoothedObjective
    #likelihood = getattr(objfunc, mods['objective'][len('Smoothed'):])
    #likelihood = mods['objective'][len('Smoothed'):]

else:
    print('Smoothed objective is needed')
    sys.exit()
map = getattr(lab, mods['map'])
#noisemod = getattr(noisemap, modes['noisemap'])
Example #10
0
from abopt.algs.lbfgs import scalar as scalar_diag

from nbodykit.cosmology import Planck15, EHPower, Cosmology
from nbodykit.algorithms.fof import FOF
from nbodykit.lab import KDDensity, BigFileMesh, BigFileCatalog, ArrayCatalog
import os, json
from solve import solve

objfunc = objectives.SmoothedObjective
#########################################

#Set parameters here
bs, nc = 400., 128
seed = 100
truth_pm = ParticleMesh(BoxSize=bs, Nmesh=(nc, nc, nc), dtype='f8')
nsteps = 5
zz = 0
aa = 1/(zz+1)
B = 1
iseed = 999

smoothings = [0] 
noisevar = 0.01
smooth = None


#
mainfolder = '/global/cscratch1/sd/chmodi/cosmo4d/'
dfolder = mainfolder + '/data/z%02d/L%04d_N%04d_S%04d_%dstep/'%(zz, bs, nc, seed, 40)