In [1]:
import hkvfewspy as hkv
from datetime import datetime
%matplotlib inline

In [2]:
hkv.__version__


Out[2]:
'0.6.0'

In [3]:
# set client
pi = hkv.Pi()
pi.setClient(wsdl='http://localhost:8081/FewsPiService/fewspiservice?wsdl')

In [4]:
# get filters
filters = pi.getFilters()
filters.f_trend_1


Out[4]:
{'id': 'f_trend.1', 'name': 'Cut-data', 'description': ''}

In [5]:
# get parameters
parameters = pi.getParameters(filters.f_trend_1['id'])
parameters.m3_minDepth_cut['id']


Out[5]:
'm3.minDepth.cut'

In [6]:
# get locations
locations = pi.getLocations(setFormat='gdf')
locations.plot()


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x9d9f860>

In [7]:
locations.locationId.iloc[0:3].tolist()


Out[7]:
['bv.1.7.2.3.2', 'bv.1.7.1.3.1', 'bv.1.7.3.1.1']

In [8]:
query = pi.setQueryParameters(prefill_defaults=True)

In [9]:
query.parameterIds(['m3.minDepth.cut'])
query.moduleInstanceIds(['pr.minDepth.cutfill.volopp.setfill'])
query.locationIds(['bv.1.7.2.3.2'])
query.startTime(datetime(2018,1,1))
query.endTime(datetime(2018,7,1))
query.clientTimeZone('Europe/Amsterdam')

In [10]:
query.query


Out[10]:
{'convertDatum': False,
 'forecastSearchCount': 0,
 'importFromExternalDataSource': False,
 'omitMissing': False,
 'onlyHeaders': False,
 'onlyManualEdits': False,
 'showEnsembleMemberIds': False,
 'showLocationAttributes': False,
 'showStatistics': False,
 'showThresholds': False,
 'useDisplayUnits': True,
 'version': '1.22',
 'parameterIds': ['m3.minDepth.cut'],
 'moduleInstanceIds': ['pr.minDepth.cutfill.volopp.setfill'],
 'locationIds': ['bv.1.7.2.3.2'],
 'startTime': datetime.datetime(2018, 1, 1, 0, 0),
 'endTime': datetime.datetime(2018, 7, 1, 0, 0),
 'clientTimeZone': 'Europe/Amsterdam'}

In [11]:
df = pi.getTimeSeries(queryParameters=query, setFormat='df', header='multiindex')

In [12]:
df.plot()


Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0xa1a1630>

In [13]:
df.head()


Out[13]:
flag value
date moduleInstanceId qualifierId parameterId units locationId stationName
2018-01-01 00:00:00+01:00 pr.minDepth.cutfill.volopp.setfill q.all m3.minDepth.cut m3 bv.1.7.2.3.2 Blauwe Slenk 0 23957
2018-01-02 00:00:00+01:00 pr.minDepth.cutfill.volopp.setfill q.all m3.minDepth.cut m3 bv.1.7.2.3.2 Blauwe Slenk 0 0
2018-01-03 00:00:00+01:00 pr.minDepth.cutfill.volopp.setfill q.all m3.minDepth.cut m3 bv.1.7.2.3.2 Blauwe Slenk 0 0
2018-01-04 00:00:00+01:00 pr.minDepth.cutfill.volopp.setfill q.all m3.minDepth.cut m3 bv.1.7.2.3.2 Blauwe Slenk 0 0
2018-01-05 00:00:00+01:00 pr.minDepth.cutfill.volopp.setfill q.all m3.minDepth.cut m3 bv.1.7.2.3.2 Blauwe Slenk 0 0

In [ ]: