Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Data gives TypeError: Invalid value for attr 'source_temporal_extent' #1118

Open
2 tasks done
AlessiaRiveros opened this issue Feb 19, 2025 · 0 comments
Open
2 tasks done
Labels
Bug Something isn't working Needs refinement issue still needs refinement

Comments

@AlessiaRiveros
Copy link

HydroMT version checks

  • I have checked that this issue has not already been reported.
  • I have checked that this bug exists on the latest version of HydroMT.

Reproducible Example

import hydromt
from hydromt.data_catalog import DataCatalog
from hydromt.log import setuplog

logger = setuplog("export data", log_level=10)

data_catalog = DataCatalog(
logger=logger,
data_libs=["deltares_data"],
)

source_list = ["era5_hourly"]

ds = data_catalog.export_data(
data_root = ('./precipitation'),
source_names=source_list,
bbox=[ 7.49480011, 43.77567187, 10.07152846, 44.67692802],
time_tuple=('2009-01-01T00:00:00','2023-01-01T00:00:00'),
)

Current behaviour

When running the above code I encounter the following error:

File c:\Users\riveros\AppData\Local\miniconda3\envs\hydromt-wflow\Lib\site-packages\xarray\backends\api.py:195, in _validate_attrs..check_attr(name, value, valid_types)
189 raise TypeError(
190 f"Invalid name for attr: {name!r} must be a string for "
191 "serialization to netCDF files"
192 )
194 if not isinstance(value, valid_types):
--> 195 raise TypeError(
196 f"Invalid value for attr {name!r}: {value!r}. For serialization to "
197 "netCDF files, its value must be of one of the following types: "
198 f"{', '.join([vtype.name for vtype in valid_types])}"
199 )

TypeError: Invalid value for attr 'source_temporal_extent': {'start': '1950-01-01', 'end': '2023-03-01'}. For serialization to netCDF files, its value must be of one of the following types: str, Number, ndarray, number, list, tuple

However, this is error does not appear when I specify: source_list = ["era5_hourly[precip]"]

Desired behaviour

I would expect the export_data to work also when not specifying a single variable from the dataset

Additional context

hydromt is version 0.10.0
The data catalog is version 0.7.0
xarray is version 2024.3.0

@AlessiaRiveros AlessiaRiveros added Bug Something isn't working Needs refinement issue still needs refinement labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Needs refinement issue still needs refinement
Projects
None yet
Development

No branches or pull requests

1 participant