Skip to content

Commit

Permalink
Per #1055, ci-run-unit, fix bug in get_data_from_lat_lon_vars() by ad…
Browse files Browse the repository at this point in the history
…ding a swap_to_north return argument. If the parsed dlat value is < 0, need to swap the data from south to north.
  • Loading branch information
JohnHalleyGotway committed Feb 5, 2022
1 parent b0ba93d commit 44a7a3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
27 changes: 19 additions & 8 deletions met/src/libcode/vx_data2d_nccf/nccf_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2419,12 +2419,13 @@ void NcCfFile::get_grid_mapping_rotated_latitude_longitude(const NcVar *grid_map
exit(1);
}

LatLonData ll_data;

ll_data = get_data_from_lat_lon_vars(_yCoordVar, _xCoordVar, lat_counts, lon_counts);

// Fill in the Rotated LatLon data structure.
// Store spacing in LatLon data structure
bool swap_to_north;
LatLonData ll_data = get_data_from_lat_lon_vars(_yCoordVar, _xCoordVar,
lat_counts, lon_counts,
swap_to_north);

// Fill in the Rotated LatLon data structure
RotatedLatLonData data;

data.name = rotated_latlon_proj_type;
Expand Down Expand Up @@ -3044,17 +3045,22 @@ void NcCfFile::get_grid_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var,
const long lat_counts, const long lon_counts) {
static const string method_name = "NcCfFile::get_grid_from_lat_lon_vars()";

LatLonData data = get_data_from_lat_lon_vars(lat_var, lon_var, lat_counts, lon_counts);
bool swap_to_north;
LatLonData data = get_data_from_lat_lon_vars(lat_var, lon_var,
lat_counts, lon_counts,
swap_to_north);

grid.set(data); // resets swap_to_north to false
if (data.delta_lat < 0) grid.set_swap_to_north(true);
if (swap_to_north) grid.set_swap_to_north(true);
}


////////////////////////////////////////////////////////////////////////


LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var,
const long lat_counts, const long lon_counts) {
const long lat_counts, const long lon_counts,
bool &swap_to_north) {
static const string method_name = "get_data_from_lat_lon_vars()";

// Figure out the dlat/dlon values from the dimension variables
Expand Down Expand Up @@ -3185,10 +3191,15 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var,
data.delta_lon = dlon;
data.Nlat = lat_counts;
data.Nlon = lon_counts;

if (dlat < 0) {
swap_to_north = true;
data.delta_lat = -dlat;
data.lat_ll = lat_values[lat_counts-1];
}
else {
swap_to_north = false;
}

return(data);

Expand Down
3 changes: 2 additions & 1 deletion met/src/libcode/vx_data2d_nccf/nccf_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class NcCfFile {
const long lat_counts, const long lon_counts);

LatLonData get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var,
const long lat_counts, const long lon_counts);
const long lat_counts, const long lon_counts,
bool &swap_to_north);
};


Expand Down

0 comments on commit 44a7a3b

Please sign in to comment.