aggregate_results_3di.nc
The aggregate_results_3di.nc file is accessed through the GridH5AggregateResultAdmin
class.
Note that it depends on the simulation’s aggregation settings which variables are available in the aggregate_results_3di.nc file.
Minimal example
from threedigrid.admin.gridresultadmin import GridH5AggregateResultAdmin
# Instantiate GridH5AggregateResultAdmin object
gridadmin_filename = r"C:\3Di\My Model\gridadmin.h5"
aggregate_results_filename = r"C:\3Di\My Simulation\aggregate_results_3di"
gar = GridH5AggregateResultAdmin(gridadmin_filename, aggregate_results_filename)
# It depends on the simulation's aggregation settings which variables are available
# Get a list of all available fields for the lines:
gar.lines._meta.get_fields()
# Get a list of all available fields for the nodes:
gar.nodes._meta.get_fields()
# Get the maximum water level (s1_max) for all nodes
# Note that the timestamps may be different for different variables
last_timestamp = gar.nodes.get_timestamps('s1_max')[-1]
nodes = gar.nodes.timeseries(start_time=0, end_time=last_timestamp).s1_max
Functionalities
The following methods and properties of the AggregateResultMixin
class are available for nodes, lines, breaches, and pumps
- AggregateResultMixin.sample(num_points=None, include_end=True)
Sample the requested timeseries and return at maximum ‘num_points’ amount of points.
- Parameters:
num_points – the amount of sample points to return
include_end – if true, the last point is always included, else the first point is always included.
- AggregateResultMixin.timeseries(start_time=None, end_time=None, indexes=None)
Allows filtering on timeseries.
- Parameters:
start_time – start_time in seconds
end_time – end_time in seconds
indexes – a slice, e.g. slice(<start>, <stop>, <step>)
You can either filter by start_time and end_time or indexes. Indexes, unlike the GridH5ResultAdmin timeseries filter, allows only for slices when used with aggregated results.
Example usage for start_time and end_time filter:
>>> from threedigrid.admin.gridresultadmin import GridH5AggregateResultAdmin # noqa >>> nc = "/code/tests/test_files/aggregate_results_3di.nc" >>> f = "/code/tests/test_files/gridadmin.h5" >>> gr = GridH5AggregateResultAdmin(f, nc) >>> gr.nodes.timeseries(start_time=0, end_time=800).s1_max
Example usage for index filter:
>>> from threedigrid.admin.gridresultadmin import GridH5AggregateResultAdmin # noqa >>> nc = "/code/tests/test_files/aggregate_results_3di.nc" >>> f = "/code/tests/test_files/gridadmin.h5" >>> gr = GridH5AggregateResultAdmin(f, nc) >>> qs_s1 = gr.nodes.timeseries(indexes=slice(0,3)).s1 >>> qs_s1.shape[0] >>> 3
- AggregateResultMixin.get_timestamps(field_name)
Get the array of timestamps for a result field
- Parameters:
field_name – name of the field
- Returns:
array of timestamps
Raises
AttributeError
when the field has no timestamps
- AggregateResultMixin.get_time_unit(field_name) str
Get the time unit for a result field
- Parameters:
field_name – name of the field
- Returns:
time unit
Raises
AttributeError
when the field has no time unit attribute
- property AggregateResultMixin.timestamps
Get the list of timestamps for the results
- property AggregateResultMixin.dt_timestamps
Attribute names
Attribute names in the GridH5AggregateResultAdmin are a combination of the variable name and the aggregation method suffix. For example, the maximum water level (s1) is accessed by the name s1_max
.
Nodes
Attribute |
Possible suffixes |
Description |
---|---|---|
infiltration_rate_simple |
min, max, avg, cum, cum_positive, cum_negative |
Infiltration rate |
intercepted_volume |
min, max, avg, sum, cum, current |
Intercepted volume |
leak |
min, max, avg, cum, cum_positive, cum_negative |
Leakage |
q_lat |
min, max, avg, cum, cum_positive, cum_negative |
Lateral discharge |
q_sss |
min, max, avg, cum, cum_positive, cum_negative |
Surface sources and sinks discharge |
rain |
min, max, avg, cum, cum_positive, cum_negative |
Rain intensity |
s1 |
min, max, avg |
Water level |
su |
min, max, avg |
Wet surface area |
ucx |
min, max, avg |
Velocity at cell center in x direction |
ucy |
min, max, avg |
Velocity at cell center in y direction |
vol |
min, max, avg, sum, cum, current |
Volume |
Lines
Attribute |
Possible suffixes |
Description |
---|---|---|
au |
min, max, avg |
Wet cross-sectional area |
q |
min, max, avg, cum, cum_positive, cum_negative |
Discharge |
qp |
min, max, avg |
Interflow discharge |
u1 |
min, max, avg |
Flow velocity |
up1 |
min, max, avg, cum, cum_positive, cum_negative |
Interflow velocity |