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 in handling of NCEP grids 228, 229, 230, and 234. #1253

Closed
JohnHalleyGotway opened this issue Feb 11, 2020 · 3 comments
Closed

Fix bug in handling of NCEP grids 228, 229, 230, and 234. #1253

JohnHalleyGotway opened this issue Feb 11, 2020 · 3 comments
Assignees
Labels
MET: Library Code priority: blocker Blocker requestor: NCAR National Center for Atmospheric Research type: bug Fix something that is not working
Milestone

Comments

@JohnHalleyGotway
Copy link
Collaborator

There is a bug when parsing the GRIB1 grid specification for NCEP grids 228, 229, 230, and 234.

These are all lat/lon grids where is data is stored from top to bottom. The min longitude is being stored as the "top" latitude instead of the "bottom" latitude:

================ GRID G228 ================
G228: latlon: lat 90.000000 to -90.000000 by 2.500000 nxny 10512 long 0.000000 to -2.500000 by 2.500000, (144 x 73) scan 64 mode 128 bdsgrid 1
ERROR : Projection: Lat/Lon Nx: 144 Ny: 73 lat_ll: 90.000 lon_ll: -0.000 delta_lat: 2.500 delta_lon: 2.500
ERROR : Projection: Lat/Lon Nx: 144 Ny: 73 lat_ll: -90.000 lon_ll: -0.000 delta_lat: 2.500 delta_lon: 2.500
================ GRID G229 ================
G229: latlon: lat 90.000000 to -90.000000 by 1.000000 nxny 65160 long 0.000000 to -1.000000 by 1.000000, (360 x 181) scan 64 mode 128 bdsgrid 1
ERROR : Projection: Lat/Lon Nx: 360 Ny: 181 lat_ll: 90.000 lon_ll: -0.000 delta_lat: 1.000 delta_lon: 1.000
ERROR : Projection: Lat/Lon Nx: 360 Ny: 181 lat_ll: -90.000 lon_ll: -0.000 delta_lat: 1.000 delta_lon: 1.000
================ GRID G230 ================
G230: latlon: lat 90.000000 to -90.000000 by 0.500000 nxny 259920 long 0.000000 to -0.500000 by 0.500000, (720 x 361) scan 64 mode 128 bdsgrid 1
ERROR : Projection: Lat/Lon Nx: 720 Ny: 361 lat_ll: 90.000 lon_ll: -0.000 delta_lat: 0.500 delta_lon: 0.500
ERROR : Projection: Lat/Lon Nx: 720 Ny: 361 lat_ll: -90.000 lon_ll: -0.000 delta_lat: 0.500 delta_lon: 0.500
================ GRID G234 ================
G234: latlon: lat 15.000000 to -45.000000 by 0.250000 nxny 16093 long -98.000000 to -65.000000 by 0.250000, (133 x 121) scan 64 mode 128 bdsgrid 1
ERROR : Projection: Lat/Lon Nx: 133 Ny: 121 lat_ll: 15.000 lon_ll: 98.000 delta_lat: 0.250 delta_lon: 0.250
ERROR : Projection: Lat/Lon Nx: 133 Ny: 241 lat_ll: -45.000 lon_ll: 98.000 delta_lat: 0.250 delta_lon: 0.250

@JohnHalleyGotway JohnHalleyGotway added type: bug Fix something that is not working component: library code priority: blocker Blocker requestor: NCAR National Center for Atmospheric Research labels Feb 11, 2020
@JohnHalleyGotway JohnHalleyGotway added this to the MET 9.0 milestone Feb 11, 2020
@JohnHalleyGotway JohnHalleyGotway self-assigned this Feb 11, 2020
@JohnHalleyGotway
Copy link
Collaborator Author

(1) I regridded GFS data to grid 230 using both copygb and wgrib2:

copygb -xg230 GFS.grb NCEP_GRIDS/G230_COPYGB.grb
wgrib2 GFS.grb2 -new_grid ncep grid 230 NCEP_GRIDS/G230_WGRIB2.grb2

(2) Running plot_data_plane on the result shows MET plotting the GRIB1 data upside-down and GRIB2 data right-side-up:

plot_data_plane NCEP_GRIDS/G230_WGRIB2.grb2 NCEP_GRIDS/G230_WGRIB2.ps 'name="TMP"; level="Z2";'
plot_data_plane NCEP_GRIDS/G228_COPYGB.grb NCEP_GRIDS/G228_COPYGB.ps 'name="TMP"; level="Z2";'

(3) Here's copygb's definition for grid 230: UPPV4.0.1/src/lib/w3nco/w3fi71.f
DATA GRD230/ 0, 255, 0, 720,361, 90000, 0, 128, -90000,
& -500, 500, 500, 64, 0, 0, 0, 0, 0/
SCANNING MODE FLAGS (CODE TABLE 8) = 64

Compare to the website:
https://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID230

(4) I'm not sure exactly where the issue lies. It could either be a problem in the scan mode for these grids (should be 0 instead of 64), or there could be some problem in the logic in MET.

For GRIB1, the scan mode = 64 matches the website (Scan Mode = 0 1 0).
wgrib -V NCEP_GRIDS/G230_COPYGB.grb
scan 64
For GRIB2, the scan mode = 0.
wgrib2 -scan -V NCEP_GRIDS/G230_WGRIB2.grb2
scan=0

@JohnHalleyGotway
Copy link
Collaborator Author

Email NOAA/EMC staff to ask for advice on how to proceed.

JohnHalleyGotway added a commit that referenced this issue Feb 13, 2020
…ydir setting is consistent with the lat1 and lat2 values. If not, modify ydir to make it consistent. This fixes the handling of grids 228, 229, 230, and 234.
@JohnHalleyGotway
Copy link
Collaborator Author

NOAA/EMC staff instructed me to use the grid definitions from ON388 instead of the (often truncated) settings from the w3 library. So I updated the definitions to match:
https://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html

However grid 234 is poorly defined. The image listed in ON388:
https://www.nco.ncep.noaa.gov/pmb/docs/on388/grids/grid234.gif

Just does not match the definition:
https://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID234

The minimum longitude is 45 S with 121 latitudes spaced 0.25 degrees apart. The puts the max latitude at -45 + 0.25 * 120 = -15. So the grid stops at 15 S but the image shows it extending to 15 N. Perhaps the grid spacing should actually be 0.5 instead?

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: NCAR National Center for Atmospheric Research type: bug Fix something that is not working
Projects
None yet
Development

No branches or pull requests

1 participant