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()