Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Constructing Gaussian latitude axis in GdsHorizCoordSys #627

Closed
rschmunk opened this issue Sep 7, 2016 · 5 comments
Closed

Constructing Gaussian latitude axis in GdsHorizCoordSys #627

rschmunk opened this issue Sep 7, 2016 · 5 comments

Comments

@rschmunk
Copy link
Contributor

rschmunk commented Sep 7, 2016

A Panoply user wrote to complain that a map plot of temperature data on a Gaussian grid was displayed inverted. I found that IDV also plotted the data upside down. In the dataset in question, the 880 latitude values are supposed to run from negative to positive, from -89.844 to 89.844.

Poking around in the NJ code to determine how the values of the latitude axis were being calculated, I found something a bit suspicious.

The method setGaussianLats in ucar.nc2.grib.GdsHorizCoordSys seems to be where the action is, and I do see that it is receiving parameters la1 -89.844, la2 89.844. The first pass at determining bestStartIndex and bestEndIndex values comes up with 879 and 0 respectively

Where things look flaky is the ensuing if statement.

if (Math.abs(bestEndIndex - bestStartIndex + 1) != nyRaw) {

In the case in question, where bestStartIndex > bestEndIndex, the inequality condition is going to be satisfied and in the ensuing if clause, bestStartIndex and bestEndIndex get flipped. In the loop after that, the values for the lat axis end up running from positive to negative.

So what I'm getting around to asking is, shouldn't the above if statement instead read

if (Math.abs(bestEndIndex - bestStartIndex) + 1 != nyRaw) {

I'm pretty unfamiliar with GRIB internals and Gaussian grids, so I'm checking here for confirmation on my suspicion rather than simply filing a pull request.

@lesserwhirls
Copy link
Collaborator

Hmmm...that does look suspicious. Would you happen to have a copy of that file that I could take a look at? I just want to make sure I am going to the correct parts of the correct GRIB spec to see what it says.

@rschmunk
Copy link
Contributor Author

The particular file I was working with is at https://dl.dropboxusercontent.com/u/18229899/test.grb

@rschmunk
Copy link
Contributor Author

Posted pull request #639 to fix this.

@lesserwhirls
Copy link
Collaborator

Hi @msdsoftware - I've scratched my head a bit, and I am leaning towards what you have done. Would it be ok if I used the test file you uploaded to write a test?

@rschmunk
Copy link
Contributor Author

rschmunk commented Sep 22, 2016

Sure. It's a test file that someone else passed on to me to demonstrate a problem, and he did label it "test". As long as it looks like valid GRIB to you, I'd say go for it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants