result_network.ResultNodes

result_network.ResultNodes(self, res1d)

Class for wrapping ResultData nodes.

By itself it is also a dict, which contains mapping between node ID and IRes1DNode object.

Parameters

Name Type Description Default
res1d Res1D Res1D object the nodes belong to. required

Attributes

Name Type Description
node_label str A label, which is appended if the node name starts with a number. The value used is node_label = ‘n_’

Methods

Name Description
add_derived_quantity Add a derived quantity to the result network.
read Read the time series data for all quantities at these locations into a DataFrame.
remove_derived_quantity Remove a derived quantity from the result network.
set_nodes Set attributes to the current ResultNodes object based on the node ID.
set_quantity_collections Set all quantity collection attributes.
set_quantity_derived Set a single derived quantity attribute on the obj.
set_res1d_node_to_dict Create a dict entry from node ID to ResultNode object.
set_res1d_object_to_dict Create a dict entry from a key name to an object or a list of objects.
to_geopandas Convert nodes to a geopandas.GeoDataFrame, optionally with quantities.

add_derived_quantity

result_network.ResultNodes.add_derived_quantity(derived_quantity)

Add a derived quantity to the result network.

Parameters

Name Type Description Default
derived_quantity DerivedQuantity Derived quantity to be added to the result network. required

read

result_network.ResultNodes.read(column_mode=None, include_derived=False)

Read the time series data for all quantities at these locations into a DataFrame.

Parameters

Name Type Description Default
column_mode str | ColumnMode(optional) Specifies the type of column index of returned DataFrame. ‘all’ - column MultiIndex with levels matching TimeSeriesId objects. ‘compact’ - same as ‘all’, but removes levels with default values. ‘timeseries’ - column index of TimeSeriesId objects None
include_derived bool Include derived quantities. False

remove_derived_quantity

result_network.ResultNodes.remove_derived_quantity(derived_quantity)

Remove a derived quantity from the result network.

Parameters

Name Type Description Default
derived_quantity DerivedQuantity or str Derived quantity to be removed from the result network. Either a DerivedQuantity object or its name. required

set_nodes

result_network.ResultNodes.set_nodes()

Set attributes to the current ResultNodes object based on the node ID.

set_quantity_collections

result_network.ResultNodes.set_quantity_collections()

Set all quantity collection attributes.

set_quantity_derived

result_network.ResultNodes.set_quantity_derived(derived_quantity)

Set a single derived quantity attribute on the obj.

set_res1d_node_to_dict

result_network.ResultNodes.set_res1d_node_to_dict(result_node)

Create a dict entry from node ID to ResultNode object.

set_res1d_object_to_dict

result_network.ResultNodes.set_res1d_object_to_dict(dict_key, obj)

Create a dict entry from a key name to an object or a list of objects.

to_geopandas

result_network.ResultNodes.to_geopandas(agg=None, agg_kwargs={}, include_derived=False)

Convert nodes to a geopandas.GeoDataFrame, optionally with quantities.

By default, quantities are not included. To include quantities, use the agg and agg_kwargs parameters.

Parameters

Name Type Description Default
agg str or callable Defines how to aggregate the quantities in time and space. Accepts any str or callable that is accepted by pandas.DataFrame.agg. None

Examples

- 'mean'  : mean value of all quantities
- 'max'   : maximum value of all quantities
-  np.max : maximum value of all quantities

agg_kwargs : dict, default {} Aggregation function for specific column levels (e.g. {time=‘min’, chainage=‘first’}). include_derived: bool, default False Include derived quantities.

Returns

Type Description
geopandas.GeoDataFrame A GeoDataFrame object with nodes as Point geometries.

Examples

Convert nodes to a GeoDataFrame (without quantities)

>>> gdf = res1d.nodes.to_geopandas()

Convert nodes to a GeoDataFrame (with quantities)

>>> gdf = res1d.nodes.to_geopandas(agg='mean')