Unidata/thredds — pull request #55 by lost-carrier (2014-06-03 15:22:55+00:00)
Title: Target 4.3.22 rawdata

Hi,

this is a proposal of how to allow the user to switch between cubicSpline and linear as interpolation method from reduced gaussian grid to regular lat lon grids. Discussion around this can be found on the mailing list - e.g. @ http://www.unidata.ucar.edu/mailing_lists/archives/netcdf-java/2014/msg00049.html (...and most probably there is more discussion ahead... ;-) ).

Here's an example of how to use it:
```
GridDataset gds = GridDataset.open("file.grb");

for (GridDatatype var : gds.getGrids()) {
Section section = ((GeoGrid) var).generateSection(0, 0, 0, 0, -1, -1);
DataReceiver rawData = ((GribIosp) gds.getNetcdfDataset().getIosp()).readData(
var.getVariable().getOriginalVariable(),
((GeoGrid) var).generateSection(0, 0, 0, 0, -1, -1),
QuasiRegular.INTERPOLATION_NONE);

GribGds gribGds = rawData.getGds(0);
if (gribGds instanceof Grib1Gds.LatLon) {
// regular lat lon
} else if (gribGds instanceof Grib1Gds.GaussianLatLon) {
// gaussian grid
Grib1Gds.GaussianLatLon gaussianGds = (Grib1Gds.GaussianLatLon) gribGds;
double minLat = gaussianGds.la2;
double maxLat = gaussianGds.la1;
double minLon = gaussianGds.lo1;
double maxLon = gaussianGds.lo2;

int[] nptsInLine = gribGds.getNptsInLine();
double[] lats = (double[]) gribGds.makeHorizCoordSys().gaussLats.get1DJavaArray(double.class);
}

Array data = rawData.getArray();
double[] doubles = (double[]) data.get1DJavaArray(double.class);

// ...

}
```

It involves a lot of casting because it is only implemented for Grib1 and Grib2 (...not sure, but other Iosps most probably do not support reduced gaussian mess at all, do they?).

Feedback welcome!

Cheers,
Jochen