def neuralnetpredict(pm, bs, nc, numd, seed, zz=0): '''For the given box, mesh, numd, seed and redshift, do the neural network prediction from the network saved in cfg file and return predict, nnpred, nnmass ''' dpath = '/global/project/projectdirs/astro250/chmodi/cosmo4d/' import yaml import nettools as ntools with open(dpath + 'train/models.yaml', 'r') as ymlfile: cfg = yaml.load(ymlfile) ptpath = dpath + 'train/' + cfg['%s-%s' % (int(bs), int(nc))][0][numd]['ppath'] mtpath = ptpath + cfg['%s-%s' % (int(bs), int(nc))][0][numd]['mpath'] # mtpath = ptpath + cfg['%s-%s'%(bs,nc)][0][numd]['mpathnf'] ptup, pftname, plocal, pdict = ntools.setuppos2(ptpath) mtup, mftname, mlocal, mdict = ntools.setupmass(mtpath) R1, R2 = pdict['R1'], pdict['R2'] num = int(numd * bs**3) meshdict, hdict = ntools.readfiles( pm, dpath + '/data/z%02d/L%04d_N%04d_S%04d_05step/' % (zz, bs, nc, seed), R1=R1, R2=R2, mexp=None) ftt = ntools.createdata(pm, meshdict, pdict['pftname'], plocal) mftt = ntools.createdata(pm, meshdict, mftname, mlocal) nnpred = ntools.applynet(ftt, ptup).reshape(nc, nc, nc) nnmass = ntools.applynet(mftt, mtup).reshape(nc, nc, nc) predict = nnpred * nnmass ## return pm.create(mode='real', value=predict), nnpred, nnmass
mexp, cc = 0.5, 4.6 stellar = False regression = False Rsm = 3 num = int(numd * bs**3) fine = 4 pm = PMnew(BoxSize=bs, Nmesh=[nc] * 3) ptpath = train + cfg['%s-%s' % (bs, nc)][0][numd]['ppath'] if regression: mtpath = ptpath + cfg['%s-%s' % (bs, nc)][0][numd]['rpath'] else: mtpath = ptpath + cfg['%s-%s' % (bs, nc)][0][numd]['mpath'] ptup, pftname, plocal, pdict = ntools.setuppos2(ptpath) if regression: mtup, mftname, mlocal, mdict = ntools.setupmassreg(mtpath) else: mtup, mftname, mlocal, mdict = ntools.setupmass(mtpath) R1, R2 = pdict['R1'], pdict['R2'] #####Files #model predicts, datas = [], [] datasgs = [[], []] sgs = [0.1, 0.20] for seed in [100, 500, 900, 800]: meshdict, dummy = ntools.readfiles( pm,