diff --git a/src/pg_rad/landscape/landscape.py b/src/pg_rad/landscape/landscape.py index 1883694..815a90d 100644 --- a/src/pg_rad/landscape/landscape.py +++ b/src/pg_rad/landscape/landscape.py @@ -3,9 +3,11 @@ import logging from matplotlib import pyplot as plt from matplotlib.patches import Circle import numpy as np +from numpy.typing import ArrayLike from pg_rad.path import Path from pg_rad.objects import PointSource +from pg_rad.physics.fluence import phi_single_source logger = logging.getLogger(__name__) @@ -35,7 +37,6 @@ class Landscape: self.air_density = air_density self.scale = scale - self.path: Path = None self.sources: list[PointSource] = [] logger.debug("Landscape initialized.") @@ -94,12 +95,10 @@ class Landscape: ValueError: If the source is outside the boundaries of the landscape. """ - max_x, max_y, max_z = self.world.shape[:3] - - if any( - not (0 <= source.x < max_x and - 0 <= source.y < max_y and - 0 <= source.z < max_z) + if not any( + (0 <= source.pos[0] <= self.world.shape[0] or + 0 <= source.pos[1] <= self.world.shape[1] or + 0 <= source.pos[2] <= self.world.shape[2]) for source in sources ): raise ValueError("One or more sources are outside the landscape!") @@ -110,8 +109,28 @@ class Landscape: """ Set the path in the landscape. """ + if not isinstance(path, Path): + raise TypeError("path must be of type Path.") self.path = path + def calculate_fluence_at(self, pos: tuple): + total_phi = 0. + for source in self.sources: + r = source.distance_to(pos) + phi_source = phi_single_source( + r=r, + activity=source.activity, + branching_ratio=source.isotope.b, + mu_mass_air=source.isotope.mu_mass_air, + air_density=self.air_density + ) + total_phi += phi_source + return total_phi + + def calculate_fluence_along_path(self): + if self.path is None: + raise ValueError("Path is not set!") + def create_landscape_from_path(path: Path, max_z: float | int = 50): """Generate a landscape from a path, using its dimensions to determine