-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Describe the bug
When reading the IBTrACS.ALL.v04r00.nc file with from_ibtracs_netcdf() the file is opened with xr.open_dataset(ibtracs_path) which opens a stream to the file that is not closed afterwards. I had problems with this on euler when trying to access the file at later stages with the following error:
OSError: [Errno -101] NetCDF: HDF error: '/cluster/work/climate/sjuhel/climada/data/IBTrACS.ALL.v04r00.nc'
To Reproduce
I haven't been able to reproduce the issue on a local computer. This is possibly related to NetCDF too.
Expected behavior
The file is properly closed once the data is loaded.
See also: pydata/xarray#2887
Climada Version: 4.1.1
System Information (please complete the following information):
- Operating system and version: Ubuntu 22.04 (euler)
- Python version: 3.10.13 (Custom venv while climada is not yet installed on the cluster, possibly part of the problems)
Additional context
I don't think this is a critical problem, but the following would probably be a better way to handle the opening of the file:
From:
climada_python/climada/hazard/tc_tracks.py
Line 469 in 8f89ce1
| ibtracs_ds = xr.open_dataset(ibtracs_path) |
to:
with xr.open_dataset(ibtracs_path) as ds:
ibtracks_ds = ds.load()