Skip to content

Commit

Permalink
Per #3024, update Grid-Stat to write 4 new columns to the GRAD line t…
Browse files Browse the repository at this point in the history
…ype.
  • Loading branch information
JohnHalleyGotway committed Nov 22, 2024
1 parent 28091e3 commit a6f7213
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 11 deletions.
1 change: 1 addition & 0 deletions data/table_files/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
tablefilesdir = $(pkgdatadir)/table_files
tablefiles_DATA = \
met_header_columns_V12.1.txt \
met_header_columns_V12.0.txt \
met_header_columns_V11.1.txt \
met_header_columns_V11.0.txt \
Expand Down
2 changes: 1 addition & 1 deletion data/table_files/met_header_columns_V12.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ V12.1 : STAT : SEEPS_MPR : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_V
V12.1 : STAT : NBRCNT : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FBS FBS_BCL FBS_BCU FSS FSS_BCL FSS_BCU AFSS AFSS_BCL AFSS_BCU UFSS UFSS_BCL UFSS_BCU F_RATE F_RATE_BCL F_RATE_BCU O_RATE O_RATE_BCL O_RATE_BCU
V12.1 : STAT : NBRCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FY_OY FY_ON FN_OY FN_ON
V12.1 : STAT : NBRCTS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL BASER BASER_NCL BASER_NCU BASER_BCL BASER_BCU FMEAN FMEAN_NCL FMEAN_NCU FMEAN_BCL FMEAN_BCU ACC ACC_NCL ACC_NCU ACC_BCL ACC_BCU FBIAS FBIAS_BCL FBIAS_BCU PODY PODY_NCL PODY_NCU PODY_BCL PODY_BCU PODN PODN_NCL PODN_NCU PODN_BCL PODN_BCU POFD POFD_NCL POFD_NCU POFD_BCL POFD_BCU FAR FAR_NCL FAR_NCU FAR_BCL FAR_BCU CSI CSI_NCL CSI_NCU CSI_BCL CSI_BCU GSS GSS_BCL GSS_BCU HK HK_NCL HK_NCU HK_BCL HK_BCU HSS HSS_BCL HSS_BCU ODDS ODDS_NCL ODDS_NCU ODDS_BCL ODDS_BCU LODDS LODDS_NCL LODDS_NCU LODDS_BCL LODDS_BCU ORSS ORSS_NCL ORSS_NCU ORSS_BCL ORSS_BCU EDS EDS_NCL EDS_NCU EDS_BCL EDS_BCU SEDS SEDS_NCL SEDS_NCU SEDS_BCL SEDS_BCU EDI EDI_NCL EDI_NCU EDI_BCL EDI_BCU SEDI SEDI_NCL SEDI_NCU SEDI_BCL SEDI_BCU BAGSS BAGSS_BCL BAGSS_BCU
V12.1 : STAT : GRAD : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FGBAR OGBAR MGBAR EGBAR S1 S1_OG FGOG_RATIO DX DY
V12.1 : STAT : GRAD : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FGBAR OGBAR MGBAR EGBAR S1 S1_OG FGOG_RATIO DX DY FGMAG OGMAG MAG_RMSE LAPLACE_RMSE
V12.1 : STAT : DMAP : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FY OY FBIAS BADDELEY HAUSDORFF MED_FO MED_OF MED_MIN MED_MAX MED_MEAN FOM_FO FOM_OF FOM_MIN FOM_MAX FOM_MEAN ZHU_FO ZHU_OF ZHU_MIN ZHU_MAX ZHU_MEAN G GBETA BETA_VALUE
V12.1 : STAT : ORANK : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL INDEX OBS_SID OBS_LAT OBS_LON OBS_LVL OBS_ELV OBS PIT RANK N_ENS_VLD (N_ENS) ENS_[0-9]* OBS_QC ENS_MEAN OBS_CLIMO_MEAN SPREAD ENS_MEAN_OERR SPREAD_OERR SPREAD_PLUS_OERR OBS_CLIMO_STDEV FCST_CLIMO_MEAN FCST_CLIMO_STDEV
V12.1 : STAT : PCT : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL (N_THRESH) THRESH_[0-9]* OY_[0-9]* ON_[0-9]*
Expand Down
12 changes: 12 additions & 0 deletions docs/Users_Guide/grid-stat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,18 @@ The format of the STAT and ASCII output of the Grid-Stat tool are the same as th
* - 34
- DY
- Gradient size in the Y-direction
* - 35
- FGMAG
- Magnitude of the forecast gradient when the X and Y-directions are interpreted as a vector
* - 36
- OGMAG
- Magnitude of the observed gradient when the X and Y-directions are intrepreted as a vector
* - 37
- MAG_RMSE
- Root mean squared difference of the forecast gradient magnitude minus the observed gradient magnitude
* - 38
- LAPLACE_RMSE
- Root mean squared difference of the sum of the forecast X and Y-gradients minus the sum of the observed forecast X and Y-gradients

.. _table_GS_format_info_DMAP:

Expand Down
2 changes: 1 addition & 1 deletion internal/test_unit/hdr/met_12_1.hdr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SEEPS_MPR : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L
NBRCNT : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FBS FBS_BCL FBS_BCU FSS FSS_BCL FSS_BCU AFSS AFSS_BCL AFSS_BCU UFSS UFSS_BCL UFSS_BCU F_RATE F_RATE_BCL F_RATE_BCU O_RATE O_RATE_BCL O_RATE_BCU
NBRCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FY_OY FY_ON FN_OY FN_ON
NBRCTS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL BASER BASER_NCL BASER_NCU BASER_BCL BASER_BCU FMEAN FMEAN_NCL FMEAN_NCU FMEAN_BCL FMEAN_BCU ACC ACC_NCL ACC_NCU ACC_BCL ACC_BCU FBIAS FBIAS_BCL FBIAS_BCU PODY PODY_NCL PODY_NCU PODY_BCL PODY_BCU PODN PODN_NCL PODN_NCU PODN_BCL PODN_BCU POFD POFD_NCL POFD_NCU POFD_BCL POFD_BCU FAR FAR_NCL FAR_NCU FAR_BCL FAR_BCU CSI CSI_NCL CSI_NCU CSI_BCL CSI_BCU GSS GSS_BCL GSS_BCU HK HK_NCL HK_NCU HK_BCL HK_BCU HSS HSS_BCL HSS_BCU ODDS ODDS_NCL ODDS_NCU ODDS_BCL ODDS_BCU LODDS LODDS_NCL LODDS_NCU LODDS_BCL LODDS_BCU ORSS ORSS_NCL ORSS_NCU ORSS_BCL ORSS_BCU EDS EDS_NCL EDS_NCU EDS_BCL EDS_BCU SEDS SEDS_NCL SEDS_NCU SEDS_BCL SEDS_BCU EDI EDI_NCL EDI_NCU EDI_BCL EDI_BCU SEDI SEDI_NCL SEDI_NCU SEDI_BCL SEDI_BCU BAGSS BAGSS_BCL BAGSS_BCU
GRAD : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FGBAR OGBAR MGBAR EGBAR S1 S1_OG FGOG_RATIO DX DY
GRAD : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FGBAR OGBAR MGBAR EGBAR S1 S1_OG FGOG_RATIO DX DY FGMAG OGMAG MAG_RMSE LAPLACE_RMSE
DMAP : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FY OY FBIAS BADDELEY HAUSDORFF MED_FO MED_OF MED_MIN MED_MAX MED_MEAN FOM_FO FOM_OF FOM_MIN FOM_MAX FOM_MEAN ZHU_FO ZHU_OF ZHU_MIN ZHU_MAX ZHU_MEAN G GBETA BETA_VALUE
ORANK : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL INDEX OBS_SID OBS_LAT OBS_LON OBS_LVL OBS_ELV OBS PIT RANK N_ENS_VLD N_ENS _VAR_
PCT : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL N_THRESH _VAR_
Expand Down
4 changes: 3 additions & 1 deletion src/basic/vx_util/stat_column_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ static const char * const grad_columns [] = {
"TOTAL",
"FGBAR", "OGBAR", "MGBAR",
"EGBAR", "S1", "S1_OG",
"FGOG_RATIO", "DX", "DY"
"FGOG_RATIO", "DX", "DY",
"FGMAG", "OGMAG", "MAG_RMSE",
"LAPLACE_RMSE"
};

static const char * const dmap_columns [] = {
Expand Down
16 changes: 15 additions & 1 deletion src/libcode/vx_stat_out/stat_columns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3976,7 +3976,9 @@ void write_grad_cols(const GRADInfo &grad_info,
// TOTAL,
// FGBAR, OGBAR, MGBAR,
// EGBAR, S1, S1_OG,
// FGOG_RATIO, DX, DY
// FGOG_RATIO, DX, DY,
// FGMAG, OGMAG, MAG_RMSE,
// LAPLACE_RMSE
//
at.set_entry(r, c+0, // Total Count
grad_info.total);
Expand Down Expand Up @@ -4008,6 +4010,18 @@ void write_grad_cols(const GRADInfo &grad_info,
at.set_entry(r, c+9, // DY
grad_info.dy);

at.set_entry(r, c+10, // FGMAG
grad_info.fgmag);

at.set_entry(r, c+11, // OGMAG
grad_info.ogmag);

at.set_entry(r, c+12, // MAG_RMSE
grad_info.magnitude_rmse());

at.set_entry(r, c+13, // LAPLACE_RMSE
grad_info.laplace_rmse());

return;
}

Expand Down
48 changes: 43 additions & 5 deletions src/libcode/vx_statistics/met_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3656,6 +3656,11 @@ GRADInfo & GRADInfo::operator+=(const GRADInfo &c) {
g_info.ogbar = (ogbar*total + c.ogbar*c.total) / g_info.total;
g_info.mgbar = (mgbar*total + c.mgbar*c.total) / g_info.total;
g_info.egbar = (egbar*total + c.egbar*c.total) / g_info.total;

g_info.fgmag = (fgmag*total + c.fgmag*c.total) / g_info.total;
g_info.ogmag = (ogmag*total + c.ogmag*c.total) / g_info.total;
g_info.mag_mse = (mag_mse*total + c.mag_mse*c.total) / g_info.total;
g_info.lap_mse = (lap_mse*total + c.lap_mse*c.total) / g_info.total;
}

assign(g_info);
Expand All @@ -3676,10 +3681,12 @@ void GRADInfo::init_from_scratch() {

void GRADInfo::clear() {

dx = dy = 0;
fgbar = ogbar = 0.0;
mgbar = egbar = 0.0;
total = 0;
total = 0;
dx = dy = 0;
fgbar = ogbar = 0.0;
mgbar = egbar = 0.0;
fgmag = ogmag = 0.0;
mag_mse = lap_mse = 0.0;

return;
}
Expand All @@ -3690,6 +3697,8 @@ void GRADInfo::assign(const GRADInfo &c) {

clear();

total = c.total;

// Gradient sizes
dx = c.dx;
dy = c.dy;
Expand All @@ -3699,7 +3708,12 @@ void GRADInfo::assign(const GRADInfo &c) {
ogbar = c.ogbar;
mgbar = c.mgbar;
egbar = c.egbar;
total = c.total;

// Gradient vector partial sums
fgmag = c.fgmag;
ogmag = c.ogmag;
mag_mse = c.mag_mse;
lap_mse = c.lap_mse;

return;
}
Expand Down Expand Up @@ -3751,6 +3765,17 @@ double GRADInfo::fgog_ratio() const {

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

double GRADInfo::magnitude_rmse() const {
return square_root(mag_mse);
}

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

double GRADInfo::laplace_rmse() const {
return square_root(lap_mse);
}
////////////////////////////////////////////////////////////////////////

void GRADInfo::set(int grad_dx, int grad_dy,
const NumArray &fgx_na, const NumArray &fgy_na,
const NumArray &ogx_na, const NumArray &ogy_na,
Expand Down Expand Up @@ -3795,12 +3820,25 @@ void GRADInfo::set(int grad_dx, int grad_dy,
wgt = wgt_na[i]/wgt_sum;

// Gradient sums
// JHG, I suspect this implementation may be very wrong!
fgbar += wgt * (fabs(fgx_na[i]) + fabs(fgy_na[i]));
ogbar += wgt * (fabs(ogx_na[i]) + fabs(ogy_na[i]));
mgbar += wgt * (max(fabs(fgx_na[i]), fabs(ogx_na[i])) +
max(fabs(fgy_na[i]), fabs(ogy_na[i])));
egbar += wgt * (fabs(fgx_na[i] - ogx_na[i]) +
fabs(fgy_na[i] - ogy_na[i]));

// Gradient vector magnitude
double fmag = square_root(fgx_na[i] * fgx_na[i] + fgy_na[i] * fgy_na[i]);
double omag = square_root(ogx_na[i] * ogx_na[i] + ogy_na[i] * ogy_na[i]);

// Gradient vector sums
fgmag += wgt * fmag;
ogmag += wgt * omag;
mag_mse += wgt * (fmag - omag)*(fmag - omag);
// TODO: confirm the algorithm for laplace_rmse
double diff = (fgx_na[i] + fgy_na[i]) - (ogx_na[i] - ogy_na[i]);
lap_mse += wgt * (diff * diff);
total++;
}

Expand Down
13 changes: 11 additions & 2 deletions src/libcode/vx_statistics/met_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,24 @@ class GRADInfo {
int dx;
int dy;

// Gradient Partial Sums
int total;
// Number of pairs
int total;

// Gradient Partial sums
double fgbar, ogbar, mgbar, egbar;

// Gradient Vector Partial Sums
double fgmag, ogmag;
double mag_mse, lap_mse;

// Gradient Statistics
double s1() const; // s1 = 100 * egbar / mgbar
double s1_og() const; // s1_og = 100 * egbar / ogbar
double fgog_ratio() const; // fgog_ratio = fgbar / ogbar

double magnitude_rmse() const;
double laplace_rmse() const;

// Compute sums
void set(int grad_dx, int grad_dy,
const NumArray &fgx_na, const NumArray &fgy_na,
Expand Down
12 changes: 12 additions & 0 deletions src/tools/core/stat_analysis/parse_stat_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ void parse_grad_line(STATLine &l, GRADInfo &grad_info) {
grad_info.egbar = atof(l.get_item("EGBAR"));
grad_info.dx = atoi(l.get_item("DX"));
grad_info.dy = atoi(l.get_item("DY"));
grad_info.fgmag = atof(l.get_item("FGMAG"));
grad_info.ogmag = atof(l.get_item("OGMAG"));

double mag_rmse = atof(l.get_item("MAG_RMSE"));
grad_info.mag_mse = (is_bad_data(mag_rmse) ?
bad_data_double :
mag_rmse * mag_rmse);

double lap_rmse = atof(l.get_item("LAPLACE_RMSE"));
grad_info.lap_mse = (is_bad_data(lap_rmse) ?
bad_data_double :
lap_rmse * lap_rmse);

return;
}
Expand Down

0 comments on commit a6f7213

Please sign in to comment.