NOAA-EMC / NCEPLIBS-ip2

Other
1 stars 4 forks source link

Problem using wgrib2 to interpolate from a global to regional lat/lon grid #1

Open GeorgeGayno-NOAA opened 4 years ago

GeorgeGayno-NOAA commented 4 years ago

wgrib2 uses the ip2 lib for interpolating between grids. James Cogan of the US ARMY ARL found a problem when interpolating 0.25-degree GFS grib 2 data to a small regional lat/lon grid. Wesley was able to reproduce the problem. Wesley's script and test data are on Mars: /gpfs/dell2/emc/modeling/noscrub/George.Gayno/ip2lib.git/wgrib2_interp_prob

Make sure the problem does not exist in the ip2 library.

MIredell commented 4 years ago

The problem does exist in both the ip and ip2 library. The offending line in both iplib and ip2lib is in the navigation gdswiz routines to calculate DLON, the longitude step. It is:

DLON=HI(MOD(HI(RLON2-RLON1)-1+3600,360.)+1)/(IM-1)

When RLON2 is less than one degree bigger than RLON1, the gdswiz routines assume this is a global extent grid including a bit of wraparound. It is unknown why that assumption had to be made but that is the effect of this calculation. For instance, if IM=7 and RLON2-RLON1=0.6 and HI=1 then HI(MOD(HI(RLON2-RLON1)-1+3600,360.)+1) would be 360.6 and DLON would be 60.1. The interpolations thereafter will be misplaced.

The proper solution could be to take the "-1" and "+1" out of the formula above, or to actually use the DLON that is provided in the grid metadata accurate to a millionth of a degree.

MIredell commented 4 years ago

Recommendation: For ip and ip2 in gdswiz00 and gdswzd00, set:

DLON=HI*(MOD(HI*(RLON2-RLON1)-1.e-3+3600.,360.)+1.e-3)/(IM-1) ! assume total grid width is at least 1.e-3 degree.

For ip2, this can be quality controlled with the "Di" metadata given with nominal 1.e-6 precision.

DLON=(DLON*(IM-1)+360*NINT((Di-DLON)*(IM-1)/360))/(IM-1)

edwardhartnett commented 3 years ago

Are we going to take the suggestion of @MIredell ?

If so, we need one or more tests to support this change.

edwardhartnett commented 2 years ago

@GeorgeGayno-NOAA @kgerheiser what should be done with this issue?

This code has been moved to NCEPLIBS-ip.

GeorgeGayno-NOAA commented 2 years ago

@GeorgeGayno-NOAA @kgerheiser what should be done with this issue?

This code has been moved to NCEPLIBS-ip.

I would add this fix.