DM_histogram.py
## @package python.DM_histogram
#
# iterating over all points of an existing ODM within python
#
from __future__ import print_function # print function syntax as in python 3
import sys
from opals import pyDM # for pyDM in release mode
def DM_iterate_simple(filename):
# open the odm / pyDM.Datamanager.load parameters: filename(string), readOnly(bool) threadSafety(bool)
dm = pyDM.Datamanager.load(filename, True, False)
# if the dm wasn't opened sucessful exit function
if not dm:
print("Unable to open ODM '" + filename + "'")
return
f = pyDM.AddInfoLayoutFactory()
f.addColumn(pyDM.ColumnSemantic.EchoNumber)
layout = f.getLayout()
print("Compute histogram of attribute 'EchoNumber'")
histoSet = dm.getHistogramSet(layout)
for histo in histoSet.histograms():
for value, count in histo.values():
print(value, "=", count)
print("done")
if len(sys.argv) == 1:
print("ODM parameter missing")
exit(-1)
DM_iterate_simple(sys.argv[1])