Skip to content

Commit 8c78b1f

Browse files
authored
Merge pull request #23 from fact-project/read_broken_run_ends
Support reading uncomplete (no run end block) corsika files
2 parents 4bdbe85 + a6b73cb commit 8c78b1f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

irf/scripts/read_corsika_headers.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,25 @@ def main(outputfile, inputdir):
7171
df = pd.DataFrame(event_headers[event_columns])
7272
to_h5py(df, outputfile, key='corsika_events', mode='a')
7373

74+
7475
print('saving runwise information')
7576
runs = pd.DataFrame(np.array(run_headers)[run_header_columns])
76-
runs['n_events'] = np.array(run_ends)['n_events']
77+
78+
# some runs might have failed and thus no run end block
79+
for run_end in run_ends:
80+
if run_end is not None:
81+
dtype = run_end.dtype
82+
break
83+
else:
84+
raise IOError('All run_end blocks are None, all runs failed.')
85+
86+
dummy = np.array([(b'RUNE', np.nan, np.nan)], dtype=dtype)[0]
87+
run_ends = [r if r is not None else dummy for r in run_ends]
88+
run_ends = np.array(run_ends)
89+
90+
print('Number of failed runs:', np.count_nonzero(np.isnan(run_ends['n_events'])))
91+
92+
runs['n_events'] = run_ends['n_events']
7793

7894
to_h5py(runs, outputfile, key='corsika_runs', mode='a')
7995
print('done')

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='irf',
6-
version='0.5.1',
6+
version='0.5.2',
77
description='Functions to do instrument response functions for FACT',
88
url='http://github.com/fact-project/irf',
99
author='Kai Brügge, Maximilian Nöthe',

0 commit comments

Comments
 (0)