Skip to content

Commit

Permalink
Merge pull request #67 from ArtesiaWater/dev
Browse files Browse the repository at this point in the history
Update reading knmi
  • Loading branch information
OnnoEbbens authored Oct 26, 2021
2 parents fa00ea0 + 0712122 commit 6cf3590
Show file tree
Hide file tree
Showing 22 changed files with 2,306 additions and 839 deletions.
27 changes: 27 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pep257:
disable:
- D203
- D212
- D213
- D214
- D215
- D404
- D405
- D406
- D407
- D408
- D409
- D410
- D411
- D413
- D415
- D416
- D417

pylint:
disable:
# Disable unnecessary else after return as it complains when
# returning in an else statement which is often more readable
- no-else-return
- too-many-arguments
- too-many-locals
902 changes: 680 additions & 222 deletions examples/02_knmi_observations.ipynb

Large diffs are not rendered by default.

255 changes: 170 additions & 85 deletions examples/03_pastastore_from_observations.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion hydropandas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .obs_collection import ObsCollection
from .observation import (Obs, GroundwaterObs, GroundwaterQualityObs,
KnmiObs, ModelObs, WaterlvlObs)
PrecipitationObs, EvaporationObs, MeteoObs,
ModelObs, WaterlvlObs)
from .extensions import geo as _geo
from .extensions import gwobs as _gwobs
from .extensions import plots as _plots
Expand Down
4 changes: 1 addition & 3 deletions hydropandas/extensions/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def get_nearest_line(self, gdf=None,
"""get nearest line for each point in the obs collection. Function
calls the nearest_polygon function.
Parameters
----------
gdf : GeoDataFrame
Expand Down Expand Up @@ -263,8 +262,7 @@ def get_nearest_polygon(self, gdf=None,
xcol_obs='x', ycol_obs='y',
multiple_polygons='error'):
"""get nearest polygon for each point in the obs collection. Function
also works for lines instead of polygons
also works for lines instead of polygons.
Parameters
----------
Expand Down
20 changes: 10 additions & 10 deletions hydropandas/extensions/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ def __init__(self, obs):

def interactive_plot(self,
savedir=None,
plot_columns=['stand_m_tov_nap'],
markers=['line'],
plot_columns=('stand_m_tov_nap',),
markers=('line',),
p=None,
plot_legend_names=[''],
plot_freq=[None],
plot_legend_names=('',),
plot_freq=(None,),
tmin=None,
tmax=None,
hoover_names=['Peil'],
hoover_names=('Peil',),
hoover_date_format="%Y-%m-%d",
ylabel='m NAP',
plot_colors=['blue'],
plot_colors=('blue',),
add_filter_to_legend=False,
return_filename=False):
"""Create an interactive plot of the observations using bokeh.
Expand Down Expand Up @@ -334,7 +334,7 @@ def interactive_plot(self,
# create plot dataframe
plot_df = self._obj[tmin:tmax].copy()
plot_df['date'] = plot_df.index.strftime(hoover_date_format)
if plot_df.empty or plot_df[plot_columns].isna().all().all():
if plot_df.empty or plot_df[list(plot_columns)].isna().all().all():
raise ValueError(
'{} has no data between {} and {}'.format(self._obj.name, tmin, tmax))

Expand All @@ -351,7 +351,7 @@ def interactive_plot(self,

# get color
if len(plot_colors) < len(plot_columns):
plot_colors = plot_colors * len(plot_columns)
plot_colors = list(plot_colors) * len(plot_columns)

# get base for hoover tooltips
plots = []
Expand All @@ -377,11 +377,11 @@ def interactive_plot(self,

# plot data

if markers[i] == 'line':
if markers[i] in ['line', 'l']:
plots.append(p.line(xcol, column, source=source, color=plot_colors[i],
legend_label=lname,
alpha=0.8, muted_alpha=0.2))
elif markers[i] == 'circle':
elif markers[i] in ['circle','c']:
plots.append(p.circle(xcol, column, source=source, color=plot_colors[i],
legend_label=lname,
alpha=0.8, muted_alpha=0.2))
Expand Down
9 changes: 5 additions & 4 deletions hydropandas/io/io_arctic.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging
from timeit import default_timer

import arctic
from tqdm import tqdm

import logging
logger = logging.getLogger(__name__)


def read_arctic(connstr, libname, ObsClass, progressbar=False):
"""Read all timeseries from Arctic database.
Expand Down Expand Up @@ -43,8 +44,8 @@ def read_arctic(connstr, libname, ObsClass, progressbar=False):
"Rows: {1:,.0f} "
"Time: {2:.2f}s "
"Rows/s: {3:,.1f}".format(len(lib.list_symbols()),
rows_read,
(end - start),
rows_read / (end - start)))
rows_read,
(end - start),
rows_read / (end - start)))

return obs_list
4 changes: 2 additions & 2 deletions hydropandas/io/io_dino.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime as dt
import logging
import os
import re
import tempfile
import warnings
import logging
from timeit import default_timer

import numpy as np
Expand Down Expand Up @@ -95,7 +95,7 @@ def _read_dino_groundwater_metadata(f, line):
for i, meta in enumerate(metalist):
meta_tsi = {}
start_date = pd.to_datetime(meta.pop('startdatum'), dayfirst=True)
end_date = pd.to_datetime(meta.pop('einddatum'), dayfirst=True)
#end_date = pd.to_datetime(meta.pop('einddatum'), dayfirst=True)
meta_tsi['locatie'] = meta['locatie']
for key in _translate_dic_float.keys():
if meta[key] == '':
Expand Down
5 changes: 3 additions & 2 deletions hydropandas/io/io_fews.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import logging
import os
import xml.etree.ElementTree as etree
from io import StringIO
Expand All @@ -8,7 +9,6 @@
from hydropandas.observation import GroundwaterObs, WaterlvlObs
from lxml.etree import iterparse

import logging
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -167,7 +167,8 @@ class of the observations, e.g. GroundwaterObs or WaterlvlObs
loc = h_attr.text
if loc not in locationIds:
element.clear()
logger.info(f" ... skipping '{loc}', not in locationIds")
logger.info(
f" ... skipping '{loc}', not in locationIds")
continue

if filterdict is not None:
Expand Down
Loading

0 comments on commit 6cf3590

Please sign in to comment.