Hello, I am trying to analyse some cordex datasets that feature a
rotated pole projection.
One is a European and the other an African domain dataset. The first reads
properly, while the second is reprojected wrong.
I had some help already when I at first thought that would be a ncWMS issue
[0], but it resulted in a flaw in the data definition.
I feel this is the appropriate space to discuss this. I would like to be
able to identify flaws in the data and possibly fix them, using the netcdf
java libraries.
So, first off, I am accessing them as gridded datasets.
GridDataset gds = GridDataset.open(inPath);
GridDatatype grid = gds.findGridDatatype("pr");
I get the coord system and projection object;
GridCoordSystem coordSys = grid.getCoordinateSystem();
ProjectionImpl proj = coordSys.getProjection();
I then print out some information about the grid mapping:
EUROPA, precipitation:
Attributes:
grid_mapping: rotated_pole
standard_name: precipitation_flux
long_name: Precipitation
units: kg m-2 s-1
coordinates: lon lat
cell_methods: time: mean
Projection: RotatedPole
Proj X Axis (rlon): -28.375 -> 18.155 (424) extent: 46.53
Proj Y Axis (rlat): -23.375 -> 21.835 (412) extent: 45.21
Time Axis (time): 2046-01-01T12:00:00Z -> 2050-12-31T12:00:00Z (1825)
Longitude: -44.5938638919001 -> 64.96437666717893 extent:
109.55824055907902
Latitude: 21.987828756838308 -> 72.5849994760081 extent: 50.59717071916978
AFRICA, temperature:
Attributes:
long_name: Near-Surface Air Temperature
standard_name: air_temperature
units: K
grid_mapping: rotated_pole
cell_methods: time: mean
coordinates: lon lat height
Projection: RotatedPole
Proj X Axis (rlon): -24.75 -> 60.3900146484375 (388) extent:
85.1400146484375
Proj Y Axis (rlat): -45.869998931884766 -> 42.35000228881836 (402)
extent: 88.22000122070312
Time Axis (time): 2051-01-01T12:00:00Z -> 2055-12-31T12:00:00Z (1825)
Longitude: -179.88999938964847 -> 179.8900146484375 extent:
359.78001403808594
Latitude: -45.869998931884766 -> 42.35000228881836 extent:
88.22000122070312
The latitude and longitude are obtained using the projToLatLon method.
CoordinateAxis xAxis = coordSys.getXHorizAxis();
CoordinateAxis yAxis = coordSys.getYHorizAxis();
Array xValues = xAxis.read();
Array yValues = yAxis.read();
int[] xShape = xValues.getShape();
int[] yShape = yValues.getShape();
Index xIndex = xValues.getIndex();
Index yIndex = yValues.getIndex();
for( int y = 0; y < yShape[0]; y++ ) {
for( int x = 0; x < xShape[0]; x++ ) {
double xVal = xValues.getDouble(xIndex.set(x));
double yVal = yValues.getDouble(yIndex.set(y));
double latitude = proj.projToLatLon(xVal, yVal).getLatitude();
double longitude = proj.projToLatLon(xVal, yVal).getLongitude();
// these are the values used
}
}
The problem is that the AFRICA dataset is read wrong (Africa is placed
between Australia and America) and from all the info I print out I am not
able to find the way to solve that. In the mentioned issue I got some help
on the need to rename some variables. But I can't find a way to identify
that issue (not even knowing it) by reading the metadata.
Can anyone give me some hint on how to identify such issues and possibly
solve them?
Thanks for any help,
Andrea
PS: For any kind soul willing to look at it, here are the two netcdfs:
https://we.tl/t-CIoO6gdj80
[0] https://github.com/Reading-eScience-Centre/ncwms/issues/93