Skip to content

Commit 4d18105

Browse files
authored
Merge pull request #378 from astro-informatics/cg_fb_example
add FB example in H5 format
2 parents 7fb88d3 + 2260265 commit 4d18105

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

data/expected/fb/convert2hdf5.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import csv
2+
import h5py
3+
4+
names = ["input_data"]
5+
for name in names:
6+
input_name = f"{name}.vis"
7+
h5_name = input_name[:input_name.rfind('.')] + '.h5'
8+
9+
udata = []
10+
vdata = []
11+
rdata = []
12+
idata = []
13+
sdata = []
14+
with open(input_name, mode ='r') as file:
15+
csvFile = csv.reader(file)
16+
for line in csvFile:
17+
u, v, re, im, sigma = line[0].split()
18+
udata.append(float(u))
19+
vdata.append(float(u))
20+
rdata.append(float(u))
21+
idata.append(float(u))
22+
sdata.append(float(u))
23+
24+
f = h5py.File(h5_name, 'w')
25+
f.create_dataset('u', data=udata)
26+
f.create_dataset('v', data=vdata)
27+
#f.create_dataset('w', data=wdata) # no w column here
28+
f.create_dataset('re', data=rdata)
29+
f.create_dataset('im', data=idata)
30+
f.create_dataset('sigma', data=sdata)
31+
f.close()
32+
33+
print(f"saved {h5_name}")

data/expected/fb/input_data.h5

516 KB
Binary file not shown.

0 commit comments

Comments
 (0)