Schemas Module
Pydantic schemas for data validation in the catchment simulation package.
Provides strict runtime validation of simulation parameters and subcatchment data, ensuring physically meaningful values before any computation begins.
- class catchment_simulation.schemas.SimulationMethodParams(*, method_name: Literal['simulate_percent_slope', 'simulate_area', 'simulate_width', 'simulate_percent_impervious', 'simulate_percent_zero_imperv', 'simulate_curb_length', 'simulate_n_imperv', 'simulate_n_perv', 'simulate_s_imperv', 'simulate_s_perv'], start: Annotated[float | None, Ge(ge=0)] = None, stop: Annotated[float | None, Ge(ge=0)] = None, step: Annotated[float | None, Gt(gt=0)] = None, catchment_name: Annotated[str, MinLen(min_length=1), MaxLen(max_length=100)])[source]
Bases:
BaseModelParameters for a single simulation run.
Range-based methods (e.g.
simulate_area) requirestart,stopandstep. Predefined methods (Manning’s n and depression storage) use literature values and do not accept range parameters.- PREDEFINED_METHODS: ClassVar[frozenset[str]] = frozenset({'simulate_n_imperv', 'simulate_n_perv', 'simulate_s_imperv', 'simulate_s_perv'})
- catchment_name: str
- method_name: Literal['simulate_percent_slope', 'simulate_area', 'simulate_width', 'simulate_percent_impervious', 'simulate_percent_zero_imperv', 'simulate_curb_length', 'simulate_n_imperv', 'simulate_n_perv', 'simulate_s_imperv', 'simulate_s_perv']
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- start: float | None
- step: float | None
- stop: float | None
- validate_method_params() SimulationMethodParams[source]
- class catchment_simulation.schemas.SimulationParams(*, start: Annotated[float, Ge(ge=0)], stop: Annotated[float, Ge(ge=0)], step: Annotated[float, Gt(gt=0)])[source]
Bases:
BaseModelValidated parameters for a simulation range sweep.
Enforces that start <= stop and step > 0, replacing manual
ifchecks with a declarative schema that raisesValidationErroron bad input.- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- start: float
- start_le_stop() SimulationParams[source]
- step: float
- stop: float
- class catchment_simulation.schemas.SubcatchmentParams(*, area: Annotated[float, Gt(gt=0)], slope: Annotated[float, Gt(gt=0), Le(le=100)], imperviousness: Annotated[float, Ge(ge=0), Le(le=100)], width: Annotated[float, Gt(gt=0)], n_imperv: Annotated[float, Gt(gt=0)], n_perv: Annotated[float, Gt(gt=0)], s_imperv: Annotated[float, Ge(ge=0)], s_perv: Annotated[float, Ge(ge=0)], pct_zero: Annotated[float, Ge(ge=0), Le(le=100)])[source]
Bases:
BaseModelPhysical parameters of a single subcatchment.
All constraints reflect physically valid ranges used in SWMM modelling.
- area: Annotated[float, Gt(gt=0)]
- imperviousness: float
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- n_imperv: float
- n_perv: float
- pct_zero: float
- s_imperv: float
- s_perv: float
- slope: float
- width: Annotated[float, Gt(gt=0)]