Example #1
0
def merge_field_nodes(fdir, lap, conf):

    fstr = fdir + '/fields-*_' + str(lap) + '.h5'
    print(fstr)
    files = glob.glob(fstr)
    files.sort(key=natural_keys)

    print(files)

    fname_merged = fdir + '/fields_' + str(lap) + '.h5'
    f5 = h5py.File(fname_merged, 'w')

    fvars = ['bx', 'by', 'bz', 'ex', 'ey', 'ez', 'jx', 'jy', 'jz', 'rho']

    for fvar in fvars:
        print("processing {}".format(fvar))

        arr = combine_tiles(files[0], fvar, conf, isp=None)
        for ff in files[1:]:
            print("  file: {}".format(ff))
            arrN = combine_tiles(ff, fvar, conf, isp=None)
            arr += arrN

        dset = f5.create_dataset(fvar, data=arr)

    f5.close()
Example #2
0
def merge_analysis_nodes(fdir, lap, isps, conf):

    fstr = fdir + '/analysis-*_' + str(lap) + '.h5'
    print(fstr)
    files = glob.glob(fstr)
    files.sort(key=natural_keys)

    print(files)

    fname_merged = fdir + '/analysis_' + str(lap) + '.h5'
    f5 = h5py.File(fname_merged, 'w')

    fvars = [
        'rho',
        'edens',
        #'temp',
        #'Vx',
        #'Vy',
        #'Vz',
        #'momx',
        #'momy',
        #'momz',
        #'pressx',
        #'pressy',
        #'pressz',
        #'shearxy',
        #'shearxz',
        #'shearyz',
    ]

    for fvar in fvars:
        print("processing {}".format(fvar))

        for isp in isps:
            print(" isp {}".format(isp))
            arr = combine_tiles(files[0], fvar, conf, isp=isp)
            for ff in files[1:]:
                print("  file: {}".format(ff))
                arrN = combine_tiles(ff, fvar, conf, isp=None)
                arr += arrN

            dset = f5.create_dataset(fvar + '_' + str(isp), data=arr)

    f5.close()
Example #3
0
    def test_write_fields2D(self):

        ##################################################
        # write

        conf = Conf()
        conf.Nx = 3
        conf.Ny = 4
        conf.Nz = 1
        conf.NxMesh = 5
        conf.NyMesh = 6
        conf.NzMesh = 1 
        conf.outdir = "io_test_2D/"

        if not os.path.exists( conf.outdir ):
            os.makedirs(conf.outdir)

        grid = pycorgi.twoD.Grid(conf.Nx, conf.Ny)
        grid.set_grid_lims(conf.xmin, conf.xmax, conf.ymin, conf.ymax)

        loadTiles2D(grid, conf)

        ref = fill_ref(grid, conf)
        fill_yee(grid, ref, conf)

        pyrunko.vlv.twoD.write_yee(grid, 0, conf.outdir)
        
        ##################################################
        # read using analysis tools
        arrs = combine_tiles(conf.outdir+"fields-0_0.h5", "ex", conf)

        Nx = grid.get_Nx()
        Ny = grid.get_Ny()
        Nz = grid.get_Nz()

        NxM = conf.NxMesh
        NyM = conf.NyMesh
        NzM = conf.NzMesh
        for i in range(grid.get_Nx()):
            for j in range(grid.get_Ny()):
                for k in range(grid.get_Nz()):
                    #if n.get_mpi_grid(i,j) == n.rank:
                    if True:
                        for q in range(conf.NxMesh):
                            for r in range(conf.NyMesh):
                                for s in range(conf.NzMesh):
                                    self.assertAlmostEqual( arrs[i*NxM + q, j*NyM + r, k*NzM + s],  
                                                             ref[i*NxM + q, j*NyM + r, k*NzM + s, 0], places=6)


        ##################################################
        # test reading back
        node2 = pycorgi.twoD.Grid(conf.Nx, conf.Ny)
        node2.set_grid_lims(conf.xmin, conf.xmax, conf.ymin, conf.ymax)
        loadTiles2D(node2, conf)

        pyrunko.vlv.twoD.read_yee(node2, 0, "io_test_2D")

        yee1 = getYee2D(grid,  conf)
        yee2 = getYee2D(node2, conf)

        for i in range(grid.get_Nx()):
            for j in range(grid.get_Ny()):
                for k in range(grid.get_Nz()):
                    #if n.get_mpi_grid(i,j) == n.rank:
                    if True:
                        for q in range(conf.NxMesh):
                            for r in range(conf.NyMesh):
                                for s in range(conf.NzMesh):
                                    for m in ["jx", "jy", "jz", "ex", "ey", "ez", "bx", "by", "bz", "rho"]:

                                        self.assertAlmostEqual( 
                                                yee1[m][i*NxM + q, j*NyM + r],
                                                yee2[m][i*NxM + q, j*NyM + r],
                                                places=6)
Example #4
0
bx = []
by = []
bz = []
jx = []
jy = []
jz = []
dens = []

start = 0
end = len(files_F)
interval = 1

for step in range(start, end, interval):
    print("reading {} and {}".format(files_F[step], files_A[step]))

    exi = combine_tiles(files_F[step], "ex", conf)[:, :, 0]
    eyi = combine_tiles(files_F[step], "ey", conf)[:, :, 0]
    ezi = combine_tiles(files_F[step], "ez", conf)[:, :, 0]

    jxi = combine_tiles(files_F[step], "jx", conf)[:, :, 0]
    jyi = combine_tiles(files_F[step], "jy", conf)[:, :, 0]
    jzi = combine_tiles(files_F[step], "jz", conf)[:, :, 0]

    bxi = combine_tiles(files_F[step], "bx", conf)[:, :, 0]
    byi = combine_tiles(files_F[step], "by", conf)[:, :, 0]
    bzi = combine_tiles(files_F[step], "bz", conf)[:, :, 0]

    densi = combine_tiles(files_F[step], "rho", conf)[:, :, 0]

    print("shape ex")
    print(np.shape(exi))