2.1. floodestimation.entities — Core components

This module contains the core components or entities, including Catchment, AmaxRecord etc.

Note that all entities are subclasses of floodestimation.db.Base which is an SQL Alchemy base class to enable saving to a (sqlite) database. All class attributes therefore are sqlalchemy.Column objects e.g. Column(Float), Column(String), etc. Attribute values can simply be set like normal, e.g. catchment.watercourse = “River Dee”.

2.1.1. Catchment — The catchment object

class floodestimation.entities.Catchment(location=None, watercourse=None)[source]

Catchment object include FEH catchment descriptors and additional information describing the catchment.

Example:

>>> from floodestimation.entities import Catchment, Descriptors
>>> catchment = Catchment("Aberdeen", "River Dee")
>>> catchment.channel_width = 1
>>> catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1, urbext=0}
>>> catchment.qmed()
0.2671386414098229
id

Gauging station number

country

Abbreviation of country, e.g. gb, ni.

channel_width

Width of the watercourse channel at the catchment outlet in m.

area

Catchment area in km²

point

Coordinates of catchment outlet as Point object

is_suitable_for_qmed

Whether this catchment can be used to estimate QMED at other similar catchments

is_suitable_for_pooling

Whether this catchment’s annual maximum flow data can be used in pooling group analyses

pot_dataset

Peaks-over-threshold dataset (one-to-one relationship)

comments

List of comments

location

Catchment outlet location name, e.g. Aberdeen

watercourse

Name of watercourse at the catchment outlet, e.g. River Dee

amax_records

List of annual maximum flow records as AmaxRecord objects

descriptors

FEH catchment descriptors (one-to-one relationship)

qmed()[source]

Returns QMED estimate using best available methodology depending on what catchment attributes are available.

Returns:QMED in m³/s
Return type:float
amax_records_start()[source]

Return first water year in amax records

amax_records_end()[source]

Return last year in amax records

record_length

Total number of valid AMAX records

2.1.2. Descriptors — A set of catchment descriptors

class floodestimation.entities.Descriptors(**kwargs)[source]

Set of FEH catchment descriptors.

This is the complete set of name = value pairs in the [DESCRIPTORS] block in a CD3 file. All other parameters are directly attributes of Catchment.

Descriptors are used as follows:

>>> from floodestimation.entities import Catchment
>>> catchment = Catchment(...)
>>> catchment.descriptors.dtm_area
416.56
>>> catchment.descriptors.centroid_ngr
(317325, 699832)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

catchment_id

One-to-one reference to corresponding Catchment object

ihdtm_ngr

Catchment outlet national grid reference as Point object. Catchment.country indicates coordinate system.

centroid_ngr

Catchment centre national grid reference as Point object. Catchment.country indicates coordinate system.

dtm_area

Surface area in km² based on digital terrain model data

altbar

Mean elevation in m

aspbar

Mean aspect (orientation) in degrees

aspvar

Aspect variance in degrees

bfihost

Base flow index based on Hydrology of Soil Types (HOST) data. Value between 0 and 1.

dplbar

Mean drainage path length in km

dpsbar

Mean drainage path slope (dimensionless)

farl

Lake, reservoir or loch flood attenuation index

fpext

Floodplain extent parameter

ldp

Longest drainage path length in km

propwet

Proportion of time soils are wet index

rmed_1h

Median annual maximum 1 hour rainfall in mm

rmed_1d

Median annual maximum 1 day rainfall in mm

rmed_2d

Median annual maximum 2 day rainfall in mm

saar

Standard annual average rainfall in mm, 1961-1990 average

saar4170

Standard annual average rainfall in mm, 1941-1970 average

sprhost

Standard percentage runoff based on Hydrology of Soil Types (HOST) data. Value between 0 and 100.

urbconc1990

Urbanisation concentration index, 1990 data

urbext1990

Urbanisation extent index, 1990 data

urbloc1990

Urbanisation location within catchment index, 1990 data

urbconc2000

Urbanisation concentration index, 2000 data

urbext2000

Urbanisation extent index, 2000 data

urbloc2000

Urbanisation location within catchment index, 2000 data

urbext(year)[source]

Estimate the urbext2000 parameter for a given year assuming a nation-wide urbanisation curve.

Methodology source: eqn 5.5, report FD1919/TR

Parameters:year (float) – Year to provide estimate for
Returns:Urban extent parameter
Return type:float

2.1.3. AmaxRecord — Annual maximum flow records

class floodestimation.entities.AmaxRecord(date, flow, stage=None, flag=0)[source]

A single annual maximum flow record.

Catchment.amax_records is a list of AmaxRecord objects.

Example:

>>> from floodestimation.entities import AmaxRecord
>>> from datetime import date
>>> record = AmaxRecord(date=date(1999,12,31), flow=51.2, stage=1.23)
catchment_id

Many-to-one reference to corresponding Catchment object

date

Date at which maximum flow occured

water_year

Water year or hydrological year (starts 1 October)

flow

Observed flow in m³/s

stage

Observed water level in m above local datum

flag

Data quality flag. 0 (default): valid value, 1: invalid value, 2: rejected record.

2.1.4. PotDataset — Peaks-over-threshold datasets

class floodestimation.entities.PotDataset(**kwargs)[source]

A peaks-over-threshold (POT) dataset including a list of PotRecord objects and some metadata such as start and end of record.

catchment_id

One-to-one reference to corresponding Catchment object

start_date

Start date of flow record

end_date

End date of flow record (inclusive)

threshold

Flow threshold in m³/s

pot_records

List of peaks-over-threshold records as PotRecord objects

pot_data_gaps

List of peaks-over-threshold records as PotDataGap objects

record_length

Return record length in years, including data gaps.

total_gap_length()[source]

Return the total length of POT gaps in years.

continuous_periods()[source]

Return a list of continuous data periods by removing the data gaps from the overall record.

2.1.5. PotRecord — Peaks-over-threshold records

class floodestimation.entities.PotRecord(date, flow, stage)[source]

A single peaks-over-threshold (POT) flow record.

Example:

>>> from floodestimation.entities import PotRecord
>>> from datetime import date
>>> record = PotRecord(date=date(1999,12,31), flow=51.2, stage=1.23)
catchment_id

Many-to-one reference to corresponding Catchment object

date

Date at which flow occured

flow

Observed flow in m³/s

stage

Observed water level in m above local datum

2.1.6. PotDataGap — Peaks-over-threshold data gaps

class floodestimation.entities.PotDataGap(**kwargs)[source]

A gap (period) in the peaks-over-threshold (POT) records.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

catchment_id

Many-to-one reference to corresponding Catchment object

start_date

Start date of gap

end_date

End date of gap (inclusive)

gap_length()[source]

Return length of data gap in years.

2.1.7. Comment — Catchment comments

class floodestimation.entities.Comment(title, content)[source]

Comments on cachment contained in CD3 file. Each comment has a title (normally one of station, catchment, qmed suitability and pooling suitability) and content.

Catchment.comments is a list of Comment objects.

Example:

>>> from floodestimation.entities import Comment
>>> comment = Comment(title="station", content="Velocity-area station on a straight reach ...")
catchment_id

Many-to-one reference to corresponding Catchment object

title

Comment title, e.g. station

content

Comment, e.g. Velocity-area station on a straight reach ...

2.1.8. Point — Point coordinates

class floodestimation.entities.Point(x, y)[source]

Point coordinate object

Example:

>>> from floodestimation.entities import Point
>>> point = Point(123000, 456000)

Coordinates systems are currently not supported. Instead use Catchment.country = ‘gb’ etc.