riverarchitect.condition

Reading a condition: its input rasters and the return periods of its discharges.

A condition is one folder under 01_Conditions/ holding the terrain, sediment and hydraulic rasters for a single planning situation. input_definitions.inp names which raster is which and gives the flood return period of each modelled discharge - it is the metadata every analysis module needs before it can start.

The file format is the original one, so existing conditions are read unchanged:

Return periods = 1.0, 1.08, 1.13 #[Comma separated LIST] defines lifespans
Flow depth (h) = h007250.tif, h007750.tif #[Comma separated LIST]
Grain sizes (D mean) = dmean #[STRING]

Everything after # is a comment, the key is matched case-insensitively on a substring, and the .tif extension is optional.

class riverarchitect.condition.Condition(name, directory=None)[source]

Bases: object

One condition folder: where its rasters are and what discharges they represent.

Parameters:
  • name (str) – condition folder name, e.g. "2100_sample".

  • directory (str) – the folder itself. Defaults to 01_Conditions/<name> under the project home.

Variables:
  • return_periods (list) – flood return period in years, one per modelled discharge.

  • discharges (list) – discharge of each hydraulic raster, parsed from its file name.

all_depth_rasters()[source]

Every h<discharge>.tif present on disk, not just those in the .inp.

input_definitions.inp lists the discharges that carry a flood return period, which is what lifespan mapping needs. A recession analysis needs the low flows too, and in a real condition those are on disk but absent from the .inp - the sample condition has 60 depth rasters and names 17.

all_velocity_rasters()[source]

Every u<discharge>.tif present on disk. See all_depth_rasters().

path(name)[source]

Absolute path of a raster in this condition, adding .tif when omitted.

exists(name)[source]

True when the named raster is present in the condition folder.

static discharge_of(raster_name)[source]

Discharge encoded in a hydraulic raster name. h001000.tif -> 1000.0.

hydraulic_pairs()[source]

Yield (return_period, depth_path, velocity_path) for each modelled discharge.

Pairs whose depth or velocity raster is missing from disk are skipped, and a condition with no return periods falls back to the discharge itself, so that a partially prepared condition still produces something rather than raising.

property max_lifespan

Longest return period in the condition; the cap on any lifespan it can support.

riverarchitect.condition.parse_input_definitions(path)[source]

Parse an input_definitions.inp file into a plain dict.

Parameters:

path (str) – path to the .inp file.

Returns:

attribute name -> value. List-valued keys give lists of strings; return periods gives a list of floats.

Return type:

dict