nansat icon indicating copy to clipboard operation
nansat copied to clipboard

Wrong _FillValue in exported netcdf

Open mortenwh opened this issue 9 years ago • 5 comments

When I export a Radarsat-2 image to netcdf, the _FillValue metadata item is set to 9.96921e+36 whereas the actual invalid data points are float(-10000). This causes the __getitem__ function in Nansat to fail. I have created a quick hack to set all values equal to float(-10000) in the np.array to np.nan when _FillValue is 9.96921e+36 but this should be corrected such that the _FillValue provided in the metadata is the same as the actual invalid data. See b7fba1f0b566a793f6f83b4619087069091a7d4b.

This problem seems to be solved in the export2thredds function, and probably the same fix should apply also in the export-function. If so, please make sure that code is not duplicated but that export and export2thredds use a common function.

I have created three tests for checking:

  • nansat.tests.test_export_netcdf (in the develop branch) which tests test_file_gcps by setting some band values to nan, then exports to a netcdf. This seems to work.
  • mapper_tests.test_mappers.TestRadarsat.test_export2thredds (in the master branch) which does not yet work because I didn't add all the parameters (see the code)
  • mapper_tests.test_mappers.TestRadarsat.test_export (in the master branch) which tests export of a radarsat-2 file

So, the tasks in this issue are to

  1. correct the export function so the metadata _FillValue item equals the actual values of invalid data
  2. remove the "hack" in nansat.Nansat.__getitem__

mortenwh avatar Mar 03 '15 13:03 mortenwh

Btw - I also removed the try-except lines in __getitem__ - if such value replacements fail it should cause errors, otherwise we'll get difficulties in debugging when problems arise... Please be very careful with try-except.

mortenwh avatar Mar 03 '15 13:03 mortenwh

orig.export2thredds(ncfile, bands = {'incidence_angle': {}}) in TestRadarsat.test_export2thredds() does not work because dataset with GCPs cannot export for Thredds. The problem should be fixed in export().

asumak avatar Mar 04 '15 14:03 asumak

Don't worry about that now - we can reproject the image to make it work later. It should be tested in any case but first the export function should be improved 4. mars 2015 15:58 skrev "Asuka Yamakawa" [email protected]:

orig.export2thredds(ncfile, bands = {'incidence_angle': {}}) in TestRadarsat.test_export2thredds() does not work because dataset with GCPs cannot export for Thredds. The problem should be fixed in export().

— Reply to this email directly or view it on GitHub https://github.com/nansencenter/nansat/issues/123#issuecomment-77172064.

mortenwh avatar Mar 04 '15 16:03 mortenwh

It is related to issue42. I will test how it works if pixelfunction returns NaN. (a6286a9)

asumak avatar Mar 04 '15 20:03 asumak

Great - that will probably work and both issues should be solved :) perfect

It is related to issue42. I will test how it works if pixelfunction returns NaN. (a6286a9 https://github.com/nansencenter/nansat/commit/a6286a96d43682c67ff9deec032d2ed1c1db60eb )

— Reply to this email directly or view it on GitHub https://github.com/nansencenter/nansat/issues/123#issuecomment-77243780.

mortenwh avatar Mar 04 '15 21:03 mortenwh