Skip to content

Commit

Permalink
fix: fixed dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jlerat committed May 2, 2024
1 parent 17d6ad0 commit a66f4a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions hydrodiy/data/dutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def compute_aggindex(time, timestep):
f" timestep={timestep}."
assert mth in allowed, errmsg
else:
allowed = ["D", "H", "MS"]
allowed = ["D", "h", "MS"]
errmsg = f"Expected time step in {'/'.join(allowed)}, got {timestep}."
assert timestep in allowed, errmsg

Expand All @@ -140,7 +140,7 @@ def compute_aggindex(time, timestep):
return time.year*100+time.month
elif timestep == "D":
return time.year*10000+time.month*100+time.day
elif timestep == "H":
elif timestep == "h":
return time.year*1000000+time.month*10000\
+time.day*100+time.hour

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

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

Expand Down
6 changes: 3 additions & 3 deletions hydrodiy/data/tests/test_hydata_dutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_combi(allclose):
@pytest.mark.skipif(not has_c_module("data", False), reason=SKIPMESS)
def test_var2h_hourly(allclose):
nval = 24*365*20
dt = pd.date_range(start="1968-01-01", freq="H", periods=nval)
dt = pd.date_range(start="1968-01-01", freq="h", periods=nval)
se = pd.Series(np.arange(nval), index=dt)

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

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

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

Expand Down
5 changes: 2 additions & 3 deletions hydrodiy/gis/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import re, os
from pathlib import Path
import pkg_resources
import math
import copy
import zipfile
Expand Down Expand Up @@ -39,8 +38,8 @@
[8, 4, 2]]).astype(np.int64)

# Path to hygis data
F_HYGIS_DATA = Path(pkg_resources.resource_filename(__name__, "data"))

FHERE = Path(__file__).resolve().parent
F_HYGIS_DATA = FHERE / "data"

# AWRAL subgrids
FZIP_AWRAL_SUBGRIDS = F_HYGIS_DATA/"AWRAL_SUBGRIDS.zip"
Expand Down
4 changes: 2 additions & 2 deletions hydrodiy/gis/oz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import re, os, json, tarfile
from pathlib import Path
import pkg_resources

import numpy as np
import pandas as pd
Expand All @@ -23,7 +22,8 @@
pass

# Decompress australia shoreline shapefile
FDATA = Path(pkg_resources.resource_filename(__name__, "data"))
FHERE = Path(__file__).resolve().parent
FDATA = FHERE / "data"
SHAPEFILES = {
"ozcoast10m": FDATA / "ne_10m_admin_0_countries_australia.shp", \
"ozcoast50m": FDATA / "ne_50m_admin_0_countries_australia.shp", \
Expand Down

0 comments on commit a66f4a7

Please sign in to comment.