Skip to content

Commit

Permalink
debugging attempt for #154 (#155)
Browse files Browse the repository at this point in the history
* debugging attempt for #154

* fix some warnings

* version bump

* probably a fix for #154

* typo
  • Loading branch information
OnnoEbbens authored Sep 10, 2023
1 parent 3a0378b commit 1afaf3c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion hydropandas/extensions/gwobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pandas as pd
from pandas.api.types import is_numeric_dtype

try:
from tqdm import tqdm
Expand Down Expand Up @@ -371,7 +372,7 @@ def set_tube_nr(
# check if column exists in obscollection
if "tube_nr" in self._obj.columns:
# set type to numeric
if self._obj["tube_nr"].dtype != np.number:
if not is_numeric_dtype(self._obj["tube_nr"]):
self._obj["tube_nr"] = pd.to_numeric(
self._obj["tube_nr"], errors="coerce"
)
Expand Down
17 changes: 10 additions & 7 deletions hydropandas/io/knmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def get_knmi_daily_rainfall_api(stn, start=None, end=None):

f = StringIO(result_str)
knmi_df, variables = read_knmi_daily_rainfall(f, meteo_var)
if stn not in knmi_df.STN.unique():
if stn not in knmi_df["STN"].unique():
return pd.DataFrame(), variables

return knmi_df[[meteo_var]], variables
Expand Down Expand Up @@ -819,8 +819,9 @@ def read_knmi_daily_rainfall_file(fname_txt, start=None, end=None):
variables["unit"] = "m"

# add station to variables
if len(df["STN"].unique()) != 1:
raise ValueError("multiple stations in single file")
unique_stn = df["STN"].unique()
if len(unique_stn) > 1:
raise ValueError(f"multiple stations in single file {unique_stn}")
else:
variables["station"] = df["STN"].iloc[0]

Expand Down Expand Up @@ -1202,8 +1203,9 @@ def read_knmi_daily_meteo_file(path, meteo_var, start=None, end=None):
df.index = df.index + pd.to_timedelta(1, unit="h")

# add station to variables
if len(df["STN"].unique()) != 1:
raise ValueError("multiple stations in single file")
unique_stn = df["STN"].unique()
if len(unique_stn) > 1:
raise ValueError(f"multiple stations in single file {unique_stn}")
else:
station = df["STN"].iloc[0]

Expand Down Expand Up @@ -1355,8 +1357,9 @@ def read_knmi_hourly(f, meteo_var, start=None, end=None):
datetime.loc[datetime.dt.hour == 0] = datetime + dt.timedelta(days=1)

# add station to variables
if len(df["STN"].unique()) != 1:
raise ValueError("multiple stations in single file")
unique_stn = df["STN"].unique()
if len(unique_stn) > 1:
raise ValueError(f"multiple stations in single file {unique_stn}")
else:
station = df["STN"].iloc[0]

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.9.0"
__version__ = "0.9.1"
3 changes: 2 additions & 1 deletion tests/test_001_to_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def test_observation_wiskicsv_gw():
header_identifier=":",
parse_dates={"datetime": [0, 1]},
index_col=["datetime"],
dayfirst=True,
translate_dic={"name": "Station Number", "x": "GlobalX", "y": "GlobalY"},
)

Expand Down Expand Up @@ -273,7 +274,7 @@ def test_knmi_obs_from_stn_no_api():

def test_knmi_obs_from_stn_without_any_data():
hpd.EvaporationObs.from_knmi(
stn=210, startdate="19500101", enddate="19600101", fill_missing_obs=False
stn=210, start="19500101", end="19600101", fill_missing_obs=False
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_004_gwobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_get_modellayers_mf2005():
import flopy

modelname = "test_mf2005"
ml = flopy.modflow.Modflow(modelname, exe_name="mf2005")
ml = flopy.modflow.Modflow(modelname)
# Model domain and grid definition
Lx = 300000.0
Ly = 400000.0
Expand Down
1 change: 1 addition & 0 deletions tests/test_007_wiski.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_read_wiski_csv() -> None:
header_identifier=":",
verbose=True,
parse_dates={"datetime": [0, 1]},
dayfirst=True,
index_col=["datetime"],
translate_dic={"name": "Station Number", "x": "GlobalX", "y": "GlobalY"},
)
Expand Down

0 comments on commit 1afaf3c

Please sign in to comment.