Read waterinfo csv#

[1]:
import os
from ddlpy.waterinfo import waterinfo_read
import matplotlib.pyplot as plt

[2]:
# example in May 2020, during DST
f = 'https://raw.githubusercontent.com/Deltares/ddlpy/main/tests/20200608_069_20200507.csv'
g = 'https://raw.githubusercontent.com/Deltares/ddlpy/main/tests/NVT_WATHTE_SCHE_20200507.csv'

file via email request: always CET wintertime: UTC + 1#

[3]:
dxf = waterinfo_read(f)
# dxf is an xarray. xarrays can carry ALL meta-data.
dxf[0]
144  rows for variable:  WATHTE
144  rows for variable:  WATHTBRKD
[3]:
<xarray.Dataset> Size: 2kB
Dimensions:  (time: 144)
Coordinates:
  * time     (time) datetime64[ns] 1kB 2020-05-06T23:00:00 ... 2020-05-07T22:...
Data variables:
    data     (time) float64 1kB -60.0 -58.0 -55.0 -51.0 ... -70.0 -69.0 -69.0
Attributes:
    file.name:               https://raw.githubusercontent.com/Deltares/ddlpy...
    file.encoding:           latin
    file.original_columns:   Index(['MONSTER_IDENTIFICATIE', 'MEETPUNT_IDENTI...
    file.original_timezone:  1
[4]:
# xarray can be mapped to pandas dataframe. NB all meta-data gets lost.
df0 = dxf[0].to_dataframe()
df1 = dxf[1].to_dataframe()
df0.plot()
df1.plot()
[4]:
<Axes: xlabel='time'>
../_images/notebooks_waterinfo_5_1.png
../_images/notebooks_waterinfo_5_2.png

file direct download: CET, with DST in summer: UCT+1 or UTC+2#

[5]:
# dxg is an xarray. xarrays can carry ALL meta-data.
dxg = waterinfo_read(g)
# xarray can be mapped to pandas dataframe. NB all meta-data gets lost.
dg0 = dxg[0].to_dataframe()
dg0.plot()
dxg[0]
144  rows for variable:  Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm
[5]:
<xarray.Dataset> Size: 2kB
Dimensions:  (time: 144)
Coordinates:
  * time     (time) datetime64[ns] 1kB 2020-05-06T22:00:00 ... 2020-05-07T21:...
Data variables:
    data     (time) int64 1kB -69 -68 -67 -65 -63 -62 ... -64 -68 -70 -69 -72
Attributes:
    file.name:               https://raw.githubusercontent.com/Deltares/ddlpy...
    file.encoding:           latin
    file.original_columns:   Index(['Datum', 'Tijd', 'Parameter', 'Locatie', ...
    file.original_timezone:  CET
../_images/notebooks_waterinfo_7_2.png

cross check two files: timezone correction#

[6]:
df0['2020-05-07 12:00:00':'2020-05-07 12:40:00'] - df1['2020-05-07 12:00:00':'2020-05-07 12:40:00']
[6]:
data
time
2020-05-07 12:00:00 -13.0
2020-05-07 12:10:00 -15.0
2020-05-07 12:20:00 -15.0
2020-05-07 12:30:00 -14.0
2020-05-07 12:40:00 -12.0
[7]:
# should be 0s
df0['2020-05-07 12:00:00':'2020-05-07 12:40:00'] - dg0['2020-05-07 12:00:00':'2020-05-07 12:40:00']
[7]:
data
time
2020-05-07 12:00:00 0.0
2020-05-07 12:10:00 0.0
2020-05-07 12:20:00 0.0
2020-05-07 12:30:00 0.0
2020-05-07 12:40:00 0.0
[8]:
%matplotlib inline
fig=plt.figure()
fig.set_figwidth(20)
plt.plot(df1.index,df1['data'],'g:',label=dxf[1].attrs['file.name']+'\n'+dxf[1]['data'].attrs['GROOTHEID_ CODE'])
plt.plot(df0.index,df0['data'],'r-',label=dxf[0].attrs['file.name']+'\n'+dxf[0]['data'].attrs['GROOTHEID_ CODE'])
plt.plot(dg0.index,dg0['data'],'b.',label=dxg[0].attrs['file.name']+'\n'+dxg[0]['data'].attrs['Parameter'])
plt.legend()
plt.grid()
../_images/notebooks_waterinfo_11_0.png
[ ]: