From 80054d2462687f3b75680afe8c2a4151d5a7053c Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 20 Nov 2024 09:47:43 -0700 Subject: [PATCH] Bugfix #3020 develop grid_stat_seeps (#3021) * Per #3020, add missing GridStatNcOutInfo::do_seeps flag and use it to determine if SEEPS information should be written to the Grid-Stat NetCDF matched pairs output file. * Unrelated to #3020, fix broken NetCDF cf-conventions links in the User's Guide. * Per #3020, no real changes. Just whitespace --- docs/Users_Guide/appendixA.rst | 3 +- docs/Users_Guide/data_io.rst | 8 ++--- src/tools/core/grid_stat/grid_stat.cc | 36 +++++++++++++------ .../core/grid_stat/grid_stat_conf_info.cc | 12 ++++--- .../core/grid_stat/grid_stat_conf_info.h | 1 + 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/docs/Users_Guide/appendixA.rst b/docs/Users_Guide/appendixA.rst index 384422af1f..5f7a861ae0 100644 --- a/docs/Users_Guide/appendixA.rst +++ b/docs/Users_Guide/appendixA.rst @@ -139,8 +139,7 @@ Q. What types of NetCDF files can MET read? the wrf_interp utility 3. NetCDF data following the `climate-forecast (CF) convention - `_ + `_ Lastly, users can write python scripts to pass data that's gridded to the MET tools in memory. If the data doesn't fall into one of those categories, diff --git a/docs/Users_Guide/data_io.rst b/docs/Users_Guide/data_io.rst index bc67895b94..0221cc7888 100644 --- a/docs/Users_Guide/data_io.rst +++ b/docs/Users_Guide/data_io.rst @@ -26,15 +26,15 @@ The MET tools use following attributes and variables for input "`CF Compliant Ne 1. The global attribute "Conventions". -2. The "`standard_name `_" and "`units `_" attributes for coordinate variables. The "`axis `_" attribute ("T" or "time") must exist as the time variable if the "standard_name" attribute does not exist. +2. The "`standard_name `_" and "`units `_" attributes for coordinate variables. The "`axis `_" attribute ("T" or "time") must exist as the time variable if the "standard_name" attribute does not exist. -3. The "`coordinates `_" attribute for the data variables. It contains the coordinate variable names. +3. The "`coordinates `_" attribute for the data variables. It contains the coordinate variable names. -4. The "`grid_mapping `_" attribute for the data variables for projections and the matching grid mapping variable (optional for latitude_longitude and rotated_latitude_longitude projections). +4. The "`grid_mapping `_" attribute for the data variables for projections and the matching grid mapping variable (optional for latitude_longitude and rotated_latitude_longitude projections). 5. The gridded data should be evenly spaced horizontally and vertically. -6. (Optional) the "`forecast_reference_time `_" variable for init_time. +6. (Optional) the "`forecast_reference_time `_" variable for init_time. MET processes the CF-Compliant gridded NetCDF files with the projection information. The CF-Compliant NetCDF is defined by the global attribute "Conventions" whose value begins with "CF-" ("CF-"). The global attribute "Conventions" is mandatory. MET accepts the variation of this attribute ("conventions" and "CONVENTIONS"). The value should be started with "CF-" and followed by the version number. MET accepts the attribute value that begins with "CF " ("CF" and a space instead of a hyphen) or "COARDS". diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 45afc74615..a1c43f0824 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -114,6 +114,7 @@ // 056 01/29/24 Halley Gotway MET #2801 Configure time difference warnings. // 057 07/05/24 Halley Gotway MET #2924 Support forecast climatology. // 058 10/03/24 Halley Gotway MET #2887 Compute weighted contingency tables. +// 059 11/15/24 Halley Gotway MET #3020 SEEPS NetCDF output. // //////////////////////////////////////////////////////////////////////// @@ -1267,23 +1268,36 @@ void process_scores() { SeepsAggScore seeps_agg; int month, day, year, hour, minute, second; + // Compute SEEPS statistics unix_to_mdyhms(fcst_dp.valid(), month, day, year, hour, minute, second); compute_aggregated_seeps_grid(fcst_dp_smooth, obs_dp_smooth, seeps_dp, seeps_dp_fcat, seeps_dp_ocat, &seeps_agg, month, hour, conf_info.seeps_p1_thresh, conf_info.seeps_climo_name); - write_nc("SEEPS_MPR_SCORE", seeps_dp, - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - write_nc("SEEPS_MPR_FCAT", seeps_dp_fcat, - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - write_nc("SEEPS_MPR_OCAT", seeps_dp_ocat, - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - write_seeps_row(shc, &seeps_agg, conf_info.output_flag[i_seeps], - stat_at, i_stat_row, txt_at[i_seeps], i_txt_row[i_seeps]); + // Write out SEEPS + if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType::None && + seeps_agg.n_obs > 0) { + + write_seeps_row(shc, &seeps_agg, + conf_info.output_flag[i_seeps], + stat_at, i_stat_row, + txt_at[i_seeps], i_txt_row[i_seeps]); + } + + // MET #3020 + // Write out the SEEPS data if requested in the config file + if(conf_info.vx_opt[i].nc_info.do_seeps) { + write_nc("SEEPS_MPR_SCORE", seeps_dp, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + write_nc("SEEPS_MPR_FCAT", seeps_dp_fcat, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + write_nc("SEEPS_MPR_OCAT", seeps_dp_ocat, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } } // Compute gradient statistics if requested in the config file diff --git a/src/tools/core/grid_stat/grid_stat_conf_info.cc b/src/tools/core/grid_stat/grid_stat_conf_info.cc index d334804850..f9b704e455 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -359,6 +359,7 @@ void GridStatConfInfo::process_flags() { if(vx_opt[i].nc_info.do_diff) nc_info.do_diff = true; if(vx_opt[i].nc_info.do_climo) nc_info.do_climo = true; if(vx_opt[i].nc_info.do_climo_cdp) nc_info.do_climo_cdp = true; + if(vx_opt[i].nc_info.do_seeps) nc_info.do_seeps = true; if(vx_opt[i].nc_info.do_weight) nc_info.do_weight = true; if(vx_opt[i].nc_info.do_nbrhd) nc_info.do_nbrhd = true; if(vx_opt[i].nc_info.do_fourier) nc_info.do_fourier = true; @@ -987,6 +988,7 @@ void GridStatVxOpt::parse_nc_info(Dictionary &odict) { nc_info.do_diff = d->lookup_bool(conf_key_diff_flag); nc_info.do_climo = d->lookup_bool(conf_key_climo_flag); nc_info.do_climo_cdp = d->lookup_bool(conf_key_climo_cdp_flag); + nc_info.do_seeps = d->lookup_bool(conf_key_seeps_flag); nc_info.do_weight = d->lookup_bool(conf_key_weight); nc_info.do_nbrhd = d->lookup_bool(conf_key_nbrhd); nc_info.do_fourier = d->lookup_bool(conf_key_fourier); @@ -1310,10 +1312,10 @@ void GridStatNcOutInfo::clear() { bool GridStatNcOutInfo::all_false() const { - bool status = do_latlon || do_raw || do_diff || - do_climo || do_climo_cdp || do_weight || - do_nbrhd || do_fourier || do_gradient || - do_distance_map || do_apply_mask; + bool status = do_latlon || do_raw || do_diff || + do_climo || do_climo_cdp || do_seeps || + do_weight || do_nbrhd || do_fourier || + do_gradient || do_distance_map || do_apply_mask; return !status; } @@ -1327,6 +1329,7 @@ void GridStatNcOutInfo::set_all_false() { do_diff = false; do_climo = false; do_climo_cdp = false; + do_seeps = false; do_weight = false; do_nbrhd = false; do_fourier = false; @@ -1346,6 +1349,7 @@ void GridStatNcOutInfo::set_all_true() { do_diff = true; do_climo = true; do_climo_cdp = true; + do_seeps = true; do_weight = true; do_nbrhd = true; do_fourier = true; diff --git a/src/tools/core/grid_stat/grid_stat_conf_info.h b/src/tools/core/grid_stat/grid_stat_conf_info.h index c3e72ee3a4..e24326c7cd 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.h +++ b/src/tools/core/grid_stat/grid_stat_conf_info.h @@ -106,6 +106,7 @@ struct GridStatNcOutInfo { bool do_diff; bool do_climo; bool do_climo_cdp; + bool do_seeps; bool do_weight; bool do_nbrhd; bool do_fourier;