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,
|
MissingConfigKeyError,
|
||||||
OutOfBoundsError,
|
OutOfBoundsError,
|
||||||
DimensionError,
|
DimensionError,
|
||||||
|
InvalidConfigValueError,
|
||||||
InvalidIsotopeError
|
InvalidIsotopeError
|
||||||
)
|
)
|
||||||
from pg_rad.logger.logger import setup_logger
|
from pg_rad.logger.logger import setup_logger
|
||||||
@ -64,15 +65,20 @@ def main():
|
|||||||
activity_MBq: 1000
|
activity_MBq: 1000
|
||||||
position: [500, 100, 0]
|
position: [500, 100, 0]
|
||||||
isotope: CS137
|
isotope: CS137
|
||||||
|
|
||||||
|
detector:
|
||||||
|
name: dummy
|
||||||
|
is_isotropic: True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cp = ConfigParser(test_yaml).parse()
|
cp = ConfigParser(test_yaml).parse()
|
||||||
landscape = LandscapeDirector.build_from_config(cp)
|
landscape = LandscapeDirector.build_from_config(cp)
|
||||||
|
detector = DetectorBuilder(cp.detector).build()
|
||||||
output = SimulationEngine(
|
output = SimulationEngine(
|
||||||
landscape=landscape,
|
landscape=landscape,
|
||||||
runtime_spec=cp.runtime,
|
runtime_spec=cp.runtime,
|
||||||
sim_spec=cp.options
|
sim_spec=cp.options,
|
||||||
|
detector=detector
|
||||||
).simulate()
|
).simulate()
|
||||||
|
|
||||||
plotter = ResultPlotter(landscape, output)
|
plotter = ResultPlotter(landscape, output)
|
||||||
@ -96,18 +102,19 @@ def main():
|
|||||||
MissingConfigKeyError,
|
MissingConfigKeyError,
|
||||||
KeyError,
|
KeyError,
|
||||||
YAMLError,
|
YAMLError,
|
||||||
):
|
) as e:
|
||||||
|
logger.critical(e)
|
||||||
logger.critical(
|
logger.critical(
|
||||||
"The provided config file is invalid. "
|
"The config file is missing required keys or may be an "
|
||||||
"Check the log above. You can consult the documentation for "
|
"invalid YAML file. Check the log above. Consult the "
|
||||||
"an explanation of how to define a config file."
|
"documentation for examples of how to write a config file."
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except (
|
except (
|
||||||
OutOfBoundsError,
|
OutOfBoundsError,
|
||||||
DimensionError,
|
DimensionError,
|
||||||
InvalidIsotopeError,
|
InvalidIsotopeError,
|
||||||
ValueError
|
InvalidConfigValueError
|
||||||
) as e:
|
) as e:
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
logger.critical(
|
logger.critical(
|
||||||
|
|||||||
Reference in New Issue
Block a user