Skip to content

Commit

Permalink
#156 added detector_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
kacper1409 committed Nov 22, 2023
1 parent 2255dbb commit 71576b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion converter/fluka/helper_parsers/detector_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from dataclasses import dataclass

@dataclass
class USRBIN():
name: str
x_min: float
Expand All @@ -8,4 +11,13 @@ class USRBIN():
y_bins: int
z_min: float
z_max: float
z_bins: int
z_bins: int

def parse_detector(detectors_json: dict, detectorUuid: str) -> USRBIN:

for detector in detectors_json['detectors']:
if detector['uuid'] == detectorUuid:
return USRBIN(
name=detector['name'],

)
13 changes: 13 additions & 0 deletions tests/fluka/test_detector_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest

from converter.fluka.helper_parsers.detector_parser import parse_detector
from converter.fluka.helper_parsers.scoring_parser import parse_scorings

@pytest.fixture(scope='module')
def detectors_json(project_fluka_json):
"""zoneManager part of Fluka project.json file"""
return project_fluka_json['detectorManager']


def test_parse_scoring(detectors_json):
scorings = parse_detector(detectors_json, 'c5d0bfa1-525a-4c22-bcc6-3b1d40e1fea3')
2 changes: 1 addition & 1 deletion tests/fluka/test_scoring_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_parse_scoring(detectors_json, scorings_json):

assert scorings[0].name == 'yz slab'
assert scorings[0].detectorUuid == 'c5d0bfa1-525a-4c22-bcc6-3b1d40e1fea3'
assert scorings[0].quantity == 'DOSE'
assert scorings[0].quantity == 'DOSE'

0 comments on commit 71576b4

Please sign in to comment.