nansencenter / nansat

Scientist friendly Python toolbox for processing 2D satellite Earth observation data.
http://nansat.readthedocs.io
GNU General Public License v3.0
178 stars 66 forks source link

Wrong _FillValue in exported netcdf #123

Open mortenwh opened 9 years ago

mortenwh commented 9 years ago

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:

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 commented 9 years ago

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.

asumak commented 9 years ago

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().

mortenwh commented 9 years ago

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

  1. mars 2015 15:58 skrev "Asuka Yamakawa" notifications@github.com:

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.

asumak commented 9 years ago

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

mortenwh commented 9 years ago

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.