mirror of
https://github.com/pim-n/pg-rad
synced 2026-03-23 21:58:12 +01:00
improve logging. update test case for detector.
This commit is contained in:
@ -10,6 +10,7 @@ from pg_rad.exceptions.exceptions import (
|
||||
MissingConfigKeyError,
|
||||
OutOfBoundsError,
|
||||
DimensionError,
|
||||
InvalidConfigValueError,
|
||||
InvalidIsotopeError
|
||||
)
|
||||
from pg_rad.logger.logger import setup_logger
|
||||
@ -64,15 +65,20 @@ def main():
|
||||
activity_MBq: 1000
|
||||
position: [500, 100, 0]
|
||||
isotope: CS137
|
||||
|
||||
detector:
|
||||
name: dummy
|
||||
is_isotropic: True
|
||||
"""
|
||||
|
||||
cp = ConfigParser(test_yaml).parse()
|
||||
landscape = LandscapeDirector.build_from_config(cp)
|
||||
|
||||
detector = DetectorBuilder(cp.detector).build()
|
||||
output = SimulationEngine(
|
||||
landscape=landscape,
|
||||
runtime_spec=cp.runtime,
|
||||
sim_spec=cp.options
|
||||
sim_spec=cp.options,
|
||||
detector=detector
|
||||
).simulate()
|
||||
|
||||
plotter = ResultPlotter(landscape, output)
|
||||
@ -96,18 +102,19 @@ def main():
|
||||
MissingConfigKeyError,
|
||||
KeyError,
|
||||
YAMLError,
|
||||
):
|
||||
) as e:
|
||||
logger.critical(e)
|
||||
logger.critical(
|
||||
"The provided config file is invalid. "
|
||||
"Check the log above. You can consult the documentation for "
|
||||
"an explanation of how to define a config file."
|
||||
"The config file is missing required keys or may be an "
|
||||
"invalid YAML file. Check the log above. Consult the "
|
||||
"documentation for examples of how to write a config file."
|
||||
)
|
||||
sys.exit(1)
|
||||
except (
|
||||
OutOfBoundsError,
|
||||
DimensionError,
|
||||
InvalidIsotopeError,
|
||||
ValueError
|
||||
InvalidConfigValueError
|
||||
) as e:
|
||||
logger.critical(e)
|
||||
logger.critical(
|
||||
|
||||
Reference in New Issue
Block a user