Files
ddOperApi/demo/DD-API-Oper demo.ipynb
Marcel Nijenhof b426be57ab Naam aanpassing ddOperApi & versie
* Aanpassingen dd-oper-api ddOperApi
 * Aanpassingen dd-api-oper ddOperApi
 * __version__ toegevoegd inclusief githook
2021-05-30 10:21:38 +02:00

267 lines
5.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Het gebruik van de rws dd-api-oper\n",
"\n",
"## Inleiding\n",
"\n",
"Rws gaat gebruik maken van de digitale delta api voor het verspreiden van data. Ze gebruiken daarbij de digitale delta variant voor operationele data voor.\n",
"\n",
"De authorisatie gebeurt op basis van PKI (overheids) certificaten.\n",
"\n",
"## Een demo van de digitale delta api op basis van python\n",
"\n",
"We zullen gebruik maken van de module \"ddOperApi\" waarmee we het gebruik demonstreren. We starten met de import van de module.\n",
"\n",
"Vervolgens maken we een object aan die we het certificaat mee geven. Dit object rws verzorgt de dd-api calls."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from ddOperApi import ddOperApi"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rws = ddApiOper(\"<TODO>.crt\", \"<TODO>.key\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Het opvragen van de lokaties\n",
"\n",
"We gaan nu de locaties opvragen. Vervolgens zullen we de details van een lokatie tonen."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lokaties = rws.locations()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"print(lokaties.locationNames())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(lokaties.data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(lokaties.locationDetail(\"hoekvanholland\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Het opvragen van de quantities\n",
"\n",
"We gaan nu de quantities opvragen. Eerst zullen we alle quantities opvragen en daarna van de locatie Hoek van Holland."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"quantities = rws.quantities()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(quantities.quantities())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"quantities_hoek = rws.locationQuantities(\"hoekvanholland\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(quantities_hoek.quantities())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Het opvragen van de waterhoogte van hoek van holland\n",
"\n",
"We gaan nu de waterhoogte opvragen van hoek van holland. Vervolgens printen we de bron, provider, aspectset, locaties en de waarde.\n",
"\n",
"Daarna kijken we naar de sip compatable output.\n",
"\n",
"We geven geen tijden op bij dit verzoek. De default is altijd de metingen van de laatste dag!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"hoekvanholland = rws.values(\"hoekvanholland\", \"waterlevel\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(hoekvanholland.source())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(hoekvanholland.provider())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(hoekvanholland.aspectSet())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(hoekvanholland.location())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for v in hoekvanholland.values():\n",
" print(v)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(hoekvanholland.sip())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import plotly.graph_objects as go"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x = []\n",
"y = []\n",
"for v in hoekvanholland.values():\n",
" x.append(v[0])\n",
" y.append(v[1]) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig = go.Figure()\n",
"fig.add_trace(go.Scatter(x=x, y=y, line=dict(color='firebrick', width=4)))\n",
"fig.update_layout(title='Waterhoogte Hoek van Holland',\n",
" xaxis_title='tijd', yaxis_title='Hooghte cm')\n",
"fig.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}