def get_meshes(seed, galaxies=False):
    mesh = {}
    mesh['s'] = tools.readbigfile(path + ftypefpm % (bs, nc, seed, step) +
                                  'mesh/s/')
    mesh['cic'] = np.load(path + ftypefpm % (bs, nc, seed, step) +
                          'mesh/d.npy')
    #    partp = tools.readbigfile(path + ftypefpm%(bs, nc, seed, step) + 'dynamic/1/Position/')
    #    mesh['cic'] = tools.paintcic(partp, bs, nc)
    #    mesh['logcic'] = np.log(1 + mesh['cic'])
    #    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['pnn'] = tools.paintnn(hposd, bs, nc)
    hmesh['mnn'] = tools.paintnn(hposd, bs, nc, massd)
    hmesh['mnnnomean'] = (hmesh['mnn']) / hmesh['mnn'].mean()
    #hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    #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['mcicovdR3'] = tools.fingauss(hmesh['mcicovd'], kk, R1, kny)
    #hmesh['pcicovd'] =  (hmesh['pcic'] - hmesh['pcic'].mean())/hmesh['pcic'].mean()
    #hmesh['pcicovdR3'] = tools.fingauss(hmesh['pcicovd'], kk, R1, kny)
    #hmesh['lmnn'] = np.log(logoffset + hmesh['mnn'])

    return mesh, hmesh
Exemplo n.º 2
0
def generate_training_data():
    meshes = {}
    cube_features, cube_target = [[] for i in range(len(cube_sizes))
                                  ], [[] for i in range(len(cube_sizes))]

    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']

        hmesh = {}
        hpath = path + ftype % (bs, ncf, seed, stepf) + 'galaxies_n05/galcat/'
        hposd = tools.readbigfile(hpath + 'Position/')
        massd = tools.readbigfile(hpath + 'Mass/').reshape(-1) * 1e10
        galtype = tools.readbigfile(hpath +
                                    'gal_type/').reshape(-1).astype(bool)
        hmesh['pnn'] = tools.paintnn(hposd, bs, ncp)
        hmesh['mnn'] = tools.paintnn(hposd, bs, ncp, massd)
        hmesh['pnnsat'] = tools.paintnn(hposd[galtype], bs, ncp)
        hmesh['pnncen'] = tools.paintnn(hposd[~galtype], bs, ncp)
        meshes[seed] = [mesh, hmesh]

        print('All the mesh have been generated for seed = %d' % seed)

        #Create training voxels
        ftlist = [mesh[i].copy() for i in ftname]
        ftlistpad = [np.pad(i, pad, 'wrap') for i in ftlist]
        #     targetmesh = hmesh['pnn']
        targetmesh = [hmesh[i].copy() for i in tgname]

        for i, size in enumerate(cube_sizes):
            print('For size = ', size)
            if size == nc:
                features = [np.stack(ftlistpad, axis=-1)]
                target = [np.stack(targetmesh, axis=-1)]
            else:
                numcubes = int(num_cubes / size * 4)
                features, target = dtools.randomvoxels(ftlistpad,
                                                       targetmesh,
                                                       numcubes,
                                                       max_offset[i],
                                                       size,
                                                       cube_sizesft[i],
                                                       seed=seed,
                                                       rprob=0)
            cube_features[i] = cube_features[i] + features
            cube_target[i] = cube_target[i] + target

    # #
    for i in range(cube_sizes.size):
        cube_target[i] = np.stack(cube_target[i], axis=0)
        cube_features[i] = np.stack(cube_features[i], axis=0)
        print(cube_features[i].shape, cube_target[i].shape)

    return meshes, cube_features, cube_target
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
0
def getgalmesh(bs,
               nc,
               seed,
               step=5,
               ncf=512,
               stepf=40,
               masswt=False,
               gridding='nn',
               path=None):

    if path is None: path = package_path + '/../../data/z00/'
    ftype = 'L%04d_N%04d_S%04d_%02dstep/'

    hpath = path + ftype % (bs, ncf, seed, stepf) + 'galaxies_n05/galcat/'
    hposd = tools.readbigfile(hpath + 'Position/')
    massd = tools.readbigfile(hpath + 'Mass/').reshape(-1) * 1e10
    galtype = tools.readbigfile(hpath + 'gal_type/').reshape(-1).astype(bool)
    if masswt: mass = massd
    else: mass = np.ones_like(massd)

    if gridding == 'nn':
        gmesh = tools.paintnn(hposd, bs, nc, mass=mass)
        satmesh = tools.paintnn(hposd[galtype], bs, nc, mass=mass[galtype])
        cenmesh = tools.paintnn(hposd[~galtype], bs, nc, mass=mass[~galtype])
    else:
        gmesh = tools.paintcic(hposd, bs, nc, mass=mass)
        satmesh = tools.paintcic(hposd[galtype], bs, nc, mass=mass[galtype])
        cenmesh = tools.paintcic(hposd[~galtype], bs, nc, mass=mass[~galtype])
    return cenmesh, satmesh, gmesh
Exemplo n.º 6
0
def get_meshes(seed, pdict=defdict):
    for i in pdict.keys(): locals()[i] = pdict[i]

    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, 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']

    hmesh = {}
    hpath = path + ftype%(bs, ncf, seed, stepf) + 'FOF/'
    hposd = tools.readbigfile(hpath + 'PeakPosition/')
    massd = tools.readbigfile(hpath + 'Mass/').reshape(-1)*1e10
    #galtype = tools.readbigfile(hpath + 'gal_type/').reshape(-1).astype(bool)
    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, ncp)
    hmesh['mnn'] = tools.paintnn(hposd, bs, ncp, massd)
    #hmesh['pnnsat'] = tools.paintnn(hposd[galtype], bs, ncp)
    #hmesh['pnncen'] = tools.paintnn(hposd[~galtype], bs, ncp)

    return mesh, hmesh
Exemplo n.º 7
0
def gethalomesh(bs,
                nc,
                seed,
                step=5,
                ncf=512,
                stepf=40,
                masswt=False,
                numd=1e-3,
                gridding='nn',
                path=None,
                getdata=False):

    if path is None: path = package_path + '/../../data/z00/'
    ftype = 'L%04d_N%04d_S%04d_%02dstep/'

    num = int(numd * bs**3)
    hposall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    massall = tools.readbigfile(path + ftype % (bs, ncf, seed, stepf) +
                                'FOF/Mass/')[1:]
    hposd = hposall[:num]
    massd = massall[:num].reshape(-1) * 1e10
    if masswt: mass = massd
    else: mass = np.ones_like(massd)

    if gridding == 'nn': hmesh = tools.paintnn(hposd, bs, nc, mass=mass)
    else: hmesh = tools.paintcic(hposd, bs, nc, weights=mass)

    if getdata: return hmesh, hposd, massd
    else: return hmesh
Exemplo n.º 8
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
Exemplo n.º 9
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-4 + 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 = {}
    hpath = path + ftype % (bs, ncf, seed, stepf) + 'galaxies_n05/galcat/'
    hposd = tools.readbigfile(hpath + 'Position/')
    massd = tools.readbigfile(hpath + 'Mass/').reshape(-1) * 1e10
    galtype = tools.readbigfile(hpath + 'gal_type/').reshape(-1).astype(bool)
    hmesh['pnn'] = tools.paintnn(hposd, bs, nc)
    hmesh['pnnovd'] = (hmesh['pnn'] -
                       hmesh['pnn'].mean()) / hmesh['pnn'].mean()
    hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    hmesh['pcicovd'] = (hmesh['pcic'] -
                        hmesh['pcic'].mean()) / hmesh['pcic'].mean()
    hmesh['mnn'] = tools.paintnn(hposd, bs, nc, massd)
    hmesh['mnnovd'] = (hmesh['mnn'] -
                       hmesh['mnn'].mean()) / hmesh['mnn'].mean()
    hmesh['mcic'] = tools.paintcic(hposd, bs, nc, massd)
    hmesh['mcicovd'] = (hmesh['mcic'] -
                        hmesh['mcic'].mean()) / hmesh['mcic'].mean()
    ##    hmesh['mnn'] = tools.paintnn(hposd, bs, nc, massd)
    ##    hmesh['pnnsat'] = tools.paintnn(hposd[galtype], bs, nc)
    ##    hmesh['pnncen'] = tools.paintnn(hposd[~galtype], bs, nc)
    ##
    ##
    if inverse: return hmesh, mesh
    else: return mesh, hmesh
Exemplo n.º 10
0
    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']

    hmesh = {}
    hpath = path + ftype%(bs, ncf, seed, stepf) + 'galaxies_n05/galcat/'
    hposd = tools.readbigfile(hpath + 'Position/')
    massd = tools.readbigfile(hpath + 'Mass/').reshape(-1)*1e10
    galtype = tools.readbigfile(hpath + 'gal_type/').reshape(-1).astype(bool)
    #hposall = tools.readbigfile(path + ftype%(bs, ncf, seed, stepf) + 'FOF/PeakPosition/')[1:]    
    #hposd = hposall[:num].copy()
    #massd = massall[:num].copy()
    #hmesh['pcic'] = tools.paintcic(hposd, bs, nc)
    hmesh['pnn'] = tools.paintnn(hposd, bs, ncp)
    #hmesh['mnn'] = tools.paintnn(hposd, bs, ncp, massd)
    hmesh['pnnsat'] = tools.paintnn(hposd[galtype], bs, ncp)
    hmesh['pnncen'] = tools.paintnn(hposd[~galtype], bs, ncp)

    print('All the mesh have been generated for seed = %d'%seed)


  #Create training voxels
    ftlist = [mesh[i].copy() for i in ftname]
    ftlistpad = [np.pad(i, pad, 'wrap') for i in ftlist]
    targetmesh = [hmesh['pnncen'], hmesh['pnnsat']]
    ntarget = len(targetmesh)

    ncube = int(ncp/cube_size)
    inp = dtools.splitvoxels(ftlistpad, cube_size=cube_sizeft, shift=cube_size, ncube=ncube)
Exemplo n.º 11
0
        os.makedirs(ofolder)
    except:
        pass
    print('Output in ofolder = \n%s' % ofolder)
    pkfile = '../flowpm/Planck15_a1p00.txt'
    config = Config(bs=bs, nc=nc, seed=seed, pkfile=pkfile)

    #Generate Data
    truth = tools.readbigfile(dpath + ftype % (bs, nc, seed, step) + 'mesh/s/')
    final = tools.readbigfile(dpath + ftype % (bs, nc, seed, step) + 'mesh/d/')
    #
    hpath = dpath + ftype % (bs, ncf, seed, stepf) + 'galaxies_n05/galcat/'
    hposd = tools.readbigfile(hpath + 'Position/')
    massd = tools.readbigfile(hpath + 'Mass/').reshape(-1) * 1e10
    galtype = tools.readbigfile(hpath + 'gal_type/').reshape(-1).astype(bool)
    allgal = tools.paintnn(hposd, bs, nc)
    satmesh = tools.paintnn(hposd[galtype], bs, nc)
    cenmesh = tools.paintnn(hposd[~galtype], bs, nc)
    data = np.stack((cenmesh, satmesh), axis=-1)

    np.save(ofolder + '/truth.f4', truth)
    np.save(ofolder + '/data.f4', data)

    ###
    #Do reconstruction here
    print('\nDo reconstruction\n')

    recong = reconmodel(config,
                        data,
                        sigma=sigma,
                        maxiter=maxiter,
Exemplo n.º 12
0
                              'mesh/s/')
    print(truth.shape)
    final = tools.readbigfile(dpath + ftype % (bs, nc, seed, step) + 'mesh/d/')
    print(final.shape)
    hposall = tools.readbigfile(dpath + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    massall = tools.readbigfile(dpath + ftype % (bs, ncf, seed, stepf) +
                                'FOF/Mass/')[1:].reshape(-1) * 1e10
    massd = massall[:num].copy()
    hposd = hposall[:num].copy()
    #
    if datacic:
        datam = tools.paintcic(hposd, bs, nc, massd)
        datap = tools.paintcic(hposd, bs, nc)
    else:
        datam = tools.paintnn(hposd, bs, nc, massd)
        datap = tools.paintnn(hposd, bs, nc)

    if usemass: data = datam
    else: data = datap
    if ovd: data = (data - data.mean()) / data.mean()

    print(data.min(), data.max(), data.mean(), data.std())

    truemeshes = [truth, final, data]
    np.save(ofolder + '/truth.f4', truth)
    np.save(ofolder + '/final.f4', final)
    np.save(ofolder + '/data.f4', data)

    ###
    #Do reconstruction here
Exemplo n.º 13
0
    print(final.shape)
    hposall = tools.readbigfile(dpath + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    #massall = tools.readbigfile(dpath + ftype%(bs, ncf, seed, stepf) + 'FOF/Mass/')[1:].reshape(-1)*1e10
    if stellar:
        massall = np.load(dpath + ftype % (bs, ncf, seed, stepf) +
                          'stellarmass.npy')
    else:
        massall = tools.readbigfile(dpath + ftype % (bs, ncf, seed, stepf) +
                                    'FOF/Mass/')[1:].reshape(-1) * 1e10
    massd = massall[:num].copy()
    hposd = hposall[:num].copy()
    #
    hmesh = {}
    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)

    datap = tools.paintcic(hposd, bs, nc)

    data = hmesh[key]

    print(data.min(), data.max(), data.mean(), data.std())
Exemplo n.º 14
0
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)

print('All the mesh have been generated')
#############################

#Create training voxels
num_cubes = 2000
cube_size = 32
max_offset = ncp - cube_size
ftlist = [mesh.copy(), meshdg.copy()]
ftname = ['density', 'GD']
nchannels = len(ftlist)
cube_features = []
cube_target = []

rand = np.random.rand
Exemplo n.º 15
0
    config = Config(bs=bs, nc=nc, seed=seed, pkfile=pkfile)
    #hgraph = dg.graphlintomod(config, modpath, pad=pad, ny=1)
    print('Diagnostic graph constructed')
    fname = open(ofolder + '/README', 'w', 1)
    fname.write('Using module from path - %s n' % modpath)
    fname.close()

    #Generate Data
    truth = tools.readbigfile(dpath + ftype % (bs, nc, seed, step) + 'mesh/s/')
    print(truth.shape)
    final = tools.readbigfile(dpath + ftype % (bs, nc, seed, step) + 'mesh/d/')
    print(final.shape)
    hposall = tools.readbigfile(dpath + ftype % (bs, ncf, seed, stepf) +
                                'FOF/PeakPosition/')[1:]
    hposd = hposall[:num].copy()
    data = tools.paintnn(hposd, bs, nc)

    truemeshes = [truth, final, data]
    np.save(ofolder + '/truth.f4', truth)
    np.save(ofolder + '/final.f4', final)
    np.save(ofolder + '/data.f4', data)

    ###
    #Do reconstruction here
    print('\nDo reconstruction\n')

    recong = rmods.graphhposft1(config,
                                modpath,
                                data,
                                pad,
                                maxiter=maxiter,
Exemplo n.º 16
0
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
    ftlist = [mesh[i].copy() for i in ftname]
    ftlistpad = [np.pad(i, pad, 'wrap') for i in ftlist]
    targetmesh = hmesh['target']
    targetmesh[targetmesh > 1] = 1
    
    ncube = int(ncp/cube_size)
    inp = dtools.splitvoxels(ftlistpad, cube_size=cube_sizeft, shift=cube_size, ncube=ncube)
    yinp = dtools.splitvoxels(targetmesh, cube_size=cube_size, shift=cube_size, ncube=ncube)
    recp = sess.run(output, feed_dict={xx:inp, yy:yinp})
    mesh['predict'] = dtools.uncubify(recp[:,:,:,:,0], shape)
Exemplo n.º 17
0
    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:]
    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, ncp)
    hmesh['mcic'] = tools.paintcic(hposd, bs, nc, mass=massd)
    hmesh['mnn'] = tools.paintnn(hposd, bs, ncp, mass=massd)

    meshes[seed] = [mesh, hmesh]

    print('All the mesh have been generated for seed = %d' % seed, file=fname)

    #Create training voxels
    ftlist = [mesh[i].copy() for i in ftname]
    ftlistpad = [np.pad(i, pad, 'wrap') for i in ftlist]
    targetmesh = hmesh['pnn']
    #Round off things to 1 again
    targetmesh[targetmesh > 1] = 1

    features, target = dtools.randomvoxels(ftlistpad,