Unidata / thredds

THREDDS Data Server v4.6
https://www.unidata.ucar.edu/software/tds/v4.6/index.html
265 stars 179 forks source link

ucar.nc2.grib.QuasiRegular cubicSpline wraps unconditionally #82

Open kbromwich opened 9 years ago

kbromwich commented 9 years ago

Hi,

NCEP is soon to change their GFS datasets (including a new field parameter), and due to this I am updating the versions of the grib and netcdf library I'm using from here. Unfortunately I have come across a problem with the QuasiRegular interpolation of datasets for a specific case.

https://github.com/Unidata/thredds/commit/90227d752f77897f9d48dd97bbbd7f40281387ca#diff-3 Earlier this year, there was a change made to the QuasiRegular class wherein handling of edge cases was changed. The change caused the "eastern" edge to continue interpolation by wrapping around to the start of the "western" dataset row. Previously the "eastern" edge was (I think) more or less ignored. While this behaviour makes sense for "global" datasets that are 0 to 360 degrees, it does not make sense for datasets that are only a cut out section. The particular case where this has been a problem is GRIB Edition 1 WAFS files.

I am not entirely sure what the proper behaviour should be in this case, though a possibility might be to interpolate in reverse from the last point to the penultimate point. More likely might be to simply ignore it like previously happened. It should be possible to distinguish between a "global" dataset that wraps and a dataset that does not wrap around, and to pass an argument to the QuasiRegular algorithms.

In the latest branch there are further changes around this code with regard to implementing linear interpolation, and there appears to be the same problem in both linear and cubic interpolation in that version of the code.

Thanks, Kohl

lost-carrier commented 9 years ago

To be honest, I was not aware that this is being used in any other form than global gaussian grids. Can you somehow send an example file?

kbromwich commented 9 years ago

This is actually a file used in unit-testing (hence noticing the change). Looking into it a bit more, I'm not sure that we actually still make much use of thinned datasets. So while this is no longer a high priority fix for me, it might be good to sort this out for the purposes of loading archived data and in case anyone else is using non-global thinned datasets.

https://www.dropbox.com/s/p01lhuidbxu539h/HPPI89_KWBC.grb?dl=0 The above file is the grib file used in the unit test. It is from 2010, so a little bit old, but not ancient.

JohnLCaron commented 8 years ago

Sorry its taken so long to respond.

Its not clear what a decent algorithm would be for non-global thin grids, if there are no bounds on the edges. in the example file, the first 3 lines, there are 2, 3 and 5 points:

   0: 103697.906250,103697.906250,
  1: 103697.906250,103697.906250,103138.687500
  2:  103697.906250, 103697.906250, 103138.687500, 103200.296875, 103357.07815

and we are supposed to interpolated to 73 (!) for each. how would you do it?

OTOH, I agree that pretending that they wrap around is stupid. The longitude extent is -120 to -30 degrees east, lat -90 to 0 degrees north.

Seems likely they sectioned a global grid?

6 Generating Process Type : (96) Global Forecast System Model T574 - Forecast hours 00-192 T190 - Forecast hours 204 - 384