Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug for Lambert Conformal grids straddling the international date line. #1276

Closed
JohnHalleyGotway opened this issue Mar 12, 2020 · 2 comments
Assignees
Labels
MET: Library Code priority: blocker Blocker requestor: Navy/NRL Naval Research Laboratory type: bug Fix something that is not working
Milestone

Comments

@JohnHalleyGotway
Copy link
Collaborator

This issue was raised via met-help:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=94492

MET is not handling GRIB1 or GRIB2 data correctly for the following grid:
1:0:vt=2016052012:500 mb:720 min fcst:TMP Temperature [K]:
ndata=18496:undef=0:mean=249.408:min=240.326:max=259.783
grid_template=30:winds(N/S):
Lambert Conformal: (136 x 136) input WE:SN output WE:SN res 48
Lat1 49.576424 Lon1 179.749024 LoV 190.000000
LatD 60.000000 Latin1 60.000000 Latin2 30.000000
LatSP 0.000000 LonSP 190.000000
North Pole (136 x 136) Dx 10000.000000 m Dy 10000.000000 m mode 48

@JohnHalleyGotway JohnHalleyGotway added type: bug Fix something that is not working component: library code priority: blocker Blocker requestor: Navy/NRL Naval Research Laboratory labels Mar 12, 2020
@JohnHalleyGotway JohnHalleyGotway added this to the MET 9.0 milestone Mar 12, 2020
@JohnHalleyGotway JohnHalleyGotway self-assigned this Mar 12, 2020
@JohnHalleyGotway JohnHalleyGotway changed the title Fix bug in Lambert Conformal projections straddling the international date line. Fix bug for Lambert Conformal grids straddling the international date line. Mar 12, 2020
@JohnHalleyGotway
Copy link
Collaborator Author

The problem and fix lie in the Lambert Conformal grid source code, lc_grid.cc.

The problem is that the longitudes of the lower-left corner and central longitude fall on opposite sides of the international date line. MET automatically rescales longitudes to put them into a standard range. One of the Lambert Conformal grid parameters is the difference between the lower-left and center longitudes. We had been getting a value of about 350 degrees, when we should have a value of about 10 degrees.

It's a one-line fix in src/libcode/vx_grid/lc_grid.cc.
OLD: theta_pin = HCone(Lon_orient - data.lon_pin);
NEW: theta_pin = HCone(rescale_deg(Lon_orient - data.lon_pin, -180.0, 180.0));

This rescales the resulting difference to the expected range of (-180, 180) and produces the desired result.

JohnHalleyGotway added a commit that referenced this issue Mar 12, 2020
@JohnHalleyGotway
Copy link
Collaborator Author

met-help user confirmed that this change fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MET: Library Code priority: blocker Blocker requestor: Navy/NRL Naval Research Laboratory type: bug Fix something that is not working
Projects
None yet
Development

No branches or pull requests

1 participant