results_3di.nc
The results_3di.nc file is accessed through the GridH5ResultAdmin
class.
Minimal example
from threedigrid.admin.gridresultadmin import GridH5ResultAdmin
from threedigrid.admin.gridadmin import GridH5Admin
# Instantiate GridH5Admin and GridH5ResultAdmin objects
gridadmin_filename = r"C:\3Di\My Model\gridadmin.h5"
results_filename = r"C:\3Di\My Simulation\results_3di.nc"
ga = GridH5Admin(gridadmin_filename)
gr = GridH5ResultAdmin(gridadmin_filename, results_filename)
# Get water level (s1) time series for node 23
last_timestamp = gr.nodes.timestamps[-1]
water_levels_23 = gr.nodes.filter(id__eq=23).timeseries(start_time=0, end_time=last_timestamp).s1
# Get the discharge (q) time series for all 1D nodes for the first hour of the simulation
discharge_1d = gr.lines.subset('1D').timeseries(start_time=0,end_time=3600).q
Functionalities
The following methods and properties of the ResultMixin
class are available for nodes, lines, breaches, and pumps
- ResultMixin.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.
- ResultMixin.timeseries(start_time=None, end_time=None, indexes=None)
Allows filtering on timeseries.
You can either filter by start_time and end_time or indexes.
Example usage for start_time and end_time filter:
>>> from threedigrid.admin.gridresultadmin import GridH5ResultAdmin >>> nc = "/code/tests/test_files/results_3di.nc" >>> f = "/code/tests/test_files/gridadmin.h5" >>> gr = GridH5ResultAdmin(f, nc) >>> gr.nodes.timeseries(start_time=0, end_time=10).s1
Example usage for index filter:
>>> from threedigrid.admin.gridresultadmin import GridH5ResultAdmin >>> nc = "/code/tests/test_files/results_3di.nc" >>> f = "/code/tests/test_files/gridadmin.h5" >>> gr = GridH5ResultAdmin(f, nc) >>> qs_s1 = gr.nodes.timeseries(indexes=[1, 2, 3]).s1 >>> qs_s1.shape >>> (3, 25156)
A more complex example combining filters:
>>> breaches_u1 = gr.lines.filter(kcu__eq=55).timeseries(indexes=[10, 11, 12, 13]).u1 # noqa >>> breaches_u1.shape >>> (4, 16)
Filtering by indexes works with both lists (like in the examples above) and slices. This code yields exactly the same result
>>> breaches_u1_slice = gr.lines.filter(kcu__eq=55).timeseries(indexes=slice(10,14)).u1 # noqa >>> breaches_u1_slice.shape >>> (4, 16) >>> assert np.all(breaches_u1 == breaches_u1_slice)
- Returns:
new instance with filtering options enabled
- property ResultMixin.timestamps
Get the list of timestamps for the results
- property ResultMixin.dt_timestamps
Meta data
Descriptions of variables in the results_3di.nc file can be retrieved using the _meta
property. For example:
gr.nodes._meta.s1
>>> s1(units=u'm', long_name=u'waterlevel', standard_name=u'water_surface_height_above_reference_datum')
s1
is a namedtuple
, so you can retrieve the units attribute by using the .
notation:
gr.nodes._meta.s1.units
or using the _as_dict
method
gr.nodes._meta.s1._asdict()['units']
Attribute names
Nodes
Variable Name |
Description |
---|---|
infiltration_rate_simple |
Infiltration rate |
intercepted_volume |
Intercepted volume |
leak |
Leakage |
q_lat |
Lateral discharge |
q_sss |
Surface sources and sinks discharge |
rain |
Rain intensity |
s1 |
Water level |
su |
Wet surface area |
ucx |
Velocity at cell center in x direction |
ucy |
Velocity at cell center in y direction |
vol |
Volume |
Lines
Variable Name |
Description |
---|---|
au |
Wet cross-sectional area |
breach_depth |
Breach depth |
breach_width |
Breach width |
q |
Discharge |
qp |
Interflow discharge |
u1 |
Flow velocity |
up1 |
Interflow velocity |