Skip to content

Commit

Permalink
Merge pull request #60 from ArtesiaWater/dev
Browse files Browse the repository at this point in the history
Minor release
  • Loading branch information
dbrakenhoff authored Mar 18, 2021
2 parents f879f2e + 684e3fe commit 8812a45
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
6 changes: 3 additions & 3 deletions docs/source/hydropandas.io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ hydropandas.io.io\_wiski module
:undoc-members:
:show-inheritance:

hydropandas.io.io\_xml module
-----------------------------
hydropandas.io.io\_fews module
------------------------------

.. automodule:: hydropandas.io.io_xml
.. automodule:: hydropandas.io.io_fews
:members:
:undoc-members:
:show-inheritance:
8 changes: 4 additions & 4 deletions hydropandas/data/knmi_meteostation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"323": 51.5333333333,
"330": 51.9833333333,
"340": 51.45,
"344": 51.58,
"344": 51.97,
"348": 51.9666666667,
"350": 51.5666666667,
"356": 51.85,
Expand Down Expand Up @@ -56,7 +56,7 @@
"323": 3.9,
"330": 4.1,
"340": 4.35,
"344": 4.27,
"344": 4.45,
"348": 4.9166666667,
"350": 4.9333333333,
"356": 5.15,
Expand Down Expand Up @@ -130,7 +130,7 @@
"323": 51796.9894138229,
"330": 66556.6593424747,
"340": 82881.4038130033,
"344": 77564.0000000000,
"344": 90598.0000000000,
"348": 122637.5500428702,
"350": 123504.8944820797,
"356": 138628.3530043226,
Expand Down Expand Up @@ -167,7 +167,7 @@
"323": 394768.744780688,
"330": 444557.6206735963,
"340": 384958.5108108983,
"344": 399602.0000000000,
"344": 442813.0000000000,
"348": 442024.5360290739,
"350": 397521.3127536682,
"356": 428968.0220408023,
Expand Down
17 changes: 10 additions & 7 deletions hydropandas/obs_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ class of the observations, e.g. GroundwaterObs or WaterlvlObs
if (file_or_dir is not None):
# get files
dirname, unzip_fnames = util.get_files(file_or_dir, ext=".xml", unpackdir=unpackdir,
force_unpack=force_unpack, preserve_datetime=preserve_datetime)
force_unpack=force_unpack, preserve_datetime=preserve_datetime)
meta.update({'filename': dirname})

obs_list = read_xml_filelist(unzip_fnames,
Expand All @@ -630,7 +630,8 @@ class of the observations, e.g. GroundwaterObs or WaterlvlObs
return cls(obs_df, name=name, meta=meta)

else:
raise ValueError('either specify variables file_or_dir or xmlstring')
raise ValueError(
'either specify variables file_or_dir or xmlstring')

@classmethod
def from_fieldlogger(cls, fname, name='', ObsClass=obs.GroundwaterObs):
Expand Down Expand Up @@ -1065,8 +1066,8 @@ def to_fieldlogger(self, fname, additional_collection=None, otype=None,
return f_df

def to_pi_xml(self, fname, timezone="", version="1.24"):
from .io import io_xml
io_xml.write_pi_xml(self, fname, timezone=timezone, version=version)
from .io import io_fews
io_fews.write_pi_xml(self, fname, timezone=timezone, version=version)

def to_pystore(self, store_name, pystore_path, groupby, item_name=None,
overwrite=False):
Expand Down Expand Up @@ -1177,7 +1178,7 @@ def to_report_table(self, columns=['locatie', 'filternr',
def to_pastastore(self, pstore=None, pstore_name='',
obs_column='stand_m_tov_nap',
kind='oseries', add_metadata=True,
verbose=False):
overwrite=False, verbose=False):
"""add observations to a new or existing pastastore.
Parameters
Expand All @@ -1193,7 +1194,9 @@ def to_pastastore(self, pstore=None, pstore_name='',
kind : str, optional
The kind of series that is added to the pastas project
add_metadata : boolean, optional
If True metadata from the observations added to the project.
If True metadata from the observations added to the project
overwrite : boolean, optional
if True, overwrite existing series in pastastore, default is False
verbose : boolean, optional
Print additional information to the screen (default is False).
Expand All @@ -1208,7 +1211,7 @@ def to_pastastore(self, pstore=None, pstore_name='',
add_metadata=add_metadata,
kind=kind,
obs_column=obs_column,
verbose=verbose)
verbose=verbose, overwrite=overwrite)

return pstore

Expand Down
2 changes: 1 addition & 1 deletion hydropandas/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.5'
__version__ = '0.3.6'
8 changes: 8 additions & 0 deletions tests/test_001_to_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,12 @@ def test_obs_from_pystore_item():


# %% KNMI
@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_obs_from_stn():
return obs.KnmiObs.from_knmi(233, "RD", verbose=True)


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_obs_from_stn_without_any_data():
try:
obs.KnmiObs.from_knmi(210, "RD",
Expand All @@ -280,20 +282,24 @@ def test_knmi_obs_from_stn_without_any_data():
return 1


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_obs_from_stn_with_missing_data_in_time_period():
return obs.KnmiObs.from_knmi(441, "RD", startdate='2010-1-2',
verbose=True)


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_obs_from_xy():
return obs.KnmiObs.from_nearest_xy(100000, 350000, "RD")


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_obs_from_obs():
pb = test_observation_gw()
return obs.KnmiObs.from_obs(pb, "EV24", fill_missing_obs=False)


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_collection_from_locations():
obsc = test_obscollection_dinozip_gw()
oc_knmi = oc.ObsCollection.from_knmi(locations=obsc,
Expand All @@ -304,6 +310,7 @@ def test_knmi_collection_from_locations():
return oc_knmi


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_collection_from_stns():
stns = [344, 260] # Rotterdam en de Bilt
oc_knmi = oc.ObsCollection.from_knmi(stns=stns,
Expand All @@ -314,6 +321,7 @@ def test_knmi_collection_from_stns():
return oc_knmi


@pytest.mark.skip(reason="KNMI API is down")
def test_knmi_collection_from_grid():
# somewhere in Noord-Holland (near Castricum)
xmid = np.array([104150., 104550.])
Expand Down
11 changes: 11 additions & 0 deletions tests/test_006_io_knmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

import numpy as np
import pandas as pd
import pytest
from hydropandas import observation as obs
from hydropandas.io import io_knmi


@pytest.mark.skip(reason="KNMI API is down")
def test_get_knmi_ts():
ts, meta = io_knmi.get_knmi_timeseries_stn(
441,
Expand All @@ -22,6 +24,7 @@ def test_get_knmi_ts():
return ts, meta


@pytest.mark.skip(reason="KNMI API is down")
def test_download_rd_210():
knmi_df, variables, stations = io_knmi.download_knmi_data(
210,
Expand All @@ -34,6 +37,7 @@ def test_download_rd_210():
return knmi_df, variables, stations


@pytest.mark.skip(reason="KNMI API is down")
def test_download_without_data():
try:
knmi_df, variables, stations = io_knmi.download_knmi_data(
Expand All @@ -50,6 +54,7 @@ def test_download_without_data():
return 1


@pytest.mark.skip(reason="KNMI API is down")
def test_download_without_data_no_error():
knmi_df, variables, stations = io_knmi.download_knmi_data(
210,
Expand All @@ -67,6 +72,7 @@ def test_download_without_data_no_error():
return knmi_df, variables, stations


@pytest.mark.skip(reason="KNMI API is down")
def test_download_ev24_240():
knmi_df, variables, stations = io_knmi.download_knmi_data(
210,
Expand All @@ -79,6 +85,7 @@ def test_download_ev24_240():
return knmi_df, variables, stations


@pytest.mark.skip(reason="KNMI API is down")
def test_fill_missing_measurements_ev24_278():
knmi_df, variables, stations = io_knmi.fill_missing_measurements(
278,
Expand All @@ -90,6 +97,7 @@ def test_fill_missing_measurements_ev24_278():
return knmi_df, variables, stations


@pytest.mark.skip(reason="KNMI API is down")
def test_fill_missing_measurements_rd_278():
knmi_df, variables, stations = io_knmi.fill_missing_measurements(
892,
Expand All @@ -101,6 +109,7 @@ def test_fill_missing_measurements_rd_278():
return knmi_df, variables, stations


@pytest.mark.skip(reason="KNMI API is down")
def test_obslist_from_grid():
xmid = np.array([104150., 104550.])
ymid = np.array([510150., 510550.])
Expand All @@ -113,6 +122,7 @@ def test_obslist_from_grid():
return obs_list


@pytest.mark.skip(reason="KNMI API is down")
def test_obslist_from_locations():
locations = pd.DataFrame(data={'x': [100000], 'y': [350000]})
obs_list = io_knmi.get_knmi_obslist(locations, meteo_vars=['EV24'],
Expand All @@ -123,6 +133,7 @@ def test_obslist_from_locations():
return obs_list


@pytest.mark.skip(reason="KNMI API is down")
def test_obslist_from_stns():
stns = [344, 260] # Rotterdam en de Bilt
obs_list = io_knmi.get_knmi_obslist(stns=stns, meteo_vars=['RH', 'EV24'],
Expand Down

0 comments on commit 8812a45

Please sign in to comment.