-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
Problem:
I wanted to rerun a previously working code (e.g. on the current main branch) using the develop branch and it suddenly failed.
import xarray as xr
import numpy as np
import datetime as dt
from climada.hazard import Hazard
"""Write a simple NetCDF file to read"""
netcdf_path = "default.nc"
intensity = np.array([[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]])
time = np.array([dt.datetime(1999, 1, 1), dt.datetime(2000, 1, 1)])
latitude = np.array([0, 1])
longitude = np.array([0, 1, 2])
dset = xr.Dataset(
{
"intensity": (["time", "latitude", "longitude"], intensity),
},
dict(time=time, latitude=latitude, longitude=longitude),
)
dset.to_netcdf(netcdf_path)
hazard = Hazard.from_xarray_raster_file(netcdf_path, "", "")
hazard.centroids.geometry
# output:
# GeoSeries([], dtype: geometry)
hazard.centroids.set_geometry_points() # <- this line fails in current develop branch
hazard.centroids.geometry
# output:
# 0 POINT (0.00000 0.00000)
# 1 POINT (1.00000 0.00000)
# 2 POINT (2.00000 0.00000)
# 3 POINT (0.00000 1.00000)
# 4 POINT (1.00000 1.00000)
# 5 POINT (2.00000 1.00000)
# dtype: geometry
Possible solution:
Have you considered keeping an "empty" set_geometry_points method instead of just removing it and issuing a deprecated warning informing the user that this function is now useless?
The code would run through smoothly and the result would be correct because now the geometry is already correctly set automatically...
Alternative solution:
I assume the next release would be a major release, so maybe keeping such functionality is not important?
Reactions are currently unavailable