Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] broken sim file reader for 0-D detectors #66

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions mccode_antlr/loader/simfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,23 @@ def parse(contents: str):
first_keywords = ['Date', 'type', 'Source', 'component', 'position', 'title', 'Ncount']
second_keywords = ['statistics', 'signal', 'values']
file_keyword = []
if len(lines) == len(first_keywords) + len(second_keywords) + 2:
nd = 0
if len(lines) == 12:
# 0-D -- old style
last_keywords = ['xylimits', 'variables']
elif len(lines) == 13:
# 0-D -- new style (as of when?)
file_keyword = ['filename']
last_keywords = ['xylimits', 'variables']
elif len(lines) == 17:
nd = 1
# 1-D
file_keyword = ['filename']
last_keywords = ['xvar', 'yvar', 'xlabel', 'ylabel', 'xlimits', 'variables']
elif len(lines) == 19:
nd = 2
# 2-D
file_keyword = ['filename']
last_keywords = ['xvar', 'yvar', 'xlabel', 'ylabel', 'zvar', 'zlabel', 'xylimits', 'variables']
else:
raise RuntimeError(f"Expected 12, 17 or 19 lines in data, got {len(lines)}")
raise RuntimeError(f"Expected 12, 13, 17 or 19 lines in data, got {len(lines)}")
keywords = first_keywords + file_keyword + second_keywords + last_keywords
values = list(read_keywords(lines, keywords))
collected = {k: v for k, v in zip(keywords, values)}
Expand Down