Beispiel #1
0
def get_meshes(seed, galaxies=False):
    mesh = {}
    mesh['s'] = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                                  'mesh/s/')
    partp = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                              'dynamic/1/Position/')
    mesh['cic'] = tools.paintcic(partp, bs, nc)
    mesh['decic'] = tools.decic(mesh['cic'], kk, kny)
    mesh['R1'] = tools.fingauss(mesh['cic'], kk, R1, kny)
    mesh['R2'] = tools.fingauss(mesh['cic'], kk, R2, kny)
    mesh['GD'] = mesh['R1'] - mesh['R2']

    hmesh = {}
    hposall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    massall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/Mass/')[1:].reshape(-1) * 1e10
    hposd = hposall[:num].copy()
    massd = massall[:num].copy()
    hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    hmesh['pnn'] = tools.paintnn(hposd, bs, nc)
    hmesh['pnnsm'] = tools.fingauss(hmesh['pnn'], kk, R1, kny)
    hmesh['mnn'] = tools.paintnn(hposd, bs, nc, massd)

    return mesh, hmesh
Beispiel #2
0
def get_meshes(seed, galaxies=False):
    mesh = {}
    mesh['s'] = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                                  'mesh/s/')
    partp = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                              'dynamic/1/Position/')
    mesh['cic'] = tools.paintcic(partp, bs, nc)
    mesh['cicovd'] = mesh['cic'] / mesh['cic'].mean() - 1
    mesh['decic'] = tools.decic(mesh['cic'], kk, kny)
    mesh['R1'] = tools.fingauss(mesh['cic'], kk, R1, kny)
    mesh['R2'] = tools.fingauss(mesh['cic'], kk, R2, kny)
    mesh['GD'] = mesh['R1'] - mesh['R2']

    hmesh = {}
    hposall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    massall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/Mass/')[1:].reshape(-1) * 1e10
    hposd = hposall[:num].copy()
    massd = massall[:num].copy()
    print(massd[-1] / 1e10)
    hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    hmesh['pnn'] = tools.paintnn(hposd, bs, nc)
    hmesh['mnn'] = tools.paintnn(hposd, bs, nc, massd)
    hmesh['mcic'] = tools.paintcic(hposd, bs, nc, massd)
    hmesh['mcicovd'] = (hmesh['mcic'] -
                        hmesh['mcic'].mean()) / hmesh['mcic'].mean()
    data = hmesh['mcicovd']
    print(data.min(), data.max(), data.mean(), data.std())

    return mesh, hmesh
Beispiel #3
0
def get_meshes(seed, galaxies=False, inverse=True):
    mesh = {}
    mesh['s'] = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                                  'mesh/s/')
    partp = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                              'dynamic/1/Position/')
    mesh['cic'] = tools.paintcic(partp, bs, nc)
    mesh['ciclog'] = np.log(1e-3 + mesh['cic'])
    mesh['cicovd'] = mesh['cic'] / mesh['cic'].mean() - 1
    mesh['decic'] = tools.decic(mesh['cic'], kk, kny)
    mesh['R1'] = tools.fingauss(mesh['cic'], kk, R1, kny)
    mesh['R2'] = tools.fingauss(mesh['cic'], kk, R2, kny)
    mesh['GD'] = mesh['R1'] - mesh['R2']

    hmesh = {}
    hposall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    if stellar:
        massall = np.load(path + ftype % (bs, ncf, seed, stepf) +
                          'stellarmass.npy')
    else:
        massall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                    'FOF/Mass/')[1:].reshape(-1) * 1e10

    hposd = hposall[:num].copy()
    massd = massall[:num].copy()
    print(massall.min() / 1e10, massall.max() / 1e10)
    print(massd.min() / 1e10, massd.max() / 1e10)

    hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    hmesh['pnn'] = tools.paintnn(hposd, bs, nc)
    hmesh['mnn'] = tools.paintnn(hposd, bs, nc, massd)
    hmesh['mcic'] = tools.paintcic(hposd, bs, nc, massd)
    hmesh['mcicnomean'] = (hmesh['mcic']) / hmesh['mcic'].mean()
    hmesh['mcicovd'] = (hmesh['mcic'] -
                        hmesh['mcic'].mean()) / hmesh['mcic'].mean()
    hmesh['pcicovd'] = (hmesh['pcic'] -
                        hmesh['pcic'].mean()) / hmesh['pcic'].mean()
    hmesh['pcicovdR3'] = tools.fingauss(hmesh['pcicovd'], kk, R1, kny)

    if inverse: return hmesh, mesh
    else: return mesh, hmesh
Beispiel #4
0
module = hub.Module('./../code/models/n%02d/%s/%s.hub'%(numd*1e4, suff, chkname))
xx = tf.placeholder(tf.float32, shape=[None, cube_sizeft, cube_sizeft, cube_sizeft, nchannels], name='input')
yy = tf.placeholder(tf.float32, shape=[None, cube_size, cube_size, cube_size, 1], name='labels')
output = module(dict(input=xx, label=yy, keepprob=1), as_dict=True)['prediction']
sess = tf.Session()
sess.run(tf.initializers.global_variables())
#
#############################
meshes = {}
cube_features, cube_target = [], []
for seed in seeds:
    mesh = {}
    partp = tools.readbigfile(path + ftype%(bs, nc, seed, step) + 'dynamic/1/Position/')
    mesh['cic'] = tools.paintcic(partp, bs, ncp)
    mesh['decic'] = tools.decic(mesh['cic'], kk, kny)
    mesh['R1'] = tools.fingauss(mesh['cic'], kk, R1, kny)
    mesh['R2'] = tools.fingauss(mesh['cic'], kk, R2, kny)
    mesh['GD'] = mesh['R1'] - mesh['R2']
    mesh['s'] = tools.readbigfile(path + ftype%(bs, nc, seed, step) + 'mesh/s/')

    hmesh = {}
    hposall = tools.readbigfile(path + ftype%(bs, ncf, seed, stepf) + 'FOF/PeakPosition/')[1:]
    hposd = hposall[:num].copy()
    hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    hmesh['pnn'] = tools.paintnn(hposd, bs, ncp)
    hmesh['target'] = hmesh['pnn'].copy()
    
    print('All the mesh have been generated for seed = %d'%seed)

    #Create training voxels
Beispiel #5
0
numd = 5e-4
num = int(numd * bs**3)
seed = 100
R1 = 3
R2 = 3 * 1.2
kny = np.pi * ncp / bs
kk = tools.fftk((ncp, ncp, ncp), bs)

suff = '2ftmdg256'
#############################
##Read data and generate meshes
#mesh = tools.readbigfile(path + ftype%(bs, nc, seed, step) + 'mesh/d/')
partp = tools.readbigfile(path + ftype % (bs, nc, seed, step) +
                          'dynamic/1/Position/')
mesh = tools.paintcic(partp, bs, ncp)
meshdecic = tools.decic(mesh, kk, kny)
meshR1 = tools.fingauss(mesh, kk, R1, kny)
meshR2 = tools.fingauss(mesh, kk, R2, kny)
meshdg = meshR1 - meshR2
#ftlist = [meshdecic.copy(), meshR1.copy(), meshdg.copy()]

hposall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                            'FOF/PeakPosition/')[1:]
hposd = hposall[:num].copy()
#hposall = hposall[:2*num]

# hpmeshall = tools.paintcic(hposall, bs, nc)
# hpmeshd = tools.paintcic(hposd, bs, nc)

#hpmeshall = tools.paintnn(hposall, bs, ncp)
hpmeshd = tools.paintnn(hposd, bs, ncp)