Skip to content

Commit

Permalink
Bugfix #3020 develop grid_stat_seeps (#3021)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JohnHalleyGotway authored Nov 20, 2024
1 parent 5767e25 commit 80054d2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
3 changes: 1 addition & 2 deletions docs/Users_Guide/appendixA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf\
-conventions.html>`_
<https://cfconventions.org/cf-conventions/cf-conventions.html>`_

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,
Expand Down
8 changes: 4 additions & 4 deletions docs/Users_Guide/data_io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#standard-name>`_" and "`units <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#units>`_" attributes for coordinate variables. The "`axis <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#time-axis-ex>`_" attribute ("T" or "time") must exist as the time variable if the "standard_name" attribute does not exist.
2. The "`standard_name <https://cfconventions.org/cf-conventions/cf-conventions.html#standard-name>`_" and "`units <https://cfconventions.org/cf-conventions/cf-conventions.html#units>`_" attributes for coordinate variables. The "`axis <https://cfconventions.org/cf-conventions/cf-conventions.html#time-axis-ex>`_" attribute ("T" or "time") must exist as the time variable if the "standard_name" attribute does not exist.

3. The "`coordinates <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#coordinate-types>`_" attribute for the data variables. It contains the coordinate variable names.
3. The "`coordinates <https://cfconventions.org/cf-conventions/cf-conventions.html#coordinate-types>`_" attribute for the data variables. It contains the coordinate variable names.

4. The "`grid_mapping <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#appendix-grid-mappings>`_" 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 <https://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings>`_" 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 <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#scalar-coordinate-variables>`_" variable for init_time.
6. (Optional) the "`forecast_reference_time <https://cfconventions.org/cf-conventions/cf-conventions.html#scalar-coordinate-variables>`_" 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-<Version_number>"). 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".

Expand Down
36 changes: 25 additions & 11 deletions src/tools/core/grid_stat/grid_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/tools/core/grid_stat/grid_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/tools/core/grid_stat/grid_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80054d2

Please sign in to comment.