How can I view this statepoint.150.h5 summary.h5 data files in openmc with which commands in ubuntu terminal?
I think most users will open the statepoint file with the openmc python api as that provides access to useful methods of extracting tallies etc.
However if you want to just see the contents from the terminal the statepoint file is a hdf5 format file so you can use commands like h5dump
h5dump statepoint.150.h5
How can i use python api for this h5 file view in openmc?
Assuming you want to access a tally you can open and print the results from within a python script like this
import openmc
sp = openmc.StatePoint(‘statepoint.150.h5’)
tally = sp.get_tally(id=1)
print(tally)
Docs for statepoints are
http://openmc.readthedocs.io/en/stable/pythonapi/generated/openmc.StatePoint.html#openmc.StatePoint
And for summary.h5 files
http://openmc.readthedocs.io/en/stable/pythonapi/generated/openmc.Summary.html#openmc.Summary
Python Api gived me this Error
LookupError Traceback (most recent call last)
Cell In[20], line 3
1 import openmc
2 sp = openmc.StatePoint(‘statepoint.150.h5’)
----> 3 tally = sp.get_tally(id=1)
4 print(tally)
File ~/.local/lib/python3.10/site-packages/openmc/statepoint.py:639, in StatePoint.get_tally(self, scores, filters, nuclides, name, id, estimator, exact_filters, exact_nuclides, exact_scores)
637 # If we did not find the Tally, return an error message
638 if tally is None:
→ 639 raise LookupError(‘Unable to get Tally’)
641 return tally
LookupError: Unable to get Tally
I forgot to mention you will need to change the id=1 part to the id number of your tally.
I changed the number 1, it gave the same error again
The example I gave does also assume you have a tally in the simulation as well knowing that tally id number.
We can adapt it to get any tally that is present
import openmc
sp = openmc.StatePoint(‘statepoint.150.h5’)
tallies = sp.tallies
print(tallies)
In my case I get this print out
{35: Tally
ID = 35
Name = dose_on_cell
Filters = CellFilter, EnergyFunctionFilter, ParticleFilter
Nuclides = total
Scores = ['flux']
Estimator = tracklength, 36: Tally
ID = 36
Name = surface_current
Filters = CellFilter, SurfaceFilter
Nuclides = total
Scores = ['current']
Estimator = analog}
>>>
Therefore I could grab tally using the ID or the dictionary key of 35
The post processing example might be helpful as a general guide
I think this example is not the correct command for assembly.Same error
AttributeError Traceback (most recent call last)
Cell In[9], line 1
----> 1 tallies = sp.get_tallies
2 print(tallies)
AttributeError: ‘StatePoint’ object has no attribute ‘get_tallies’
corrected sp.get_tallies to sp.tallies
This code runnig but output:{ }
In [6] : import openmc
sp = openmc.StatePoint(‘statepoint.150.h5’)
tallies = sp.tallies
print(tallies)
Output:{}
Sounds like there are no tallies in the model
Here’s the user’s guide section on tallies: 8. Specifying Tallies — OpenMC Documentation
You may also want to have a look at our Jupyter notebook examples.