Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies = [
"matplotlib >=3.6.0",
"numpy >=1.25.0",
"owslib >=0.29.1",
"pandas >=2.2.0,<3.0",
"pandas >=2.2.0",
"pint >=0.24.4",
"pydantic >=2.11",
"pydap >=3.5.6",
Expand Down
9 changes: 9 additions & 0 deletions src/ravenpy/config/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datetime as dt
import os
import typing
import warnings
from collections.abc import Sequence
from pathlib import Path
from typing import Optional, Union
Expand Down Expand Up @@ -126,6 +128,13 @@ def nc_specs(
if ds["station_id"].shape and len(ds["station_id"]) > i:
attrs["name"] = ds["station_id"].values[i]

# Extract start and end datetime as private attributes
try:
attrs["_start_date"] = np.datetime64(ds.cf["time"][0].values, "us").astype(dt.datetime)
attrs["_end_date"] = np.datetime64(ds.cf["time"][-1].values, "us").astype(dt.datetime)
except:
warnings.info("Could not extract start and end dates from dataset.")

return attrs


Expand Down
10 changes: 2 additions & 8 deletions src/ravenpy/extractors/routing_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def extract(self) -> dict:
# Read routing data

# WGS 84 / North Pole LAEA Canada
self._routing_data = self._routing_data.to_crs(epsg=GridWeightExtractor.CRS_CAEA)
df = self._routing_data.to_crs(epsg=GridWeightExtractor.CRS_CAEA)

def keep_only_valid_downsubid_and_obs_nm(g):
"""
Expand Down Expand Up @@ -436,13 +436,7 @@ def keep_only_valid_downsubid_and_obs_nm(g):
return row

# Remove duplicate HRU_IDs while making sure that we keep relevant DowSubId and Obs_NM values
# FIXME: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns.
# This behavior is deprecated, and in a future version of pandas the grouping columns will be
# excluded from the operation. Either pass `include_groups=False` to exclude the groupings or
# explicitly select the grouping columns after groupby to silence this warning.
self._routing_data = self._routing_data.groupby(self._routing_id_field, group_keys=False).apply(
keep_only_valid_downsubid_and_obs_nm, include_groups=True
)
self._routing_data = df.groupby(self._routing_id_field, group_keys=False)[df.columns.to_list()].apply(keep_only_valid_downsubid_and_obs_nm)

# Make sure those are ints
self._routing_data.SubId = self._routing_data.SubId.astype(int)
Expand Down
Loading