def create_hdf5_data_sample_pspace(self, filename, schema_val, datas, time_list): """ Create particle-space sample data using lattice-space data. CAUTION: The coordinate of particle-space data is different from lattices-space data slightly. """ hdf5_file = h5py.File(filename, 'w') # calculate world size hcp = HCPLattice() hcp.load_schema_value(schema_val) wsize = hcp.get_world_sizes() voxelRadius = 1.0e-10 sca = voxelRadius * 2.0 # particle schema for paricle space. pschema = \ [ ('id', 'u8',), ('species_id', 'u8',), ('position', 'f8', (3,)) ] # set data data_group = hdf5_file.create_group('data') data_group.attrs['world_size'] = max(wsize) for time, data in zip(time_list, datas): time_group = data_group.create_group(str(time)) time_group.attrs['t'] = time # pattern 1 time_dset = time_group.create_dataset('particles', (len(data), ), pschema) for i, record in enumerate(data): nindex = record[0] + hcp.get_theStartCoord() co = hcp.coord2point(nindex) wrec = (nindex, record[1], (co[0] * sca, co[1] * sca, co[2] * sca)) time_dset[i] = wrec # set species self.create_species_pspace(hdf5_file) hdf5_file.close()
def create_hdf5_data_sample(self, filename, schema_val, datas, time_list): hdf5_file = h5py.File(filename, 'w') # header header_group = hdf5_file.create_group('lattice_info') hcp = HCPLattice() hcp.load_schema_value(schema_val) hcp_dset = header_group.create_dataset('HCP_group', (2, ), hcp.get_lattice_schema()) hcp_dset.attrs['lattice_type'] = hcp.get_lattice_type() hcp_dset[0] = schema_val #for dummy lattice info voxelRadius = 1.0e-10 theNormalizedVoxelRadius = 0.5 hcp_dset[1] = (2, (1.5, 0.9, 0.4), voxelRadius, theNormalizedVoxelRadius) simple = SimpleLattice() simple_dset = header_group.create_dataset('Simple_group', (1, ), simple.get_lattice_schema()) simple_dset.attrs['lattice_type'] = simple.get_lattice_type() simple_dset[0] = (3, (1.0, 1.0, 1.0), voxelRadius, theNormalizedVoxelRadius) # set data data_group = hdf5_file.create_group('data') for time, data in zip(time_list, datas): time_group = data_group.create_group(str(time)) time_group.attrs['t'] = time # pattern 1 time_dset = time_group.create_dataset('particles', (len(data), ), hcp.get_partilce_schema()) for i, record in enumerate(data): nindex = record[0] + hcp.get_theStartCoord() time_dset[i] = (nindex, record[1], record[2]) # set species self.create_species(hdf5_file) hdf5_file.close()
def create_hdf5_data_sample(self, filename, schema_val, datas, time_list): hdf5_file = h5py.File(filename, "w") # header header_group = hdf5_file.create_group("lattice_info") hcp = HCPLattice() hcp.load_schema_value(schema_val) hcp_dset = header_group.create_dataset("HCP_group", (2,), hcp.get_lattice_schema()) hcp_dset.attrs["lattice_type"] = hcp.get_lattice_type() hcp_dset[0] = schema_val # for dummy lattice info voxelRadius = 1.0e-10 theNormalizedVoxelRadius = 0.5 hcp_dset[1] = (2, (1.5, 0.9, 0.4), voxelRadius, theNormalizedVoxelRadius) simple = SimpleLattice() simple_dset = header_group.create_dataset("Simple_group", (1,), simple.get_lattice_schema()) simple_dset.attrs["lattice_type"] = simple.get_lattice_type() simple_dset[0] = (3, (1.0, 1.0, 1.0), voxelRadius, theNormalizedVoxelRadius) # set data data_group = hdf5_file.create_group("data") for time, data in zip(time_list, datas): time_group = data_group.create_group(str(time)) time_group.attrs["t"] = time # pattern 1 time_dset = time_group.create_dataset("particles", (len(data),), hcp.get_partilce_schema()) for i, record in enumerate(data): nindex = record[0] + hcp.get_theStartCoord() time_dset[i] = (nindex, record[1], record[2]) # set species self.create_species(hdf5_file) hdf5_file.close()
def create_hdf5_data_sample_pspace(self, filename, schema_val, datas, time_list): """ Create particle-space sample data using lattice-space data. CAUTION: The coordinate of particle-space data is different from lattices-space data slightly. """ hdf5_file = h5py.File(filename, "w") # calculate world size hcp = HCPLattice() hcp.load_schema_value(schema_val) wsize = hcp.get_world_sizes() voxelRadius = 1.0e-10 sca = voxelRadius * 2.0 # particle schema for paricle space. pschema = [("id", "u8"), ("species_id", "u8"), ("position", "f8", (3,))] # set data data_group = hdf5_file.create_group("data") data_group.attrs["world_size"] = max(wsize) for time, data in zip(time_list, datas): time_group = data_group.create_group(str(time)) time_group.attrs["t"] = time # pattern 1 time_dset = time_group.create_dataset("particles", (len(data),), pschema) for i, record in enumerate(data): nindex = record[0] + hcp.get_theStartCoord() co = hcp.coord2point(nindex) wrec = (nindex, record[1], (co[0] * sca, co[1] * sca, co[2] * sca)) time_dset[i] = wrec # set species self.create_species_pspace(hdf5_file) hdf5_file.close()