Skip to content

Commit a66f4a7

Browse files
committed
fix: fixed dependency
1 parent 17d6ad0 commit a66f4a7

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

hydrodiy/data/dutils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def compute_aggindex(time, timestep):
127127
f" timestep={timestep}."
128128
assert mth in allowed, errmsg
129129
else:
130-
allowed = ["D", "H", "MS"]
130+
allowed = ["D", "h", "MS"]
131131
errmsg = f"Expected time step in {'/'.join(allowed)}, got {timestep}."
132132
assert timestep in allowed, errmsg
133133

@@ -140,7 +140,7 @@ def compute_aggindex(time, timestep):
140140
return time.year*100+time.month
141141
elif timestep == "D":
142142
return time.year*10000+time.month*100+time.day
143-
elif timestep == "H":
143+
elif timestep == "h":
144144
return time.year*1000000+time.month*10000\
145145
+time.day*100+time.hour
146146

@@ -501,7 +501,7 @@ def var2h(se, nbsec_per_period=3600, maxgapsec=5*86400, rainfall=False, display=
501501
raise ValueError(f"c_hydrodiy_data.var2h returns {ierr}")
502502

503503
# Convert to hourly series
504-
freq = "H" if nbsec_per_period == 3600 else "30min"
504+
freq = "h" if nbsec_per_period == 3600 else "30min"
505505
dt = pd.date_range(hstart, freq=freq, periods=nvalh)
506506
hvalues = pd.Series(hvalues, index=dt)
507507

hydrodiy/data/tests/test_hydata_dutils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def test_combi(allclose):
282282
@pytest.mark.skipif(not has_c_module("data", False), reason=SKIPMESS)
283283
def test_var2h_hourly(allclose):
284284
nval = 24*365*20
285-
dt = pd.date_range(start="1968-01-01", freq="H", periods=nval)
285+
dt = pd.date_range(start="1968-01-01", freq="h", periods=nval)
286286
se = pd.Series(np.arange(nval), index=dt)
287287

288288
seh = dutils.var2h(se, display=True)
@@ -531,14 +531,14 @@ def test_compute_aggindex(allclose):
531531
m = dutils.compute_aggindex(t, "MS")
532532
assert allclose(m, t.year*100+t.month)
533533

534-
t = pd.date_range("2003-01-01", "2004-12-31", freq="H")
534+
t = pd.date_range("2003-01-01", "2004-12-31", freq="h")
535535
d = dutils.compute_aggindex(t, "D")
536536
assert np.unique(d).shape[0] == 731
537537
assert d[-1] == 20041231
538538

539539
t = pd.date_range("2003-01-01 00:00:00", \
540540
"2003-01-10 23:00:00", freq="min")
541-
h = dutils.compute_aggindex(t, "H")
541+
h = dutils.compute_aggindex(t, "h")
542542
assert np.unique(h).shape[0] == 240
543543
assert h[-1] == 2003011023
544544

hydrodiy/gis/grid.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import re, os
44
from pathlib import Path
5-
import pkg_resources
65
import math
76
import copy
87
import zipfile
@@ -39,8 +38,8 @@
3938
[8, 4, 2]]).astype(np.int64)
4039

4140
# Path to hygis data
42-
F_HYGIS_DATA = Path(pkg_resources.resource_filename(__name__, "data"))
43-
41+
FHERE = Path(__file__).resolve().parent
42+
F_HYGIS_DATA = FHERE / "data"
4443

4544
# AWRAL subgrids
4645
FZIP_AWRAL_SUBGRIDS = F_HYGIS_DATA/"AWRAL_SUBGRIDS.zip"

hydrodiy/gis/oz.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import re, os, json, tarfile
44
from pathlib import Path
5-
import pkg_resources
65

76
import numpy as np
87
import pandas as pd
@@ -23,7 +22,8 @@
2322
pass
2423

2524
# Decompress australia shoreline shapefile
26-
FDATA = Path(pkg_resources.resource_filename(__name__, "data"))
25+
FHERE = Path(__file__).resolve().parent
26+
FDATA = FHERE / "data"
2727
SHAPEFILES = {
2828
"ozcoast10m": FDATA / "ne_10m_admin_0_countries_australia.shp", \
2929
"ozcoast50m": FDATA / "ne_50m_admin_0_countries_australia.shp", \

0 commit comments

Comments
 (0)