IAP GITLAB

Skip to content
Snippets Groups Projects
Commit ac743a8b authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan: Committed by Maximilian Reininghaus
Browse files

Python code

parent a5e71bef
No related branches found
No related tags found
No related merge requests found
set (TOOLS_FILES plot_tracks.sh plot_crossings.sh)
set (TOOLS_FILES plot_tracks.sh plot_crossings.sh read_hist.py)
install (
FILES ${TOOLS_FILES}
......
import numpy as np
import matplotlib.pyplot as plt
import boost_histogram as bh
import operator
import functools
def read_hist(filename):
"""
read numpy file produced with CORSIKA 8's save_hist() function into
boost-histogram object.
"""
d = np.load(filename)
axistypes = d['axistypes'].view('c')
axes = []
for i, at in enumerate(axistypes):
if at == b'c':
axes.append(bh.axis.Variable(d[f'binedges_{i}'], overflow=True, underflow=True))
elif at == b'd':
axes.append(bh.axis.IntCategory(d[f'binedges_{i}']))
h = bh.Histogram(*axes)
h.view(flow=True)[:] = d['data']
return h
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment