grat.model.bottlenecks
¶
Delivery limits shared by a group of sites.
Bottleneck
¶
Bottleneck(
bottleneck_id: int,
name: str | None = None,
capacity: float | None = None,
wafr_sources: list | None = None,
capacity_irrigation: float | None = None,
irrigation_days: list | None = None,
**kwargs,
)
A daily delivery limit shared by every site behind it.
A bottleneck caps how much water can reach the sites that name it on a given day, no matter how much WAFR is available. Each bottleneck is associated with one or more WAFR sources and only limits water from those.
Sites name the bottlenecks that restrict them via their bottleneck_ids. A site
behind several bottlenecks is limited by the tightest of them.
Capacity is tracked as a running daily budget: available_throughput starts at
the day's capacity and is drawn down by update_usage as sites take water.
Attributes:
| Name | Type | Description |
|---|---|---|
available_throughput |
throughput still unused (acre-feet), one entry per day of the water year. Drawn down as sites take water, and may go negative. |
Build a bottleneck.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bottleneck_id
|
int
|
bottleneck identifier, matched against a site's
|
required |
name
|
str | None
|
human-readable name of the bottleneck. |
None
|
capacity
|
float | None
|
throughput limit outside the irrigation season (acre-feet per day). |
None
|
wafr_sources
|
list | None
|
names of the WAFR sources this bottleneck restricts. Water from any other source passes unrestricted. |
None
|
capacity_irrigation
|
float | None
|
throughput limit during the irrigation season (acre-feet per day). |
None
|
irrigation_days
|
list | None
|
zero-indexed days of the water year that use
|
None
|
**kwargs
|
additional attributes, set directly on the instance. |
{}
|
Source code in src/grat/model/bottlenecks.py
update_usage
¶
Charge a volume against the bottleneck's remaining throughput for a day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
day
|
int
|
zero-indexed day of the water year. |
required |
amount
|
float
|
volume delivered through the bottleneck (acre-feet). |
required |
Source code in src/grat/model/bottlenecks.py
get_available_throughput
¶
Return the volume that can still pass through the bottleneck on a day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
day
|
int
|
zero-indexed day of the water year. |
required |
Returns:
| Type | Description |
|---|---|
|
Remaining throughput (acre-feet). Clamped to zero, so an |
|
|
over-subscribed bottleneck reports no capacity rather than a |
|
|
negative one. |
Source code in src/grat/model/bottlenecks.py
get_bottlenecks
¶
Select the bottlenecks that restrict a given site's delivery from a source.
A bottleneck matches when its identifier is one the site names and it restricts the WAFR source in question.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bottleneck_list
|
list
|
every bottleneck in the system. |
required |
bottleneck_ids
|
the identifiers named by the site. |
required | |
wafr_source
|
str
|
name of the WAFR source supplying the water. |
required |
Returns:
| Type | Description |
|---|---|
|
The matching bottlenecks, empty if the site is unrestricted for this source. |
Source code in src/grat/model/bottlenecks.py
bottleneck_capacity_logger
¶
Report which bottlenecks ran out of capacity, day by day.
A bottleneck counts as having hit its limit on any day where its remaining throughput has fallen to zero or below.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bottleneck_list
|
list
|
every bottleneck in the system. |
required |
Returns:
| Type | Description |
|---|---|
|
One list per day of the water year, each holding the identifiers of the |
|
|
bottlenecks that hit their limit that day. |