Skip to content

Commit c50cb2d

Browse files
authored
Merge pull request #67 from SteSeg/result_database_2
Database of results for reference
2 parents 812577f + 1ef1229 commit c50cb2d

File tree

121 files changed

+145
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+145
-3
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import h5py
2+
import pandas as pd
3+
import xarray as xr
4+
import numpy as np
5+
import openmc_fusion_benchmarks as ofb
6+
import os
7+
8+
def get_tally_dataframe(file, tally_name):
9+
10+
with h5py.File(file) as f:
11+
df = pd.DataFrame(f[tally_name+'/table'][()]).drop(columns='index')
12+
13+
return df
14+
15+
def save_result(df, filename, group, realization_label):
16+
# Convert to xarray and add dimensions
17+
t = xr.DataArray(
18+
df.values[np.newaxis, :, :], # shape: (1, r, c)
19+
dims=["realization", "row", "column"],
20+
coords={
21+
"realization": [realization_label],
22+
"column": df.columns,
23+
"row": np.arange(df.shape[0]),
24+
},
25+
name=group
26+
)
27+
28+
# Save the tally data to a netCDF file
29+
ofb.utils._save_result(new_result=t, filename=filename,
30+
group=group, realization_label=realization_label)
31+
32+
return
33+
34+
def convert_all_files():
35+
folder_path = 'oktavian_al'
36+
# Get only file names in the directory
37+
file_names = [f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))]
38+
39+
for file in file_names:
40+
if file.endswith('.h5'):
41+
ndf = get_tally_dataframe(os.path.join(folder_path, file), 'nspectrum')
42+
pdf = get_tally_dataframe(os.path.join(folder_path, file), 'gspectrum')
43+
44+
new_filename = file.replace('.h5', '_csg.h5')
45+
46+
save_result(ndf, new_filename, 'neutron_leakage', 'baseline')
47+
save_result(pdf, new_filename, 'photon_leakage', 'baseline')
48+
49+
# if __name__ == "__main__":
50+
# convert_all_files()
-1.01 MB
Binary file not shown.
-1.33 MB
Binary file not shown.
-1.39 MB
Binary file not shown.
-1.06 MB
Binary file not shown.
-1.04 MB
Binary file not shown.
-988 KB
Binary file not shown.
-988 KB
Binary file not shown.
-761 KB
Binary file not shown.
-761 KB
Binary file not shown.

0 commit comments

Comments
 (0)