mirror of
https://github.com/pim-n/pg-rad
synced 2026-03-23 21:58:12 +01:00
Add flip direction. Change mean to Trapezoidal rule for integration along path. Scale count rate properly with acquisition time
This commit is contained in:
@ -12,7 +12,8 @@ from pg_rad.inputparser.specs import (
|
||||
SimulationSpec,
|
||||
CSVPathSpec,
|
||||
AbsolutePointSourceSpec,
|
||||
RelativePointSourceSpec
|
||||
RelativePointSourceSpec,
|
||||
DetectorSpec
|
||||
)
|
||||
|
||||
from pg_rad.path.path import Path, path_from_RT90
|
||||
@ -30,6 +31,7 @@ class LandscapeBuilder:
|
||||
self._point_sources = []
|
||||
self._size = None
|
||||
self._air_density = 1.243
|
||||
self._detector = None
|
||||
|
||||
logger.debug(f"LandscapeBuilder initialized: {self.name}")
|
||||
|
||||
@ -58,10 +60,12 @@ class LandscapeBuilder:
|
||||
self,
|
||||
sim_spec: SimulationSpec
|
||||
):
|
||||
segments = sim_spec.path.segments
|
||||
lengths = sim_spec.path.lengths
|
||||
angles = sim_spec.path.angles
|
||||
alpha = sim_spec.path.alpha
|
||||
path = sim_spec.path
|
||||
segments = path.segments
|
||||
lengths = path.lengths
|
||||
angles = path.angles
|
||||
alpha = path.alpha
|
||||
z = path.z
|
||||
|
||||
sg = SegmentedRoadGenerator(
|
||||
ds=sim_spec.runtime.speed * sim_spec.runtime.acquisition_time,
|
||||
@ -76,7 +80,11 @@ class LandscapeBuilder:
|
||||
alpha=alpha
|
||||
)
|
||||
|
||||
self._path = Path(list(zip(x, y)))
|
||||
self._path = Path(
|
||||
list(zip(x, y)),
|
||||
z=z,
|
||||
opposite_direction=path.opposite_direction
|
||||
)
|
||||
self._fit_landscape_to_path()
|
||||
return self
|
||||
|
||||
@ -89,7 +97,8 @@ class LandscapeBuilder:
|
||||
df=df,
|
||||
east_col=spec.east_col_name,
|
||||
north_col=spec.north_col_name,
|
||||
z=spec.z
|
||||
z=spec.z,
|
||||
opposite_direction=spec.opposite_direction
|
||||
)
|
||||
|
||||
self._fit_landscape_to_path()
|
||||
@ -151,6 +160,10 @@ class LandscapeBuilder:
|
||||
name=s.name
|
||||
))
|
||||
|
||||
def set_detector(self, spec: DetectorSpec) -> Self:
|
||||
self._detector = spec
|
||||
return self
|
||||
|
||||
def _fit_landscape_to_path(self) -> None:
|
||||
"""The size of the landscape will be updated if
|
||||
1) _size is not set, or
|
||||
@ -221,6 +234,7 @@ class LandscapeBuilder:
|
||||
name=self.name,
|
||||
path=self._path,
|
||||
point_sources=self._point_sources,
|
||||
detector=self._detector,
|
||||
size=self._size,
|
||||
air_density=self._air_density
|
||||
)
|
||||
|
||||
@ -45,5 +45,6 @@ class LandscapeDirector:
|
||||
sim_spec=config,
|
||||
)
|
||||
lb.set_point_sources(*config.point_sources)
|
||||
lb.set_detector(config.detector)
|
||||
landscape = lb.build()
|
||||
return landscape
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
|
||||
from pg_rad.path.path import Path
|
||||
from pg_rad.detector.detectors import AngularDetector, IsotropicDetector
|
||||
from pg_rad.objects.sources import PointSource
|
||||
|
||||
|
||||
@ -17,6 +18,7 @@ class Landscape:
|
||||
path: Path,
|
||||
air_density: float,
|
||||
point_sources: list[PointSource],
|
||||
detector: IsotropicDetector | AngularDetector,
|
||||
size: tuple[int, int, int]
|
||||
):
|
||||
"""Initialize a landscape.
|
||||
@ -34,5 +36,6 @@ class Landscape:
|
||||
self.point_sources = point_sources
|
||||
self.size = size
|
||||
self.air_density = air_density
|
||||
self.detector = detector
|
||||
|
||||
logger.debug(f"Landscape created: {self.name}")
|
||||
|
||||
Reference in New Issue
Block a user