structure_control_actions_3di.nc
If there are any structure control actions during the simulation, these are logged to the structure_control_actions_3di.nc file. This file can be accessed through the GridH5StructureControl
class.
Minimal example
from threedigrid.admin.gridresultadmin import GridH5StructureControl
from threedigrid.admin.structure_controls.exporters import structure_control_actions_to_csv
gst = GridH5StructureControl("gridadmin.h5", "structure_control_actions_3di.nc")
gst.table_control
structure_control_actions_to_csv(gst, "test.csv")
Functionalities
The main class GridH5StructureControl
is documented below.
This class’ table_control
, memory_control
, or timed_control
properties return instances of _GridH5NestedStructureControl
, also documented below.
- class threedigrid.admin.gridresultadmin.GridH5StructureControl(h5_file_path: str, netcdf_file_path: str, file_modus: str = 'r', swmr: bool = False)
Interface for structure control netcdf
This interface is different from the GridH5ResultAdmin and GridH5AggregateResultAdmin, as it resembles less the Nodes and Lines data compared to those interfaces. This interface should be viewed as a CSV file interface which can be used to extract the different control structures by control type and output data. It supplies interfaces to Nodes, Lines, Weirs, etc but does not provide the same timeseries filter capabilities as the GridH5ResultAdmin and GridH5AggregateResultAdmin.
>>> gst = GridH5StructureControl(gridadmin_path, struct_control_actions_3di.nc) >>> gst.table_control >>> gst.timed_control >>> gst.memory_control >>> gst.table_control.id >>> struct_control = gst.table_control.group_by_id(ga.table_control.id[0]) >>> struct_control.time >>> struct_control.action_value_1
- get_source_table(action_type, grid_id)
Get source_table and source_table_id based on action_type and grid_id
- property memory_control: _GridH5NestedStructureControl
Get the memory control actions as
_GridH5NestedStructureControl
object
- property table_control: _GridH5NestedStructureControl
Get the table control actions as
_GridH5NestedStructureControl
object
- property timed_control: _GridH5NestedStructureControl
Get the timed control actions as
_GridH5NestedStructureControl
object
- class threedigrid.admin.gridresultadmin._GridH5NestedStructureControl(structure_control: GridH5StructureControl, control_type: StructureControlTypes)
- property action_type: ndarray
Get the action types
- property action_value_1: ndarray
Get the action values
- property action_value_2: ndarray
Get the second action values (negative discharge for
action_type == 'set_discharge_coefficients'
)
- property grid_id: ndarray
Get the grid ID’s, i.e. the ID of the Node or Line upon which the structure control action acts
- group_by_action_type(value: str) List[StructureControl]
Get all structure control actions with
action_type == value
- group_by_action_value_1(min: float, max: float) List[StructureControl]
Get all structure control actions where
min <= action_value_1 <= max
- group_by_action_value_2(min: float, max: float) List[StructureControl]
Get all structure control actions where
min <= action_value_2 <= max
- group_by_grid_id(value: int) List[StructureControl]
Get all structure control actions with
grid_id == value
- group_by_id(id: str) StructureControl | None
Get the structure control action with given
id
.ID is unique. Get content_type and content_pk from gridadmin. All controls are on lines except set_pump_capacity
- group_by_is_active(value: int) List[StructureControl]
Get all structure control actions with
is_active == value
- group_by_time(min: float, max: float) List[StructureControl]
Get all structure control actions where
min <= time <= max
- property id: ndarray
Get the ID’s of the structure control action
- property is_active: ndarray
Get the boolean values indicating if the structure control action is active
- property time: ndarray
Get the times (in s since start of simulation) at which the structure controls acted
Exporters
- threedigrid.admin.structure_controls.exporters.structure_control_actions_to_csv(structure_control: GridH5StructureControl, out_path: str)
Set place table, timed, and memory controls after each other in one file.
Attribute names
Attribute |
Description |
---|---|
action_type |
Action type |
action_value_1 |
Action value 1, e.g. crest_level if action_type = set_crest_level |
action_value_2 |
Action value 2 (relevant if action_type = set_discharge_coefficients) |
id |
ID of the structure control action |
is_active |
Is the structure control active |
source_table |
Source table in the schematisation for the structure on which the structure control acts |
source_table_id |
ID of the feature in the schematisation |
time |
Time in seconds since start of simulation at which structure control action takes place |