Skip to content

Commit 9d7930d

Browse files
committed
nested dict for transport
1 parent d6f6d30 commit 9d7930d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/openmc_data_to_json/core.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,14 @@ def cross_section_h5_file_to_json_file(
404404
'neutron_number': dict_of_reactions[0]["Neutron number"],
405405
'element': dict_of_reactions[0]["Element"],
406406
'atomic_symbol': dict_of_reactions[0]["Atomic symbol"],
407-
'incident_particle': dict_of_reactions[0]["Incident particle"],
408407
'library': dict_of_reactions[0]["Library"],
409408
}
409+
incident_particle = dict_of_reactions[0]["Incident particle"]
410+
410411
#TODO check if multiple temperatures are present
411412
temperature_found = dict_of_reactions[0]['Temperature(K)']
413+
414+
dict_of_mt_key_energy_xs_values = {}
412415
for entry in dict_of_reactions:
413416
del entry["uuid"]
414417
del entry["Proton number"]
@@ -424,8 +427,18 @@ def cross_section_h5_file_to_json_file(
424427
entry['mt_reaction_number'] = entry.pop('MT reaction number')
425428
entry['cross_section'] = entry.pop('cross section')
426429

427-
428-
dict_of_multiple_reactions['temperature'] = {temperature_found: dict_of_reactions},
430+
dict_of_mt_key_energy_xs_values[entry['mt_reaction_number']] = {
431+
'cross_section': entry['cross_section'],
432+
'energy': entry['energy']
433+
}
434+
435+
dict_of_multiple_reactions['incident_particle'] = {
436+
incident_particle: {
437+
'temperature': {
438+
temperature_found: dict_of_mt_key_energy_xs_values,
439+
}
440+
}
441+
}
429442

430443
with open(output, "w") as fout:
431444
json.dump(dict_of_multiple_reactions, fout, indent=indent)

0 commit comments

Comments
 (0)