Skip to content

Raster-Shaped Inputs

Leading dimensions represent raster cells; time, cohort and material axes follow them. This small raster has two rows, three columns and one cohort per cell. The event inputs broadcast with the population and landscape:

from datetime import date

import astropy.units as u
import numpy as np

from ecosys import EcosysEngine, SimulationRequest
from ecosys.domain.events import DepositionEvent
from ecosys.domain.landscape import Landscape
from ecosys.domain.populations import PopulationCohorts

shape = (2, 3)
event = DepositionEvent(
    nuclide_id="cs_137",
    date=date(2001, 1, 1),
    integrated_air_activity=np.ones(shape) * u.Bq * u.s / u.m**3,
    wet_ground_deposition=np.ones(shape) * u.Bq / u.m**2,
    rainfall=np.ones(shape) * u.mm,
)
population = PopulationCohorts(
    initial_age=np.array([30]) * u.year,
    population=np.ones(shape + (1,)) * u.dimensionless_unscaled,
)
valid = np.array([[True, True, False], [True, True, True]])
landscape = Landscape(np.full(shape, "arable"), validity_mask=valid)
request = SimulationRequest.on_default_grid(
    (event,), population, landscape=landscape,
    output_start_date=event.date, horizon_years=1,
)
result = EcosysEngine().run(request)
assert result.per_capita.interval.shape == shape + (request.output_count, 1)
assert result.materials.concentration.shape[:3] == shape + (request.output_count,)

The landscape validity mask is separate from numerical values, so a valid zero remains distinct from an invalid cell. The mask must have the same shape as the soil-type array. Inputs still require finite physical values at masked cells. For larger rasters, use chunked execution.