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

Can't write Float16 data cubes #316

Closed
ayushpatnaikgit opened this issue Sep 25, 2022 · 2 comments
Closed

Can't write Float16 data cubes #316

ayushpatnaikgit opened this issue Sep 25, 2022 · 2 comments

Comments

@ayushpatnaikgit
Copy link

Can't write a data cube which has Float16 values.

raster = Raster("test.nc")
raster = Float16.(raster)
write("test.nc", raster) # doesn't work
ERROR: Your data is not a type that netcdf can store

While there are no issues if I convert it to Float32 and then write.

raster = Float32.(raster)
write("test.nc", raster)  # this works

Also no issues if I convert it to Float64 and then write.

raster = Float64.(raster)
write("test.nc", raster)  # this works

I used this netCDF file for testing. It's called mumbai_radiance.nc instead of test.nc

@rafaqz
Copy link
Owner

rafaqz commented Sep 25, 2022

NetCDF doesn't support Float16. But maybe we should silently convert to Float32?

Xarray seemed to decide it was best to make the user do that manually:
pydata/xarray#1877

But we could make the error message clearer? Another option is to convert to Float32 but print a @warning message so the user is aware that is happening.

@ayushpatnaikgit
Copy link
Author

I also think that it's best for the user to convert it manually, and it can be suggested in the error message. Perhaps something like:

if typeof(raster[1]) == Float16
@error "NetCDF doesn't support Float16, convert your variable Float32.  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants