-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add custom exception when Raster
(sub)classes are supplied to Coreg classes
#145
Comments
|
We could have a |
Well, this seems straightforward enough to not have a function for it. But you could have a condition at the beginning of the function, to define both terms either from the Raster attributes, or from the arguments raster and transform. |
We had this in GeoImg, basically each function started with a: if isinstance(reference_dem,GeoImg):
reference_array=reference_dem.img
elif isinstance(reference_dem,np.ndarray):
reference_array=reference_dem
else:
raise ValueError() But this rapidly becomes annoying... we get used to it and, then we need to write it at the beginning of each function. So I agree: 3 would be ideal... but seems complex. |
Since the latest geoutils, numpy operations now work natively on rasters! This issue might therefore be solved (as soon as it is included in a release of course). But the behaviour should optimally be tested in xdem. |
I quite often accidentally do:
note that this will not work, as the
reference_dem
argument is supposed to be a numpy array (so the function call should takereference_dem.data
). When the above is called, a not-so-helpful error message comes up:I see three solutions for this:
isinstance(reference_dem, Raster)
to be more helpful.Raster
(sub)classes as coreg arguments. This would reduce the need for thetransform
argument as that can be read automatically fromreference_dem
.np.isfinite
to run on a Raster as if it was called onRaster.data
:np.isfinite(Raster) -> np.ndarray
Thoughs, @adehecq and @rhugonnet ?
The text was updated successfully, but these errors were encountered: