result_network.ResultReaches
result_network.ResultReaches(self, res1d)
Class for wrapping ResultData reaches.
By itself it is also a dict, which contains mapping between reach name and IRes1DReach object or a list of IRes1DReach objects.
Parameters
Name | Type | Description | Default |
---|---|---|---|
res1d |
Res1D | Res1D object the reaches belong to. | required |
Attributes
Name | Type | Description |
---|---|---|
reach_label | str | A label, which is appended if the reach name starts with a number. The value used is reach_label = ‘r_’ |
result_reach_map | dict | Dictionary from reach name to a list of ResultReach objects. This is needed, because the reach name is not necessarily unique and several reaches could have the same name. |
Methods
Name | Description |
---|---|
add_derived_quantity | Add a derived quantity to the result network. |
get_or_create_result_reach | Create or get already existing ResultReach object. |
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_quantity_collections | Set quantity collections to the current ResultReaches object. |
set_quantity_derived | Set a single derived quantity attribute on the obj. |
set_reaches | Set attributes to the current ResultReaches object based on the reach name. |
set_res1d_object_to_dict | Create a dict entry from a key name to an object or a list of objects. |
to_geopandas | Convert reaches to a geopandas.GeoDataFrame object. |
add_derived_quantity
result_network.ResultReaches.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 |
get_or_create_result_reach
result_network.ResultReaches.get_or_create_result_reach(reach)
Create or get already existing ResultReach object.
There potentially could be just a single ResultReach object, for many IRes1DReach object, which have the same name.
Also update self’s dict entry from reach name to a ResultReach object.
read
result_network.ResultReaches.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.ResultReaches.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_quantity_collections
result_network.ResultReaches.set_quantity_collections()
Set quantity collections to the current ResultReaches object.
set_quantity_derived
result_network.ResultReaches.set_quantity_derived(derived_quantity)
Set a single derived quantity attribute on the obj.
set_reaches
result_network.ResultReaches.set_reaches()
Set attributes to the current ResultReaches object based on the reach name.
set_res1d_object_to_dict
result_network.ResultReaches.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.ResultReaches.to_geopandas(agg=None, agg_kwargs={}, segmented=True, include_derived=False)
Convert reaches to a geopandas.GeoDataFrame object.
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’}). segmented : bool, (default=True) True - one LineString per IRes1DReach object. False - one LineString per reach name. include_derived : bool, default False Include derived quantities.
Returns
Type | Description |
---|---|
geopandas.GeoDataFrame | A GeoDataFrame object with reaches as LineString geometries. |
Examples
Convert reaches to a GeoDataFrame (without quantities)
>>> gdf = res1d.reaches.to_geopandas()
Convert reaches to a GeoDataFrame with aggregated quantities
>>> gdf = res1d.reaches.to_geopandas(agg='mean')