Skip to content

Commit

Permalink
Bugfix #2833 main_v11.1 azimuth (#2834)
Browse files Browse the repository at this point in the history
* Per #2833, fix n-1 bug when defining the azimuth delta for range/azimuth grids.

* Per #2833, port fixes over from the bugfix_2833_develop_azimuth branch over to the main_v11.1 branch.

---------

Co-authored-by: MET Tools Test Account <met_test@seneca.rap.ucar.edu>
  • Loading branch information
JohnHalleyGotway and MET Tools Test Account authored Mar 27, 2024
1 parent 2aa027a commit c6ac1cd
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 34 deletions.
3 changes: 1 addition & 2 deletions data/config/TCRMWConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ regrid = {
//
n_range = 100;
n_azimuth = 180;
max_range_km = 1000.0;
delta_range_km = 10.0;
rmw_scale = 0.2;
rmw_scale = NA;

//
// Optionally convert u/v winds to tangential/radial winds
Expand Down
14 changes: 3 additions & 11 deletions docs/Users_Guide/tc-rmw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,19 @@ The **n_azimuth** parameter is the number of equally spaced azimuth intervals in

_______________________

.. code-block:: none
max_range_km = 100.0;
The **max_range_km** parameter specifies the maximum range of the range-azimuth grid, in kilometers. If this parameter is specified and not **rmw_scale**, the radial grid spacing will be **max_range_km / n_range**.

_______________________

.. code-block:: none
delta_range_km = 10.0;
The **delta_range_km** parameter specifies the spacing of the range rings, in kilometers.
The **delta_range_km** parameter specifies the spacing of the range rings, in kilometers. The range values start with 0 km and extend out to **n_range - 1** times this delta spacing.

_______________________

.. code-block:: none
rmw_scale = 0.2;
rmw_scale = NA;
The **rmw_scale** parameter overrides the **max_range_km** parameter. When this is set the radial grid spacing will be **rmw_scale** in units of the RMW, which varies along the storm track.
If changed from its default value of **NA**, the **rmw_scale** parameter overrides the **delta_range_km** parameter. The radial grid spacing is defined using **rmw_scale** in units of the RMW, which varies along the storm track. For example, setting **rmw_scale** to 0.2 would define the delta range spacing as 20% of the radius of maximum winds around each point. Note that RMW is defined in nautical miles but is converted to kilometers for this computation.

_______________________

Expand Down
3 changes: 1 addition & 2 deletions internal/test_unit/config/TCRMWConfig_gonzalo
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ regrid = {
//
n_range = 50;
n_azimuth = 90;
max_range_km = 1000.0;
delta_range_km = 10.0;
rmw_scale = 0.2;
rmw_scale = NA;

//
// Optionally convert u/v winds to tangential/radial winds
Expand Down
3 changes: 1 addition & 2 deletions internal/test_unit/config/TCRMWConfig_pressure_lev_out
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ regrid = {
//
n_range = 100;
n_azimuth = 180;
max_range_km = 1000.0;
delta_range_km = 10.0;
delta_range_km = NA;
rmw_scale = 0.2;

//
Expand Down
1 change: 0 additions & 1 deletion src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,6 @@ static const char conf_key_nc_pairs_grid[] = "nc_pairs_grid";

static const char conf_key_n_range[] = "n_range";
static const char conf_key_n_azimuth[] = "n_azimuth";
static const char conf_key_max_range[] = "max_range_km";
static const char conf_key_delta_range[] = "delta_range_km";
static const char conf_key_rmw_scale[] = "rmw_scale";
static const char conf_key_compute_tangential_and_radial_winds[] = "compute_tangential_and_radial_winds";
Expand Down
5 changes: 3 additions & 2 deletions src/libcode/vx_grid/tcrmw_grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ RLLD.rot_lat_ll = 90.0 - range_max_deg;
RLLD.rot_lon_ll = 0.0;

RLLD.delta_rot_lat = range_max_deg/(Range_n - 1);
// RLLD.delta_rot_lon = 360.0/Azimuth_n;
RLLD.delta_rot_lon = 360.0/(Azimuth_n - 1);

// MET #2833 divide by n rather than n-1 for the azimuth increment
RLLD.delta_rot_lon = 360.0/Azimuth_n;

RLLD.Nlat = Range_n;
RLLD.Nlon = Azimuth_n;
Expand Down
4 changes: 2 additions & 2 deletions src/libcode/vx_grid/tcrmw_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TcrmwGrid : public RotatedLatLonGrid {
int azimuth_n () const;

double range_max_km () const;
double range_delta_km () const; // Range_Max_km/Range_n
double range_delta_km () const; // Range_max_km/(Range_n - 1)

double azimuth_delta_deg () const; // 360.0/Azimuth_n

Expand Down Expand Up @@ -117,7 +117,7 @@ inline int TcrmwGrid::azimuth_n () const { return ( Azimuth_n ); }

inline double TcrmwGrid::range_max_km () const { return ( Range_max_km ); }

inline double TcrmwGrid::range_delta_km () const { return ( Range_max_km/Range_n ); }
inline double TcrmwGrid::range_delta_km () const { return ( Range_max_km/(Range_n - 1) ); }

inline double TcrmwGrid::azimuth_delta_deg () const { return ( 360.0/Azimuth_n ); }

Expand Down
5 changes: 4 additions & 1 deletion src/tools/tc_utils/tc_diag/tc_diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Mod# Date Name Description
// ---- ---- ---- -----------
// 000 09/27/22 Halley Gotway New
// 001 03/11/24 Halley Gotway MET#2833 range/azimuth grid
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1557,7 +1558,9 @@ void TmpFileInfo::setup_nc_file(const DomainInfo &di,
// Set grid center
d.lat_center = pnt_ptr->lat();
d.lon_center = -1.0*pnt_ptr->lon(); // degrees east to west
d.range_max_km = di.delta_range_km * d.range_n;

// MET #2833 multiply by n-1 since the ranges begin at 0 km
d.range_max_km = di.delta_range_km * (d.range_n - 1);

// Instantiate the grid
grid_out.set(d);
Expand Down
26 changes: 20 additions & 6 deletions src/tools/tc_utils/tc_rmw/tc_rmw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main
// 003 09/28/22 Prestopnik MET #2227 Remove namspace std and netCDF from header files
// 004 04/26/23 Halley Gotway MET #2523 Reorder NetCDF dimensions
// 005 03/11/24 Halley Gotway MET #2833 range/azimuth grid
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -552,7 +553,13 @@ void setup_grid() {
grid_data.name = "TCRMW";
grid_data.range_n = conf_info.n_range;
grid_data.azimuth_n = conf_info.n_azimuth;
grid_data.range_max_km = conf_info.max_range_km;

// Define the maximum range in km based on the fixed increment
if(is_bad_data(conf_info.rmw_scale)) {
grid_data.range_max_km =
conf_info.delta_range_km *
(conf_info.n_range - 1);
}

tcrmw_grid.set_from_data(grid_data);
grid.set(grid_data);
Expand Down Expand Up @@ -591,8 +598,9 @@ void setup_nc_file() {
lead_time_str_var, lead_time_sec_var);

// Define range and azimuth dimensions
def_tc_range_azimuth(nc_out, range_dim, azimuth_dim, tcrmw_grid,
conf_info.rmw_scale);
def_tc_range_azimuth(nc_out,
range_dim, azimuth_dim,
tcrmw_grid, conf_info.rmw_scale);

// Define latitude and longitude arrays
def_tc_lat_lon(nc_out,
Expand Down Expand Up @@ -686,9 +694,15 @@ void process_fields(const TrackInfoArray& tracks) {
grid_data.lat_center = point.lat();
grid_data.lon_center = -1.0*point.lon(); // internal sign change

// RMW is same as mrd()
grid_data.range_max_km = conf_info.rmw_scale *
point.mrd() * tc_km_per_nautical_miles * conf_info.n_range;
// Define the maximum range in km relative to the radius of maximum winds
if(!is_bad_data(conf_info.rmw_scale)) {
grid_data.range_max_km =
conf_info.rmw_scale *
point.mrd() * tc_km_per_nautical_miles *
(conf_info.n_range - 1);
}

// Re-define the range/azimuth grid
tcrmw_grid.clear();
tcrmw_grid.set_from_data(grid_data);
grid.clear();
Expand Down
13 changes: 9 additions & 4 deletions src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void TCRMWConfInfo::clear() {

n_range = bad_data_int;
n_azimuth = bad_data_int;
max_range_km = bad_data_double;
delta_range_km = bad_data_double;
rmw_scale = bad_data_double;

Expand Down Expand Up @@ -173,15 +172,21 @@ void TCRMWConfInfo::process_config(GrdFileType ftype) {
// Conf: n_azimuth
n_azimuth = Conf.lookup_int(conf_key_n_azimuth);

// Conf: max_range
max_range_km = Conf.lookup_double(conf_key_max_range);

// Conf: delta_range
delta_range_km = Conf.lookup_double(conf_key_delta_range);

// Conf: rmw_scale
rmw_scale = Conf.lookup_double(conf_key_rmw_scale);

// Error check
if(is_bad_data(delta_range_km) && is_bad_data(rmw_scale)) {
mlog << Error << "\nTCRMWConfInfo::process_config() -> "
<< "the \"" << conf_key_delta_range << "\" and \""
<< conf_key_rmw_scale << "\" configuration options "
<< "cannot both be set to bad data.\n\n";
exit(1);
}

compute_tangential_and_radial_winds = Conf.lookup_bool(conf_key_compute_tangential_and_radial_winds);
u_wind_field_name = Conf.lookup_string(conf_key_u_wind_field_name);
v_wind_field_name = Conf.lookup_string(conf_key_v_wind_field_name);
Expand Down
1 change: 0 additions & 1 deletion src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class TCRMWConfInfo {
// Range/Azimuth information
int n_range;
int n_azimuth;
double max_range_km;
double delta_range_km;
double rmw_scale;

Expand Down

0 comments on commit c6ac1cd

Please sign in to comment.