In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd

In [2]:
PORT=9876
import veneer
v = veneer.Veneer(PORT)

In [3]:
v.source_version()


Out[3]:
[4, 7, 0, 8165]

In [4]:
network = v.network()
network.plot(links={'color':'black'})


Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x1f7bd2d45c0>

Finding water users and demands


In [5]:
v.model.node.water_users.names()


Out[5]:
['IrrigationOnlyForestWU', 'IrrigationOnlyUrbanWU', 'BothWU']

In [6]:
v.model.node.water_users.demands()


Out[6]:
['ForIrrigation', 'my_new_irrigator', 'ForIrrigation', 'ForIrrigation']

In [7]:
v.model.node.water_users.demands(nodes='IrrigationOnlyForestWU')


Out[7]:
['ForIrrigation', 'my_new_irrigator']

Creating new demand models


In [11]:
v.model.node.water_users.add_timeseries?


Signature: v.model.node.water_users.add_timeseries(name=None, activate=False, nodes=None)
Docstring:
Create a new demand on one or more water user nodes

name: name for new demand. If not provided, will be '<demandtype> from script'.
      IF the name already exists on another demand on a particular water user, the existing demand will be replaced!

activate: if True, set the new demand model to be the active demand model on the water user
File:      d:\src\projects\py\veneer-py\veneer\water_users.py
Type:      method

In [12]:
v.model.node.water_users.add_irrigator?


Signature: v.model.node.water_users.add_irrigator(name=None, activate=False, nodes=None)
Docstring:
Create a new demand on one or more water user nodes

name: name for new demand. If not provided, will be '<demandtype> from script'.
      IF the name already exists on another demand on a particular water user, the existing demand will be replaced!

activate: if True, set the new demand model to be the active demand model on the water user
File:      d:\src\projects\py\veneer-py\veneer\water_users.py
Type:      method

In [9]:
v.model.node.water_users.add_timeseries('my new timeseries demand',nodes='IrrigationOnlyForestWU')


Out[9]:
1

In [10]:
v.model.node.water_users.demands(nodes='IrrigationOnlyForestWU')


Out[10]:
['ForIrrigation', 'my_new_irrigator', 'my new timeseries demand']

Set active demand

Water users have one active demand and optional inactive demands.

We can specify the active demand for one or more nodes. If the specified demand is note available on a particular node, it will have no effect.


In [13]:
v.model.node.water_users.set_active_demand('my new timeseries demand')
# SAFE because 'my new timeseries demand' only exists on one node


Out[13]:
1

Configuring demand parameters

Currently no functionality for the specific demand models...

Time series demands can be configured via 'DemandModel.Order' (assuming the time series demand is the active demand model)


In [15]:
v.model.node.water_users.set_param_values('DemandModel.Order',5,nodes='IrrigationOnlyForestWU')

# Note, the above will not take effect if a function is already being used. Need to cancel the function...
# v.model.node.water_users.clear_function_usage('DemandModel.Order',nodes='IrrigationOnlyForestWU')


Out[15]:
True

Similarly, we can use assign_time_series...


In [16]:
# v.model.node.water_users.assign_time_series('DemandModel.Order','col','datasource',nodes='IrrigationOnlyForestWU')

In [ ]: