*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 51e69554 authored by Patrick Kappl's avatar Patrick Kappl
Browse files

Test overwriting hdf5 files

parent 5a52c05e
No related branches found
No related tags found
No related merge requests found
......@@ -45,9 +45,15 @@ class Adga(object):
data_set[...] = g2[i, ...]
print(data_set[0, 0, 0])
output = subprocess.check_output("python print_hdf5_data.py g4iw.hdf5"
+ " worm-001/ineq-001/g4iw-worm"
+ "/00001/value", shell=True)
print(output.decode("utf-8"))
self.g4iw_file.flush()
self.g4iw_file.close()
self.g4iw_file = h5py.File("g4iw.hdf5", "r+")
output = subprocess.check_output("python print_hdf5_data.py g4iw.hdf5"
+ " worm-001/ineq-001/g4iw-worm"
+ "/00001/value", shell=True)
print(output.decode("utf-8"))
# Delete g4iw_sym.hdf5
symmetry_file = "g4iw_sym.hdf5"
......
# %%
import h5py
import subprocess
# %% Create test file and dataset
f = h5py.File("test.hdf5", "a")
f.create_dataset("data", data=0, dtype=int)
f.close()
# %% Read data from test file
f1 = h5py.File("test.hdf5", "r+")
a = f1["data"][...]
print(a)
# %%
f1.close()
# %% Overwrite data of test file
f2 = h5py.File("test.hdf5", "r+")
dset = f2["data"]
# %%
dset[...] = 2
# %%
f2.flush()
# %%
f2.close()
#%%
output = subprocess.check_output("F:/Miniconda3/envs/test/python.exe"
+ " print_hdf5_data.py test.hdf5 data",
shell=True)
print(output.decode("utf-8"))
# %%
import h5py
import sys
import numpy as np
if len(sys.argv) >= 2:
file_name = sys.argv[1]
if len(sys.argv) >= 3:
data_set_name = sys.argv[2]
f = h5py.File(file_name, "r")
a = np.array(f[data_set_name][...])
if a.ndim == 0:
print(a)
else:
a.flatten()
print(a[0])
f.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment