Skip to content

Commit

Permalink
Per #2118, I found a reference in ECMWF documentation for specifying …
Browse files Browse the repository at this point in the history
…rotated lat/lon grids in GRIB1.

https://apps.ecmwf.int/codes/grib/format/grib1/grids/10/
These changes update the MET code to parse location of the south pole and auxiliary rotation.
I double-checked in wgrib and see the exact same processing for rotated lat/lon GRIB1 files.
So I'm confident in the approach. While it would be preferable to have additional sample data for testing,
it's no longer a requirement for this bugfix.
  • Loading branch information
JohnHalleyGotway committed Apr 6, 2022
1 parent b368ad1 commit ec295a9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
21 changes: 21 additions & 0 deletions met/src/libcode/vx_data2d_grib/grib_classes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,27 @@ else if ((h.type == 5))

file << " scan_flag: " << (int) h.grid_type.stereographic.scan_flag << "\n\n";
}
else if ((h.type == 10))
{

file << " lat1: " << char3_to_int(h.grid_type.rot_latlon_grid.lat1) << "\n";
file << " lon1: " << char3_to_int(h.grid_type.rot_latlon_grid.lon1) << "\n";

file << " res_flag: " << (int) h.grid_type.rot_latlon_grid.res_flag << "\n";

file << " lat2: " << char3_to_int(h.grid_type.rot_latlon_grid.lat2) << "\n";
file << " lon2: " << char3_to_int(h.grid_type.rot_latlon_grid.lon2) << "\n";

file << " di: " << char2_to_int(h.grid_type.rot_latlon_grid.di) << "\n";
file << " dj: " << char2_to_int(h.grid_type.rot_latlon_grid.dj) << "\n";

file << " scan_flag: " << (int) h.grid_type.rot_latlon_grid.scan_flag << "\n";

file << " lat_sp: " << char3_to_int(h.grid_type.rot_latlon_grid.lat_sp) << "\n";
file << " lon_sp: " << char3_to_int(h.grid_type.rot_latlon_grid.lon_sp) << "\n";

file << " rotation: " << char4_to_dbl(h.grid_type.rot_latlon_grid.rotation) << "\n\n";
}

return ( file );

Expand Down
9 changes: 8 additions & 1 deletion met/src/libcode/vx_data2d_grib/grib_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ struct LatLon { // Latitude/Longitude Grid

};

// Reference: https://apps.ecmwf.int/codes/grib/format/grib1/grids/10

struct RotLatLon { // Rotated Latitude/Longitude Grid

unsigned char lat1[3]; // 11 - 13
Expand All @@ -196,7 +198,12 @@ struct RotLatLon { // Rotated Latitude/Longitude Gri

unsigned char scan_flag; // 28

unsigned char unused[14]; // 29 - 42
unsigned char unused[4]; // 29 - 32

unsigned char lat_sp[3]; // 33 - 35
unsigned char lon_sp[3]; // 36 - 38

unsigned char rotation[4]; // 39 - 42

};

Expand Down
12 changes: 7 additions & 5 deletions met/src/libcode/vx_data2d_grib/grib_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,15 @@ if ( ! all_bits_set(gds.grid_type.rot_latlon_grid.di, 2) ) {

}

// Location of (rotated) south pole and auxiliary rotation hard-coded to 0
// Location of (rotated) south pole
data.true_lat_south_pole =
decode_lat_lon(gds.grid_type.rot_latlon_grid.lat_sp, 3);

data.true_lat_south_pole = -90.0;
data.true_lon_south_pole =
-1.0*rescale_lon(decode_lat_lon(gds.grid_type.rot_latlon_grid.lon_sp, 3));

data.true_lon_south_pole = 0.0;

data.aux_rotation = 0.0;
// Auxiliary rotation
data.aux_rotation = char4_to_dbl(gds.grid_type.rot_latlon_grid.rotation);

data.dump();

Expand Down

0 comments on commit ec295a9

Please sign in to comment.