Skip to content

Commit

Permalink
address usage warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Feb 25, 2025
1 parent 0d6d248 commit a811f75
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ravenpy/config/rvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class RVI(RV):

run_name: Optional[str] = optfield(alias="RunName")
calendar: Optional[o.Calendar] = optfield(alias="Calendar")
start_date: Optional[date] = optfield(alias="StartDate")
start_date: Optional[Union[str, date]] = optfield(alias="StartDate")
assimilation_start_time: Optional[date] = optfield(alias="AssimilationStartTime")
end_date: Optional[date] = optfield(alias="EndDate")
end_date: Optional[Union[str, date]] = optfield(alias="EndDate")
duration: Optional[float] = optfield(alias="Duration")
time_step: Optional[Union[float, str]] = optfield(alias="TimeStep")
interpolation: Optional[o.Interpolation] = optfield(alias="Interpolation")
Expand Down
1 change: 1 addition & 0 deletions src/ravenpy/extractors/routing_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from osgeo import ogr, osr
from shapely import wkt

osr.UseExceptions()
except (ImportError, ModuleNotFoundError) as e:
msg = gis_import_error_message.format(Path(__file__).stem)
raise ImportError(msg) from e
Expand Down
4 changes: 3 additions & 1 deletion src/ravenpy/utilities/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

try:
import rasterio
from osgeo.gdal import Dataset, DEMProcessing
from osgeo.gdal import Dataset, DEMProcessing, UseExceptions
from shapely.geometry import GeometryCollection, MultiPolygon, Polygon, shape

UseExceptions()
except (ImportError, ModuleNotFoundError) as e:
msg = gis_import_error_message.format(Path(__file__).stem)
raise ImportError(msg) from e
Expand Down
4 changes: 3 additions & 1 deletion src/ravenpy/utilities/forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ def ensemble_prediction(

# Run the model for each year
ensemble = []
forecast_ds = xr.open_dataset(forecast, use_cftime=True)

time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)
forecast_ds = xr.open_dataset(forecast, decode_times=time_coder)

for member in range(0, len(forecast_ds[ens_dim])):
# Prepare model instance
Expand Down
4 changes: 2 additions & 2 deletions tests/test_forecasting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import datetime as dt
from datetime import datetime as dt

import numpy as np
import pytest
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_forecasting_GEPS(numeric_config, get_local_testdata):
# Prepare a RAVEN model run using historical data, GR4JCN in this case.
# This is a dummy run to get initial states. In a real forecast situation,
# this run would end on the day before the forecast, but process is the same.
wup.start_date = dt.datetime(2000, 1, 1)
wup.start_date = dt(2000, 1, 1)
wup.duration = 30

e = Emulator(wup)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_hydrobasins_upstream_aggregate(self, tmp_path):
aggregated = self.geoserver.hydrobasins_aggregate(gdf_upstream)

assert len(aggregated) == 1
assert float(aggregated.SUB_AREA.values) == 4977.8
assert aggregated.SUB_AREA.values[0] == 4977.8
np.testing.assert_equal(
aggregated.geometry.bounds.values,
np.array([[-83.8167, 8.7625, -82.7125, 9.5875]]),
Expand Down

0 comments on commit a811f75

Please sign in to comment.