From d8572b9aac058efb5fa602d82b9bfd551b6943d9 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 2 Feb 2024 16:58:42 +0000 Subject: [PATCH 001/114] 2673 Moved dvariable declaration after include --- src/basic/enum_to_string/enum_to_string.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/basic/enum_to_string/enum_to_string.cc b/src/basic/enum_to_string/enum_to_string.cc index 0045f23735..1e7a1f31d7 100644 --- a/src/basic/enum_to_string/enum_to_string.cc +++ b/src/basic/enum_to_string/enum_to_string.cc @@ -10,12 +10,6 @@ //////////////////////////////////////////////////////////////////////// -static const int debug = 0; - - -//////////////////////////////////////////////////////////////////////// - - #include #include @@ -36,6 +30,12 @@ static const int debug = 0; using namespace std; +//////////////////////////////////////////////////////////////////////// + + +static const int debug = 0; + + //////////////////////////////////////////////////////////////////////// From 6ebfdac2b17fbe842e51e52bd27ea04a42ee5658 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 2 Feb 2024 17:41:26 +0000 Subject: [PATCH 002/114] #2673 Move down namespace below include --- src/basic/enum_to_string/info.cc | 4 ++-- src/basic/vx_config/grdfiletype_to_string.cc | 8 ++++---- src/basic/vx_log/concat_string.cc | 4 ++-- src/basic/vx_log/file_fxns.cc | 5 +++-- src/basic/vx_log/indent.cc | 4 ++-- src/basic/vx_log/str_wrappers.cc | 4 ++-- src/basic/vx_log/string_array.cc | 6 +++--- src/basic/vx_math/affine.cc | 6 +++--- src/basic/vx_math/hist.cc | 7 +++---- src/basic/vx_math/legendre.cc | 8 ++------ src/basic/vx_math/nint.cc | 7 +++---- src/basic/vx_math/nti.cc | 5 ++--- src/basic/vx_math/ptile.cc | 7 +++---- src/basic/vx_math/pwl.cc | 6 +++--- src/basic/vx_math/viewgravity_to_string.cc | 6 +++--- src/basic/vx_math/vx_vector.cc | 8 ++------ src/basic/vx_util/ascii_header.cc | 4 ++-- src/basic/vx_util/ascii_table.cc | 4 ++-- src/basic/vx_util/asciitablejust_to_string.cc | 7 +++---- src/basic/vx_util/check_endian.cc | 5 ++--- src/basic/vx_util/comma_string.cc | 7 +++---- src/basic/vx_util/command_line.cc | 4 ++-- src/basic/vx_util/conversions.cc | 4 ++-- src/basic/vx_util/data_cube.cc | 4 ++-- src/basic/vx_util/data_line.cc | 5 ++--- src/basic/vx_util/data_plane.cc | 4 ++-- src/basic/vx_util/data_plane_util.cc | 4 ++-- src/basic/vx_util/file_exists.cc | 6 ++---- src/basic/vx_util/file_linecount.cc | 8 ++------ src/basic/vx_util/file_size.cc | 8 ++------ src/basic/vx_util/filename_suffix.cc | 4 ++-- src/basic/vx_util/fix_float.cc | 5 ++--- src/basic/vx_util/get_filenames.cc | 5 ++--- src/basic/vx_util/grib_constants.cc | 4 ++-- src/basic/vx_util/interp_mthd.cc | 4 ++-- src/basic/vx_util/interp_util.cc | 4 ++-- src/basic/vx_util/is_number.cc | 7 +++---- src/basic/vx_util/long_array.cc | 10 +++------- src/basic/vx_util/main.cc | 4 ++-- src/basic/vx_util/make_path.cc | 5 ++--- src/basic/vx_util/mask_poly.cc | 4 ++-- src/basic/vx_util/memory.cc | 4 ++-- src/basic/vx_util/met_buffer.cc | 5 ++--- src/basic/vx_util/normalize.cc | 4 ++-- src/basic/vx_util/num_array.cc | 6 ++---- src/basic/vx_util/observation.cc | 4 ++-- src/basic/vx_util/ordinal.cc | 7 +++---- src/basic/vx_util/polyline.cc | 4 ++-- src/basic/vx_util/python_line.cc | 6 +++--- src/basic/vx_util/read_fortran_binary.cc | 5 ++--- src/basic/vx_util/roman_numeral.cc | 5 ++--- src/basic/vx_util/smart_buffer.cc | 8 ++------ src/basic/vx_util/string_fxns.cc | 7 +++---- src/basic/vx_util/substring.cc | 7 +++---- src/basic/vx_util/thresh_array.cc | 4 ++-- src/basic/vx_util/two_to_one.cc | 4 ++-- src/basic/vx_util_math/so3.cc | 6 ++---- 57 files changed, 132 insertions(+), 179 deletions(-) diff --git a/src/basic/enum_to_string/info.cc b/src/basic/enum_to_string/info.cc index 224ea9df07..48aa93e67e 100644 --- a/src/basic/enum_to_string/info.cc +++ b/src/basic/enum_to_string/info.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "info.h" #include "str_wrappers.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/grdfiletype_to_string.cc b/src/basic/vx_config/grdfiletype_to_string.cc index e82450caf8..6a2140927e 100644 --- a/src/basic/vx_config/grdfiletype_to_string.cc +++ b/src/basic/vx_config/grdfiletype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "grdfiletype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ ConcatString grdfiletype_to_string(const GrdFileType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/basic/vx_log/concat_string.cc b/src/basic/vx_log/concat_string.cc index ff9e9c1701..5208644928 100644 --- a/src/basic/vx_log/concat_string.cc +++ b/src/basic/vx_log/concat_string.cc @@ -18,12 +18,12 @@ #include #include -using namespace std; - #include "concat_string.h" #include "logger.h" #include "str_wrappers.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/file_fxns.cc b/src/basic/vx_log/file_fxns.cc index e3ac30e48f..c3bc9452ab 100644 --- a/src/basic/vx_log/file_fxns.cc +++ b/src/basic/vx_log/file_fxns.cc @@ -7,8 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,9 @@ using namespace std; #include "file_fxns.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// bool is_regular_file(const char *path) { diff --git a/src/basic/vx_log/indent.cc b/src/basic/vx_log/indent.cc index 918fca7020..4c1427b083 100644 --- a/src/basic/vx_log/indent.cc +++ b/src/basic/vx_log/indent.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "indent.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/str_wrappers.cc b/src/basic/vx_log/str_wrappers.cc index 4361388d71..dfe67d6b57 100644 --- a/src/basic/vx_log/str_wrappers.cc +++ b/src/basic/vx_log/str_wrappers.cc @@ -11,11 +11,11 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "logger.h" #include "str_wrappers.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/string_array.cc b/src/basic/vx_log/string_array.cc index 03116b5e3d..1a3f106800 100644 --- a/src/basic/vx_log/string_array.cc +++ b/src/basic/vx_log/string_array.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "indent.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/affine.cc b/src/basic/vx_math/affine.cc index f4899de86d..427755da1f 100644 --- a/src/basic/vx_math/affine.cc +++ b/src/basic/vx_math/affine.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/hist.cc b/src/basic/vx_math/hist.cc index d1eb05750c..90b28ea623 100644 --- a/src/basic/vx_math/hist.cc +++ b/src/basic/vx_math/hist.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/legendre.cc b/src/basic/vx_math/legendre.cc index 682ba30027..605378f10a 100644 --- a/src/basic/vx_math/legendre.cc +++ b/src/basic/vx_math/legendre.cc @@ -1,8 +1,5 @@ - - //////////////////////////////////////////////////////////////////////// - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -11,12 +8,9 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +19,8 @@ using namespace std; #include "legendre.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/nint.cc b/src/basic/vx_math/nint.cc index 76e4cb6780..a512a36668 100644 --- a/src/basic/vx_math/nint.cc +++ b/src/basic/vx_math/nint.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +18,9 @@ using namespace std; #include "nint.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/nti.cc b/src/basic/vx_math/nti.cc index 5c4c9b6003..e020832d93 100644 --- a/src/basic/vx_math/nti.cc +++ b/src/basic/vx_math/nti.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +18,8 @@ using namespace std; #include "nti.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/ptile.cc b/src/basic/vx_math/ptile.cc index 9812403a84..0ed5d97863 100644 --- a/src/basic/vx_math/ptile.cc +++ b/src/basic/vx_math/ptile.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - /////////////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +22,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/pwl.cc b/src/basic/vx_math/pwl.cc index 5e8fc7cb7f..c505db383a 100644 --- a/src/basic/vx_math/pwl.cc +++ b/src/basic/vx_math/pwl.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,9 @@ using namespace std; #include "is_bad_data.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/viewgravity_to_string.cc b/src/basic/vx_math/viewgravity_to_string.cc index ed8dbefb66..b1bc46c2a1 100644 --- a/src/basic/vx_math/viewgravity_to_string.cc +++ b/src/basic/vx_math/viewgravity_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "viewgravity_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/vx_vector.cc b/src/basic/vx_math/vx_vector.cc index fd6c7f0645..7833be1fe1 100644 --- a/src/basic/vx_math/vx_vector.cc +++ b/src/basic/vx_math/vx_vector.cc @@ -1,8 +1,5 @@ - - //////////////////////////////////////////////////////////////////////// - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -11,12 +8,9 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +21,8 @@ using namespace std; #include "trig.h" #include "vx_vector.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/ascii_header.cc b/src/basic/vx_util/ascii_header.cc index 27c1d69a1a..e7898b65cc 100644 --- a/src/basic/vx_util/ascii_header.cc +++ b/src/basic/vx_util/ascii_header.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "ascii_header.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // diff --git a/src/basic/vx_util/ascii_table.cc b/src/basic/vx_util/ascii_table.cc index d7e2640fa4..0725cde4e4 100644 --- a/src/basic/vx_util/ascii_table.cc +++ b/src/basic/vx_util/ascii_table.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,8 @@ using namespace std; #include "fix_float.h" #include "util_constants.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/asciitablejust_to_string.cc b/src/basic/vx_util/asciitablejust_to_string.cc index 3415941569..f5a42fde27 100644 --- a/src/basic/vx_util/asciitablejust_to_string.cc +++ b/src/basic/vx_util/asciitablejust_to_string.cc @@ -6,7 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -24,14 +23,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "asciitablejust_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/check_endian.cc b/src/basic/vx_util/check_endian.cc index 30c236f9c5..f0aa3d13c9 100644 --- a/src/basic/vx_util/check_endian.cc +++ b/src/basic/vx_util/check_endian.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +17,8 @@ using namespace std; #include "check_endian.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/comma_string.cc b/src/basic/vx_util/comma_string.cc index 4c27d13f23..c2e5d41516 100644 --- a/src/basic/vx_util/comma_string.cc +++ b/src/basic/vx_util/comma_string.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -23,6 +19,9 @@ using namespace std; #include "comma_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/command_line.cc b/src/basic/vx_util/command_line.cc index 73aab12b2b..81c12dd185 100644 --- a/src/basic/vx_util/command_line.cc +++ b/src/basic/vx_util/command_line.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "util_constants.h" #include "file_exists.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/conversions.cc b/src/basic/vx_util/conversions.cc index 4d77ea5427..e13a64eb95 100644 --- a/src/basic/vx_util/conversions.cc +++ b/src/basic/vx_util/conversions.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "util_constants.h" #include "is_bad_data.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// double convert_gpm_to_msl(double gpm, double lat) { diff --git a/src/basic/vx_util/data_cube.cc b/src/basic/vx_util/data_cube.cc index 646f477151..dcd295f70f 100644 --- a/src/basic/vx_util/data_cube.cc +++ b/src/basic/vx_util/data_cube.cc @@ -19,13 +19,13 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "data_cube.h" #include "vx_log.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// DataCube::DataCube() { diff --git a/src/basic/vx_util/data_line.cc b/src/basic/vx_util/data_line.cc index 2246dfbba4..43814d39b5 100644 --- a/src/basic/vx_util/data_line.cc +++ b/src/basic/vx_util/data_line.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -34,6 +31,8 @@ using namespace std; #include "python_line.h" #endif /* WITH_PYTHON */ +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/data_plane.cc b/src/basic/vx_util/data_plane.cc index a6d702f0b6..20ea713e42 100644 --- a/src/basic/vx_util/data_plane.cc +++ b/src/basic/vx_util/data_plane.cc @@ -20,8 +20,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include @@ -32,6 +30,8 @@ using namespace std; #include "vx_cal.h" #include "math_constants.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Begin Code for class DataPlane diff --git a/src/basic/vx_util/data_plane_util.cc b/src/basic/vx_util/data_plane_util.cc index e20c49712d..044c07dd11 100644 --- a/src/basic/vx_util/data_plane_util.cc +++ b/src/basic/vx_util/data_plane_util.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "GridTemplate.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Utility functions operating on a DataPlane diff --git a/src/basic/vx_util/file_exists.cc b/src/basic/vx_util/file_exists.cc index a51db6f164..59751bfd7c 100644 --- a/src/basic/vx_util/file_exists.cc +++ b/src/basic/vx_util/file_exists.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +22,8 @@ using namespace std; #include "file_exists.h" #include "empty_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/file_linecount.cc b/src/basic/vx_util/file_linecount.cc index 8ea6cd2637..a7a73b3a94 100644 --- a/src/basic/vx_util/file_linecount.cc +++ b/src/basic/vx_util/file_linecount.cc @@ -1,5 +1,3 @@ - - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -9,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +20,8 @@ using namespace std; #include "empty_string.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/file_size.cc b/src/basic/vx_util/file_size.cc index 485b1b1b52..60852927e7 100644 --- a/src/basic/vx_util/file_size.cc +++ b/src/basic/vx_util/file_size.cc @@ -1,5 +1,3 @@ - - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -9,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +22,8 @@ using namespace std; #include "file_size.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/filename_suffix.cc b/src/basic/vx_util/filename_suffix.cc index ebcf211bd9..cb7b916098 100644 --- a/src/basic/vx_util/filename_suffix.cc +++ b/src/basic/vx_util/filename_suffix.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "filename_suffix.h" #include "concat_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/fix_float.cc b/src/basic/vx_util/fix_float.cc index 1e39aaf7e3..0339cdcbe5 100644 --- a/src/basic/vx_util/fix_float.cc +++ b/src/basic/vx_util/fix_float.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +18,8 @@ using namespace std; #include "fix_float.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/get_filenames.cc b/src/basic/vx_util/get_filenames.cc index f8d1bb5d3f..df81b25d50 100644 --- a/src/basic/vx_util/get_filenames.cc +++ b/src/basic/vx_util/get_filenames.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +27,8 @@ using namespace std; #include "get_filenames.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/grib_constants.cc b/src/basic/vx_util/grib_constants.cc index 612db90eeb..f3fa9215e7 100644 --- a/src/basic/vx_util/grib_constants.cc +++ b/src/basic/vx_util/grib_constants.cc @@ -6,8 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; - /////////////////////////////////////////////////////////////////////////////// #include @@ -24,6 +22,8 @@ using namespace std; #include "grib_constants.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// bool is_precip_grib_code(int gc) { diff --git a/src/basic/vx_util/interp_mthd.cc b/src/basic/vx_util/interp_mthd.cc index 73a3dbc054..856627db95 100644 --- a/src/basic/vx_util/interp_mthd.cc +++ b/src/basic/vx_util/interp_mthd.cc @@ -8,8 +8,6 @@ /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -18,6 +16,8 @@ using namespace std; #include "interp_mthd.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// ConcatString interpmthd_to_string(const InterpMthd m) { diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index b28ecc40dd..dfad729e29 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // diff --git a/src/basic/vx_util/is_number.cc b/src/basic/vx_util/is_number.cc index 7daec912ee..0c9ad401d1 100644 --- a/src/basic/vx_util/is_number.cc +++ b/src/basic/vx_util/is_number.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +21,9 @@ using namespace std; #include "substring.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/long_array.cc b/src/basic/vx_util/long_array.cc index c0e493628c..330fd6a2e2 100644 --- a/src/basic/vx_util/long_array.cc +++ b/src/basic/vx_util/long_array.cc @@ -1,5 +1,3 @@ - - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -9,14 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -27,6 +20,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/main.cc b/src/basic/vx_util/main.cc index 5144ab5643..f75b648e3f 100644 --- a/src/basic/vx_util/main.cc +++ b/src/basic/vx_util/main.cc @@ -33,8 +33,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include @@ -43,6 +41,8 @@ using namespace std; #include "memory.h" #include "logger.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/make_path.cc b/src/basic/vx_util/make_path.cc index c6f207183a..badeed3d59 100644 --- a/src/basic/vx_util/make_path.cc +++ b/src/basic/vx_util/make_path.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +24,8 @@ using namespace std; #include "make_path.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/mask_poly.cc b/src/basic/vx_util/mask_poly.cc index 6a8f176c9f..8e0166d9ac 100644 --- a/src/basic/vx_util/mask_poly.cc +++ b/src/basic/vx_util/mask_poly.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/memory.cc b/src/basic/vx_util/memory.cc index a832b79840..26bcbf9b6c 100644 --- a/src/basic/vx_util/memory.cc +++ b/src/basic/vx_util/memory.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -18,6 +16,8 @@ using namespace std; #include "memory.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/met_buffer.cc b/src/basic/vx_util/met_buffer.cc index ef1e8c481c..5af20835a6 100644 --- a/src/basic/vx_util/met_buffer.cc +++ b/src/basic/vx_util/met_buffer.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +20,8 @@ using namespace std; #include "read_fortran_binary.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/normalize.cc b/src/basic/vx_util/normalize.cc index 831af6c6a1..1c17f0474f 100644 --- a/src/basic/vx_util/normalize.cc +++ b/src/basic/vx_util/normalize.cc @@ -8,8 +8,6 @@ /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -18,6 +16,8 @@ using namespace std; #include "normalize.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// ConcatString normalizetype_to_string(const NormalizeType type) { diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index 3b68d21978..d25e8bb034 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; -using namespace std; - #include #include #include @@ -28,6 +24,8 @@ using namespace std; #include "nint.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/observation.cc b/src/basic/vx_util/observation.cc index 1fe4ea7ede..b469a00fba 100644 --- a/src/basic/vx_util/observation.cc +++ b/src/basic/vx_util/observation.cc @@ -10,14 +10,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "vx_log.h" #include "vx_math.h" #include "vx_util.h" #include "observation.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/ordinal.cc b/src/basic/vx_util/ordinal.cc index 7d8c98e4f4..57c917e507 100644 --- a/src/basic/vx_util/ordinal.cc +++ b/src/basic/vx_util/ordinal.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +20,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/polyline.cc b/src/basic/vx_util/polyline.cc index 88570f369d..9ffdc6bb3d 100644 --- a/src/basic/vx_util/polyline.cc +++ b/src/basic/vx_util/polyline.cc @@ -19,8 +19,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -33,6 +31,8 @@ using namespace std; #include "vx_math.h" #include "vx_util.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class Polyline diff --git a/src/basic/vx_util/python_line.cc b/src/basic/vx_util/python_line.cc index 0fd205825c..36d0c2fc67 100644 --- a/src/basic/vx_util/python_line.cc +++ b/src/basic/vx_util/python_line.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -29,6 +26,9 @@ using namespace std; #include "python_line.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/read_fortran_binary.cc b/src/basic/vx_util/read_fortran_binary.cc index 78680f707e..843f8031eb 100644 --- a/src/basic/vx_util/read_fortran_binary.cc +++ b/src/basic/vx_util/read_fortran_binary.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +23,8 @@ using namespace std; #include "check_endian.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/roman_numeral.cc b/src/basic/vx_util/roman_numeral.cc index c278179994..afa89e8891 100644 --- a/src/basic/vx_util/roman_numeral.cc +++ b/src/basic/vx_util/roman_numeral.cc @@ -7,12 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +20,8 @@ using namespace std; #include "roman_numeral.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/smart_buffer.cc b/src/basic/vx_util/smart_buffer.cc index 9645b6d773..0bd09c8029 100644 --- a/src/basic/vx_util/smart_buffer.cc +++ b/src/basic/vx_util/smart_buffer.cc @@ -1,8 +1,5 @@ - - //////////////////////////////////////////////////////////////////////// - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -11,12 +8,9 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +24,8 @@ using namespace std; #include "smart_buffer.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/string_fxns.cc b/src/basic/vx_util/string_fxns.cc index 3d17832de5..ab84446789 100644 --- a/src/basic/vx_util/string_fxns.cc +++ b/src/basic/vx_util/string_fxns.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -31,6 +27,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/substring.cc b/src/basic/vx_util/substring.cc index 8fdec968b9..b6ee3ab23d 100644 --- a/src/basic/vx_util/substring.cc +++ b/src/basic/vx_util/substring.cc @@ -7,13 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -23,6 +19,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index a5063de78f..ad35ecac09 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -7,8 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static const int thresharray_alloc_inc = 10; diff --git a/src/basic/vx_util/two_to_one.cc b/src/basic/vx_util/two_to_one.cc index cb0229a350..c29aa3b741 100644 --- a/src/basic/vx_util/two_to_one.cc +++ b/src/basic/vx_util/two_to_one.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util_math/so3.cc b/src/basic/vx_util_math/so3.cc index 5e6266801d..6797d76f04 100644 --- a/src/basic/vx_util_math/so3.cc +++ b/src/basic/vx_util_math/so3.cc @@ -1,5 +1,3 @@ - - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2023 // ** University Corporation for Atmospheric Research (UCAR) @@ -11,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +21,8 @@ using namespace std; #include "fix_float.h" #include "trig.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// From c78860291efe269d275efc786a6d7926f6323c37 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 14 Feb 2024 14:43:24 -0700 Subject: [PATCH 003/114] Feature #2395 wdir (#2820) * Per #2395, add new columns to VL1L2, VAL1L2, and VCNT line types for wind direction statistics. Work still in progress. * Per #2395, write the new VCNT columns to the output and document the additions to the VL1L2, VAL1L2, and VCNT columns. * Per #2395, add the definition of new statistics to Appendix G. * Per #2395, update file version history. * Per #2395, tweak warning message about zero wind vectors and update grid-stat and point-stat to log calls to the do_vl1l2() function. * Per #2395, refine the weights for wind direction stats, ignoring the undefined directions. * Update src/tools/core/stat_analysis/aggr_stat_line.cc * Update src/tools/core/stat_analysis/parse_stat_line.cc * Update src/tools/core/stat_analysis/aggr_stat_line.cc --- data/table_files/met_header_columns_V12.0.txt | 6 +- docs/Users_Guide/appendixG.rst | 167 +++++++++---- docs/Users_Guide/point-stat.rst | 30 +++ internal/test_unit/hdr/met_12_0.hdr | 6 +- src/basic/vx_util/stat_column_defs.h | 16 +- src/libcode/vx_stat_out/stat_columns.cc | 60 ++++- src/libcode/vx_statistics/met_stats.cc | 228 ++++++++++++------ src/libcode/vx_statistics/met_stats.h | 32 +-- src/tools/core/grid_stat/grid_stat.cc | 3 + src/tools/core/point_stat/point_stat.cc | 3 + .../core/stat_analysis/aggr_stat_line.cc | 17 ++ .../core/stat_analysis/parse_stat_line.cc | 8 + 12 files changed, 421 insertions(+), 155 deletions(-) diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index bf218d00bc..7ed1e5a187 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -27,9 +27,9 @@ V12.0 : STAT : RELP : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : SAL1L2 : 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 FABAR OABAR FOABAR FFABAR OOABAR MAE V12.0 : STAT : SL1L2 : 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 FBAR OBAR FOBAR FFBAR OOBAR MAE V12.0 : STAT : SSVAR : 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_BIN BIN_i BIN_N VAR_MIN VAR_MAX VAR_MEAN FBAR OBAR FOBAR FFBAR OOBAR FBAR_NCL FBAR_NCU FSTDEV FSTDEV_NCL FSTDEV_NCU OBAR_NCL OBAR_NCU OSTDEV OSTDEV_NCL OSTDEV_NCU PR_CORR PR_CORR_NCL PR_CORR_NCU ME ME_NCL ME_NCU ESTDEV ESTDEV_NCL ESTDEV_NCU MBIAS MSE BCMSE RMSE -V12.0 : STAT : VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR -V12.0 : STAT : VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR -V12.0 : STAT : VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU +V12.0 : STAT : VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR DIRA_ME DIRA_MAE DIRA_MSE +V12.0 : STAT : VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR DIR_ME DIR_MAE DIR_MSE +V12.0 : STAT : VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU DIR_ME DIR_ME_BCL DIR_ME_BCU DIR_MAE DIR_MAE_BCL DIR_MAE_BCU DIR_MSE DIR_MSE_BCL DIR_MSE_BCU DIR_RMSE DIR_RMSE_BCL DIR_RMSE_BCU V12.0 : STAT : GENMPR : 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 STORM_ID PROB_LEAD PROB_VAL AGEN_INIT AGEN_FHR AGEN_LAT AGEN_LON AGEN_DLAND BGEN_LAT BGEN_LON BGEN_DLAND GEN_DIST GEN_TDIFF INIT_TDIFF DEV_CAT OPS_CAT V12.0 : STAT : SSIDX : 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 FCST_MODEL REF_MODEL N_INIT N_TERM N_VLD SS_INDEX diff --git a/docs/Users_Guide/appendixG.rst b/docs/Users_Guide/appendixG.rst index c2811fe4fa..821a4a4c5d 100644 --- a/docs/Users_Guide/appendixG.rst +++ b/docs/Users_Guide/appendixG.rst @@ -46,7 +46,6 @@ In the same manner, we can compare the directions of two different nonzero vecto __________________________ - Now let us specialize this discussion of vectors to verification of wind vector data. We will denote the forecast wind vector by :math:`\mathbf{F}`, and the observed wind vector by **O**. These are two-dimensional horizontal vectors with *u* and *v* components as follows: .. math:: \mathbf{F} = (u_f,v_f) \text{ and } \mathbf{O} = (u_o,v_o) @@ -71,35 +70,33 @@ Now let us look at the definitions of the vector statistics produced by MET: _________________________ - FBAR and OBAR are the average values of the forecast and observed wind speed. .. math:: - \text{FBAR} = \frac{1}{N} \sum_i s_{fi} - - \text{OBAR} = {1 \over N} \sum_i s_{oi} + \text{FBAR} = \frac{1}{N} \sum_i s_{fi} -_________________________ + \text{OBAR} = {1 \over N} \sum_i s_{oi} +_________________________ FS_RMS and OS_RMS are the root-mean-square values of the forecast and observed wind speeds. .. only:: latex - .. math:: - - \text{FS\_RMS} = [ \frac{1}{N} \sum_i s_{fi}^2]^{1/2} + .. math:: + + \text{FS\_RMS} = [ \frac{1}{N} \sum_i s_{fi}^2]^{1/2} - \text{OS\_RMS} = [\frac{1}{N} \sum_i s_{oi}^2]^{1/2} + \text{OS\_RMS} = [\frac{1}{N} \sum_i s_{oi}^2]^{1/2} .. only:: html - .. math:: - - \text{FS_RMS} = [ \frac{1}{N} \sum_i s_{fi}^2]^{1/2} + .. math:: - \text{OS_RMS} = [\frac{1}{N} \sum_i s_{oi}^2]^{1/2} + \text{FS_RMS} = [ \frac{1}{N} \sum_i s_{fi}^2]^{1/2} + + \text{OS_RMS} = [\frac{1}{N} \sum_i s_{oi}^2]^{1/2} ___________________________ @@ -107,13 +104,12 @@ MSVE and RMSVE are, respectively, the mean squared, and root mean squared, lengt .. math:: - \text{MSVE} = \frac{1}{N} \sum_i | \mathbf{F}_i - \mathbf{O}_i|^2 + \text{MSVE} = \frac{1}{N} \sum_i | \mathbf{F}_i - \mathbf{O}_i|^2 - \text{RMSVE} = \sqrt{MSVE} + \text{RMSVE} = \sqrt{MSVE} ____________________________ - FSTDEV and OSTDEV are the standard deviations of the forecast and observed wind speeds. .. math:: \text{FSTDEV } = \frac{1}{N} \sum_i (s_{fi} - \text{FBAR})^2 = \frac{1}{N} \sum_i s_{fi}^2 - \text{FBAR}^2 @@ -125,91 +121,84 @@ ___________________________ FDIR and ODIR are the direction (angle) of :math:`\mathbf{F}_a \text{ and } \mathbf{O}_a` with respect to the grid directions. .. math:: \text{FDIR } = \text{ direction angle of } \mathbf{F}_a - - \text{ODIR} = \text{ direction angle of } \mathbf{O}_a -________________________ + \text{ODIR} = \text{ direction angle of } \mathbf{O}_a +________________________ FBAR_SPEED and OBAR_SPEED are the lengths of the average forecast and observed wind vectors. Note that this is *not* the same as the average forecast and observed wind speeds (*ie.,* the length of an average vector :math:`\neq` the average length of the vector). .. only:: latex - .. math:: - - \text{FBAR\_SPEED } = | \mathbf{F}_a | - - \text{OBAR\_SPEED } = | \mathbf{O}_a | + .. math:: + + \text{FBAR\_SPEED } = | \mathbf{F}_a | + + \text{OBAR\_SPEED } = | \mathbf{O}_a | .. only:: html - .. math:: - - \text{FBAR_SPEED } = | \mathbf{F}_a | - - \text{OBAR_SPEED } = | \mathbf{O}_a | + .. math:: + \text{FBAR_SPEED } = | \mathbf{F}_a | -________________________ + \text{OBAR_SPEED } = | \mathbf{O}_a | +________________________ VDIFF_SPEED is the length (*ie. speed*) of the vector difference between the average forecast and average observed wind vectors. .. only:: latex - .. math:: \text{VDIFF\_SPEED } = | \mathbf{F}_a - \mathbf{O}_a | + .. math:: \text{VDIFF\_SPEED } = | \mathbf{F}_a - \mathbf{O}_a | .. only:: html - .. math:: \text{VDIFF_SPEED } = | \mathbf{F}_a - \mathbf{O}_a | + .. math:: \text{VDIFF_SPEED } = | \mathbf{F}_a - \mathbf{O}_a | .. only:: latex - Note that this is *not* the same as the difference in lengths (speeds) of the average forecast and observed wind vectors. That quantity is called SPEED_ERR (see below). There is a relationship between these two statistics however: using some of the results obtained in the introduction to this appendix, we can say that :math:`| | \mathbf{F}_a | - | \mathbf{O}_a | | \leq | \mathbf{F}_a - \mathbf{O}_a |` or, equivalently, that :math:`\vert \text{SPEED\_ERR } \vert \leq \text{VDIFF\_SPEED. }` + Note that this is *not* the same as the difference in lengths (speeds) of the average forecast and observed wind vectors. That quantity is called SPEED_ERR (see below). There is a relationship between these two statistics however: using some of the results obtained in the introduction to this appendix, we can say that :math:`| | \mathbf{F}_a | - | \mathbf{O}_a | | \leq | \mathbf{F}_a - \mathbf{O}_a |` or, equivalently, that :math:`\vert \text{SPEED\_ERR } \vert \leq \text{VDIFF\_SPEED. }` .. only:: html - Note that this is *not* the same as the difference in lengths (speeds) of the average forecast and observed wind vectors. That quantity is called SPEED_ERR (see below). There is a relationship between these two statistics however: using some of the results obtained in the introduction to this appendix, we can say that :math:`| | \mathbf{F}_a | - | \mathbf{O}_a | | \leq | \mathbf{F}_a - \mathbf{O}_a |` or, equivalently, that :math:`\vert \text{SPEED_ERR } \vert \leq \text{VDIFF_SPEED. }` + Note that this is *not* the same as the difference in lengths (speeds) of the average forecast and observed wind vectors. That quantity is called SPEED_ERR (see below). There is a relationship between these two statistics however: using some of the results obtained in the introduction to this appendix, we can say that :math:`| | \mathbf{F}_a | - | \mathbf{O}_a | | \leq | \mathbf{F}_a - \mathbf{O}_a |` or, equivalently, that :math:`\vert \text{SPEED_ERR } \vert \leq \text{VDIFF_SPEED. }` _________________________ - -VDIFF_DIR is the direction of the vector difference of the average forecast and average observed wind vectors. Note that this is {\it not} the same as the difference in direction of the average forecast and average observed wind vectors. This latter quantity would be FDIR :math:`-` ODIR. +VDIFF_DIR is the direction of the vector difference of the average forecast and average observed wind vectors. Note that this is *not* the same as the difference in direction of the average forecast and average observed wind vectors. This latter quantity would be FDIR :math:`-` ODIR. .. only:: latex - .. math:: \text{VDIFF\_DIR } = \text{ direction of } (\mathbf{F}_a - \mathbf{O}_a) + .. math:: \text{VDIFF\_DIR } = \text{ direction of } (\mathbf{F}_a - \mathbf{O}_a) .. only:: html - .. math:: \text{VDIFF_DIR } = \text{ direction of } (\mathbf{F}_a - \mathbf{O}_a) + .. math:: \text{VDIFF_DIR } = \text{ direction of } (\mathbf{F}_a - \mathbf{O}_a) _________________________ - SPEED_ERR is the difference in the lengths (speeds) of the average forecast and average observed wind vectors. (See the discussion of VDIFF_SPEED above.) .. only:: latex - .. math:: \text{SPEED\_ERR } = | \mathbf{F}_a | - | \mathbf{O}_a | = \text{ FBAR\_SPEED } - \text{ OBAR\_SPEED } + .. math:: \text{SPEED\_ERR } = | \mathbf{F}_a | - | \mathbf{O}_a | = \text{ FBAR\_SPEED } - \text{ OBAR\_SPEED } .. only:: html - .. math:: \text{SPEED_ERR } = | \mathbf{F}_a | - | \mathbf{O}_a | = \text{ FBAR_SPEED } - \text{ OBAR_SPEED } - + .. math:: \text{SPEED_ERR } = | \mathbf{F}_a | - | \mathbf{O}_a | = \text{ FBAR_SPEED } - \text{ OBAR_SPEED } ___________________________ - SPEED_ABSERR is the absolute value of SPEED_ERR. Note that we have SPEED_ABSERR :math:`\leq` VDIFF_SPEED (see the discussion of VDIFF_SPEED above). .. only:: latex - .. math:: \text{SPEED\_ABSERR } = \vert \text{SPEED\_ERR } \vert + .. math:: \text{SPEED\_ABSERR } = \vert \text{SPEED\_ERR } \vert .. only:: html - .. math:: \text{SPEED_ABSERR } = \vert \text{SPEED_ERR } \vert + .. math:: \text{SPEED_ABSERR } = \vert \text{SPEED_ERR } \vert __________________________ @@ -217,20 +206,96 @@ DIR_ERR is the signed angle between the directions of the average forecast and a .. only:: latex - .. math:: \text{DIR\_ERR } = \text{ direction between } N(\mathbf{F}_a) \text{ and } N(\mathbf{O}_a) + .. math:: \text{DIR\_ERR } = \text{ direction between } N(\mathbf{F}_a) \text{ and } N(\mathbf{O}_a) .. only:: html - .. math:: \text{DIR_ERR } = \text{ direction between } N(\mathbf{F}_a) \text{ and } N(\mathbf{O}_a) + .. math:: \text{DIR_ERR } = \text{ direction between } N(\mathbf{F}_a) \text{ and } N(\mathbf{O}_a) __________________________ - + DIR_ABSERR is the absolute value of DIR_ERR. In other words, it's an unsigned angle rather than a signed angle. .. only:: latex - .. math:: \text{DIR\_ABSERR } = \vert \text{DIR\_ERR } \vert + .. math:: \text{DIR\_ABSERR } = \vert \text{DIR\_ERR } \vert + +.. only:: html + + .. math:: \text{DIR_ABSERR } = \vert \text{DIR_ERR } \vert + +__________________________ + +The following statistics are computed by comparing the forecast and observed wind directions for each individual matched pair. + +For each point, the directed angle difference in degrees is computed between the forecast and observed wind vectors and rescaled to the range from -180, exclusive, to 180, inclusive. + +.. math:: + + N(\mathbf{F}_i) - N(\mathbf{O}_i) \in (-180, 180] + +Note however that the direction of the zero vector is undefined. Points for which the forecast or observed wind direction is undefined are excluded from the analysis and result in a warning message being printed. The "wind_thresh" and "wind_logic" configuration options, described in :numref:`config_options`, can be used to filter the wind vectors down to a subset that meet the specified wind speed threshold. + +__________________________ + +DIR_ME is the average of the signed difference between the forecast and observed wind directions. + +.. only:: latex + + .. math:: + + \text{DIR\_ME} = \frac{1}{N} \sum_i (N(\mathbf{F}_i) - N(\mathbf{O}_i)) .. only:: html - .. math:: \text{DIR_ABSERR } = \vert \text{DIR_ERR } \vert + .. math:: + + \text{DIR_ME} = \frac{1}{N} \sum_i (N(\mathbf{F}_i) - N(\mathbf{O}_i)) + +__________________________ + +DIR_MAE is the average of the absolute value of the difference between the forecast and observed wind directions. + +.. only:: latex + + .. math:: + + \text{DIR\_MAE} = \frac{1}{N} \sum_i | N(\mathbf{F}_i) - N(\mathbf{O}_i) | + +.. only:: html + + .. math:: + + \text{DIR_MAE} = \frac{1}{N} \sum_i | N(\mathbf{F}_i) - N(\mathbf{O}_i) | + +__________________________ + +DIR_MSE is the average of the squared difference between the forecast and observed wind directions. + +.. only:: latex + + .. math:: + + \text{DIR\_MSE} = \frac{1}{N} \sum_i (N(\mathbf{F}_i) - N(\mathbf{O}_i))^2 + +.. only:: html + + .. math:: + + \text{DIR_MSE} = \frac{1}{N} \sum_i (N(\mathbf{F}_i) - N(\mathbf{O}_i))^2 + +__________________________ + +DIR_RMSE is the square root of the average squared difference between the forecast and observed wind directions. + +.. only:: latex + + .. math:: + + \text{DIR\_RMSE} = \sqrt{DIR\_MSE} + +.. only:: html + + .. math:: + + \text{DIR_RMSE} = \sqrt{DIR\_MSE} diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index 4258e8057f..d5f895a8aa 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -1285,6 +1285,15 @@ The first set of header columns are common to all of the output files generated * - 34 - O_SPEED_BAR - Mean observed wind speed + * - 35 + - DIR_ME + - Mean wind direction difference, from -180 to 180 degrees + * - 36 + - DIR_MAE + - Mean absolute wind direction difference + * - 37 + - DIR_MSE + - Mean squared wind direction difference .. _table_PS_format_info_VAL1L2: @@ -1331,6 +1340,15 @@ The first set of header columns are common to all of the output files generated * - 34 - OA_SPEED_BAR - Mean observed wind speed anomaly + * - 35 + - DIRA_ME + - Mean wind direction anomaly difference, from -180 to 180 degrees + * - 36 + - DIRA_MAE + - Mean absolute wind direction anomaly difference + * - 37 + - DIRA_MSE + - Mean squared wind direction anomaly difference .. _table_PS_format_info_VCNT: @@ -1410,6 +1428,18 @@ The first set of header columns are common to all of the output files generated * - 85-87 - ANOM_CORR_UNCNTR, :raw-html:`
` ANOM_CORR_UNCNTR_BCL, :raw-html:`
` ANOM_CORR_UNCNTR_BCU - Uncentered vector Anomaly Correlation excluding mean error including bootstrap upper and lower confidence limits + * - 88-90 + - DIR_ME, :raw-html:`
` DIR_ME_BCL, :raw-html:`
` DIR_ME_BCU + - Mean direction difference, from -180 to 180 degrees, including bootstrap upper and lower confidence limits + * - 91-93 + - DIR_MAE, :raw-html:`
` DIR_MAE_BCL, :raw-html:`
` DIR_MAE_BCU + - Mean absolute direction difference including bootstrap upper and lower confidence limits + * - 94-96 + - DIR_MSE, :raw-html:`
` DIR_MSE_BCL, :raw-html:`
` DIR_MSE_BCU + - Mean squared direction difference including bootstrap upper and lower confidence limits + * - 97-99 + - DIR_RMSE, :raw-html:`
` DIR_RMSE_BCL, :raw-html:`
` DIR_RMSE_BCU + - Root mean squared direction difference including bootstrap upper and lower confidence limits .. _table_PS_format_info_MPR: diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index 888df0f61d..d6bf9fb0b9 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -27,9 +27,9 @@ RELP : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L SAL1L2 : 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 FABAR OABAR FOABAR FFABAR OOABAR MAE SL1L2 : 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 FBAR OBAR FOBAR FFBAR OOBAR MAE SSVAR : 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_BIN BIN_i BIN_N VAR_MIN VAR_MAX VAR_MEAN FBAR OBAR FOBAR FFBAR OOBAR FBAR_NCL FBAR_NCU FSTDEV FSTDEV_NCL FSTDEV_NCU OBAR_NCL OBAR_NCU OSTDEV OSTDEV_NCL OSTDEV_NCU PR_CORR PR_CORR_NCL PR_CORR_NCU ME ME_NCL ME_NCU ESTDEV ESTDEV_NCL ESTDEV_NCU MBIAS MSE BCMSE RMSE -VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR -VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR -VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU +VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR DIR_ME DIR_MAE DIR_MSE +VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR DIRA_ME DIRA_MAE DIRA_MSE +VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU DIR_ME DIR_ME_BCL DIR_ME_BCU DIR_MAE DIR_MAE_BCL DIR_MAE_BCU DIR_MSE DIR_MSE_BCL DIR_MSE_BCU DIR_RMSE DIR_RMSE_BCL DIR_RMSE_BCU GENMPR : 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 STORM_ID PROB_LEAD PROB_VAL AGEN_INIT AGEN_FHR AGEN_LAT AGEN_LON AGEN_DLAND BGEN_LAT BGEN_LON BGEN_DLAND GEN_DIST GEN_TDIFF INIT_TDIFF DEV_CAT OPS_CAT SSIDX : 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 FCST_MODEL REF_MODEL N_INIT N_TERM N_VLD SS_INDEX MODE_SOA : 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 N_VALID GRID_RES OBJECT_ID OBJECT_CAT CENTROID_X CENTROID_Y CENTROID_LAT CENTROID_LON AXIS_ANG LENGTH WIDTH AREA AREA_THRESH CURVATURE CURVATURE_X CURVATURE_Y COMPLEXITY INTENSITY_10 INTENSITY_25 INTENSITY_50 INTENSITY_75 INTENSITY_90 INTENSITY_50 INTENSITY_SUM diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index f77e2200cb..909441b5ba 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -124,14 +124,16 @@ static const char * vl1l2_columns [] = { "TOTAL", "UFBAR", "VFBAR", "UOBAR", "VOBAR", "UVFOBAR", "UVFFBAR", "UVOOBAR", "F_SPEED_BAR", - "O_SPEED_BAR" + "O_SPEED_BAR", "DIR_ME", "DIR_MAE", + "DIR_MSE" }; static const char * val1l2_columns [] = { - "TOTAL", "UFABAR", "VFABAR", - "UOABAR", "VOABAR", "UVFOABAR", - "UVFFABAR", "UVOOABAR", "FA_SPEED_BAR", - "OA_SPEED_BAR" + "TOTAL", "UFABAR", "VFABAR", + "UOABAR", "VOABAR", "UVFOABAR", + "UVFFABAR", "UVOOABAR", "FA_SPEED_BAR", + "OA_SPEED_BAR", "DIRA_ME", "DIRA_MAE", + "DIRA_MSE" }; @@ -158,6 +160,10 @@ static const char * vcnt_columns [] = { "ANOM_CORR", "ANOM_CORR_NCL", "ANOM_CORR_NCU", "ANOM_CORR_BCL", "ANOM_CORR_BCU", "ANOM_CORR_UNCNTR", "ANOM_CORR_UNCNTR_BCL", "ANOM_CORR_UNCNTR_BCU", + "DIR_ME", "DIR_ME_BCL", "DIR_ME_BCU", + "DIR_MAE", "DIR_MAE_BCL", "DIR_MAE_BCU", + "DIR_MSE", "DIR_MSE_BCL", "DIR_MSE_BCU", + "DIR_RMSE", "DIR_RMSE_BCL", "DIR_RMSE_BCU" }; static const char * pct_columns [] = { diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index bd1dd46218..034c3c1961 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -2901,7 +2901,8 @@ void write_sl1l2_cols(const SL1L2Info &sl1l2_info, // Scalar L1L2 Line Type (SL1L2) // Dump out the SL1L2 line: // TOTAL, FBAR, OBAR, - // FOBAR, FFBAR, OOBAR + // FOBAR, FFBAR, OOBAR, + // MAE // at.set_entry(r, c+0, // Total Count sl1l2_info.scount); @@ -2974,7 +2975,8 @@ void write_vl1l2_cols(const VL1L2Info &vl1l2_info, // TOTAL, UFBAR, VFBAR, // UOBAR, VOBAR, UVFOBAR, // UVFFBAR, UVOOBAR F_SPEED_BAR, - // O_SPEED_BAR, + // O_SPEED_BAR, DIR_ME, DIR_MAE, + // DIR_MSE // at.set_entry(r, c+0, // Total Count @@ -3007,6 +3009,15 @@ void write_vl1l2_cols(const VL1L2Info &vl1l2_info, at.set_entry(r, c+9, // O_SPEED_BAR vl1l2_info.o_speed_bar); + at.set_entry(r, c+10, // DIR_ME + vl1l2_info.dir_bar); + + at.set_entry(r, c+11, // DIR_MAE + vl1l2_info.absdir_bar); + + at.set_entry(r, c+12, // DIR_MSE + vl1l2_info.dir2_bar); + return; } @@ -3018,10 +3029,11 @@ void write_val1l2_cols(const VL1L2Info &vl1l2_info, // // Vector Anomaly L1L2 Line Type (VAL1L2) // Dump out the VAL1L2 line: - // TOTAL, UFABAR, VFABAR, - // UOABAR, VOABAR, UVFOABAR, - // UVFFABAR, UVOOABAR, FA_SPEED_BAR, - // OA_SPEED_BAR + // TOTAL, UFABAR, VFABAR, + // UOABAR, VOABAR, UVFOABAR, + // UVFFABAR, UVOOABAR, FA_SPEED_BAR, + // OA_SPEED_BAR, DIRA_ME, DIRA_MAE, + // DIRA_MSE // at.set_entry(r, c+0, // Total Anomaly Count @@ -3054,6 +3066,15 @@ void write_val1l2_cols(const VL1L2Info &vl1l2_info, at.set_entry(r, c+9, // OA_SPEED_BAR vl1l2_info.oa_speed_bar); + at.set_entry(r, c+10, // DIRA_ME + vl1l2_info.dira_bar); + + at.set_entry(r, c+11, // DIRA_MAE + vl1l2_info.absdira_bar); + + at.set_entry(r, c+12, // DIRA_MSE + vl1l2_info.dira2_bar); + return; } @@ -3084,10 +3105,17 @@ void write_vcnt_cols(const VL1L2Info &vcnt_info, int i, // SPD_ABSERR, SPD_ABSERR_BCL, SPD_ABSERR_BCU, // DIR_ERR, DIR_ERR_BCL, DIR_ERR_BCU, // DIR_ABSERR, DIR_ABSERR_BCL, DIR_ABSERR_BCU, - // ANOM_CORR, ANOM_CORR_NCL, ANOM_CORR_NCU, ANOM_CORR_BCL, ANOM_CORR_BCU - // ANOM_CORR_UNCNTR, ANOM_CORR_UNCNTR_BCL, ANOM_CORR_UNCNTR_BCU + // ANOM_CORR, ANOM_CORR_NCL, ANOM_CORR_NCU, + // ANOM_CORR_BCL, ANOM_CORR_BCU + // ANOM_CORR_UNCNTR, ANOM_CORR_UNCNTR_BCL, ANOM_CORR_UNCNTR_BCU, + // DIR_ME, DIR_ME_BCL, DIR_ME_BCU, + // DIR_MAE, DIR_MAE_BCL, DIR_MAE_BCU, + // DIR_MSE, DIR_MSE_BCL, DIR_MSE_BCU, + // DIR_RMSE, DIR_RMSE_BCL, DIR_RMSE_BCU // + // TODO: MET #963 Compute the VCNT bootstrap CI's + at.set_entry(r, c++, max(vcnt_info.vcount, // TOTAL vcnt_info.vacount)); @@ -3173,6 +3201,22 @@ void write_vcnt_cols(const VL1L2Info &vcnt_info, int i, at.set_entry(r, c++, (string)na_str); // ANOM_CORR_UNCNTR_BCL at.set_entry(r, c++, (string)na_str); // ANOM_CORR_UNCNTR_BCU + at.set_entry(r, c++, vcnt_info.DIR_ME.v); // DIR_ME + at.set_entry(r, c++, (string)na_str); // DIR_ME_BCL + at.set_entry(r, c++, (string)na_str); // DIR_ME_BCU + + at.set_entry(r, c++, vcnt_info.DIR_MAE.v); // DIR_MAE + at.set_entry(r, c++, (string)na_str); // DIR_MAE_BCL + at.set_entry(r, c++, (string)na_str); // DIR_MAE_BCU + + at.set_entry(r, c++, vcnt_info.DIR_MSE.v); // DIR_MSE + at.set_entry(r, c++, (string)na_str); // DIR_MSE_BCL + at.set_entry(r, c++, (string)na_str); // DIR_MSE_BCU + + at.set_entry(r, c++, vcnt_info.DIR_RMSE.v); // DIR_RMSE + at.set_entry(r, c++, (string)na_str); // DIR_RMSE_BCL + at.set_entry(r, c++, (string)na_str); // DIR_RMSE_BCU + return; } diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index fd50117173..a33f1adc73 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -1362,7 +1362,7 @@ VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { v_info.allocate_n_alpha(n_alpha); for(int i=0; i 0) { v_info.uf_bar = (uf_bar*vcount + c.uf_bar*c.vcount) /v_info.vcount; @@ -1374,20 +1374,26 @@ VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { v_info.uvoo_bar = (uvoo_bar*vcount + c.uvoo_bar*c.vcount) /v_info.vcount; v_info.f_speed_bar = (f_speed_bar*vcount + c.f_speed_bar*c.vcount)/v_info.vcount; v_info.o_speed_bar = (o_speed_bar*vcount + c.o_speed_bar*c.vcount)/v_info.vcount; + v_info.dir_bar = (dir_bar*vcount + c.dir_bar*c.vcount) /v_info.vcount; + v_info.absdir_bar = (absdir_bar*vcount + c.absdir_bar*c.vcount) /v_info.vcount; + v_info.dir2_bar = (dir2_bar*vcount + c.dir2_bar*c.vcount) /v_info.vcount; } - v_info.vacount = vacount + c.vacount; + v_info.vacount = vacount + c.vacount; if(v_info.vacount > 0) { - v_info.ufa_bar = (ufa_bar*vacount + c.ufa_bar*c.vacount) /v_info.vacount; - v_info.vfa_bar = (vfa_bar*vacount + c.vfa_bar*c.vacount) /v_info.vacount; - v_info.uoa_bar = (uoa_bar*vacount + c.uoa_bar*c.vacount) /v_info.vacount; - v_info.voa_bar = (voa_bar*vacount + c.voa_bar*c.vacount) /v_info.vacount; - v_info.uvfoa_bar = (uvfoa_bar*vacount + c.uvfoa_bar*c.vacount)/v_info.vacount; - v_info.uvffa_bar = (uvffa_bar*vacount + c.uvffa_bar*c.vacount)/v_info.vacount; - v_info.uvooa_bar = (uvooa_bar*vacount + c.uvooa_bar*c.vacount)/v_info.vacount; + v_info.ufa_bar = (ufa_bar*vacount + c.ufa_bar*c.vacount) /v_info.vacount; + v_info.vfa_bar = (vfa_bar*vacount + c.vfa_bar*c.vacount) /v_info.vacount; + v_info.uoa_bar = (uoa_bar*vacount + c.uoa_bar*c.vacount) /v_info.vacount; + v_info.voa_bar = (voa_bar*vacount + c.voa_bar*c.vacount) /v_info.vacount; + v_info.uvfoa_bar = (uvfoa_bar*vacount + c.uvfoa_bar*c.vacount) /v_info.vacount; + v_info.uvffa_bar = (uvffa_bar*vacount + c.uvffa_bar*c.vacount) /v_info.vacount; + v_info.uvooa_bar = (uvooa_bar*vacount + c.uvooa_bar*c.vacount) /v_info.vacount; v_info.fa_speed_bar = (fa_speed_bar*vacount + c.fa_speed_bar*c.vacount)/v_info.vacount; v_info.oa_speed_bar = (oa_speed_bar*vacount + c.oa_speed_bar*c.vacount)/v_info.vacount; + v_info.dira_bar = (dira_bar*vacount + c.dira_bar*c.vacount) /v_info.vacount; + v_info.absdira_bar = (absdira_bar*vacount + c.absdira_bar*c.vacount) /v_info.vacount; + v_info.dira2_bar = (dira2_bar*vacount + c.dira2_bar*c.vacount) /v_info.vacount; } v_info.compute_stats(); @@ -1416,24 +1422,20 @@ void VL1L2Info::zero_out() { // VL1L2 Quantities // - uf_bar = 0.0; - vf_bar = 0.0; - uo_bar = 0.0; - vo_bar = 0.0; - uvfo_bar = 0.0; - uvff_bar = 0.0; - uvoo_bar = 0.0; - f_speed_bar = 0.0; - o_speed_bar = 0.0; - - f_bar = 0.0; - o_bar = 0.0; - me = 0.0; - mse = 0.0; - rmse = 0.0; - speed_bias = 0.0; - - vcount = 0; + uf_bar = 0.0; + vf_bar = 0.0; + uo_bar = 0.0; + vo_bar = 0.0; + uvfo_bar = 0.0; + uvff_bar = 0.0; + uvoo_bar = 0.0; + f_speed_bar = 0.0; + o_speed_bar = 0.0; + dir_bar = 0.0; + absdir_bar = 0.0; + dir2_bar = 0.0; + + vcount = 0; // // VAL1L2 Quantities @@ -1448,6 +1450,9 @@ void VL1L2Info::zero_out() { uvooa_bar = 0.0; fa_speed_bar = 0.0; oa_speed_bar = 0.0; + dira_bar = 0.0; + absdira_bar = 0.0; + dira2_bar = 0.0; vacount = 0; @@ -1459,6 +1464,8 @@ void VL1L2Info::zero_out() { void VL1L2Info::clear() { n = 0; + n_dir_undef = 0; + n_dira_undef = 0; n_alpha = 0; if(alpha) { delete [] alpha; alpha = (double *) 0; } @@ -1486,6 +1493,10 @@ void VL1L2Info::clear() { DIR_ABSERR.clear(); ANOM_CORR.clear(); ANOM_CORR_UNCNTR.clear(); + DIR_ME.clear(); + DIR_MAE.clear(); + DIR_MSE.clear(); + DIR_RMSE.clear(); zero_out(); @@ -1504,27 +1515,26 @@ void VL1L2Info::assign(const VL1L2Info &c) { logic = c.logic; n = c.n; + n_dir_undef = c.n_dir_undef; + n_dira_undef = c.n_dira_undef; allocate_n_alpha(c.n_alpha); for(i=0; i 0) { + dir_bar /= dir_wgt_sum; + absdir_bar /= dir_wgt_sum; + dir2_bar /= dir_wgt_sum; + } + + // Normalize anomalous wind direction differences + if(dira_wgt_sum > 0) { + dira_bar /= dira_wgt_sum; + absdira_bar /= dira_wgt_sum; + dira2_bar /= dira_wgt_sum; + } + if(vcount > 0) compute_stats(); - // Check for 0 points + // Check for zero points if(vcount == 0) { uf_bar = bad_data_double; @@ -1681,11 +1735,9 @@ void VL1L2Info::set(const PairDataPoint &pd_u_all, uvoo_bar = bad_data_double; f_speed_bar = bad_data_double; o_speed_bar = bad_data_double; - - me = bad_data_double; - mse = bad_data_double; - rmse = bad_data_double; - speed_bias = bad_data_double; + dir_bar = bad_data_double; + absdir_bar = bad_data_double; + dir2_bar = bad_data_double; FBAR.v = bad_data_double; OBAR.v = bad_data_double; @@ -1716,9 +1768,11 @@ void VL1L2Info::set(const PairDataPoint &pd_u_all, ANOM_CORR.v = bad_data_double; ANOM_CORR_UNCNTR.v = bad_data_double; - } - else { - rmse = sqrt(mse); + + DIR_ME.v = bad_data_double; + DIR_MAE.v = bad_data_double; + DIR_MSE.v = bad_data_double; + DIR_RMSE.v = bad_data_double; } if(vacount == 0) { @@ -1731,6 +1785,9 @@ void VL1L2Info::set(const PairDataPoint &pd_u_all, uvooa_bar = bad_data_double; fa_speed_bar = bad_data_double; oa_speed_bar = bad_data_double; + dira_bar = bad_data_double; + absdira_bar = bad_data_double; + dira2_bar = bad_data_double; } return; @@ -1772,6 +1829,10 @@ void VL1L2Info::allocate_n_alpha(int i) { DIR_ABSERR.allocate_n_alpha(n_alpha); ANOM_CORR.allocate_n_alpha(n_alpha); ANOM_CORR_UNCNTR.allocate_n_alpha(n_alpha); + DIR_ME.allocate_n_alpha(n_alpha); + DIR_MAE.allocate_n_alpha(n_alpha); + DIR_MSE.allocate_n_alpha(n_alpha); + DIR_RMSE.allocate_n_alpha(n_alpha); } return; @@ -1820,6 +1881,20 @@ void VL1L2Info::compute_stats() { uf_bar*uo_bar + vf_bar*vo_bar); DIR_ABSERR.v = fabs(DIR_ERR.v); + + // Print undefined wind direction warning message + if(n_dir_undef > 0) { + mlog << Warning << "\nVL1L2Info::compute_stats() -> " + << "Skipping " << n_dir_undef << " of " << vcount + << " vector pairs for which the direction difference is undefined.\n" + << "Set the \"wind_thresh\" and \"wind_logic\" configuration options " + << "to exclude zero vectors.\n\n"; + } + + DIR_ME.v = dir_bar; + DIR_MAE.v = absdir_bar; + DIR_MSE.v = dir2_bar; + DIR_RMSE.v = sqrt(dir2_bar); } if(vacount > 0) { @@ -1837,6 +1912,15 @@ void VL1L2Info::compute_stats() { } ANOM_CORR_UNCNTR.v = compute_anom_corr_uncntr(uvffa_bar, uvooa_bar, uvfoa_bar); + + // Print undefined wind direction warning message + if(n_dira_undef > 0) { + mlog << Warning << "\nVL1L2Info::compute_stats() -> " + << "Skipping " << n_dira_undef << " of " << vacount + << " anomaly vector pairs for which the direction difference is undefined.\n" + << "Set the \"wind_thresh\" and \"wind_logic\" configuration options " + << "to exclude zero vectors.\n\n"; + } } // Compute parametric confidence intervals @@ -1932,6 +2016,10 @@ double VL1L2Info::get_stat(const char *stat_name) { else if(strcmp(stat_name, "DIR_ABSERR" ) == 0) v = DIR_ABSERR.v; else if(strcmp(stat_name, "ANOM_CORR" ) == 0) v = ANOM_CORR.v; else if(strcmp(stat_name, "ANOM_CORR_UNCNTR") == 0) v = ANOM_CORR_UNCNTR.v; + else if(strcmp(stat_name, "DIR_ME" ) == 0) v = DIR_ME.v; + else if(strcmp(stat_name, "DIR_MAE" ) == 0) v = DIR_MAE.v; + else if(strcmp(stat_name, "DIR_MSE" ) == 0) v = DIR_MSE.v; + else if(strcmp(stat_name, "DIR_RMSE" ) == 0) v = DIR_RMSE.v; else { mlog << Error << "\nVL1L2Info::get_stat() -> " << "unknown continuous statistic name \"" << stat_name diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index f17a0c867a..f0715d45b3 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -276,6 +276,10 @@ class VL1L2Info { // Number of points int n; + + // Number of points for which the wind direction difference is undefined + int n_dir_undef; + int n_dira_undef; // VL1L2 Quantities @@ -291,6 +295,10 @@ class VL1L2Info { double f_speed_bar; double o_speed_bar; + double dir_bar; // Average direction difference in (-180, +180] + double absdir_bar; // Average absolute direction difference + double dir2_bar; // Average squared direction difference + // Vector continuous statistics derived from VL1L2 and VAL1L2 partial sums CIInfo FBAR; @@ -322,21 +330,11 @@ class VL1L2Info { CIInfo ANOM_CORR; CIInfo ANOM_CORR_UNCNTR; - - // - // Extra VL1L2 quantities - // - - double f_bar; // fcst wind speed - double o_bar; // obs wind speed - - double me; // mean error - - double mse; // mean squared error - - double rmse; // root mean squared error - - double speed_bias; + + CIInfo DIR_ME; + CIInfo DIR_MAE; + CIInfo DIR_MSE; + CIInfo DIR_RMSE; int vcount; @@ -353,6 +351,10 @@ class VL1L2Info { double fa_speed_bar; double oa_speed_bar; + double dira_bar; // Average anomalous direction difference in (-180, +180] + double absdira_bar; // Average anomalous absolute direction difference + double dira2_bar; // Average anomalous squared direction difference + int vacount; // Compute sums diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index d2f137ff0c..c65ca49109 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -2253,6 +2253,9 @@ void do_vl1l2(VL1L2Info *&v_info, int i_vx, const PairDataPoint *pd_v_ptr) { int i, j; + mlog << Debug(2) + << "Computing Vector Partial Sums and Continuous Vector Statistics.\n"; + // Check that the number of pairs are the same if(pd_u_ptr->n_obs != pd_v_ptr->n_obs) { mlog << Error << "\ndo_vl1l2() -> " diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 474fdde6ec..6c50ea880c 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -1632,6 +1632,9 @@ void do_vl1l2(VL1L2Info *&v_info, int i_vx, const PairDataPoint *pd_u_ptr, const PairDataPoint *pd_v_ptr) { int i, j; + mlog << Debug(2) + << "Computing Vector Partial Sums and Continuous Vector Statistics.\n"; + // // Check that the number of pairs are the same // diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 5edf0a5025..99b5906429 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -37,6 +37,8 @@ // -out_thresh and -out_line_type options. // 017 11/10/22 Halley Gotway MET #2339 Add SEEPS and SEEPS_MPR // line types. +// 018 02/13/24 Halley Gotway MET #2395 Add wind direction stats +// to VL1L2, VAL1L2, and VCNT. // //////////////////////////////////////////////////////////////////////// @@ -2139,6 +2141,21 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, it->second.pd_v.f_na[i]*it->second.pd_v.f_na[i]); v_info.o_speed_bar = sqrt(it->second.pd_u.o_na[i]*it->second.pd_u.o_na[i] + it->second.pd_v.o_na[i]*it->second.pd_v.o_na[i]); + + double d_diff = angle_difference( + it->second.pd_u.f_na[i], it->second.pd_v.f_na[i], + it->second.pd_u.o_na[i], it->second.pd_v.o_na[i]); + + if(is_bad_data(d_diff)) { + v_info.n_dir_undef = 1; + } + else { + v_info.n_dir_undef = 0; + v_info.dir_bar = d_diff; + v_info.absdir_bar = abs(d_diff); + v_info.dir2_bar = d_diff*d_diff; + } + aggr.vl1l2_info += v_info; // diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index 77758a91bd..57bc92eb46 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -31,6 +31,8 @@ // 011 01/24/20 Halley Gotway Add RPS line type. // 012 11/10/22 Halley Gotway MET #2339 Add SEEPS and SEEPS_MPR // line types. +// 013 02/13/24 Halley Gotway MET #2395 Add wind direction stats +// to VL1L2, VAL1L2, and VCNT. // //////////////////////////////////////////////////////////////////////// @@ -234,6 +236,9 @@ void parse_vl1l2_line(STATLine &l, VL1L2Info &v_info) { v_info.uvoo_bar = atof(l.get_item("UVOOBAR")); v_info.f_speed_bar = atof(l.get_item("F_SPEED_BAR")); v_info.o_speed_bar = atof(l.get_item("O_SPEED_BAR")); + v_info.dir_bar = atof(l.get_item("DIR_ME")); + v_info.absdir_bar = atof(l.get_item("DIR_MAE")); + v_info.dir2_bar = atof(l.get_item("DIR_MSE")); v_info.compute_stats(); @@ -256,6 +261,9 @@ void parse_val1l2_line(STATLine &l, VL1L2Info &v_info) { v_info.uvooa_bar = atof(l.get_item("UVOOABAR")); v_info.fa_speed_bar = atof(l.get_item("FA_SPEED_BAR")); v_info.oa_speed_bar = atof(l.get_item("OA_SPEED_BAR")); + v_info.dira_bar = atof(l.get_item("DIRA_ME")); + v_info.absdira_bar = atof(l.get_item("DIRA_MAE")); + v_info.dira2_bar = atof(l.get_item("DIRA_MSE")); v_info.compute_stats(); From 67ee04eb96d5156bf228856ef47b2050e7ce6e7d Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 15 Feb 2024 08:50:31 -0700 Subject: [PATCH 004/114] Recent changes to branch protection rules for the develop branch have broken the logic of the update_truth.yml GHA workflow. Instead of submitting a PR to merge develop into develop-ref directly, use an intermediate update_truth_for_develop branch. --- .github/workflows/update_truth.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_truth.yml b/.github/workflows/update_truth.yml index 4b8c310dd7..adb67ecacc 100644 --- a/.github/workflows/update_truth.yml +++ b/.github/workflows/update_truth.yml @@ -45,10 +45,12 @@ jobs: git config --global user.email "97135045+metplus-bot@users.noreply.github.com" echo git checkout ${branch_name} git checkout ${branch_name} + echo git checkout -b update_truth_for_${branch_name} + git checkout -b update_truth_for_${branch_name} echo git merge -s ours origin/${branch_name}-ref git merge -s ours origin/${branch_name}-ref - echo git push origin ${branch_name} - git push origin ${branch_name} + echo git push origin update_truth_for_${branch_name} + git push origin update_truth_for_${branch_name} - name: Create Pull Request run: gh pr create --base $BASE --body "$BODY" --title "$TITLE" From b558794ac458c3e90922b3896305d62a82529064 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 22 Feb 2024 13:58:30 -0700 Subject: [PATCH 005/114] Feature #2280 ens_prob (#2823) * Per #2280, update to support probability threshold strings like ==8, where 8 is the number of ensemble members, to create probability bins centered on the n/8 for n = 0 ... 8. * Per #2280, update docs about probability threshold settings. * Per #2280, use a loose tolerance when checking for consistent bin widths. * Per #2280, add a new unit test for grid_stat to demonstrate processing the output from gen_ens_prod. * Per #2280, when verifying NMEP probability forecasts, smooth the obs data first. * Per #2280, only request STAT output for the PCT line type to match unit_grid_stat.xml and minimize the new output files. * Per #2280, update config option docs. * Per #2280, update config option docs. --- .github/workflows/testing.yml | 4 +- docs/Users_Guide/config_options.rst | 70 +++-- .../config/GridStatConfig_gen_ens_prod | 285 ++++++++++++++++++ internal/test_unit/xml/unit_grid_stat.xml | 20 +- src/basic/vx_util/thresh_array.cc | 180 +++++++---- src/basic/vx_util/thresh_array.h | 5 +- 6 files changed, 484 insertions(+), 80 deletions(-) create mode 100644 internal/test_unit/config/GridStatConfig_gen_ens_prod diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b667511b92..1fccc357fa 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -136,7 +136,7 @@ jobs: - jobid: 'job1' tests: 'ascii2nc' - jobid: 'job2' - tests: 'pb2nc madis2nc pcp_combine' + tests: 'pb2nc madis2nc pcp_combine gen_ens_prod' fail-fast: false steps: - uses: actions/checkout@v4 @@ -176,7 +176,7 @@ jobs: - jobid: 'job1' tests: 'ascii2nc_indy pb2nc_indy tc_dland tc_pairs tc_stat plot_tc tc_rmw rmw_analysis tc_diag tc_gen' - jobid: 'job2' - tests: 'met_test_scripts mode_multivar mode_graphics mtd regrid airnow gsi_tools netcdf modis series_analysis gen_ens_prod wwmca_regrid gen_vx_mask grid_weight interp_shape grid_diag grib_tables lidar2nc shift_data_plane trmm2nc aeronet wwmca_plot ioda2nc gaussian' + tests: 'met_test_scripts mode_multivar mode_graphics mtd regrid airnow gsi_tools netcdf modis series_analysis wwmca_regrid gen_vx_mask grid_weight interp_shape grid_diag grib_tables lidar2nc shift_data_plane trmm2nc aeronet wwmca_plot ioda2nc gaussian' fail-fast: false steps: - uses: actions/checkout@v4 diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index 60f81e5ef1..ec76ecf7d5 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -101,13 +101,13 @@ The configuration file language supports the following data types: the user has already determined to be 2.5 outside of MET. * "==FBIAS" for a user-specified frequency bias value. - e.g. "==FBIAS1" to automatically de-bias the data, "==FBIAS0.9" to select a low-bias threshold, or "==FBIAS1.1" to select a high-bias threshold. - This option must be used in - conjunction with a simple threshold in the other field. For example, - when "obs.cat_thresh = >5.0" and "fcst.cat_thresh = ==FBIAS1;", - MET applies the >5.0 threshold to the observations and then chooses a - forecast threshold which results in a frequency bias of 1. - The frequency bias can be any float value > 0.0. + e.g. "==FBIAS1" to automatically de-bias the data, "==FBIAS0.9" to + select a low-bias threshold, or "==FBIAS1.1" to select a high-bias + threshold. This option must be used in conjunction with a simple + threshold in the other field. For example, when "obs.cat_thresh = >5.0" + and "fcst.cat_thresh = ==FBIAS1;", MET applies the >5.0 threshold to + the observations and then chooses a forecast threshold which results in + a frequency bias of 1. The frequency bias can be any float value > 0.0. * "CDP" for climatological distribution percentile thresholds. These thresholds require that the climatological mean and standard @@ -842,32 +842,37 @@ to be verified. This dictionary may include the following entries: When set as a boolean to TRUE, it indicates that the "fcst.field" data should be treated as probabilities. For example, when verifying the - probabilistic NetCDF output of Ensemble-Stat, one could configure the - Grid-Stat or Point-Stat tools as follows: + probabilistic NetCDF output of Gen-Ens-Prod for an ensemble of size 10, + one could configure the Grid-Stat or Point-Stat tools as follows: .. code-block:: none fcst = { - field = [ { name = "APCP_24_A24_ENS_FREQ_gt0.0"; - level = "(*,*)"; - prob = TRUE; } ]; + field = [ { name = "APCP_24_A24_ENS_FREQ_gt0.0"; + level = "(*,*)"; + cat_thresh = ==10; + prob = TRUE; } ]; } Setting "prob = TRUE" indicates that the "APCP_24_A24_ENS_FREQ_gt0.0" - data should be processed as probabilities. + data should be processed as probabilities. Setting "cat_thresh = ==10" + indicates that these probabilities are derived from an ensemble with 10 + members and 11 probability bins should be defined, each centered on the + value n/10 for n = 0, 1, ... 10. When set as a dictionary, it defines the probabilistic field to be used. For example, when verifying GRIB files containing probabilistic - data, one could configure the Grid-Stat or Point-Stat tools as - follows: + data, one could configure the Grid-Stat or Point-Stat tools as follows: .. code-block:: none fcst = { - field = [ { name = "PROB"; level = "A24"; - prob = { name = "APCP"; thresh_lo = 2.54; } }, - { name = "PROB"; level = "P850"; - prob = { name = "TMP"; thresh_hi = 273; } } ]; + field = [ { name = "PROB"; level = "A24"; + prob = { name = "APCP"; thresh_lo = 2.54; } + cat_thresh = ==0.25; }, + { name = "PROB"; level = "P850"; + prob = { name = "TMP"; thresh_hi = 273; } + cat_thresh = ==0.1; } ]; } The example above selects two probabilistic fields. In both, "name" @@ -883,6 +888,31 @@ to be verified. This dictionary may include the following entries: with a range [0, 100], it will automatically rescale it to be [0, 1] before applying the probabilistic verification methods. + Probabilistic statistics in MET are derived from an Nx2 probabilistic + contingency table. The N-dimension is determined by the number of + probability bins requested. The "cat_thresh" configuration option + defines the number of and size of these probabibility bins. The bins + must include the full range of possible probability values, [0, 1]. + Since selecting bins of equal width is common, shorthand notation is + provided to do so. The following options are supported. + + * :code:`cat_thresh = [ ==0.25 ];` specifies an equal probability bin + width of 0.25 and defines 4 bins between the values 0, 0.25, 0.5, 0.75, + and 1.0. The :code:`==p` threshold may be set to any probability bin + width greater than 0 and less than 1. + + * :code:`cat_thresh = [ ==10 ];` specifies probability bins for an + ensemble of size 10 and defines 11 bins between the values -0.05, 0.05, + 0.15, ..., 0.95, and 1.05. Note that each bin is centered on the + probability value n/10, for n = 0 to 10. The :code:`==n` threshold may + be set to any integer number of ensemble members greater than 1 to + define n+1 probability bins. + + * :code:`cat_thresh = [ >=0, >=0.5, >=0.75, >=1.0 ];` explicitly + specifies the probability thresholds and defines 3 bins of unequal + width between the values 0, 0.5, 0.75, and 1.0. By convention, the + greater-than-or-equal-to (">=" or "ge") inequality type is required. + * Set "prob_as_scalar = TRUE" to override the processing of probability data. When the "prob" entry is set as a dictionary to define the field of interest, setting "prob_as_scalar = TRUE" indicates that this @@ -2047,7 +2077,7 @@ This dictionary may include the following entries: .. code-block:: none hira = { - flag = FALSE; + flag = FALSE; width = [ 2, 3, 4, 5 ]; vld_thresh = 1.0; cov_thresh = [ ==0.25 ]; diff --git a/internal/test_unit/config/GridStatConfig_gen_ens_prod b/internal/test_unit/config/GridStatConfig_gen_ens_prod new file mode 100644 index 0000000000..8893c2d5ff --- /dev/null +++ b/internal/test_unit/config/GridStatConfig_gen_ens_prod @@ -0,0 +1,285 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Grid-Stat configuration file. +// +// For additional information, please see the MET User's Guide. +// +//////////////////////////////////////////////////////////////////////////////// + +// +// Output model name to be written +// +model = "FCST"; + +// +// Output description to be written +// May be set separately in each "obs.field" entry +// +desc = "NA"; + +// +// Output observation type to be written +// +obtype = "ANALYS"; + +//////////////////////////////////////////////////////////////////////////////// + +// +// Verification grid +// May be set separately in each "field" entry +// +regrid = { + to_grid = NONE; + method = NEAREST; + width = 1; + vld_thresh = 0.5; + shape = SQUARE; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// May be set separately in each "field" entry +// +censor_thresh = []; +censor_val = []; +mpr_column = []; +mpr_thresh = []; +cat_thresh = []; +cnt_thresh = [ NA ]; +cnt_logic = UNION; +wind_thresh = [ NA ]; +wind_logic = UNION; +eclv_points = 0.05; +nc_pairs_var_name = ""; +nc_pairs_var_suffix = ""; +hss_ec_value = NA; +rank_corr_flag = FALSE; + +// +// Forecast and observation fields to be verified +// +fcst = { + + level = "(*,*)"; + cat_thresh = ==7; + prob = TRUE; + + field = [ + { name = "UGRD_Z10_ENS_FREQ_ltCDP25"; }, + { name = "UGRD_Z10_ENS_NEP_ltCDP25_NBRHD25"; }, + { name = "UGRD_Z10_ENS_NMEP_ltCDP25_NBRHD25_GAUSSIAN1"; } + ]; + +} +obs = { + + name = "UGRD"; + level = "Z10"; + cat_thresh = =0.5 ]; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Fourier decomposition +// May be set separately in each "obs.field" entry +// +fourier = { + wave_1d_beg = []; + wave_1d_end = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Gradient statistics +// May be set separately in each "obs.field" entry +// +gradient = { + dx = [ 1 ]; + dy = [ 1 ]; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Distance Map statistics +// May be set separately in each "obs.field" entry +// +distance_map = { + baddeley_p = 2; + baddeley_max_dist = NA; + fom_alpha = 0.1; + zhu_weight = 0.5; + beta_value(n) = n * n / 2.0; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Threshold for SEEPS p1 (Probability of being dry) +// +seeps_p1_thresh = >=0.1&&<=0.85; + +//////////////////////////////////////////////////////////////////////////////// + +// +// Statistical output types +// May be set separately in each "obs.field" entry +// +output_flag = { + fho = NONE; + ctc = NONE; + cts = NONE; + mctc = NONE; + mcts = NONE; + cnt = NONE; + sl1l2 = NONE; + sal1l2 = NONE; + vl1l2 = NONE; + val1l2 = NONE; + vcnt = NONE; + pct = STAT; + pstd = NONE; + pjc = NONE; + prc = NONE; + eclv = NONE; + nbrctc = NONE; + nbrcts = NONE; + nbrcnt = NONE; + grad = NONE; + dmap = NONE; + seeps = NONE; +} + +// +// NetCDF matched pairs output file +// May be set separately in each "obs.field" entry +// +nc_pairs_flag = FALSE; + +//////////////////////////////////////////////////////////////////////////////// + +ugrid_dataset = ""; +ugrid_max_distance_km = 30; +ugrid_coordinates_file = ""; + +//////////////////////////////////////////////////////////////////////////////// + +grid_weight_flag = NONE; +tmp_dir = "/tmp"; +output_prefix = "${OUTPUT_PREFIX}"; +version = "V12.0.0"; + +//////////////////////////////////////////////////////////////////////////////// diff --git a/internal/test_unit/xml/unit_grid_stat.xml b/internal/test_unit/xml/unit_grid_stat.xml index f70f53ad22..cc24ad21d3 100644 --- a/internal/test_unit/xml/unit_grid_stat.xml +++ b/internal/test_unit/xml/unit_grid_stat.xml @@ -11,7 +11,7 @@ ]> - + @@ -328,4 +328,22 @@ + + &MET_BIN;/grid_stat + + OUTPUT_PREFIX GEN_ENS_PROD + CLIMO_MEAN_FILE &DATA_DIR_CLIMO;/NCEP_1.0deg/cmean_1d.19790410 + CLIMO_STDEV_FILE &DATA_DIR_CLIMO;/NCEP_1.0deg/cstdv_1d.19790410 + + \ + &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_NO_CTRL_20120410_120000V.nc \ + &DATA_DIR_MODEL;/grib1/arw-tom-gep0/arw-tom-gep0_2012040912_F024.grib \ + &CONFIG_DIR;/GridStatConfig_gen_ens_prod \ + -outdir &OUTPUT_DIR;/grid_stat -v 1 + + + &OUTPUT_DIR;/grid_stat/grid_stat_GEN_ENS_PROD_240000L_20120410_120000V.stat + + + diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index 8d1fda8312..eae780063f 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -527,6 +527,33 @@ void ThreshArray::get_simple_nodes(vector &v) { } +//////////////////////////////////////////////////////////////////////// + +bool ThreshArray::equal_bin_width(double &width) const { + + // Check number of elements + if(Nelements < 2) { + width = bad_data_double; + return(false); + } + + // Initialize return values + width = t[1].get_value() - t[0].get_value(); + bool is_equal = true; + + // Check for consistent widths, ignoring the last bin + for(int i=0; i<(Nelements-2); i++) { + double cur_width = t[i+1].get_value() - t[i].get_value(); + if(!is_eq(width, cur_width, loose_tol)) { + width = bad_data_double; + is_equal = false; + break; + } + } // end for i + + return(is_equal); +} + //////////////////////////////////////////////////////////////////////// // // External utility for parsing probability thresholds. @@ -535,8 +562,6 @@ void ThreshArray::get_simple_nodes(vector &v) { ThreshArray string_to_prob_thresh(const char *s) { ThreshArray ta; - double v; - int i; // Parse the input string as a comma-separated list ta.add_css(s); @@ -545,30 +570,29 @@ ThreshArray string_to_prob_thresh(const char *s) { if(ta.n() == 1 && ta[0].get_type() == thresh_eq) { // Store the threshold value - v = ta[0].get_value(); + double v = ta[0].get_value(); // Threshold value must be between 0 and 1 - if(v <= 0 || v >=1) { + // or be an integer greater than 1 + if(v <= 0 || (v >=1 && !is_eq(nint(v), v))) { mlog << Error << "\nstring_to_prob_thresh() -> " - << "threshold value (" << v - << ") must be between 0 and 1.\n\n"; + << "the threshold string (" << s + << ") must specify a probability bin width between 0 and 1 " + << "or an integer number of ensemble members.\n\n"; exit(1); } - // Determine input precision - ConcatString cs; - const char *ptr = strchr(s, '.'); - int prec = ( ptr ? m_strlen(++ptr) : 0 ); - cs.set_precision(prec); - - // Construct list of probability thresholds using the input precision - ta.clear(); - for(i=0; i*v<1.0; i++) { - cs << cs_erase << ">=" << i*v; - ta.add(cs.c_str()); + // Define probability bins from [0, 1] with equal width + if(v > 0 && v < 1) { + const char *ptr = strchr(s, '.'); + double prec = (ptr ? m_strlen(++ptr) : 0); + ta = define_prob_bins(0.0, 1.0, v, prec); + } + // Define ensemble probability bins + else { + double inc = 1.0/nint(v); + ta = define_prob_bins(-inc/2.0, 1.0+inc/2.0, inc, bad_data_int); } - cs << cs_erase << ">=" << 1.0; - ta.add(cs.c_str()); } // Check probability thresholds @@ -577,6 +601,39 @@ ThreshArray string_to_prob_thresh(const char *s) { return(ta); } +//////////////////////////////////////////////////////////////////////// + +ThreshArray define_prob_bins(double beg, double end, double inc, int prec) { + ThreshArray ta; + double v; + + // Check inputs + if(beg > 0 || end < 1 || inc <= 0 || + (!is_bad_data(prec) && prec < 0)) { + mlog << Error << "\nget_prob_bins() -> " + << "the probability thresholds must begin (" + << beg << ") <= 0 and end (" + << end << ") >= 1 with an increment (" + << inc << ") between 0 and 1 and precision (" + << prec << ") >= 0.\n\n"; + exit(1); + } + + // Set the specified precision + ConcatString cs; + if(!is_bad_data(prec)) cs.set_precision(prec); + + // Construct a list of probability thresholds + v = beg; + while(v <= end) { + cs << cs_erase << ">=" << v; + ta.add(cs.c_str()); + v += inc; + } + + return(ta); +} + //////////////////////////////////////////////////////////////////////// // // Convert array of probability thresholds to a string. @@ -584,47 +641,51 @@ ThreshArray string_to_prob_thresh(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString prob_thresh_to_string(const ThreshArray &ta) { - ConcatString s; + ConcatString cs; ThreshArray prob_ta; - bool status = true; + double w; // Check for probability thresholds - if(!check_prob_thresh(ta, false)) status = false; + if(check_prob_thresh(ta, false)) { - // Use the second threshold to construct a probability threshold array - // and check for equality - if(status) { - s << "==" << ta[1].get_value(); - prob_ta = string_to_prob_thresh(s.c_str()); - status = (ta == prob_ta); + // Check for equal bin widths + if(ta.equal_bin_width(w)) { + if(is_eq(ta[0].get_value(), 0.0) && + is_eq(ta[(ta.n() - 1)].get_value(), 1.0)) { + cs << "==" << w; + } + else { + cs << "==" << nint(1/w); + } + prob_ta = string_to_prob_thresh(cs.c_str()); + if(!(ta == prob_ta)) cs.clear(); + } } - // If not an array of probabilities, return comma-separated string - if(!status) s = ta.get_str(); + // Return comma-separated list of thresholds + if(cs.length() == 0) cs = ta.get_str(); - return(s); + return(cs); } //////////////////////////////////////////////////////////////////////// bool check_prob_thresh(const ThreshArray &ta, bool error_out) { - int i, n; - n = ta.n(); + const char * method_name = "check_prob_thresh() -> "; - // Check for at least 3 thresholds beginning with 0 and ending with 1. - if(n < 3 || - !is_eq(ta[0].get_value(), 0.0) || - !is_eq(ta[n-1].get_value(), 1.0)) { + int n = ta.n(); + // Check for at least 3 thresholds that include the range [0, 1] + if(n < 3 || ta[0].get_value() > 0 || ta[n-1].get_value() < 1) { if(error_out) { - mlog << Error << "\ncheck_prob_thresh() -> " - << "When verifying a probability field, you must " - << "select at least 3 thresholds beginning with 0.0 " - << "and ending with 1.0 (current setting: " - << ta.get_str() << ").\n" - << "Consider using the ==p shorthand notation for bins " - << "of equal width.\n\n"; + mlog << Error << "\n" << method_name + << "when verifying a probability field, you must " + << "select at least 3 thresholds which include the range [0, 1] " + << "(current setting: " << ta.get_str() << ").\n" + << "Consider using the \"==n\" shorthand notation to specify " + << "probability bins of equal width, for n < 1, or the integer " + << "number of ensemble members, for n > 1.\n\n"; exit(1); } else { @@ -632,18 +693,20 @@ bool check_prob_thresh(const ThreshArray &ta, bool error_out) { } } - for(i=0; i " - << "When verifying a probability field, all " + mlog << Error << "\n" << method_name + << "when verifying a probability field, all " << "thresholds must be greater than or equal to, " << "using \"ge\" or \">=\" (current setting: " << ta.get_str() << ").\n" - << "Consider using the ==p shorthand notation for bins " - << "of equal width.\n\n"; + << "Consider using the \"==n\" shorthand notation to specify " + << "probability bins of equal width, for n < 1, or the integer " + << "number of ensemble members, for n > 1.\n\n"; exit(1); } else { @@ -651,15 +714,20 @@ bool check_prob_thresh(const ThreshArray &ta, bool error_out) { } } - // Check that all thresholds are in [0, 1]. - if(ta[i].get_value() < 0.0 || ta[i].get_value() > 1.0) { + // Break out of the last loop + if(i+1 == n) break; + + // Check that all probability bins overlap with [0, 1] + if((ta[i].get_value() < 0 && ta[i+1].get_value() < 0) || + (ta[i].get_value() > 1 && ta[i+1].get_value() > 1)) { if(error_out) { - mlog << Error << "\ncheck_prob_thresh() -> " - << "When verifying a probability field, all thresholds " - << "must be between 0 and 1 (current setting: " + mlog << Error << "\n" << method_name + << "when verifying a probability field, each probability bin " + << "must overlap the range [0, 1] (current setting: " << ta.get_str() << ").\n" - << "Consider using the ==p shorthand notation for bins " - << "of equal width.\n\n"; + << "Consider using the \"==n\" shorthand notation to specify " + << "probability bins of equal width, for n < 1, or the integer " + << "number of ensemble members, for n > 1.\n\n"; exit(1); } else { diff --git a/src/basic/vx_util/thresh_array.h b/src/basic/vx_util/thresh_array.h index f4fe0c4336..4ad5cf5146 100644 --- a/src/basic/vx_util/thresh_array.h +++ b/src/basic/vx_util/thresh_array.h @@ -87,6 +87,8 @@ class ThreshArray { bool check_dbl(double) const; bool check_dbl(double, double, double) const; + + bool equal_bin_width(double &) const; }; //////////////////////////////////////////////////////////////////////// @@ -99,7 +101,8 @@ inline SingleThresh * ThreshArray::buf() const { return ( t ); //////////////////////////////////////////////////////////////////////// extern ThreshArray string_to_prob_thresh (const char *); -extern ConcatString prob_thresh_to_string (const ThreshArray &); +extern ConcatString prob_thresh_to_string (const ThreshArray &); +extern ThreshArray define_prob_bins (double, double, double, int); extern bool check_prob_thresh (const ThreshArray &, bool error_out = true); extern ThreshArray process_perc_thresh_bins (const ThreshArray &); extern ThreshArray process_rps_cdp_thresh (const ThreshArray &); From 7f513ebb270578e3958f61c2a3c9113161360bce Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 27 Feb 2024 15:58:51 +0000 Subject: [PATCH 006/114] #2673 Change 0 to nullptr --- src/basic/enum_to_string/enum_to_string.cc | 6 ++-- src/basic/enum_to_string/scope.cc | 12 ++++---- src/basic/vx_config/celltype_to_string.cc | 2 +- src/basic/vx_config/grdfiletype_to_string.cc | 2 +- src/basic/vx_config/icode.cc | 14 ++++----- src/basic/vx_config/idstack.cc | 12 ++++---- src/basic/vx_config/number_stack.cc | 6 ++-- src/basic/vx_config/threshold.cc | 28 ++++++++--------- src/basic/vx_log/logger.cc | 4 +-- src/basic/vx_log/str_wrappers.cc | 2 +- src/basic/vx_math/hist.cc | 6 ++-- src/basic/vx_math/legendre.cc | 4 +-- src/basic/vx_math/ptile.cc | 8 ++--- src/basic/vx_math/viewgravity_to_string.cc | 2 +- src/basic/vx_util/ascii_table.cc | 4 +-- src/basic/vx_util/asciitablejust_to_string.cc | 2 +- src/basic/vx_util/command_line.cc | 10 +++---- src/basic/vx_util/crr_array.h | 8 ++--- src/basic/vx_util/data_line.cc | 10 +++---- src/basic/vx_util/data_plane.cc | 30 +++++++++---------- src/basic/vx_util/get_filenames.cc | 6 ++-- src/basic/vx_util/interp_util.cc | 10 +++---- src/basic/vx_util/is_number.cc | 4 +-- src/basic/vx_util/long_array.cc | 10 +++---- src/basic/vx_util/make_path.cc | 4 +-- src/basic/vx_util/ncrr_array.h | 14 ++++----- src/basic/vx_util/num_array.cc | 12 ++++---- src/basic/vx_util/ordinal.cc | 2 +- src/basic/vx_util/polyline.cc | 18 +++++------ src/basic/vx_util/thresh_array.cc | 10 +++---- src/basic/vx_util/two_d_array.h | 4 +-- 31 files changed, 133 insertions(+), 133 deletions(-) diff --git a/src/basic/enum_to_string/enum_to_string.cc b/src/basic/enum_to_string/enum_to_string.cc index 7760d47c26..1eb8fb1ae6 100644 --- a/src/basic/enum_to_string/enum_to_string.cc +++ b/src/basic/enum_to_string/enum_to_string.cc @@ -47,10 +47,10 @@ using namespace std; extern int yyparse(); // extern FILE * yyin; -FILE * yyin = 0; +FILE * yyin = nullptr; // extern char * yytext; -char * yytext = 0; +char * yytext = nullptr; extern int yydebug; @@ -90,7 +90,7 @@ bool do_reverse = false; bool verbose = true; -const char * program_name = (const char *) 0; +const char * program_name = (const char *) nullptr; //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/enum_to_string/scope.cc b/src/basic/enum_to_string/scope.cc index fc69bddf92..0d3f4ad5dd 100644 --- a/src/basic/enum_to_string/scope.cc +++ b/src/basic/enum_to_string/scope.cc @@ -38,7 +38,7 @@ ScopeStackElement::ScopeStackElement() { -Name = (const char *) 0; +Name = (const char *) nullptr; clear(); @@ -64,7 +64,7 @@ ScopeStackElement::ScopeStackElement(const ScopeStackElement & e) { -Name = (const char *) 0; +Name = (const char *) nullptr; assign(e); @@ -116,7 +116,7 @@ void ScopeStackElement::clear() Level = 0; -if ( Name ) { delete [] Name; Name = (const char *) 0; } +if ( Name ) { delete [] Name; Name = (const char *) nullptr; } return; @@ -131,12 +131,12 @@ void ScopeStackElement::set_name(const char * text) { const char *method_name = "void ScopeStackElement::set_name(const char *) -> "; -if ( Name ) { delete [] Name; Name = (const char *) 0; } +if ( Name ) { delete [] Name; Name = (const char *) nullptr; } if ( !text ) return; int k; -char * c = (char *) 0; +char * c = (char *) nullptr; k = m_strlen(text); @@ -154,7 +154,7 @@ m_strncpy(c, text, k, method_name); c[k] = (char) 0; // just to make sure -Name = (const char *) c; c = (char *) 0; +Name = (const char *) c; c = (char *) nullptr; return; diff --git a/src/basic/vx_config/celltype_to_string.cc b/src/basic/vx_config/celltype_to_string.cc index 226f8c50c7..32476474c2 100644 --- a/src/basic/vx_config/celltype_to_string.cc +++ b/src/basic/vx_config/celltype_to_string.cc @@ -39,7 +39,7 @@ ConcatString celltype_to_string(const CellType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/basic/vx_config/grdfiletype_to_string.cc b/src/basic/vx_config/grdfiletype_to_string.cc index e6f5b11b89..3a95b3eb1b 100644 --- a/src/basic/vx_config/grdfiletype_to_string.cc +++ b/src/basic/vx_config/grdfiletype_to_string.cc @@ -39,7 +39,7 @@ ConcatString grdfiletype_to_string(const GrdFileType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/basic/vx_config/icode.cc b/src/basic/vx_config/icode.cc index 0b5dfa631d..26aa274458 100644 --- a/src/basic/vx_config/icode.cc +++ b/src/basic/vx_config/icode.cc @@ -114,9 +114,9 @@ d = 0.0; type = no_cell_type; -name = (char *) 0; +name = (char *) nullptr; -text = (char *) 0; +text = (char *) nullptr; e = 0; @@ -596,7 +596,7 @@ void IcodeVector::init_from_scratch() { -Cell = (IcodeCell *) 0; +Cell = (IcodeCell *) nullptr; Ncells = Nalloc = 0; @@ -1155,7 +1155,7 @@ ICVStack::ICVStack() { -for (int j=0; j n ) return; int k; -Identifier * inew = (Identifier *) 0; +Identifier * inew = (Identifier *) nullptr; k = n/id_array_jump; @@ -507,9 +507,9 @@ if ( !inew ) { for (int j=0; jabbr_s << thresh_abbr_str[ind] << t; node = a; -a = 0; +a = nullptr; return; @@ -1527,7 +1527,7 @@ a->abbr_s << thresh_abbr_str[ind] << cs; node = a; -a = 0; +a = nullptr; return; @@ -1565,7 +1565,7 @@ a->set_na(); node = a; -a = 0; +a = nullptr; return; diff --git a/src/basic/vx_log/logger.cc b/src/basic/vx_log/logger.cc index 50199434c6..281d13cb47 100644 --- a/src/basic/vx_log/logger.cc +++ b/src/basic/vx_log/logger.cc @@ -438,7 +438,7 @@ Logger & Logger::operator=(const Logger & l) void Logger::init_from_scratch() { - out = (ofstream *) 0; + out = (ofstream *) nullptr; clear(); @@ -458,7 +458,7 @@ void Logger::clear() delete out; - out = (ofstream *) 0; + out = (ofstream *) nullptr; } diff --git a/src/basic/vx_log/str_wrappers.cc b/src/basic/vx_log/str_wrappers.cc index 0f58d0ab86..d0eb8b5922 100644 --- a/src/basic/vx_log/str_wrappers.cc +++ b/src/basic/vx_log/str_wrappers.cc @@ -49,7 +49,7 @@ void m_strcpy(char *to_str, const char *from_str, const char *method_name, // to_string should not allocated. This allocates and return to_str after copying char *m_strcpy2(const char *from_str, const char *method_name, const char *extra_msg) { - char *to_str = (char *) 0; + char *to_str = (char *) nullptr; if (from_str) { int str_len = m_strlen(from_str); diff --git a/src/basic/vx_math/hist.cc b/src/basic/vx_math/hist.cc index fb3cfa52c6..067a848013 100644 --- a/src/basic/vx_math/hist.cc +++ b/src/basic/vx_math/hist.cc @@ -52,7 +52,7 @@ Histogram::~Histogram() { -if ( Count ) { delete [] Count; Count = (int *) 0; } +if ( Count ) { delete [] Count; Count = (int *) nullptr; } } @@ -94,7 +94,7 @@ void Histogram::init_from_scratch() { -Count = (int *) 0; +Count = (int *) nullptr; Nbins = 0; @@ -143,7 +143,7 @@ void Histogram::set_nbd(int n, double b, double d) { -if ( Count ) { delete [] Count; Count = (int *) 0; } +if ( Count ) { delete [] Count; Count = (int *) nullptr; } Nbins = n; diff --git a/src/basic/vx_math/legendre.cc b/src/basic/vx_math/legendre.cc index 6d1b87317c..7ba2c696e6 100644 --- a/src/basic/vx_math/legendre.cc +++ b/src/basic/vx_math/legendre.cc @@ -139,9 +139,9 @@ void Legendre::clear() { -if ( P ) { delete [] P; P = 0; } +if ( P ) { delete [] P; P = nullptr; } -if ( PP ) { delete [] PP; PP = 0; } +if ( PP ) { delete [] PP; PP = nullptr; } X = 0.0; diff --git a/src/basic/vx_math/ptile.cc b/src/basic/vx_math/ptile.cc index 31d3152284..c80051ac79 100644 --- a/src/basic/vx_math/ptile.cc +++ b/src/basic/vx_math/ptile.cc @@ -215,8 +215,8 @@ if ( n <= 1 ) return(0); int i, j, ties_current, ties_total, tie_rank_start = 0, tie_rank_end; double tie_rank_mean; -RankInfo *rank_info = (RankInfo *) 0; -double *ordered_array = (double *) 0; +RankInfo *rank_info = (RankInfo *) nullptr; +double *ordered_array = (double *) nullptr; double prev_v, v; rank_info = new RankInfo [n]; @@ -296,8 +296,8 @@ if(ties_current != 0) { } } -if(rank_info) { delete [] rank_info; rank_info = (RankInfo *) 0; } -if(ordered_array) { delete [] ordered_array; ordered_array = (double *) 0; } +if(rank_info) { delete [] rank_info; rank_info = (RankInfo *) nullptr; } +if(ordered_array) { delete [] ordered_array; ordered_array = (double *) nullptr; } return(ties_total); diff --git a/src/basic/vx_math/viewgravity_to_string.cc b/src/basic/vx_math/viewgravity_to_string.cc index 9a7034fbcf..1363a26679 100644 --- a/src/basic/vx_math/viewgravity_to_string.cc +++ b/src/basic/vx_math/viewgravity_to_string.cc @@ -39,7 +39,7 @@ ConcatString viewgravity_to_string(const ViewGravity t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/basic/vx_util/ascii_table.cc b/src/basic/vx_util/ascii_table.cc index ff70dff926..db58781ba1 100644 --- a/src/basic/vx_util/ascii_table.cc +++ b/src/basic/vx_util/ascii_table.cc @@ -1022,7 +1022,7 @@ fix_float(str); if ( DoCommaString ) { char junk[256]; m_strncpy(junk, str.c_str(), str.length(), method_name); - char * p = (char *) 0; + char * p = (char *) nullptr; long X; ConcatString s; ConcatString j2; @@ -1248,7 +1248,7 @@ s = out; // done // -if ( out ) { delete [] out; out = (char *) 0; } +if ( out ) { delete [] out; out = (char *) nullptr; } return ( s ); diff --git a/src/basic/vx_util/asciitablejust_to_string.cc b/src/basic/vx_util/asciitablejust_to_string.cc index 50fbf4387e..6c378d863e 100644 --- a/src/basic/vx_util/asciitablejust_to_string.cc +++ b/src/basic/vx_util/asciitablejust_to_string.cc @@ -39,7 +39,7 @@ ConcatString asciitablejust_to_string(const AsciiTableJust t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/basic/vx_util/command_line.cc b/src/basic/vx_util/command_line.cc index 2063d37d51..7911439c79 100644 --- a/src/basic/vx_util/command_line.cc +++ b/src/basic/vx_util/command_line.cc @@ -234,7 +234,7 @@ void CLOptionInfoArray::init_from_scratch() { -e = (CLOptionInfo *) 0; +e = (CLOptionInfo *) nullptr; AllocInc = 16; // default value @@ -252,7 +252,7 @@ void CLOptionInfoArray::clear() { -if ( e ) { delete [] e; e = (CLOptionInfo *) 0; } +if ( e ) { delete [] e; e = (CLOptionInfo *) nullptr; } @@ -298,7 +298,7 @@ if ( n <= Nalloc ) return; n = AllocInc*( (n + AllocInc - 1)/AllocInc ); int j; -CLOptionInfo * u = (CLOptionInfo *) 0; +CLOptionInfo * u = (CLOptionInfo *) nullptr; u = new CLOptionInfo [n]; @@ -317,11 +317,11 @@ for(j=0; j::init_from_scratch() { -e = (T *) 0; +e = (T *) nullptr; AllocInc = 25; // default value @@ -130,7 +130,7 @@ void CRR_Array::clear() { -if ( e ) { delete [] e; e = (T *) 0; } +if ( e ) { delete [] e; e = (T *) nullptr; } @@ -201,11 +201,11 @@ for(j=0; jclose(); - delete in; in = (ifstream *) 0; + delete in; in = (ifstream *) nullptr; } diff --git a/src/basic/vx_util/data_plane.cc b/src/basic/vx_util/data_plane.cc index a46cb4664d..d9977f7a92 100644 --- a/src/basic/vx_util/data_plane.cc +++ b/src/basic/vx_util/data_plane.cc @@ -1303,10 +1303,10 @@ void DataPlaneArray::init_from_scratch() { -Lower = (double *) 0; -Upper = (double *) 0; +Lower = (double *) nullptr; +Upper = (double *) nullptr; -Plane = (DataPlane **) 0; +Plane = (DataPlane **) nullptr; Nplanes = 0; @@ -1330,11 +1330,11 @@ if ( Nplanes > 0 ) { for (j=0; j= n ) return; int j, k; -DataPlane ** p = (DataPlane **) 0; -double * b = (double *) 0; -double * t = (double *) 0; +DataPlane ** p = (DataPlane **) nullptr; +double * b = (double *) nullptr; +double * t = (double *) nullptr; if ( ! exact ) { @@ -1411,7 +1411,7 @@ t = new double [n]; for (j=0; j::init_from_scratch() { -e = (T **) 0; +e = (T **) nullptr; AllocInc = ncrr_default_alloc_inc; @@ -158,11 +158,11 @@ if ( e ) { for (j=0; j::bubble_sort_decreasing(ncrr_cmp_func _cmp) if ( Nelements < 2 ) return; int j, k; -T * temp = 0; +T * temp = nullptr; for (j=0; j<(Nelements - 1); ++j) { diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index 20632a8978..c4d16f078a 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -642,9 +642,9 @@ int NumArray::rank_array(int &ties) int n_vld, i; - double *data = (double *) 0; - int *data_loc = (int *) 0; - double *data_rank = (double *) 0; + double *data = (double *) nullptr; + int *data_loc = (int *) nullptr; + double *data_rank = (double *) nullptr; // // Arrays to store the raw data values to be ranked, their locations, @@ -690,9 +690,9 @@ int NumArray::rank_array(int &ties) // // Deallocate memory // - if(data) { delete [] data; data = (double *) 0; } - if(data_loc) { delete [] data_loc; data_loc = (int *) 0; } - if(data_rank) { delete [] data_rank; data_rank = (double *) 0; } + if(data) { delete [] data; data = (double *) nullptr; } + if(data_loc) { delete [] data_loc; data_loc = (int *) nullptr; } + if(data_rank) { delete [] data_rank; data_rank = (double *) nullptr; } Sorted = false; diff --git a/src/basic/vx_util/ordinal.cc b/src/basic/vx_util/ordinal.cc index ef8bf4ab1e..66d8417952 100644 --- a/src/basic/vx_util/ordinal.cc +++ b/src/basic/vx_util/ordinal.cc @@ -74,7 +74,7 @@ if ( (n >= 10) && (n <= 20) ) { m_strcpy(out, th, method_name, "out1"); retur n %= 10; -const char * ans = (const char *) 0; +const char * ans = (const char *) nullptr; switch ( n ) { diff --git a/src/basic/vx_util/polyline.cc b/src/basic/vx_util/polyline.cc index 3ae48006f8..aa75ecda94 100644 --- a/src/basic/vx_util/polyline.cc +++ b/src/basic/vx_util/polyline.cc @@ -40,7 +40,7 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// Polyline::Polyline() { - u = v = (double *) 0; + u = v = (double *) nullptr; clear(); } @@ -55,7 +55,7 @@ Polyline::~Polyline() { /////////////////////////////////////////////////////////////////////////////// Polyline::Polyline(const Polyline &c) { - u = v = (double *) 0; + u = v = (double *) nullptr; assign(c); } @@ -75,8 +75,8 @@ Polyline & Polyline::operator=(const Polyline &c) { void Polyline::clear() { - if(u) { delete [] u; u = (double *) 0; } - if(v) { delete [] v; v = (double *) 0; } + if(u) { delete [] u; u = (double *) nullptr; } + if(v) { delete [] v; v = (double *) nullptr; } n_points = n_alloc = 0; @@ -203,8 +203,8 @@ void Polyline::extend_points(int n) { } int i; - double *uu = (double *) 0; - double *vv = (double *) 0; + double *uu = (double *) nullptr; + double *vv = (double *) nullptr; uu = new double [n]; vv = new double [n]; @@ -222,13 +222,13 @@ void Polyline::extend_points(int n) { vv[i] = v[i]; } - delete [] u; u = (double *) 0; - delete [] v; v = (double *) 0; + delete [] u; u = (double *) nullptr; + delete [] v; v = (double *) nullptr; u = uu; v = vv; - uu = vv = (double *) 0; + uu = vv = (double *) nullptr; return; } diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index eae780063f..2eb7f07e67 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -65,7 +65,7 @@ ThreshArray & ThreshArray::operator=(const ThreshArray & a) { void ThreshArray::init_from_scratch() { - t = (SingleThresh *) 0; + t = (SingleThresh *) nullptr; clear(); @@ -76,7 +76,7 @@ void ThreshArray::init_from_scratch() { void ThreshArray::clear() { - if(t) { delete [] t; t = (SingleThresh *) 0; } + if(t) { delete [] t; t = (SingleThresh *) nullptr; } Nelements = Nalloc = 0; @@ -134,17 +134,17 @@ void ThreshArray::extend(int n, bool exact) { n = k*thresharray_alloc_inc; } - SingleThresh *u = (SingleThresh *) 0; + SingleThresh *u = (SingleThresh *) nullptr; u = new SingleThresh [n]; if(t) { for(j=0; j::init_from_scratch() { -E = (T *) 0; +E = (T *) nullptr; clear(); @@ -133,7 +133,7 @@ void TwoD_Array::clear() { -if ( E ) { delete [] E; E = (T *) 0; } +if ( E ) { delete [] E; E = (T *) nullptr; } Nx = Ny = 0; From 7483636985decd60e028e9bd79d26da2710a6299 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 27 Feb 2024 16:52:00 +0000 Subject: [PATCH 007/114] #2673 Change 0 to nullptr --- src/libcode/vx_afm/afm.cc | 84 +++++++++---------- src/libcode/vx_afm/afmkeyword_to_string.cc | 2 +- src/libcode/vx_afm/afmtokentype_to_string.cc | 2 +- .../vx_analysis_util/analysis_utils.cc | 2 +- src/libcode/vx_analysis_util/mode_atts.cc | 8 +- src/libcode/vx_analysis_util/mode_job.cc | 20 ++--- src/libcode/vx_analysis_util/mode_line.cc | 8 +- src/libcode/vx_analysis_util/stat_job.cc | 42 +++++----- src/libcode/vx_analysis_util/stat_line.cc | 2 +- src/libcode/vx_analysis_util/time_series.cc | 4 +- src/libcode/vx_bool_calc/bool_calc.cc | 8 +- src/libcode/vx_bool_calc/token_stack.cc | 8 +- src/libcode/vx_bool_calc/tokenizer.cc | 4 +- src/libcode/vx_color/color_list.cc | 10 +-- src/libcode/vx_color/color_table.cc | 22 ++--- src/libcode/vx_data2d/data_class.cc | 12 +-- src/libcode/vx_data2d/leveltype_to_string.cc | 2 +- .../vx_data2d_factory/data2d_factory.cc | 8 +- src/libcode/vx_data2d_grib/data2d_grib.cc | 4 +- .../vx_data2d_grib/data2d_grib_utils.cc | 2 +- src/libcode/vx_data2d_grib/grib_classes.cc | 50 +++++------ src/libcode/vx_data2d_grib/grib_strings.cc | 4 +- src/libcode/vx_data2d_grib2/data2d_grib2.cc | 4 +- src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc | 4 +- src/libcode/vx_data2d_nc_met/data2d_nc_met.cc | 6 +- src/libcode/vx_data2d_nc_met/get_met_grid.cc | 2 +- src/libcode/vx_data2d_nc_met/met_file.cc | 16 ++-- .../vx_data2d_nc_met/var_info_nc_met.cc | 5 +- src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc | 8 +- .../vx_data2d_nc_wrf/var_info_nc_wrf.cc | 5 +- src/libcode/vx_data2d_nc_wrf/wrf_file.cc | 22 ++--- src/libcode/vx_data2d_python/data2d_python.cc | 6 +- .../vx_data2d_python/grid_from_python_dict.cc | 14 ++-- src/libcode/vx_gis/shapetype_to_string.cc | 2 +- src/libcode/vx_gis/shp_array.h | 8 +- src/libcode/vx_grid/find_grid_by_name.cc | 28 +++---- src/libcode/vx_grid/lc_grid.cc | 8 +- src/libcode/vx_grid/merc_grid.cc | 8 +- src/libcode/vx_grid/semilatlon_grid.cc | 4 +- src/libcode/vx_grid/st_grid.cc | 8 +- src/libcode/vx_gsl_prob/gsl_randist.cc | 20 ++--- src/libcode/vx_gsl_prob/gsl_statistics.cc | 4 +- src/libcode/vx_gsl_prob/gsl_wavelet2d.cc | 8 +- 43 files changed, 252 insertions(+), 246 deletions(-) diff --git a/src/libcode/vx_afm/afm.cc b/src/libcode/vx_afm/afm.cc index e40ac65256..97ff1e20d9 100644 --- a/src/libcode/vx_afm/afm.cc +++ b/src/libcode/vx_afm/afm.cc @@ -253,9 +253,9 @@ void LigatureInfo::init_from_scratch() { -successor_name = (char *) 0; +successor_name = (char *) nullptr; -ligature_name = (char *) 0; +ligature_name = (char *) nullptr; clear(); @@ -273,9 +273,9 @@ void LigatureInfo::clear() { -if ( successor_name ) { delete [] successor_name; successor_name = (char *) 0; } +if ( successor_name ) { delete [] successor_name; successor_name = (char *) nullptr; } -if ( ligature_name ) { delete [] ligature_name; ligature_name = (char *) 0; } +if ( ligature_name ) { delete [] ligature_name; ligature_name = (char *) nullptr; } successor_index = ligature_index = -1; @@ -424,9 +424,9 @@ void AfmCharMetrics::init_from_scratch() { -name = (char *) 0; +name = (char *) nullptr; -linfo = (LigatureInfo *) 0; +linfo = (LigatureInfo *) nullptr; clear(); @@ -443,9 +443,9 @@ void AfmCharMetrics::clear() { -if ( name ) { delete [] name; name = (char *) 0; } +if ( name ) { delete [] name; name = (char *) nullptr; } -if ( linfo ) { delete [] linfo; linfo = (LigatureInfo *) 0; } +if ( linfo ) { delete [] linfo; linfo = (LigatureInfo *) nullptr; } ascii_code = -1; @@ -622,7 +622,7 @@ void PCC::init_from_scratch() { -name = (char *) 0; +name = (char *) nullptr; clear(); @@ -638,7 +638,7 @@ void PCC::clear() { -if ( name ) { delete [] name; name = (char *) 0; } +if ( name ) { delete [] name; name = (char *) nullptr; } delta_x = 0; @@ -762,9 +762,9 @@ void AfmCompositeInfo::init_from_scratch() { -name = (char *) 0; +name = (char *) nullptr; -pcc = (PCC *) 0; +pcc = (PCC *) nullptr; clear(); @@ -780,9 +780,9 @@ void AfmCompositeInfo::clear() { -if ( name ) { delete [] name; name = (char *) 0; } +if ( name ) { delete [] name; name = (char *) nullptr; } -if ( pcc ) { delete [] pcc; pcc = (PCC *) 0; } +if ( pcc ) { delete [] pcc; pcc = (PCC *) nullptr; } n_parts = 0; @@ -926,9 +926,9 @@ void KPX::init_from_scratch() { -name1 = (char *) 0; +name1 = (char *) nullptr; -name2 = (char *) 0; +name2 = (char *) nullptr; clear(); @@ -946,8 +946,8 @@ void KPX::clear() { -if ( name1 ) { delete [] name1; name1 = (char *) 0; } -if ( name2 ) { delete [] name2; name2 = (char *) 0; } +if ( name1 ) { delete [] name1; name1 = (char *) nullptr; } +if ( name2 ) { delete [] name2; name2 = (char *) nullptr; } dx = 0.0; @@ -1069,22 +1069,22 @@ void Afm::init_from_scratch() { -in = (ifstream *) 0; +in = (ifstream *) nullptr; -cm = (AfmCharMetrics *) 0; +cm = (AfmCharMetrics *) nullptr; -FontName = (char *) 0; -FullName = (char *) 0; -FamilyName = (char *) 0; -Weight = (char *) 0; -Version = (char *) 0; -EncodingScheme = (char *) 0; +FontName = (char *) nullptr; +FullName = (char *) nullptr; +FamilyName = (char *) nullptr; +Weight = (char *) nullptr; +Version = (char *) nullptr; +EncodingScheme = (char *) nullptr; -compinfo = (AfmCompositeInfo *) 0; +compinfo = (AfmCompositeInfo *) nullptr; -kpx = (KPX *) 0; +kpx = (KPX *) nullptr; @@ -1104,28 +1104,28 @@ void Afm::clear() { -if ( in ) { delete in; in = (ifstream *) 0; } +if ( in ) { delete in; in = (ifstream *) nullptr; } line_number = 0; -if ( FontName ) { delete [] FontName; FontName = (char *) 0; } -if ( FullName ) { delete [] FullName; FullName = (char *) 0; } -if ( FamilyName ) { delete [] FamilyName; FamilyName = (char *) 0; } -if ( Weight ) { delete [] Weight; Weight = (char *) 0; } -if ( Version ) { delete [] Version; Version = (char *) 0; } -if ( EncodingScheme ) { delete [] EncodingScheme; EncodingScheme = (char *) 0; } +if ( FontName ) { delete [] FontName; FontName = (char *) nullptr; } +if ( FullName ) { delete [] FullName; FullName = (char *) nullptr; } +if ( FamilyName ) { delete [] FamilyName; FamilyName = (char *) nullptr; } +if ( Weight ) { delete [] Weight; Weight = (char *) nullptr; } +if ( Version ) { delete [] Version; Version = (char *) nullptr; } +if ( EncodingScheme ) { delete [] EncodingScheme; EncodingScheme = (char *) nullptr; } -if ( cm ) { delete [] cm; cm = (AfmCharMetrics *) 0; } +if ( cm ) { delete [] cm; cm = (AfmCharMetrics *) nullptr; } n_cms = 0; -if ( compinfo ) { delete [] compinfo; compinfo = (AfmCompositeInfo *) 0; } +if ( compinfo ) { delete [] compinfo; compinfo = (AfmCompositeInfo *) nullptr; } n_composites = 0; -if ( kpx ) { delete [] kpx; kpx = (KPX *) 0; } +if ( kpx ) { delete [] kpx; kpx = (KPX *) nullptr; } n_kern_pairs = 0; @@ -1443,7 +1443,7 @@ for (j=0; jclose(); -delete in; in = (ifstream *) 0; +delete in; in = (ifstream *) nullptr; line_number = 0; @@ -2231,8 +2231,8 @@ if ( ascii_code_2 < 0 ) ascii_code_2 += 256; int j; int cm_index_1, cm_index_2; -const char * n1 = (const char *) 0; -const char * n2 = (const char *) 0; +const char * n1 = (const char *) nullptr; +const char * n2 = (const char *) nullptr; cm_index_1 = lookup_cm(ascii_code_1); cm_index_2 = lookup_cm(ascii_code_2); @@ -2279,7 +2279,7 @@ void set_string(char * & s, const char * text) { -if ( s ) { delete [] s; s = (char *) 0; } +if ( s ) { delete [] s; s = (char *) nullptr; } if ( !text ) return; diff --git a/src/libcode/vx_afm/afmkeyword_to_string.cc b/src/libcode/vx_afm/afmkeyword_to_string.cc index 2f0bc4ebeb..f2e6d2be89 100644 --- a/src/libcode/vx_afm/afmkeyword_to_string.cc +++ b/src/libcode/vx_afm/afmkeyword_to_string.cc @@ -39,7 +39,7 @@ ConcatString afmkeyword_to_string(const AfmKeyword t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/libcode/vx_afm/afmtokentype_to_string.cc b/src/libcode/vx_afm/afmtokentype_to_string.cc index c08fb62f19..02023ee560 100644 --- a/src/libcode/vx_afm/afmtokentype_to_string.cc +++ b/src/libcode/vx_afm/afmtokentype_to_string.cc @@ -39,7 +39,7 @@ ConcatString afmtokentype_to_string(const AfmTokenType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/libcode/vx_analysis_util/analysis_utils.cc b/src/libcode/vx_analysis_util/analysis_utils.cc index c0c079cec3..be09c352c2 100644 --- a/src/libcode/vx_analysis_util/analysis_utils.cc +++ b/src/libcode/vx_analysis_util/analysis_utils.cc @@ -56,7 +56,7 @@ while((c = strtok_r(L, delim, &temp_ptr)) != nullptr) { // done // -if ( L ) { delete [] L; L = (char *) 0; } +if ( L ) { delete [] L; L = (char *) nullptr; } return ( a ); diff --git a/src/libcode/vx_analysis_util/mode_atts.cc b/src/libcode/vx_analysis_util/mode_atts.cc index e63d661549..622a167d37 100644 --- a/src/libcode/vx_analysis_util/mode_atts.cc +++ b/src/libcode/vx_analysis_util/mode_atts.cc @@ -97,7 +97,7 @@ void ModeAttributes::init_from_scratch() { -poly = (MaskPoly *) 0; +poly = (MaskPoly *) nullptr; clear(); @@ -408,7 +408,7 @@ interest_max_set = 0; interest_max = 0.0; -if ( poly ) { delete poly; poly =(MaskPoly *) 0; } +if ( poly ) { delete poly; poly =(MaskPoly *) nullptr; } return; @@ -1356,7 +1356,7 @@ int ModeAttributes::is_keeper(const ModeLine & L) const int i; double x; unixtime t; -const char * c = (const char *) 0; +const char * c = (const char *) nullptr; // @@ -1923,7 +1923,7 @@ void ModeAttributes::parse_command_line(StringArray & a) { int j; -const char * c = (const char *) 0; +const char * c = (const char *) nullptr; j = 0; diff --git a/src/libcode/vx_analysis_util/mode_job.cc b/src/libcode/vx_analysis_util/mode_job.cc index b2e0b1339f..736379d6c9 100644 --- a/src/libcode/vx_analysis_util/mode_job.cc +++ b/src/libcode/vx_analysis_util/mode_job.cc @@ -107,11 +107,11 @@ void BasicModeAnalysisJob::init_from_scratch() { -accums = (NumArray *) 0; +accums = (NumArray *) nullptr; -dumpfile = (ostream *) 0; // don't delete +dumpfile = (ostream *) nullptr; // don't delete -outfile = (ostream *) 0; // don't delete +outfile = (ostream *) nullptr; // don't delete clear(); @@ -133,16 +133,16 @@ atts.clear(); columns.clear(); -if ( accums ) { delete [] accums; accums = (NumArray *) 0; } +if ( accums ) { delete [] accums; accums = (NumArray *) nullptr; } n_lines_read = n_lines_kept = 0; // Write any remaning lines to the dump file if ( dumpfile ) *(dumpfile) << dump_at; -dumpfile = (ostream *) 0; // don't delete +dumpfile = (ostream *) nullptr; // don't delete -outfile = (ostream *) 0; // don't delete +outfile = (ostream *) nullptr; // don't delete n_dump = 0; @@ -756,7 +756,7 @@ void ByCaseJob::init_from_scratch() { -info = (ByCaseInfo *) 0; +info = (ByCaseInfo *) nullptr; BasicModeAnalysisJob::init_from_scratch(); @@ -774,7 +774,7 @@ void ByCaseJob::clear() BasicModeAnalysisJob::clear(); -if ( info ) { delete [] info; info = (ByCaseInfo *) 0; } +if ( info ) { delete [] info; info = (ByCaseInfo *) nullptr; } valid_times.clear(); @@ -995,7 +995,7 @@ valid_times.sort_increasing(); n_valid_times = valid_times.n_elements(); -if ( info ) { delete [] info; info = (ByCaseInfo *) 0; } +if ( info ) { delete [] info; info = (ByCaseInfo *) nullptr; } info = new ByCaseInfo [n_valid_times + 1]; // in case n_valid_times is zero @@ -1030,7 +1030,7 @@ else do_output(cout); // done // -if ( info ) { delete [] info; info = (ByCaseInfo *) 0; } +if ( info ) { delete [] info; info = (ByCaseInfo *) nullptr; } return; diff --git a/src/libcode/vx_analysis_util/mode_line.cc b/src/libcode/vx_analysis_util/mode_line.cc index 5a7319565f..3d565c1f5d 100644 --- a/src/libcode/vx_analysis_util/mode_line.cc +++ b/src/libcode/vx_analysis_util/mode_line.cc @@ -139,7 +139,7 @@ void ModeLine::clear() DataLine::clear(); HdrFlag = false; -HdrLine = (AsciiHeaderLine *) 0; +HdrLine = (AsciiHeaderLine *) nullptr; return; @@ -426,7 +426,7 @@ unixtime ModeLine::fcst_init() const unixtime v, l; -const char * c = (char *) 0; +const char * c = (char *) nullptr; c = get_item("FCST_VALID"); @@ -528,7 +528,7 @@ unixtime ModeLine::obs_init() const unixtime v, l; -const char * c = (char *) 0; +const char * c = (char *) nullptr; c = get_item("OBS_VALID"); @@ -999,7 +999,7 @@ nfcst = nobs = -1; if ( is_single() ) return ( false ); const char * c = object_id(); -const char * u = (const char *) 0; +const char * u = (const char *) nullptr; // // skip leading F, O, CF or CO diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 963271d905..6f09f1779c 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -75,13 +75,13 @@ STATAnalysisJob & STATAnalysisJob::operator=( void STATAnalysisJob::init_from_scratch() { - dump_row = (char *) 0; - dr_out = (ofstream *) 0; + dump_row = (char *) nullptr; + dr_out = (ofstream *) nullptr; n_dump = 0; - stat_file = (char *) 0; - stat_out = (ofstream *) 0; - boot_rng = (char *) 0; - boot_seed = (char *) 0; + stat_file = (char *) nullptr; + stat_out = (ofstream *) nullptr; + boot_rng = (char *) nullptr; + boot_seed = (char *) nullptr; model.set_ignore_case(1); desc.set_ignore_case(1); @@ -183,8 +183,8 @@ void STATAnalysisJob::clear() { close_dump_row_file(); close_stat_file(); - if(dump_row) { delete [] dump_row; dump_row = (char *) 0; } - if(stat_file) { delete [] stat_file; stat_file = (char *) 0; } + if(dump_row) { delete [] dump_row; dump_row = (char *) nullptr; } + if(stat_file) { delete [] stat_file; stat_file = (char *) nullptr; } stat_row = 0; @@ -1102,7 +1102,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { jc_array.add(c); - lp = (char *) 0; + lp = (char *) nullptr; } // @@ -1210,11 +1210,11 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { if(jc_array[i] == "-job") { if(set_job_type(jc_array[i+1].c_str()) != 0) { - delete [] line; line = 0; lp = 0; + lp = nullptr; mlog << Error << "\nSTATAnalysisJob::STATAnalysisJob::parse_job_command() -> " << "unrecognized job type specified \"" << jc_array[i] << "\" in job command line: " << jobstring << "\n\n"; - if(line) { delete [] line; line = (char *) 0; } + if(line) { delete [] line; line = (char *) nullptr; } throw(1); } i++; @@ -1636,7 +1636,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { << "unrecognized switch \"" << jc_array[i] << "\" in job command line: " << jobstring << "\n\n"; - if(line) { delete [] line; line = (char *) 0; } + if(line) { delete [] line; line = (char *) nullptr; } throw(1); } // end if @@ -1658,7 +1658,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { << "no match found for " << (line_type.n() == 1 ? line_type[0] : "header") << " column named \"" << hdr_name[i] << "\"\n\n"; - if(line) { delete [] line; line = (char *) 0; } + if(line) { delete [] line; line = (char *) nullptr; } throw(1); } } // end for @@ -1672,8 +1672,8 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { // // Deallocate memory // - if(line) { delete [] line; line = (char *) 0; } - lp = (char *) 0; + if(line) { delete [] line; line = (char *) nullptr; } + lp = (char *) nullptr; return; } @@ -1712,7 +1712,7 @@ int STATAnalysisJob::set_job_type(const char *c) { void STATAnalysisJob::set_dump_row(const char *c) { - if(dump_row) { delete [] dump_row; dump_row = (char *) 0; } + if(dump_row) { delete [] dump_row; dump_row = (char *) nullptr; } if(!c) return; @@ -1727,7 +1727,7 @@ void STATAnalysisJob::set_dump_row(const char *c) { void STATAnalysisJob::set_stat_file(const char *c) { - if(stat_file) { delete [] stat_file; stat_file = (char *) 0; } + if(stat_file) { delete [] stat_file; stat_file = (char *) nullptr; } if(!c) return; @@ -1823,7 +1823,7 @@ void STATAnalysisJob::set_mask_sid(const char *c) { void STATAnalysisJob::set_boot_rng(const char *c) { - if(boot_rng) { delete [] boot_rng; boot_rng = (char *) 0; } + if(boot_rng) { delete [] boot_rng; boot_rng = (char *) nullptr; } if(!c) return; @@ -1838,7 +1838,7 @@ void STATAnalysisJob::set_boot_rng(const char *c) { void STATAnalysisJob::set_boot_seed(const char *c) { - if(boot_seed) { delete [] boot_seed; boot_seed = (char *) 0; } + if(boot_seed) { delete [] boot_seed; boot_seed = (char *) nullptr; } if(!c) return; @@ -1915,7 +1915,7 @@ void STATAnalysisJob::close_dump_row_file() { dr_out->close(); delete dr_out; - dr_out = (ofstream *) 0; + dr_out = (ofstream *) nullptr; n_dump = 0; } @@ -2136,7 +2136,7 @@ void STATAnalysisJob::close_stat_file() { stat_out->close(); delete stat_out; - stat_out = (ofstream *) 0; + stat_out = (ofstream *) nullptr; } return; diff --git a/src/libcode/vx_analysis_util/stat_line.cc b/src/libcode/vx_analysis_util/stat_line.cc index faf5c409f3..d229712943 100644 --- a/src/libcode/vx_analysis_util/stat_line.cc +++ b/src/libcode/vx_analysis_util/stat_line.cc @@ -141,7 +141,7 @@ void STATLine::clear() DataLine::clear(); Type = no_stat_line_type; -HdrLine = (AsciiHeaderLine *) 0; +HdrLine = (AsciiHeaderLine *) nullptr; return; diff --git a/src/libcode/vx_analysis_util/time_series.cc b/src/libcode/vx_analysis_util/time_series.cc index a07c07debd..dd284f35ad 100644 --- a/src/libcode/vx_analysis_util/time_series.cc +++ b/src/libcode/vx_analysis_util/time_series.cc @@ -94,7 +94,7 @@ void TimeSeries::init_from_scratch() { -Value = (double *) 0; +Value = (double *) nullptr; clear(); @@ -110,7 +110,7 @@ void TimeSeries::clear() { -if ( Value ) { delete [] Value; Value = (double *) 0; } +if ( Value ) { delete [] Value; Value = (double *) nullptr; } Nelements = 0; diff --git a/src/libcode/vx_bool_calc/bool_calc.cc b/src/libcode/vx_bool_calc/bool_calc.cc index 21ccd83921..d0582e3478 100644 --- a/src/libcode/vx_bool_calc/bool_calc.cc +++ b/src/libcode/vx_bool_calc/bool_calc.cc @@ -53,9 +53,9 @@ void BoolCalc::init_from_scratch() { -s = 0; +s = nullptr; -program = 0; +program = nullptr; clear(); @@ -71,9 +71,9 @@ void BoolCalc::clear() { -if ( s ) { delete s; s = 0; } +if ( s ) { delete s; s = nullptr; } -if ( program ) { delete program; program = 0; } +if ( program ) { delete program; program = nullptr; } Max_depth = Max_local = 0; diff --git a/src/libcode/vx_bool_calc/token_stack.cc b/src/libcode/vx_bool_calc/token_stack.cc index cdcdb2f039..41e27122fa 100644 --- a/src/libcode/vx_bool_calc/token_stack.cc +++ b/src/libcode/vx_bool_calc/token_stack.cc @@ -99,7 +99,7 @@ void TokenStack::init_from_scratch() { -e = (Token *) 0; +e = (Token *) nullptr; AllocInc = 50; // default value @@ -117,7 +117,7 @@ void TokenStack::clear() { -if ( e ) { delete [] e; e = (Token *) 0; } +if ( e ) { delete [] e; e = (Token *) nullptr; } @@ -189,11 +189,11 @@ for(j=0; j= n ) return; int k; -ClistEntry * u = (ClistEntry *) 0; +ClistEntry * u = (ClistEntry *) nullptr; k = n/colorlist_alloc_inc; @@ -348,11 +348,11 @@ if ( e ) { for (k=0; k failed to read colortable file \"" << input_filename << "\"\n\n"; @@ -593,11 +593,11 @@ sort(); // done // -fclose(colorin); colorin = (FILE *) 0; +fclose(colorin); colorin = (FILE *) nullptr; -input_filename = (const char *) 0; +input_filename = (const char *) nullptr; -the_table = (ColorTable *) 0; +the_table = (ColorTable *) nullptr; clist.clear(); @@ -802,7 +802,7 @@ void ColorTable::extend(int n) if ( Nalloc >= n ) return; int j; -CtableEntry * u = (CtableEntry *) 0; +CtableEntry * u = (CtableEntry *) nullptr; j = n/ctable_alloc_inc; @@ -828,11 +828,11 @@ if ( Entry ) { } - delete [] Entry; Entry = (CtableEntry *) 0; + delete [] Entry; Entry = (CtableEntry *) nullptr; } -Entry = u; u = (CtableEntry *) 0; +Entry = u; u = (CtableEntry *) nullptr; // diff --git a/src/libcode/vx_data2d/data_class.cc b/src/libcode/vx_data2d/data_class.cc index 1d95284e38..8f6fb7cda3 100644 --- a/src/libcode/vx_data2d/data_class.cc +++ b/src/libcode/vx_data2d/data_class.cc @@ -106,8 +106,8 @@ void Met2dDataFile::mtddf_init_from_scratch() { -Raw_Grid = (Grid *) 0; -Dest_Grid = (Grid *) 0; +Raw_Grid = (Grid *) nullptr; +Dest_Grid = (Grid *) nullptr; ShiftRight = 0; @@ -123,8 +123,8 @@ void Met2dDataFile::mtddf_clear() { -if ( Raw_Grid ) { delete Raw_Grid; Raw_Grid = (Grid *) 0; } -if ( Dest_Grid ) { delete Dest_Grid; Dest_Grid = (Grid *) 0; } +if ( Raw_Grid ) { delete Raw_Grid; Raw_Grid = (Grid *) nullptr; } +if ( Dest_Grid ) { delete Dest_Grid; Dest_Grid = (Grid *) nullptr; } Filename.clear(); @@ -268,7 +268,7 @@ mlog << Debug(3) << "Resetting grid definition from \"" } -if ( Dest_Grid ) { delete Dest_Grid; Dest_Grid = 0; } +if ( Dest_Grid ) { delete Dest_Grid; Dest_Grid = nullptr; } Dest_Grid = new Grid; @@ -295,7 +295,7 @@ if ( ! Raw_Grid ) { } -if ( Dest_Grid ) { delete Dest_Grid; Dest_Grid = 0; } +if ( Dest_Grid ) { delete Dest_Grid; Dest_Grid = nullptr; } Dest_Grid = new Grid; diff --git a/src/libcode/vx_data2d/leveltype_to_string.cc b/src/libcode/vx_data2d/leveltype_to_string.cc index 1c7d52b24e..8c119b8b45 100644 --- a/src/libcode/vx_data2d/leveltype_to_string.cc +++ b/src/libcode/vx_data2d/leveltype_to_string.cc @@ -39,7 +39,7 @@ ConcatString leveltype_to_string(const LevelType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/libcode/vx_data2d_factory/data2d_factory.cc b/src/libcode/vx_data2d_factory/data2d_factory.cc index 7d188c2080..39fcc7f786 100644 --- a/src/libcode/vx_data2d_factory/data2d_factory.cc +++ b/src/libcode/vx_data2d_factory/data2d_factory.cc @@ -161,7 +161,7 @@ MetPythonDataFile * p = nullptr; Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename) { GrdFileType type; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // // Determine the file type @@ -195,7 +195,7 @@ Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, { - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // // Use the file type, if valid @@ -246,7 +246,7 @@ Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, bool is_2d_data_file(const ConcatString &filename, const ConcatString &config_str) { Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; GrdFileType type = FileType_None; // Check for a requested file type @@ -260,7 +260,7 @@ bool is_2d_data_file(const ConcatString &filename, mtddf = mtddf_factory.new_met_2d_data_file(filename.c_str(), type); bool status = (mtddf != 0); - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } return(status); } diff --git a/src/libcode/vx_data2d_grib/data2d_grib.cc b/src/libcode/vx_data2d_grib/data2d_grib.cc index 09dc80815a..a436d725a4 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib.cc @@ -103,7 +103,7 @@ void MetGrib1DataFile::grib1_init_from_scratch() { -GF = (GribFile *) 0; +GF = (GribFile *) nullptr; Plane.clear(); @@ -121,7 +121,7 @@ void MetGrib1DataFile::close() { -if ( GF ) { delete GF; GF = (GribFile *) 0; } +if ( GF ) { delete GF; GF = (GribFile *) nullptr; } CurrentRecord.reset(); diff --git a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc index 2f1f66385b..2f8f61dfe0 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc @@ -577,7 +577,7 @@ void read_pds(const GribRecord &r, int &bms_flag, unixtime &init_ut, unixtime &valid_ut, int &accum) { double sec_per_fcst_unit = 0.0; unsigned char pp1[2]; - Section1_Header *pds = (Section1_Header *) 0; + Section1_Header *pds = (Section1_Header *) nullptr; pds = (Section1_Header *) r.pds; diff --git a/src/libcode/vx_data2d_grib/grib_classes.cc b/src/libcode/vx_data2d_grib/grib_classes.cc index 5954a6ed7d..03817a9790 100644 --- a/src/libcode/vx_data2d_grib/grib_classes.cc +++ b/src/libcode/vx_data2d_grib/grib_classes.cc @@ -63,7 +63,7 @@ GribRecord::GribRecord() { is = new Section0_Header; -pds = (unsigned char *) 0; +pds = (unsigned char *) nullptr; gds = new Section2_Header; bms = new Section3_Header; bds = new Section4_Header; @@ -102,8 +102,8 @@ word_size = 0; data_lseek_offset = record_lseek_offset = (off_t) 0; -// data = (unsigned char *) 0; -// bitmap = (unsigned char *) 0; +// data = (unsigned char *) nullptr; +// bitmap = (unsigned char *) nullptr; // //data_size = data_alloc = 0; //bitmap_size = bitmap_alloc = 0; @@ -135,13 +135,13 @@ GribRecord::~GribRecord() { -if ( is ) { delete is; is = (Section0_Header *) 0; } -if ( pds ) { delete [] pds; pds = (unsigned char *) 0; } -if ( gds ) { delete gds; gds = (Section2_Header *) 0; } -if ( bms ) { delete bms; bms = (Section3_Header *) 0; } -if ( bds ) { delete bds; bds = (Section4_Header *) 0; } -//if ( data ) { delete data; data = (vector *) 0; } -//if ( bitmap ) { delete bitmap; bitmap = (vector *) 0; } +if ( is ) { delete is; is = (Section0_Header *) nullptr; } +if ( pds ) { delete [] pds; pds = (unsigned char *) nullptr; } +if ( gds ) { delete gds; gds = (Section2_Header *) nullptr; } +if ( bms ) { delete bms; bms = (Section3_Header *) nullptr; } +if ( bds ) { delete bds; bds = (Section4_Header *) nullptr; } +//if ( data ) { delete data; data = (vector *) nullptr; } +//if ( bitmap ) { delete bitmap; bitmap = (vector *) nullptr; } } @@ -316,8 +316,8 @@ uint4 GribRecord::long_data_value(int n) const int k, byte, shift; uint4 value, u; -unsigned char *c1 = (unsigned char *) 0; -const unsigned char *c2 = (unsigned char *) 0; +unsigned char *c1 = (unsigned char *) nullptr; +const unsigned char *c2 = (unsigned char *) nullptr; k = n*word_size; @@ -522,7 +522,7 @@ fd = -1; file_start = (long) -1; -name = (char *) 0; +name = (char *) nullptr; referenceCount = n_alloc = issue = lead = 0; @@ -530,9 +530,9 @@ buf_size = (size_t) 0; n_records = (unsigned int) 0; -buf = (unsigned char *) 0; +buf = (unsigned char *) nullptr; -record_info = (RecordInfo *) 0; +record_info = (RecordInfo *) nullptr; } @@ -546,11 +546,11 @@ GribFileRep::~GribFileRep() if ( fd >= 0 ) { ::close(fd); fd = -1; } -if ( buf ) { delete [] buf; buf = (unsigned char *) 0; } +if ( buf ) { delete [] buf; buf = (unsigned char *) nullptr; } -if ( name ) { delete [] name; name = (char *) 0; } +if ( name ) { delete [] name; name = (char *) nullptr; } -if ( n_alloc ) { delete [] record_info; record_info = (RecordInfo *) 0; } +if ( n_alloc ) { delete [] record_info; record_info = (RecordInfo *) nullptr; } } @@ -565,7 +565,7 @@ void GribFileRep::record_extend(int n) if ( n_alloc > n ) return; int j; -RecordInfo *r = (RecordInfo *) 0; +RecordInfo *r = (RecordInfo *) nullptr; ++n; @@ -600,9 +600,9 @@ for (j=n_records; jrecord_extend(1); diff --git a/src/libcode/vx_data2d_grib/grib_strings.cc b/src/libcode/vx_data2d_grib/grib_strings.cc index f9b3edcdac..31d5428c1e 100644 --- a/src/libcode/vx_data2d_grib/grib_strings.cc +++ b/src/libcode/vx_data2d_grib/grib_strings.cc @@ -266,7 +266,7 @@ int str_to_grib_code(const char *c, int &pcode, int gc = bad_data_int; const int buf_len = 512; char tmp_str[buf_len + 1]; - char *ptr = (char *) 0, *save_ptr = (char *) 0; + char *ptr = (char *) nullptr, *save_ptr = (char *) nullptr; const char *method_name = "str_to_grib_code() -> "; // Parse out strings of the form: @@ -308,7 +308,7 @@ int str_to_prob_info(const char *c, double &pthresh_lo, double &pthresh_hi, int gc = bad_data_int, i, n_lt, n_gt; const int buf_len = 512; char tmp_str[buf_len + 1]; - char *ptr = (char *) 0, *save_ptr = (char *) 0; + char *ptr = (char *) nullptr, *save_ptr = (char *) nullptr; SingleThresh st; const char *method_name = "str_to_prob_info()"; diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.cc b/src/libcode/vx_data2d_grib2/data2d_grib2.cc index 5ea279fb96..401d226f8e 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.cc +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.cc @@ -1583,7 +1583,7 @@ long MetGrib2DataFile::read_grib2_record(long offset, g2int unpack, fread(cgrib, sizeof(unsigned char), lgrib, FileGrib2); if(g2_info(cgrib, listsec0, listsec1, &numfields, &numlocal)) { - if(cgrib) { delete [] cgrib; cgrib = (unsigned char *) 0; } + if(cgrib) { delete [] cgrib; cgrib = (unsigned char *) nullptr; } return -1; } @@ -1591,7 +1591,7 @@ long MetGrib2DataFile::read_grib2_record(long offset, g2int unpack, g2_getfld(cgrib, ifld, unpack, 1, &gfld); // cleanup - if(cgrib) { delete [] cgrib; cgrib = (unsigned char *) 0; } + if(cgrib) { delete [] cgrib; cgrib = (unsigned char *) nullptr; } // reset to default out of memory handler set_new_handler(oom); diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc index 72275ecd9f..fcece7b021 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc @@ -110,7 +110,7 @@ NcVarInfo *MetNcCFDataFile::find_first_data_var() { void MetNcCFDataFile::close() { - if(_file) { delete _file; _file = (NcCfFile *) 0; } + if(_file) { delete _file; _file = (NcCfFile *) nullptr; } return; } @@ -260,7 +260,7 @@ bool MetNcCFDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) } // Read the data - NcVarInfo *info = (NcVarInfo *) 0; + NcVarInfo *info = (NcVarInfo *) nullptr; bool status = _file->getData(vinfo_nc->req_name().c_str(), dimension, diff --git a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc index 40caecba95..fa2dad9289 100644 --- a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc @@ -63,7 +63,7 @@ MetNcMetDataFile & MetNcMetDataFile::operator=(const MetNcMetDataFile &) { void MetNcMetDataFile::nc_met_init_from_scratch() { - MetNc = (MetNcFile *) 0; + MetNc = (MetNcFile *) nullptr; close(); @@ -74,7 +74,7 @@ void MetNcMetDataFile::nc_met_init_from_scratch() { void MetNcMetDataFile::close() { - if(MetNc) { delete MetNc; MetNc = (MetNcFile *) 0; } + if(MetNc) { delete MetNc; MetNc = (MetNcFile *) nullptr; } return; } @@ -123,7 +123,7 @@ bool MetNcMetDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) { bool status = false; ConcatString req_time_str, data_time_str; VarInfoNcMet * vinfo_nc = (VarInfoNcMet *) &vinfo; - NcVarInfo *info = (NcVarInfo *) 0; + NcVarInfo *info = (NcVarInfo *) nullptr; int i; // Initialize the data plane diff --git a/src/libcode/vx_data2d_nc_met/get_met_grid.cc b/src/libcode/vx_data2d_nc_met/get_met_grid.cc index 7ae924bd34..0f4331b811 100644 --- a/src/libcode/vx_data2d_nc_met/get_met_grid.cc +++ b/src/libcode/vx_data2d_nc_met/get_met_grid.cc @@ -700,7 +700,7 @@ void get_semilatlon_var(NcFile *ncfile, const char * var_name, NumArray &out_na) double * data_values = new double[ count ]; get_nc_data(&nc_var, data_values); for(int i=0; i= max_met_args ) { int j, count; bool found = false; -NcVarInfo * var = (NcVarInfo *) 0; +NcVarInfo * var = (NcVarInfo *) nullptr; const int Nx = grid.nx(); const int Ny = grid.ny(); LongArray b = a; diff --git a/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc b/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc index 338d83e8f4..3512727c8d 100644 --- a/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc @@ -148,7 +148,10 @@ void VarInfoNcMet::add_dimension(int dim) { void VarInfoNcMet::set_magic(const ConcatString &nstr, const ConcatString &lstr) { ConcatString tmp_str; - char *ptr = (char *) 0, *ptr2 = (char *) 0, *ptr3 = (char *) 0, *save_ptr = (char *) 0; + char *ptr = (char *) nullptr; + char *ptr2 = (char *) nullptr; + char *ptr3 = (char *) nullptr; + char *save_ptr = (char *) nullptr; // Store the magic string VarInfo::set_magic(nstr, lstr); diff --git a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc index e249856a7a..2ff9592e9a 100644 --- a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc @@ -64,7 +64,7 @@ MetNcWrfDataFile & MetNcWrfDataFile::operator=(const MetNcWrfDataFile &) { void MetNcWrfDataFile::nc_wrf_init_from_scratch() { - WrfNc = (WrfFile *) 0; + WrfNc = (WrfFile *) nullptr; close(); @@ -75,7 +75,7 @@ void MetNcWrfDataFile::nc_wrf_init_from_scratch() { void MetNcWrfDataFile::close() { - if(WrfNc) { delete WrfNc; WrfNc = (WrfFile *) 0; } + if(WrfNc) { delete WrfNc; WrfNc = (WrfFile *) nullptr; } return; } @@ -125,7 +125,7 @@ bool MetNcWrfDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) { double pressure; ConcatString level_str; VarInfoNcWrf * vinfo_nc = (VarInfoNcWrf *) &vinfo; - NcVarInfo *info = (NcVarInfo *) 0; + NcVarInfo *info = (NcVarInfo *) nullptr; // Initialize the data plane plane.clear(); @@ -204,7 +204,7 @@ int MetNcWrfDataFile::data_plane_array(VarInfo &vinfo, bool found = false; VarInfoNcWrf *vinfo_nc = (VarInfoNcWrf *) &vinfo; LongArray dim = vinfo_nc->dimension(); - NcVarInfo *info = (NcVarInfo *) 0; + NcVarInfo *info = (NcVarInfo *) nullptr; LongArray cur_dim; DataPlane cur_plane; diff --git a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc index 62c1d9c834..1edc5a102f 100644 --- a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc @@ -160,7 +160,10 @@ void VarInfoNcWrf::set_dimension(int i_dim, int dim) { void VarInfoNcWrf::set_magic(const ConcatString &nstr, const ConcatString &lstr) { ConcatString tmp_str; - char *ptr = (char *) 0, *ptr2 = (char *) 0, *ptr3 = (char *) 0, *save_ptr = (char *) 0; + char *ptr = (char *) nullptr; + char *ptr2 = (char *) nullptr; + char *ptr3 = (char *) nullptr; + char *save_ptr = (char *) nullptr; const char *method_name = "VarInfoNcWrf::set_magic() -> "; // Store the magic string diff --git a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc index 19c99b6de8..79e277bef6 100644 --- a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc +++ b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc @@ -124,13 +124,13 @@ void WrfFile::init_from_scratch() { -Nc = (NcFile *) 0; +Nc = (NcFile *) nullptr; -Dim = (NcDim **) 0; +Dim = (NcDim **) nullptr; -Var = (NcVarInfo *) 0; +Var = (NcVarInfo *) nullptr; -Time = (unixtime *) 0; +Time = (unixtime *) nullptr; close(); @@ -146,21 +146,21 @@ void WrfFile::close() { -if ( Nc ) { delete Nc; Nc = (NcFile *) 0; } +if ( Nc ) { delete Nc; Nc = (NcFile *) nullptr; } -if ( Dim ) { delete [] Dim; Dim = (NcDim **) 0; } +if ( Dim ) { delete [] Dim; Dim = (NcDim **) nullptr; } -if ( Time ) { delete [] Time; Time = (unixtime *) 0; } +if ( Time ) { delete [] Time; Time = (unixtime *) nullptr; } Ndims = 0; DimNames.clear(); -Tdim = (NcDim *) 0; +Tdim = (NcDim *) nullptr; Nvars = 0; -if ( Var ) { delete [] Var; Var = (NcVarInfo *) 0; } +if ( Var ) { delete [] Var; Var = (NcVarInfo *) nullptr; } InitTime = (unixtime) 0; @@ -605,8 +605,8 @@ int j, k, count; int x, y; double value; bool found = false; -NcVarInfo * var = (NcVarInfo *) 0; -NcVarInfo * P = (NcVarInfo *) 0; +NcVarInfo * var = (NcVarInfo *) nullptr; +NcVarInfo * P = (NcVarInfo *) nullptr; LongArray b = a; pressure = bad_data_double; diff --git a/src/libcode/vx_data2d_python/data2d_python.cc b/src/libcode/vx_data2d_python/data2d_python.cc index 3b146f45f7..546a68514d 100644 --- a/src/libcode/vx_data2d_python/data2d_python.cc +++ b/src/libcode/vx_data2d_python/data2d_python.cc @@ -153,7 +153,7 @@ close(); ConcatString full_path, file_name; int i, file_argc; -char **file_argv = (char **) 0; // allocated +char **file_argv = (char **) nullptr; // allocated StringArray sa; const char *method_name = "MetPythonDataFile::open() "; @@ -231,9 +231,9 @@ if ( ShiftRight != 0 ) Plane.shift_right(ShiftRight); if ( file_argv ) { for ( i=1; i::init_from_scratch() { -E = (T *) 0; +E = (T *) nullptr; AllocInc = 25; // default value @@ -143,7 +143,7 @@ void Shp_Array::clear() { -if ( E ) { delete [] E; E = (T *) 0; } +if ( E ) { delete [] E; E = (T *) nullptr; } @@ -214,11 +214,11 @@ for(j=0; j Date: Tue, 27 Feb 2024 16:52:10 +0000 Subject: [PATCH 008/114] #2673 Change 0 to nullptr --- src/libcode/vx_nc_obs/met_point_data.cc | 16 ++-- src/libcode/vx_nc_obs/nc_point_obs.cc | 4 +- src/libcode/vx_nc_util/grid_output.cc | 2 +- src/libcode/vx_nc_util/nc_utils.cc | 8 +- src/libcode/vx_nc_util/nc_var_info.cc | 6 +- src/libcode/vx_pb_util/do_blocking.cc | 2 +- src/libcode/vx_pb_util/do_unblocking.cc | 2 +- src/libcode/vx_plot_util/vx_plot_util.cc | 2 +- .../vx_pointdata_python/pointdata_python.cc | 2 +- src/libcode/vx_ps/documentmedia_to_string.cc | 2 +- .../vx_ps/documentorientation_to_string.cc | 2 +- src/libcode/vx_ps/fontfamily_to_string.cc | 2 +- src/libcode/vx_ps/ps_text.cc | 18 ++-- src/libcode/vx_ps/table_helper.cc | 10 +- src/libcode/vx_ps/vx_ps.cc | 8 +- src/libcode/vx_pxm/pcm.cc | 10 +- src/libcode/vx_pxm/pgm.cc | 2 +- src/libcode/vx_pxm/ppm.cc | 8 +- src/libcode/vx_pxm/pxm_base.cc | 10 +- src/libcode/vx_render/flate_filter.cc | 6 +- src/libcode/vx_render/ps_filter.cc | 4 +- src/libcode/vx_render/psout_filter.cc | 6 +- src/libcode/vx_render/render_pbm.cc | 6 +- src/libcode/vx_render/render_pcm.cc | 6 +- src/libcode/vx_render/render_pgm.cc | 6 +- src/libcode/vx_render/render_ppm.cc | 6 +- src/libcode/vx_series_data/series_data.cc | 8 +- src/libcode/vx_shapedata/engine.cc | 38 ++++---- src/libcode/vx_shapedata/interest.cc | 22 ++--- src/libcode/vx_shapedata/mode_conf_info.cc | 38 ++++---- src/libcode/vx_shapedata/node.cc | 37 +++---- src/libcode/vx_shapedata/shapedata.cc | 2 +- src/libcode/vx_stat_out/stat_columns.cc | 4 +- src/libcode/vx_statistics/apply_mask.cc | 22 ++--- src/libcode/vx_statistics/compute_ci.cc | 96 ++++++++++--------- src/libcode/vx_statistics/contable_nx2.cc | 6 +- src/libcode/vx_statistics/contable_stats.cc | 20 ++-- src/libcode/vx_statistics/met_stats.cc | 62 ++++++------ src/libcode/vx_statistics/obs_error.cc | 20 ++-- src/libcode/vx_statistics/pair_base.cc | 18 ++-- .../vx_statistics/pair_data_ensemble.cc | 32 +++---- src/libcode/vx_statistics/pair_data_point.cc | 36 +++---- src/libcode/vx_statistics/read_climo.cc | 8 +- src/libcode/vx_tc_util/atcf_line_base.cc | 10 +- src/libcode/vx_tc_util/atcf_track_line.cc | 10 +- src/libcode/vx_tc_util/diag_file.cc | 8 +- src/libcode/vx_tc_util/pair_data_genesis.cc | 2 +- src/libcode/vx_tc_util/prob_rirw_pair_info.cc | 4 +- src/libcode/vx_tc_util/tc_columns.cc | 2 +- src/libcode/vx_tc_util/tc_stat_line.cc | 4 +- src/libcode/vx_tc_util/track_info.cc | 10 +- src/libcode/vx_tc_util/track_pair_info.cc | 12 +-- src/libcode/vx_tc_util/vx_tc_nc_util.cc | 6 +- .../vx_time_series/time_series_util.cc | 2 +- 54 files changed, 351 insertions(+), 344 deletions(-) diff --git a/src/libcode/vx_nc_obs/met_point_data.cc b/src/libcode/vx_nc_obs/met_point_data.cc index 0312f97800..ad30186dbe 100644 --- a/src/libcode/vx_nc_obs/met_point_data.cc +++ b/src/libcode/vx_nc_obs/met_point_data.cc @@ -38,7 +38,7 @@ using namespace std; MetPointData::MetPointData() { // Derived class should set obs_data - obs_data = (MetPointObsData *)0; + obs_data = (MetPointObsData *) nullptr; init_from_scratch(); } @@ -267,31 +267,31 @@ void MetPointObsData::clear() { void MetPointObsData::clear_numbers() { if (0 != obs_ids) { delete [] obs_ids; - obs_ids = (int *)0; + obs_ids = (int *) nullptr; } if (0 != obs_hids) { delete [] obs_hids; - obs_hids = (int *)0; + obs_hids = (int *) nullptr; } if (0 != obs_qids) { delete [] obs_qids; - obs_qids = (int *)0; + obs_qids = (int *) nullptr; } if (0 != obs_lvls) { delete [] obs_lvls; - obs_lvls = (float *)0; + obs_lvls = (float *) nullptr; } if (0 != obs_hgts) { delete [] obs_hgts; - obs_hgts = (float *)0; + obs_hgts = (float *) nullptr; } if (0 != obs_vals) { delete [] obs_vals; - obs_vals = (float *)0; + obs_vals = (float *) nullptr; } if (0 != obs_arr) { delete [] obs_arr; - obs_arr = (float *)0; + obs_arr = (float *) nullptr; } } diff --git a/src/libcode/vx_nc_obs/nc_point_obs.cc b/src/libcode/vx_nc_obs/nc_point_obs.cc index 33e1dfa85b..ea60b62834 100644 --- a/src/libcode/vx_nc_obs/nc_point_obs.cc +++ b/src/libcode/vx_nc_obs/nc_point_obs.cc @@ -55,7 +55,7 @@ void MetNcPointObs::init_from_scratch() { MetPointData::init_from_scratch(); keep_nc = false; - obs_nc = (NcFile *) 0; + obs_nc = (NcFile *) nullptr; } //////////////////////////////////////////////////////////////////////// @@ -65,7 +65,7 @@ void MetNcPointObs::close() { if ( !keep_nc && obs_nc ) { delete obs_nc; - obs_nc = (NcFile *) 0; + obs_nc = (NcFile *) nullptr; } } diff --git a/src/libcode/vx_nc_util/grid_output.cc b/src/libcode/vx_nc_util/grid_output.cc index 079d376844..67ddbd22f6 100644 --- a/src/libcode/vx_nc_util/grid_output.cc +++ b/src/libcode/vx_nc_util/grid_output.cc @@ -882,7 +882,7 @@ if ( standard_name_str ) add_att(&nc_var, standard_name_att_name, standard_name put_nc_data(&nc_var, &var_data[0], nc_dim->getSize(), 0); -if ( var_data ) { delete [] var_data; var_data = (float *) 0; } +if ( var_data ) { delete [] var_data; var_data = (float *) nullptr; } // // done diff --git a/src/libcode/vx_nc_util/nc_utils.cc b/src/libcode/vx_nc_util/nc_utils.cc index dcd24b59b1..b1140d4d47 100644 --- a/src/libcode/vx_nc_util/nc_utils.cc +++ b/src/libcode/vx_nc_util/nc_utils.cc @@ -418,7 +418,7 @@ ConcatString get_log_msg_for_att(const NcVarAtt *att, string var_name, //////////////////////////////////////////////////////////////////////// NcVarAtt *get_nc_att(const NcVar * var, const ConcatString &att_name, bool exit_on_error) { - NcVarAtt *att = (NcVarAtt *)0; + NcVarAtt *att = (NcVarAtt *) nullptr; static const char *method_name = "get_nc_att(NcVar) -> "; // @@ -453,7 +453,7 @@ NcVarAtt *get_nc_att(const NcVar * var, const ConcatString &att_name, bool exit_ //////////////////////////////////////////////////////////////////////// NcGroupAtt *get_nc_att(const NcFile * nc, const ConcatString &att_name, bool exit_on_error) { - NcGroupAtt *att = (NcGroupAtt *)0; + NcGroupAtt *att = (NcGroupAtt *) nullptr; static const char *method_name = "get_nc_att(NcFile) -> "; // @@ -491,7 +491,7 @@ NcGroupAtt *get_nc_att(const NcFile * nc, const ConcatString &att_name, bool exi bool get_nc_att_value(const NcVar *var, const ConcatString &att_name, ConcatString &att_val, int grp_id, bool exit_on_error) { bool status = false; - NcVarAtt *att = (NcVarAtt *) 0; + NcVarAtt *att = (NcVarAtt *) nullptr; // Initialize att_val.clear(); @@ -3456,7 +3456,7 @@ NcVar get_nc_var_time(const NcFile *nc) { //////////////////////////////////////////////////////////////////////// NcFile *open_ncfile(const char * nc_name, bool write) { - NcFile *nc = (NcFile *)0; + NcFile *nc = (NcFile *) nullptr; try { if (write) { diff --git a/src/libcode/vx_nc_util/nc_var_info.cc b/src/libcode/vx_nc_util/nc_var_info.cc index 4d23e8e65b..6804e65592 100644 --- a/src/libcode/vx_nc_util/nc_var_info.cc +++ b/src/libcode/vx_nc_util/nc_var_info.cc @@ -113,7 +113,7 @@ return ( * this ); void NcVarInfo::init_from_scratch() { -Dims = (NcDim **) 0; +Dims = (NcDim **) nullptr; clear(); @@ -127,7 +127,7 @@ return; void NcVarInfo::clear() { -var = (NcVar *) 0; // don't delete +var = (NcVar *) nullptr; // don't delete name.clear(); @@ -147,7 +147,7 @@ AccumTime = 0; Ndims = 0; -if ( Dims ) { delete [] Dims; Dims = (NcDim **) 0; } +if ( Dims ) { delete [] Dims; Dims = (NcDim **) nullptr; } x_slot = y_slot = z_slot = t_slot = -1; diff --git a/src/libcode/vx_pb_util/do_blocking.cc b/src/libcode/vx_pb_util/do_blocking.cc index a43b33a768..8672f2bf05 100644 --- a/src/libcode/vx_pb_util/do_blocking.cc +++ b/src/libcode/vx_pb_util/do_blocking.cc @@ -110,7 +110,7 @@ void write_pad(int fd, unsigned int value, PadSize padsize) int n_written, bytes; unsigned int I; unsigned long long L; -unsigned char * b = (unsigned char *) 0; +unsigned char * b = (unsigned char *) nullptr; switch ( padsize ) { diff --git a/src/libcode/vx_pb_util/do_unblocking.cc b/src/libcode/vx_pb_util/do_unblocking.cc index 31e07e2631..195b1a8dda 100644 --- a/src/libcode/vx_pb_util/do_unblocking.cc +++ b/src/libcode/vx_pb_util/do_unblocking.cc @@ -80,7 +80,7 @@ int n_read, bytes; int value; unsigned int I; unsigned long long L; -unsigned char * b = (unsigned char *) 0; +unsigned char * b = (unsigned char *) nullptr; switch ( padsize ) { diff --git a/src/libcode/vx_plot_util/vx_plot_util.cc b/src/libcode/vx_plot_util/vx_plot_util.cc index abf4e4be7c..83bc4ddf76 100644 --- a/src/libcode/vx_plot_util/vx_plot_util.cc +++ b/src/libcode/vx_plot_util/vx_plot_util.cc @@ -45,7 +45,7 @@ void draw_map(const Grid &gr, const Box &gr_bb, PSfile &p, const Box &dim, } int i; - Dictionary *map_dict = (Dictionary *) 0; + Dictionary *map_dict = (Dictionary *) nullptr; ConcatString file_name, line_dash; NumArray line_color; double line_width; diff --git a/src/libcode/vx_pointdata_python/pointdata_python.cc b/src/libcode/vx_pointdata_python/pointdata_python.cc index fdb1cb34a3..e5ec4865bd 100644 --- a/src/libcode/vx_pointdata_python/pointdata_python.cc +++ b/src/libcode/vx_pointdata_python/pointdata_python.cc @@ -133,7 +133,7 @@ close(); ConcatString full_path, file_name; int i, file_argc; -char **file_argv = (char **) 0; // allocated +char **file_argv = (char **) nullptr; // allocated StringArray sa; const char *method_name = "MetPythonPointDataFile::open() "; diff --git a/src/libcode/vx_ps/documentmedia_to_string.cc b/src/libcode/vx_ps/documentmedia_to_string.cc index d64d6b9123..78be40f3a3 100644 --- a/src/libcode/vx_ps/documentmedia_to_string.cc +++ b/src/libcode/vx_ps/documentmedia_to_string.cc @@ -39,7 +39,7 @@ ConcatString documentmedia_to_string(const DocumentMedia t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/libcode/vx_ps/documentorientation_to_string.cc b/src/libcode/vx_ps/documentorientation_to_string.cc index e98342f078..2ad6baa576 100644 --- a/src/libcode/vx_ps/documentorientation_to_string.cc +++ b/src/libcode/vx_ps/documentorientation_to_string.cc @@ -39,7 +39,7 @@ ConcatString documentorientation_to_string(const DocumentOrientation t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/libcode/vx_ps/fontfamily_to_string.cc b/src/libcode/vx_ps/fontfamily_to_string.cc index 4540a5afc9..5d427f1049 100644 --- a/src/libcode/vx_ps/fontfamily_to_string.cc +++ b/src/libcode/vx_ps/fontfamily_to_string.cc @@ -39,7 +39,7 @@ ConcatString fontfamily_to_string(const FontFamily t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/libcode/vx_ps/ps_text.cc b/src/libcode/vx_ps/ps_text.cc index f4438e208b..f8effa1a87 100644 --- a/src/libcode/vx_ps/ps_text.cc +++ b/src/libcode/vx_ps/ps_text.cc @@ -105,9 +105,9 @@ void VxpsTextNode::init_from_scratch() { -Text = (char *) 0; +Text = (char *) nullptr; -next = (VxpsTextNode *) 0; +next = (VxpsTextNode *) nullptr; clear(); @@ -127,7 +127,7 @@ void VxpsTextNode::clear() // clear out this node // -if ( Text ) { delete [] Text; Text = (char *) 0; } +if ( Text ) { delete [] Text; Text = (char *) nullptr; } Nchars = Nalloc = 0; @@ -144,7 +144,7 @@ Width = 0.0; // send "clear" message down the chain // -if ( next ) { delete next; next = (VxpsTextNode *) 0; } +if ( next ) { delete next; next = (VxpsTextNode *) nullptr; } // // done @@ -287,7 +287,7 @@ void VxpsTextNode::extend(int n) if ( n < Nalloc ) return; int k; -char * u = (char *) 0; +char * u = (char *) nullptr; const char *method_name = "VxpsTextNode::extend"; // @@ -328,11 +328,11 @@ if ( Text ) m_strncpy(u, Text, (n-1), method_name, "Text"); // toss old, grab new // -if ( Text ) { delete [] Text; Text = (char *) 0; } +if ( Text ) { delete [] Text; Text = (char *) nullptr; } Text = u; -u = (char *) 0; +u = (char *) nullptr; // // done @@ -351,7 +351,7 @@ void VxpsTextNode::set_text(const char * s) { const char *method_name = "VxpsTextNode::set_text"; -if ( Text ) { delete [] Text; Text = (char *) 0; Nalloc = 0; } +if ( Text ) { delete [] Text; Text = (char *) nullptr; Nalloc = 0; } Nchars = m_strlen(s); @@ -627,7 +627,7 @@ if ( (k < 0) || (k > 255) ) { int j; char junk[16]; -char * c = (char *) 0; +char * c = (char *) nullptr; c = junk + (sizeof(junk) - 1); diff --git a/src/libcode/vx_ps/table_helper.cc b/src/libcode/vx_ps/table_helper.cc index 9e1eee2f87..d951a1e220 100644 --- a/src/libcode/vx_ps/table_helper.cc +++ b/src/libcode/vx_ps/table_helper.cc @@ -100,9 +100,9 @@ void TableHelper::init_from_scratch() { -ColWidth = (double *) 0; +ColWidth = (double *) nullptr; -RowHeight = (double *) 0; +RowHeight = (double *) nullptr; clear(); @@ -118,11 +118,11 @@ void TableHelper::clear() { -Plot = (PSfile *) 0; // not allocated, so don't delete +Plot = (PSfile *) nullptr; // not allocated, so don't delete -if ( ColWidth ) { delete [] ColWidth; ColWidth = (double *) 0; } +if ( ColWidth ) { delete [] ColWidth; ColWidth = (double *) nullptr; } -if ( RowHeight ) { delete [] RowHeight; RowHeight = (double *) 0; } +if ( RowHeight ) { delete [] RowHeight; RowHeight = (double *) nullptr; } Xpin = Ypin = Upin = Vpin = 0.0; diff --git a/src/libcode/vx_ps/vx_ps.cc b/src/libcode/vx_ps/vx_ps.cc index 5462b63737..04afccc98c 100644 --- a/src/libcode/vx_ps/vx_ps.cc +++ b/src/libcode/vx_ps/vx_ps.cc @@ -159,7 +159,7 @@ PSfile::~PSfile() close(); -delete afm; afm = (Afm *) 0; +delete afm; afm = (Afm *) nullptr; } @@ -171,7 +171,7 @@ void PSfile::init_from_scratch() { -File = (ofstream *) 0; +File = (ofstream *) nullptr; psout.ignore_columns = true; @@ -399,7 +399,7 @@ if ( File ) { File->close(); - delete File; File = (ofstream *) 0; + delete File; File = (ofstream *) nullptr; } @@ -572,7 +572,7 @@ const double scale = 0.001*font_size; double x_cur, y_cur; double dx, dy; VxpsTextNode node; -VxpsTextNode * n = (VxpsTextNode *) 0; +VxpsTextNode * n = (VxpsTextNode *) nullptr; make_list(current_font, font_size, *afm, node, s); diff --git a/src/libcode/vx_pxm/pcm.cc b/src/libcode/vx_pxm/pcm.cc index f1107ccf20..cf10e9fcaa 100644 --- a/src/libcode/vx_pxm/pcm.cc +++ b/src/libcode/vx_pxm/pcm.cc @@ -122,7 +122,7 @@ void Pcm::clear() clear_common(); -if ( Colormap ) { delete [] Colormap; Colormap = (Color *) 0; } +if ( Colormap ) { delete [] Colormap; Colormap = (Color *) nullptr; } Ncolors = 0; @@ -142,9 +142,9 @@ void Pcm::init_from_scratch() // PxmBase::init_from_scratch(); -Colormap = (Color *) 0; +Colormap = (Color *) nullptr; -Name = (char *) 0; +Name = (char *) nullptr; Ncolors = 0; @@ -753,7 +753,7 @@ int row, col; int Nrows_new, Ncols_new, bytes; int row_new = 0, col_new = 0; int n_new, n_old; -unsigned char *u = (unsigned char *) 0; +unsigned char *u = (unsigned char *) nullptr; if ( a == 2 ) { @@ -870,7 +870,7 @@ void Pcm::set_colormap(const Color * c, int n) { -if ( Colormap ) { delete [] Colormap; Colormap = (Color *) 0; } +if ( Colormap ) { delete [] Colormap; Colormap = (Color *) nullptr; } Colormap = new Color [n]; diff --git a/src/libcode/vx_pxm/pgm.cc b/src/libcode/vx_pxm/pgm.cc index a38d4fd4e1..06e5294d14 100644 --- a/src/libcode/vx_pxm/pgm.cc +++ b/src/libcode/vx_pxm/pgm.cc @@ -610,7 +610,7 @@ int row, col; int Nrows_new, Ncols_new, bytes; int row_new = 0, col_new = 0; int n_new, n_old; -unsigned char *u = (unsigned char *) 0; +unsigned char *u = (unsigned char *) nullptr; if ( a == 2 ) { // a == 0 has already been checked for diff --git a/src/libcode/vx_pxm/ppm.cc b/src/libcode/vx_pxm/ppm.cc index 27cf265eb3..033c25a6a5 100644 --- a/src/libcode/vx_pxm/ppm.cc +++ b/src/libcode/vx_pxm/ppm.cc @@ -165,7 +165,7 @@ Color Ppm::getrc(int r, int c) const { int n; -unsigned char * u = (unsigned char *) 0; +unsigned char * u = (unsigned char *) nullptr; Color color; @@ -206,7 +206,7 @@ void Ppm::putrc(const Color & color, int r, int c) { int n; -unsigned char * u = (unsigned char *) 0; +unsigned char * u = (unsigned char *) nullptr; n = rc_to_n(r, c); @@ -605,7 +605,7 @@ void Ppm::make_gray() int j, n; Color c; -unsigned char * u = (unsigned char *) 0; +unsigned char * u = (unsigned char *) nullptr; n = Nrows*Ncols; @@ -644,7 +644,7 @@ int row, col; int Nrows_new, Ncols_new, bytes; int row_new = 0, col_new = 0; int n_new, n_old; -unsigned char *u = (unsigned char *) 0; +unsigned char *u = (unsigned char *) nullptr; if ( a == 2 ) { diff --git a/src/libcode/vx_pxm/pxm_base.cc b/src/libcode/vx_pxm/pxm_base.cc index bc52724b35..e4db7a82e6 100644 --- a/src/libcode/vx_pxm/pxm_base.cc +++ b/src/libcode/vx_pxm/pxm_base.cc @@ -65,9 +65,9 @@ void PxmBase::init_from_scratch() { -data = (unsigned char *) 0; +data = (unsigned char *) nullptr; -Name = (char *) 0; +Name = (char *) nullptr; clear_common(); @@ -85,11 +85,11 @@ void PxmBase::clear_common() { -if ( data ) { delete [] data; data = (unsigned char *) 0; } +if ( data ) { delete [] data; data = (unsigned char *) nullptr; } Nalloc = 0; -if ( Name ) { delete [] Name; Name = (char *) 0; } +if ( Name ) { delete [] Name; Name = (char *) nullptr; } Nrows = Ncols = 0; @@ -291,7 +291,7 @@ for (j=0; jignore_columns = false; *v = psout; -v = (PSFilter **) 0; +v = (PSFilter **) nullptr; @@ -194,7 +194,7 @@ for (r=0; reod(); -delete out; out = (PSFilter *) 0; +delete out; out = (PSFilter *) nullptr; plot.file() << "\n\n"; diff --git a/src/libcode/vx_render/render_pcm.cc b/src/libcode/vx_render/render_pcm.cc index 04e99f0414..6fbb3a283f 100644 --- a/src/libcode/vx_render/render_pcm.cc +++ b/src/libcode/vx_render/render_pcm.cc @@ -49,7 +49,7 @@ int nx, ny; double w, h; unsigned char u; Color color; -PSFilter *out = (PSFilter *) 0; +PSFilter *out = (PSFilter *) nullptr; PSFilter **v = &out; @@ -105,7 +105,7 @@ psout->ignore_columns = false; *v = psout; -v = (PSFilter **) 0; +v = (PSFilter **) nullptr; set_up_colortable(plot.file(), pcm, info); @@ -173,7 +173,7 @@ for (r=0; reod(); -delete out; out = (PSFilter *) 0; +delete out; out = (PSFilter *) nullptr; plot.file() << "\n\n"; diff --git a/src/libcode/vx_render/render_pgm.cc b/src/libcode/vx_render/render_pgm.cc index 11d0d6801e..df72e6f85b 100644 --- a/src/libcode/vx_render/render_pgm.cc +++ b/src/libcode/vx_render/render_pgm.cc @@ -45,7 +45,7 @@ int nx, ny; double w, h; unsigned char u; Color color; -PSFilter *out = (PSFilter *) 0; +PSFilter *out = (PSFilter *) nullptr; PSFilter **v = &out; @@ -101,7 +101,7 @@ psout->ignore_columns = false; *v = psout; -v = (PSFilter **) 0; +v = (PSFilter **) nullptr; @@ -173,7 +173,7 @@ for (r=0; reod(); -delete out; out = (PSFilter *) 0; +delete out; out = (PSFilter *) nullptr; plot.file() << "\n\n"; diff --git a/src/libcode/vx_render/render_ppm.cc b/src/libcode/vx_render/render_ppm.cc index 15d4c2200f..cf7e51f97e 100644 --- a/src/libcode/vx_render/render_ppm.cc +++ b/src/libcode/vx_render/render_ppm.cc @@ -34,7 +34,7 @@ plot.gsave(); int j, r, c; double w, h; -PSFilter *out = (PSFilter *) 0; +PSFilter *out = (PSFilter *) nullptr; PSFilter **v = &out; Color color; @@ -92,7 +92,7 @@ psout->ignore_columns = false; *v = psout; -v = (PSFilter **) 0; +v = (PSFilter **) nullptr; @@ -164,7 +164,7 @@ for (r=0; r<(image.nrows()); ++r) { out->eod(); -delete out; out = (PSFilter *) 0; +delete out; out = (PSFilter *) nullptr; plot.file() << "\n\n"; diff --git a/src/libcode/vx_series_data/series_data.cc b/src/libcode/vx_series_data/series_data.cc index 03b227b0f2..1417e785f2 100644 --- a/src/libcode/vx_series_data/series_data.cc +++ b/src/libcode/vx_series_data/series_data.cc @@ -83,7 +83,7 @@ bool read_single_entry(VarInfo* info, const ConcatString& filename, const GrdFileType type, DataPlane& dp, Grid& grid) { Met2dDataFileFactory mtddf_factory; - Met2dDataFile* mtddf = (Met2dDataFile*) 0; + Met2dDataFile* mtddf = (Met2dDataFile*) nullptr; // Check that file exists if(!file_exists(filename.c_str())) { @@ -102,7 +102,7 @@ bool read_single_entry(VarInfo* info, const ConcatString& filename, if(found) grid = mtddf->grid(); // Cleanup - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } return(found); } @@ -165,7 +165,7 @@ bool read_all_entries(vector &vi_list, const ConcatString &filename, const GrdFileType type, vector &dp_list, Grid &grid) { Met2dDataFileFactory mtddf_factory; - Met2dDataFile* mtddf = (Met2dDataFile*) 0; + Met2dDataFile* mtddf = (Met2dDataFile*) nullptr; // Check that file exists if(!file_exists(filename.c_str())) { @@ -184,7 +184,7 @@ bool read_all_entries(vector &vi_list, const ConcatString &filename, if(n_valid > 0) grid = mtddf->grid(); // Cleanup - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } return(n_valid > 0); } diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index c393610c2f..dd7ab216c0 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -53,27 +53,27 @@ ModeFuzzyEngine::~ModeFuzzyEngine() { // if(fcst_raw) { delete fcst_raw; - fcst_raw = (ShapeData *) 0; + fcst_raw = (ShapeData *) nullptr; } if(fcst_thresh) { delete fcst_thresh; - fcst_thresh = (ShapeData *) 0; + fcst_thresh = (ShapeData *) nullptr; } if(fcst_conv) { delete fcst_conv; - fcst_conv = (ShapeData *) 0; + fcst_conv = (ShapeData *) nullptr; } if(fcst_mask) { delete fcst_mask; - fcst_mask = (ShapeData *) 0; + fcst_mask = (ShapeData *) nullptr; } if(fcst_split) { delete fcst_split; - fcst_split = (ShapeData *) 0; + fcst_split = (ShapeData *) nullptr; } if(fcst_clus_split) { delete fcst_clus_split; - fcst_clus_split = (ShapeData *) 0; + fcst_clus_split = (ShapeData *) nullptr; } // @@ -81,27 +81,27 @@ ModeFuzzyEngine::~ModeFuzzyEngine() { // if(obs_raw) { delete obs_raw; - obs_raw = (ShapeData *) 0; + obs_raw = (ShapeData *) nullptr; } if(obs_thresh) { delete obs_thresh; - obs_thresh = (ShapeData *) 0; + obs_thresh = (ShapeData *) nullptr; } if(obs_conv) { delete obs_conv; - obs_conv = (ShapeData *) 0; + obs_conv = (ShapeData *) nullptr; } if(obs_mask) { delete obs_mask; - obs_mask = (ShapeData *) 0; + obs_mask = (ShapeData *) nullptr; } if(obs_split) { delete obs_split; - obs_split = (ShapeData *) 0; + obs_split = (ShapeData *) nullptr; } if(obs_clus_split) { delete obs_clus_split; - obs_clus_split = (ShapeData *) 0; + obs_clus_split = (ShapeData *) nullptr; } // @@ -109,11 +109,11 @@ ModeFuzzyEngine::~ModeFuzzyEngine() { // if(fcst_engine) { delete fcst_engine; - fcst_engine = (ModeFuzzyEngine *) 0; + fcst_engine = (ModeFuzzyEngine *) nullptr; } if(obs_engine) { delete obs_engine; - obs_engine = (ModeFuzzyEngine *) 0; + obs_engine = (ModeFuzzyEngine *) nullptr; } } @@ -139,7 +139,7 @@ ModeFuzzyEngine & ModeFuzzyEngine::operator=(const ModeFuzzyEngine & eng) { void ModeFuzzyEngine::init_from_scratch() { - grid = (Grid *) 0; + grid = (Grid *) nullptr; // // Reset all fcst and obs processing flags to initial state @@ -178,8 +178,8 @@ void ModeFuzzyEngine::init_from_scratch() { obs_split = new ShapeData; obs_clus_split = new ShapeData; - fcst_engine = (ModeFuzzyEngine *) 0; - obs_engine = (ModeFuzzyEngine *) 0; + fcst_engine = (ModeFuzzyEngine *) nullptr; + obs_engine = (ModeFuzzyEngine *) nullptr; n_fcst = 0; n_obs = 0; @@ -2925,7 +2925,7 @@ double total_interest(ModeConfInfo &mc, const PairFeature &p, double interest_percentile(ModeFuzzyEngine &eng, const double p, const int flag) { int i, fcst_i, obs_i, n_values; double interest, ptile; - double *v = (double *) 0; + double *v = (double *) nullptr; NumArray fcst_na, obs_na; if(eng.conf_info.match_flag == 0 || @@ -2993,7 +2993,7 @@ double interest_percentile(ModeFuzzyEngine &eng, const double p, const int flag) // Done // - if(v) { delete [] v; v = (double *) 0; } + if(v) { delete [] v; v = (double *) nullptr; } return(ptile); } diff --git a/src/libcode/vx_shapedata/interest.cc b/src/libcode/vx_shapedata/interest.cc index d33d32e426..d89ce2a0ff 100644 --- a/src/libcode/vx_shapedata/interest.cc +++ b/src/libcode/vx_shapedata/interest.cc @@ -92,7 +92,7 @@ void SingleFeature::init_from_scratch() { -boundary = (Polyline *) 0; +boundary = (Polyline *) nullptr; clear(); @@ -126,16 +126,16 @@ void SingleFeature::clear() intensity_ptile.sum = 0.0; user_ptile = 0.0; - Raw = (const ShapeData *) 0; - Thresh = (const ShapeData *) 0; - Split = (const ShapeData *) 0; + Raw = (const ShapeData *) nullptr; + Thresh = (const ShapeData *) nullptr; + Split = (const ShapeData *) nullptr; convex_hull.clear(); // // Deallocate memory // - if(boundary) { delete [] boundary; boundary = (Polyline *) 0; } + if(boundary) { delete [] boundary; boundary = (Polyline *) nullptr; } n_bdy = 0; return; @@ -358,8 +358,8 @@ void PairFeature::clear() complexity_ratio = 0.0; percentile_intensity_ratio = 0.0; - Obs = (const SingleFeature *) 0; // DON'T delete - Fcst = (const SingleFeature *) 0; // DON'T delete + Obs = (const SingleFeature *) nullptr; // DON'T delete + Fcst = (const SingleFeature *) nullptr; // DON'T delete return; } @@ -600,8 +600,8 @@ void get_percentiles(DistributionPercentiles &ptile, { int i, x, y, n_values; int nx, ny; - double *v = (double *) 0; - double *v_tmp = (double *) 0; + double *v = (double *) nullptr; + double *v_tmp = (double *) nullptr; const char *method_name = "get_percentiles() -> "; nx = raw.data.nx(); @@ -682,8 +682,8 @@ void get_percentiles(DistributionPercentiles &ptile, // // Free memory // - if(v_tmp) { delete [] v_tmp; v_tmp = (double *) 0; } - if(v) { delete [] v; v = (double *) 0; } + if(v_tmp) { delete [] v_tmp; v_tmp = (double *) nullptr; } + if(v) { delete [] v; v = (double *) nullptr; } // // Done diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index 5852d9f51e..2a5b84514f 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -137,7 +137,7 @@ void ModeConfInfo::assign( const ModeConfInfo &m) } // need to be recomputed, maybe, so do so just in case - Dictionary * dict = (Dictionary *) 0; + Dictionary * dict = (Dictionary *) nullptr; dict = conf.lookup_dictionary(conf_key_interest_function); centroid_dist_if = parse_interest_function(dict, conf_key_centroid_dist); boundary_dist_if = parse_interest_function(dict, conf_key_boundary_dist); @@ -226,16 +226,16 @@ void ModeConfInfo::clear() inten_perc_value = bad_data_int; - centroid_dist_if = (PiecewiseLinear *) 0; - boundary_dist_if = (PiecewiseLinear *) 0; - convex_hull_dist_if = (PiecewiseLinear *) 0; - angle_diff_if = (PiecewiseLinear *) 0; - aspect_diff_if = (PiecewiseLinear *) 0; - area_ratio_if = (PiecewiseLinear *) 0; - int_area_ratio_if = (PiecewiseLinear *) 0; - curvature_ratio_if = (PiecewiseLinear *) 0; - complexity_ratio_if = (PiecewiseLinear *) 0; - inten_perc_ratio_if = (PiecewiseLinear *) 0; + centroid_dist_if = (PiecewiseLinear *) nullptr; + boundary_dist_if = (PiecewiseLinear *) nullptr; + convex_hull_dist_if = (PiecewiseLinear *) nullptr; + angle_diff_if = (PiecewiseLinear *) nullptr; + aspect_diff_if = (PiecewiseLinear *) nullptr; + area_ratio_if = (PiecewiseLinear *) nullptr; + int_area_ratio_if = (PiecewiseLinear *) nullptr; + curvature_ratio_if = (PiecewiseLinear *) nullptr; + complexity_ratio_if = (PiecewiseLinear *) nullptr; + inten_perc_ratio_if = (PiecewiseLinear *) nullptr; total_interest_thresh = bad_data_double; @@ -308,7 +308,7 @@ void ModeConfInfo::process_config_traditional(GrdFileType ftype, GrdFileType oty void ModeConfInfo::process_config_except_fields() { - Dictionary * dict = (Dictionary *) 0; + Dictionary * dict = (Dictionary *) nullptr; // Dump the contents of the config file @@ -536,8 +536,8 @@ void ModeConfInfo::process_config_both(GrdFileType ftype, GrdFileType otype, int j, k, n; - Dictionary * fcst_dict = (Dictionary *) 0; - Dictionary * obs_dict = (Dictionary *) 0; + Dictionary * fcst_dict = (Dictionary *) nullptr; + Dictionary * obs_dict = (Dictionary *) nullptr; // Conf: fcst and obs @@ -608,7 +608,7 @@ void ModeConfInfo::process_config_fcst(GrdFileType ftype, int field_index) { int j, k, n; - Dictionary * fcst_dict = (Dictionary *) 0; + Dictionary * fcst_dict = (Dictionary *) nullptr; fcst_dict = conf.lookup_dictionary(conf_key_fcst); shift_right = fcst_dict->lookup_int(conf_key_shift_right); @@ -645,7 +645,7 @@ void ModeConfInfo::process_config_obs(GrdFileType otype, int field_index) { int j, k, n; - Dictionary * obs_dict = (Dictionary *) 0; + Dictionary * obs_dict = (Dictionary *) nullptr; obs_dict = conf.lookup_dictionary(conf_key_obs); shift_right = obs_dict->lookup_int(conf_key_shift_right); @@ -1270,7 +1270,7 @@ void ModeConfInfo::parse_nc_info() { -const DictionaryEntry * e = (const DictionaryEntry *) 0; +const DictionaryEntry * e = (const DictionaryEntry *) nullptr; e = conf.lookup(conf_key_nc_pairs_flag); @@ -1587,7 +1587,7 @@ GrdFileType ModeConfInfo::file_type_for_field(bool isFcst, int field_index) // look at the dictionary for the obs or forecast at index, with // parents - Dictionary * dict = (Dictionary *) 0; + Dictionary * dict = (Dictionary *) nullptr; if (isFcst) { dict = conf.lookup_dictionary(conf_key_fcst); } else { @@ -1682,7 +1682,7 @@ void ModeConfInfo::get_multivar_programs() { -Dictionary * dict = (Dictionary *) 0; +Dictionary * dict = (Dictionary *) nullptr; fcst_multivar_logic.clear(); obs_multivar_logic.clear(); diff --git a/src/libcode/vx_shapedata/node.cc b/src/libcode/vx_shapedata/node.cc index d344322bd5..c687148522 100644 --- a/src/libcode/vx_shapedata/node.cc +++ b/src/libcode/vx_shapedata/node.cc @@ -38,9 +38,9 @@ using namespace std; Node::Node() { - child = (Node *) 0; + child = (Node *) nullptr; - sibling = (Node *) 0; + sibling = (Node *) nullptr; clear(); } @@ -76,12 +76,12 @@ void Node::clear() { if(child) { child->clear(); - delete child; child = (Node *) 0; + delete child; child = (Node *) nullptr; } if(sibling) { sibling->clear(); - delete sibling; sibling = (Node *) 0; + delete sibling; sibling = (Node *) nullptr; } p.clear(); @@ -127,7 +127,7 @@ void Node::assign_tree(const Node *n_ptr) { /////////////////////////////////////////////////////////////////////////////// void Node::add_child(const Polyline * poly) { - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; // Check for first child if(child == nullptr) { @@ -183,7 +183,7 @@ void Node::add_child(const Polyline * poly) { int Node::n_children() const { int count; - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; count = 0; @@ -207,7 +207,7 @@ int Node::n_children() const { Node *Node::get_child(int n) const { int children_count, i; - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; if( n >= (children_count = n_children()) ) { @@ -229,7 +229,7 @@ Node *Node::get_child(int n) const { int Node::is_closed() const { int closed; - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; // Check if the current polyline is closed closed = p.is_closed(); @@ -269,7 +269,7 @@ void Node::centroid(double &ubar, double &vbar) const { /////////////////////////////////////////////////////////////////////////////// void Node::translate(double du, double dv) { - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; // Translate each point of the current polyline p.translate(du, dv); @@ -339,7 +339,7 @@ void Node::rotate(double deg) { /////////////////////////////////////////////////////////////////////////////// void Node::rotate(double deg, double ubar, double vbar) { - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; p.rotate(deg, ubar, vbar); @@ -359,7 +359,7 @@ void Node::rotate(double deg, double ubar, double vbar) { double Node::uv_signed_area() const { double sum; - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; sum = p.uv_signed_area(); @@ -379,7 +379,7 @@ double Node::uv_signed_area() const { int Node::is_inside(double u_test, double v_test) const { int count; - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; if(p.is_inside(u_test, v_test)) { @@ -411,7 +411,7 @@ int Node::is_inside(double u_test, double v_test) const { int Node::is_polyline_point(double u_test, double v_test) const { int poly_point; - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; poly_point = p.is_polyline_point(u_test, v_test); @@ -431,7 +431,7 @@ int Node::is_polyline_point(double u_test, double v_test) const { /////////////////////////////////////////////////////////////////////////////// void Node::bounding_box(Box &bb) const { - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; p.bounding_box(bb); @@ -455,7 +455,7 @@ void Node::bounding_box(Box &bb) const { /////////////////////////////////////////////////////////////////////////////// void Node::sum_first_moments(double &sum_x, double &sum_y) const { - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; p.sum_first_moments(sum_x, sum_y); @@ -475,7 +475,7 @@ void Node::sum_first_moments(double &sum_x, double &sum_y) const { void Node::sum_second_moments(double x_bar, double y_bar, double &Ixx, double &Ixy, double &Iyy) const { - Node *n_ptr = (Node *) 0; + Node *n_ptr = (Node *) nullptr; p.sum_second_moments(x_bar, y_bar, Ixx, Ixy, Iyy); @@ -500,7 +500,8 @@ void Node::sum_second_moments(double x_bar, double y_bar, double node_dist(const Node &a, const Node &b) { double min_dist, dist; int i_a, i_b, num_a, num_b; - Node *a_ptr = (Node *) 0, *b_ptr = (Node *) 0; + Node *a_ptr = (Node *) nullptr; + Node *b_ptr = (Node *) nullptr; num_a = a.n_children(); num_b = b.n_children(); @@ -538,7 +539,7 @@ double node_dist(const Node &a, const Node &b) { double node_polyline_dist(const Node &a, const Polyline &b) { double min_dist, dist; int i_a, num_a; - Node *a_ptr = (Node *) 0; + Node *a_ptr = (Node *) nullptr; num_a = a.n_children(); diff --git a/src/libcode/vx_shapedata/shapedata.cc b/src/libcode/vx_shapedata/shapedata.cc index bc7332bc94..4fa554cea2 100644 --- a/src/libcode/vx_shapedata/shapedata.cc +++ b/src/libcode/vx_shapedata/shapedata.cc @@ -1253,7 +1253,7 @@ void Cell::clear() { -if ( e ) { delete [] e; e = (int *) 0; } +if ( e ) { delete [] e; e = (int *) nullptr; } n = 0; diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 034c3c1961..7138675705 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -29,7 +29,7 @@ const bool use_weighted_seeps = false; //////////////////////////////////////////////////////////////////////// void parse_row_col(const char *col_name, int &r, int &c) { - const char *ptr = (const char *) 0; + const char *ptr = (const char *) nullptr; // Parse Fi_Oj strings r = atoi(++col_name); @@ -76,7 +76,7 @@ void close_txt_file(ofstream *&out, const char *file_name) { // Close the output file out->close(); delete out; - out = (ofstream *) 0; + out = (ofstream *) nullptr; return; } diff --git a/src/libcode/vx_statistics/apply_mask.cc b/src/libcode/vx_statistics/apply_mask.cc index 010c091825..f3073d5f8f 100644 --- a/src/libcode/vx_statistics/apply_mask.cc +++ b/src/libcode/vx_statistics/apply_mask.cc @@ -108,7 +108,7 @@ Grid parse_grid_string(const char *grid_str) { << grid_str << "\".\n"; Met2dDataFileFactory m_factory; - Met2dDataFile *met_ptr = (Met2dDataFile *) 0; + Met2dDataFile *met_ptr = (Met2dDataFile *) nullptr; // Open the data file if(!(met_ptr = m_factory.new_met_2d_data_file(grid_str))) { @@ -251,7 +251,7 @@ void parse_grid_mask(const ConcatString &mask_grid_str, Grid &grid) { << mask_grid_str << "\".\n"; Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // Attempt to open the data file if(!(mtddf = mtddf_factory.new_met_2d_data_file( @@ -451,11 +451,11 @@ void parse_poly_2d_data_mask(const ConcatString &mask_poly_str, // 2D Data file Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // VarInfo object VarInfoFactory info_factory; - VarInfo *info = (VarInfo *) 0; + VarInfo *info = (VarInfo *) nullptr; // Open the data file mtddf = mtddf_factory.new_met_2d_data_file(file_name.c_str(), type); @@ -504,8 +504,8 @@ void parse_poly_2d_data_mask(const ConcatString &mask_poly_str, if(append_thresh) mask_name << st.get_str(); // Clean up - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - if(info) { delete info; info = (VarInfo *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } + if(info) { delete info; info = (VarInfo *) nullptr; } return; } @@ -603,15 +603,15 @@ DataPlane parse_geog_data(Dictionary *dict, const Grid &vx_grid, StringArray geog_files; RegridInfo regrid_info; GrdFileType ftype; - Dictionary *field_dict = (Dictionary *) 0; + Dictionary *field_dict = (Dictionary *) nullptr; bool found = false; int i; Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; VarInfoFactory info_factory; - VarInfo *info = (VarInfo *) 0; + VarInfo *info = (VarInfo *) nullptr; if(!dict) { mlog << Error << "\nparse_geog_data() -> " @@ -673,8 +673,8 @@ DataPlane parse_geog_data(Dictionary *dict, const Grid &vx_grid, } // Deallocate memory - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - if(info) { delete info; info = (VarInfo *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } + if(info) { delete info; info = (VarInfo *) nullptr; } } if(!found) { diff --git a/src/libcode/vx_statistics/compute_ci.cc b/src/libcode/vx_statistics/compute_ci.cc index e4a9aabae7..e8a2d1df26 100644 --- a/src/libcode/vx_statistics/compute_ci.cc +++ b/src/libcode/vx_statistics/compute_ci.cc @@ -283,14 +283,15 @@ void compute_cts_stats_ci_bca(const gsl_rng *rng_ptr, int i, j, c; double s; NumArray i_na, ir_na, si_na, sr_na; - CTSInfo *cts_tmp = (CTSInfo *) 0; + CTSInfo *cts_tmp = (CTSInfo *) nullptr; // // Temp file streams for categorical statistics // - ofstream *cts_i_out = (ofstream *) 0, *cts_r_out = (ofstream *) 0; - ConcatString *cts_i_file = (ConcatString *) 0; - ConcatString *cts_r_file = (ConcatString *) 0; + ofstream *cts_i_out = (ofstream *) nullptr; + ofstream *cts_r_out = (ofstream *) nullptr; + ConcatString *cts_i_file = (ConcatString *) nullptr; + ConcatString *cts_r_file = (ConcatString *) nullptr; ConcatString prefix; // @@ -378,11 +379,11 @@ void compute_cts_stats_ci_bca(const gsl_rng *rng_ptr, } // deallocate memory - if(cts_tmp) { delete [] cts_tmp; cts_tmp = (CTSInfo *) 0; } - if(cts_i_out) { delete [] cts_i_out; cts_i_out = (ofstream *) 0; } - if(cts_r_out) { delete [] cts_r_out; cts_r_out = (ofstream *) 0; } - if(cts_i_file) { delete [] cts_i_file; cts_i_file = (ConcatString *) 0; } - if(cts_r_file) { delete [] cts_r_file; cts_r_file = (ConcatString *) 0; } + if(cts_tmp) { delete [] cts_tmp; cts_tmp = (CTSInfo *) nullptr; } + if(cts_i_out) { delete [] cts_i_out; cts_i_out = (ofstream *) nullptr; } + if(cts_r_out) { delete [] cts_r_out; cts_r_out = (ofstream *) nullptr; } + if(cts_i_file) { delete [] cts_i_file; cts_i_file = (ConcatString *) nullptr; } + if(cts_r_file) { delete [] cts_r_file; cts_r_file = (ConcatString *) nullptr; } throw(1); } } @@ -712,11 +713,11 @@ void compute_cts_stats_ci_bca(const gsl_rng *rng_ptr, // // Deallocate memory // - if(cts_tmp) { delete [] cts_tmp; cts_tmp = (CTSInfo *) 0; } - if(cts_i_out) { delete [] cts_i_out; cts_i_out = (ofstream *) 0; } - if(cts_r_out) { delete [] cts_r_out; cts_r_out = (ofstream *) 0; } - if(cts_i_file) { delete [] cts_i_file; cts_i_file = (ConcatString *) 0; } - if(cts_r_file) { delete [] cts_r_file; cts_r_file = (ConcatString *) 0; } + if(cts_tmp) { delete [] cts_tmp; cts_tmp = (CTSInfo *) nullptr; } + if(cts_i_out) { delete [] cts_i_out; cts_i_out = (ofstream *) nullptr; } + if(cts_r_out) { delete [] cts_r_out; cts_r_out = (ofstream *) nullptr; } + if(cts_i_file) { delete [] cts_i_file; cts_i_file = (ConcatString *) nullptr; } + if(cts_r_file) { delete [] cts_r_file; cts_r_file = (ConcatString *) nullptr; } return; } @@ -1420,13 +1421,14 @@ void compute_cts_stats_ci_perc(const gsl_rng *rng_ptr, int i, j, m, c; double s; NumArray i_na, ir_na, sr_na; - CTSInfo *cts_tmp = (CTSInfo *) 0; + CTSInfo *cts_tmp = (CTSInfo *) nullptr; // // Temp file streams for categorical statistics // - ofstream *cts_r_out = (ofstream *) 0; - ConcatString *cts_r_file = (ConcatString *) 0, prefix; + ofstream *cts_r_out = (ofstream *) nullptr; + ConcatString *cts_r_file = (ConcatString *) nullptr; + ConcatString prefix; // // Check that the forecast and observation arrays of the same length @@ -1506,9 +1508,9 @@ void compute_cts_stats_ci_perc(const gsl_rng *rng_ptr, // for(i=0; iempty() ) { } -if ( Thresholds ) { delete [] Thresholds; Thresholds = (double *) 0; } +if ( Thresholds ) { delete [] Thresholds; Thresholds = (double *) nullptr; } Thresholds = new double [Nrows + 1]; diff --git a/src/libcode/vx_statistics/contable_stats.cc b/src/libcode/vx_statistics/contable_stats.cc index f103284ee0..62e7a7e2f2 100644 --- a/src/libcode/vx_statistics/contable_stats.cc +++ b/src/libcode/vx_statistics/contable_stats.cc @@ -1077,8 +1077,8 @@ if ( N == 0 ) return ( bad_data_double ); int j, k, m, n; const double DN = (double) N; double t, sum; -double * p = (double *) 0; -double * s = (double *) 0; +double * p = (double *) nullptr; +double * s = (double *) nullptr; // // can't compute gerrity when the first column contains all zeros @@ -1140,8 +1140,8 @@ for (j=0; jfile_type()); @@ -1090,7 +1090,7 @@ void VxPairDataEnsemble::set_obs_info(VarInfo *info) { VarInfoFactory f; // Deallocate, if necessary - if(obs_info) { delete obs_info; obs_info = (VarInfo *) 0; } + if(obs_info) { delete obs_info; obs_info = (VarInfo *) nullptr; } // Perform a deep copy obs_info = f.new_var_info(info->file_type()); @@ -1439,7 +1439,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, double cmn_v, csd_v, obs_v, wgt_v; int cmn_lvl_blw, cmn_lvl_abv; int csd_lvl_blw, csd_lvl_abv; - ObsErrorEntry *oerr_ptr = (ObsErrorEntry *) 0; + ObsErrorEntry *oerr_ptr = (ObsErrorEntry *) nullptr; // Check the observation VarInfo file type if(obs_info->file_type() != FileType_Gb1) { diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 15aa9133f0..7282d1504d 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -416,18 +416,18 @@ VxPairDataPoint & VxPairDataPoint::operator=(const VxPairDataPoint &vx_pd) { void VxPairDataPoint::init_from_scratch() { - fcst_info = (VarInfo *) 0; - climo_info = (VarInfo *) 0; - obs_info = (VarInfoGrib *) 0; - - pd = (PairDataPoint ***) 0; - rej_typ = (int ***) 0; - rej_mask = (int ***) 0; - rej_fcst = (int ***) 0; - rej_cmn = (int ***) 0; - rej_csd = (int ***) 0; - rej_mpr = (int ***) 0; - rej_dup = (int ***) 0; + fcst_info = (VarInfo *) nullptr; + climo_info = (VarInfo *) nullptr; + obs_info = (VarInfoGrib *) nullptr; + + pd = (PairDataPoint ***) nullptr; + rej_typ = (int ***) nullptr; + rej_mask = (int ***) nullptr; + rej_fcst = (int ***) nullptr; + rej_cmn = (int ***) nullptr; + rej_csd = (int ***) nullptr; + rej_mpr = (int ***) nullptr; + rej_dup = (int ***) nullptr; n_msg_typ = 0; n_mask = 0; @@ -443,9 +443,9 @@ void VxPairDataPoint::init_from_scratch() { void VxPairDataPoint::clear() { int i, j, k; - if(fcst_info) { delete fcst_info; fcst_info = (VarInfo *) 0; } - if(climo_info) { delete climo_info; climo_info = (VarInfo *) 0; } - if(obs_info) { delete obs_info; obs_info = (VarInfoGrib *) 0; } + if(fcst_info) { delete fcst_info; fcst_info = (VarInfo *) nullptr; } + if(climo_info) { delete climo_info; climo_info = (VarInfo *) nullptr; } + if(obs_info) { delete obs_info; obs_info = (VarInfoGrib *) nullptr; } desc.clear(); @@ -576,7 +576,7 @@ void VxPairDataPoint::set_fcst_info(VarInfo *info) { VarInfoFactory f; // Deallocate, if necessary - if(fcst_info) { delete fcst_info; fcst_info = (VarInfo *) 0; } + if(fcst_info) { delete fcst_info; fcst_info = (VarInfo *) nullptr; } // Perform a deep copy fcst_info = f.new_var_info(info->file_type()); @@ -591,7 +591,7 @@ void VxPairDataPoint::set_climo_info(VarInfo *info) { VarInfoFactory f; // Deallocate, if necessary - if(climo_info) { delete climo_info; climo_info = (VarInfo *) 0; } + if(climo_info) { delete climo_info; climo_info = (VarInfo *) nullptr; } // Perform a deep copy climo_info = f.new_var_info(info->file_type()); @@ -605,7 +605,7 @@ void VxPairDataPoint::set_climo_info(VarInfo *info) { void VxPairDataPoint::set_obs_info(VarInfoGrib *info) { // Deallocate, if necessary - if(obs_info) { delete obs_info; obs_info = (VarInfoGrib *) 0; } + if(obs_info) { delete obs_info; obs_info = (VarInfoGrib *) nullptr; } // Perform a deep copy obs_info = new VarInfoGrib; diff --git a/src/libcode/vx_statistics/read_climo.cc b/src/libcode/vx_statistics/read_climo.cc index 27fe9e5eae..6e077c9173 100644 --- a/src/libcode/vx_statistics/read_climo.cc +++ b/src/libcode/vx_statistics/read_climo.cc @@ -152,10 +152,10 @@ void read_climo_file(const char *climo_file, GrdFileType ctype, DataPlaneArray &dpa) { Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; VarInfoFactory info_factory; - VarInfo *info = (VarInfo *) 0; + VarInfo *info = (VarInfo *) nullptr; DataPlaneArray clm_dpa; DataPlane dp; @@ -240,8 +240,8 @@ void read_climo_file(const char *climo_file, GrdFileType ctype, } // end for i // Deallocate memory - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - if(info) { delete info; info = (VarInfo *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } + if(info) { delete info; info = (VarInfo *) nullptr; } return; } diff --git a/src/libcode/vx_tc_util/atcf_line_base.cc b/src/libcode/vx_tc_util/atcf_line_base.cc index 6db2d00651..7a5f658e5f 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.cc +++ b/src/libcode/vx_tc_util/atcf_line_base.cc @@ -79,10 +79,10 @@ void ATCFLineBase::init_from_scratch() { set_delimiter(","); // Initialize pointers - BasinMap = (map *) 0; - BestTechnique = (StringArray *) 0; - OperTechnique = (StringArray *) 0; - TechSuffix = (ConcatString *) 0; + BasinMap = (map *) nullptr; + BestTechnique = (StringArray *) nullptr; + OperTechnique = (StringArray *) nullptr; + TechSuffix = (ConcatString *) nullptr; clear(); @@ -503,7 +503,7 @@ ATCFLineType string_to_atcflinetype(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString atcflinetype_to_string(const ATCFLineType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case ATCFLineType_Track: s = "Track"; break; diff --git a/src/libcode/vx_tc_util/atcf_track_line.cc b/src/libcode/vx_tc_util/atcf_track_line.cc index 106a646f88..19007127d0 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.cc +++ b/src/libcode/vx_tc_util/atcf_track_line.cc @@ -553,7 +553,7 @@ WatchWarnType string_to_watchwarntype(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString watchwarntype_to_string(const WatchWarnType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case TropicalStormWatch: s = "TSWATCH"; break; @@ -597,7 +597,7 @@ CycloneLevel string_to_cyclonelevel(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString cyclonelevel_to_string(const CycloneLevel t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case Disturbance: s = "DB"; break; @@ -657,7 +657,7 @@ QuadrantType string_to_quadranttype(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString quadranttype_to_string(const QuadrantType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case FullCircle: s = "AAA"; break; @@ -698,7 +698,7 @@ SubregionCode string_to_subregioncode(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString subregioncode_to_string(const SubregionCode t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case Arabian_Sea: s = "A"; break; @@ -733,7 +733,7 @@ SystemsDepth string_to_systemsdepth(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString systemsdepth_to_string(const SystemsDepth t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case DeepDepth: s = "D"; break; diff --git a/src/libcode/vx_tc_util/diag_file.cc b/src/libcode/vx_tc_util/diag_file.cc index 95336c7765..35680981a7 100644 --- a/src/libcode/vx_tc_util/diag_file.cc +++ b/src/libcode/vx_tc_util/diag_file.cc @@ -339,10 +339,10 @@ void DiagFile::read_cira_rt(const ConcatString &path, if(convert_map) { if(convert_map->count(cs) > 0) fx_ptr = &convert_map->at(cs); else if(convert_map->count(dl[1]) > 0) fx_ptr = &convert_map->at(dl[1]); - else fx_ptr = (UserFunc_1Arg *) 0; + else fx_ptr = (UserFunc_1Arg *) nullptr; } else { - fx_ptr = (UserFunc_1Arg *) 0; + fx_ptr = (UserFunc_1Arg *) nullptr; } // Parse the data values @@ -492,10 +492,10 @@ void DiagFile::read_ships_rt(const ConcatString &path, // Check for a conversion function if(convert_map) { if(convert_map->count(cs) > 0) fx_ptr = &convert_map->at(cs); - else fx_ptr = (UserFunc_1Arg *) 0; + else fx_ptr = (UserFunc_1Arg *) nullptr; } else { - fx_ptr = (UserFunc_1Arg *) 0; + fx_ptr = (UserFunc_1Arg *) nullptr; } // Parse the data values diff --git a/src/libcode/vx_tc_util/pair_data_genesis.cc b/src/libcode/vx_tc_util/pair_data_genesis.cc index c5665e318f..9f5dd56f87 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.cc +++ b/src/libcode/vx_tc_util/pair_data_genesis.cc @@ -28,7 +28,7 @@ using namespace std; //////////////////////////////////////////////////////////////////////// ConcatString genesispaircategory_to_string(const GenesisPairCategory c) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(c) { case FYOYGenesis: s = "FYOY"; break; diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc index 364e754035..e80d254f32 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc @@ -71,7 +71,7 @@ void ProbRIRWPairInfo::init_from_scratch() { void ProbRIRWPairInfo::clear() { ProbRIRW.clear(); - BDeck = (TrackInfo *) 0; + BDeck = (TrackInfo *) nullptr; StormName.clear(); BModel.clear(); BLat = BLon = bad_data_double; @@ -274,7 +274,7 @@ void ProbRIRWPairInfo::set(const TCStatLine &l) { ProbRIRW.set(l); // Do not populate the BDECK - BDeck = (TrackInfo *) 0; + BDeck = (TrackInfo *) nullptr; // Store column information StormName = l.get_item("STORM_NAME", false); diff --git a/src/libcode/vx_tc_util/tc_columns.cc b/src/libcode/vx_tc_util/tc_columns.cc index 3e38075aa7..af191ca329 100644 --- a/src/libcode/vx_tc_util/tc_columns.cc +++ b/src/libcode/vx_tc_util/tc_columns.cc @@ -58,7 +58,7 @@ void close_tc_txt_file(ofstream *&out, const char *file_name) { // Close the output file out->close(); delete out; - out = (ofstream *) 0; + out = (ofstream *) nullptr; return; } diff --git a/src/libcode/vx_tc_util/tc_stat_line.cc b/src/libcode/vx_tc_util/tc_stat_line.cc index 78bd215196..d30a909a54 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.cc +++ b/src/libcode/vx_tc_util/tc_stat_line.cc @@ -100,7 +100,7 @@ void TCStatLine::clear() { DataLine::clear(); Type = NoTCStatLineType; - HdrLine = (AsciiHeaderLine *) 0; + HdrLine = (AsciiHeaderLine *) nullptr; return; } @@ -382,7 +382,7 @@ TCStatLineType string_to_tcstatlinetype(const char *s) { //////////////////////////////////////////////////////////////////////// ConcatString tcstatlinetype_to_string(const TCStatLineType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case TCStatLineType_TCMPR: s = TCStatLineType_TCMPR_Str; break; diff --git a/src/libcode/vx_tc_util/track_info.cc b/src/libcode/vx_tc_util/track_info.cc index 379d60faa1..9202fe2afe 100644 --- a/src/libcode/vx_tc_util/track_info.cc +++ b/src/libcode/vx_tc_util/track_info.cc @@ -62,7 +62,7 @@ TrackInfo & TrackInfo::operator=(const TrackInfo & t) { void TrackInfo::init_from_scratch() { - Point = (TrackPoint *) 0; + Point = (TrackPoint *) nullptr; clear(); @@ -106,7 +106,7 @@ void TrackInfo::clear() { void TrackInfo::clear_points() { - if(Point) { delete [] Point; Point = (TrackPoint *) 0; } + if(Point) { delete [] Point; Point = (TrackPoint *) nullptr; } NPoints = NAlloc = 0; return; @@ -249,7 +249,7 @@ void TrackInfo::assign(const TrackInfo &t) { void TrackInfo::extend(int n, bool exact) { int j, k; - TrackPoint *new_line = (TrackPoint *) 0; + TrackPoint *new_line = (TrackPoint *) nullptr; // Check if enough memory is already allocated if(NAlloc >= n) return; @@ -273,12 +273,12 @@ void TrackInfo::extend(int n, bool exact) { // Copy the array contents and delete the old one if(Point) { for(j=0; j= n) return; @@ -1045,12 +1045,12 @@ void TrackPairInfoArray::extend(int n, bool exact) { // Copy the array contents and delete the old one if(Pair) { for(j=0; j Date: Tue, 27 Feb 2024 16:52:17 +0000 Subject: [PATCH 009/114] #2673 Change 0 to nullptr --- src/tools/core/ensemble_stat/ensemble_stat.cc | 12 +-- src/tools/core/ensemble_stat/ensemble_stat.h | 4 +- .../ensemble_stat/ensemble_stat_conf_info.cc | 12 +-- src/tools/core/grid_stat/grid_stat.cc | 4 +- src/tools/core/grid_stat/grid_stat.h | 10 +-- src/tools/core/mode/mode_exec.cc | 74 +++++++++---------- src/tools/core/mode/mode_ps_file.cc | 10 +-- src/tools/core/mode_analysis/mode_analysis.cc | 10 +-- src/tools/core/point_stat/point_stat.cc | 4 +- src/tools/core/point_stat/point_stat.h | 4 +- .../core/series_analysis/series_analysis.cc | 22 +++--- .../core/series_analysis/series_analysis.h | 8 +- .../series_analysis_conf_info.cc | 20 ++--- .../core/stat_analysis/aggr_stat_line.cc | 18 ++--- .../core/stat_analysis/parse_stat_line.cc | 4 +- src/tools/core/stat_analysis/stat_analysis.cc | 2 +- src/tools/core/stat_analysis/stat_analysis.h | 2 +- .../core/stat_analysis/stat_analysis_job.cc | 2 +- src/tools/core/wavelet_stat/wavelet_stat.cc | 71 +++++++++--------- src/tools/core/wavelet_stat/wavelet_stat.h | 12 +-- .../wavelet_stat/wavelet_stat_conf_info.cc | 34 ++++----- 21 files changed, 171 insertions(+), 168 deletions(-) diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 8b86abcec5..d5342146f2 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -640,7 +640,7 @@ void process_n_vld() { bool get_data_plane(const char *infile, GrdFileType ftype, VarInfo *info, DataPlane &dp, bool do_regrid) { bool found; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // Read the current ensemble file if(!(mtddf = mtddf_factory.new_met_2d_data_file(infile, ftype))) { @@ -916,7 +916,7 @@ void process_point_vx() { void process_point_obs(int i_nc) { int i_obs, j; unixtime hdr_ut; - NcFile *obs_in = (NcFile *) 0; + NcFile *obs_in = (NcFile *) nullptr; const char *method_name = "process_point_obs() -> "; mlog << Debug(2) << "\n" << sep_str << "\n\n" @@ -1122,7 +1122,7 @@ bool process_point_ens(int i_vx, int i_ens, DataPlaneArray &fcst_dpa) { //////////////////////////////////////////////////////////////////////// void process_point_scores() { - PairDataEnsemble *pd_ptr = (PairDataEnsemble *) 0; + PairDataEnsemble *pd_ptr = (PairDataEnsemble *) nullptr; PairDataEnsemble pd; ConcatString cs; int i, j, k, l; @@ -1326,7 +1326,7 @@ void process_grid_vx() { mlog << Debug(3) << "Observation error for gridded verification is " << "defined by a table lookup for each point.\n"; - oerr_ptr = (ObsErrorEntry *) 0; + oerr_ptr = (ObsErrorEntry *) nullptr; } } } @@ -1850,7 +1850,7 @@ void setup_txt_files() { max_col += n_header_columns; // Initialize file stream - stat_out = (ofstream *) 0; + stat_out = (ofstream *) nullptr; // Build the file name stat_file << tmp_str << stat_file_ext; @@ -1884,7 +1884,7 @@ void setup_txt_files() { if(i == i_orank && !point_obs_flag) continue; // Initialize file stream - txt_out[i] = (ofstream *) 0; + txt_out[i] = (ofstream *) nullptr; // Build the file name txt_file[i] << tmp_str << "_" << txt_file_abbr[i] diff --git a/src/tools/core/ensemble_stat/ensemble_stat.h b/src/tools/core/ensemble_stat/ensemble_stat.h index 1dde2c06a1..28d26a5585 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.h +++ b/src/tools/core/ensemble_stat/ensemble_stat.h @@ -123,7 +123,7 @@ static int compress_level = -1; // Output NetCDF file static bool out_nc_flag = false; static ConcatString out_nc_file; -static netCDF::NcFile *nc_out = (netCDF::NcFile *) 0; +static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; static netCDF::NcDim lat_dim; static netCDF::NcDim lon_dim; @@ -133,7 +133,7 @@ static StringArray nc_orank_var_sa; // Output STAT file static ConcatString stat_file; -static std::ofstream *stat_out = (std::ofstream *) 0; +static std::ofstream *stat_out = (std::ofstream *) nullptr; static AsciiTable stat_at; static int i_stat_row; diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 8da7df73c6..be18529e0e 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -50,8 +50,8 @@ EnsembleStatConfInfo::~EnsembleStatConfInfo() { void EnsembleStatConfInfo::init_from_scratch() { // Initialize pointers - vx_opt = (EnsembleStatVxOpt *) 0; - rng_ptr = (gsl_rng *) 0; + vx_opt = (EnsembleStatVxOpt *) nullptr; + rng_ptr = (gsl_rng *) nullptr; clear(); @@ -86,7 +86,7 @@ void EnsembleStatConfInfo::clear() { nc_info.clear(); // Deallocate memory - if(vx_opt) { delete [] vx_opt; vx_opt = (EnsembleStatVxOpt *) 0; } + if(vx_opt) { delete [] vx_opt; vx_opt = (EnsembleStatVxOpt *) nullptr; } // Reset counts n_vx = 0; @@ -122,8 +122,8 @@ void EnsembleStatConfInfo::process_config(GrdFileType etype, int i, j, n_ens_files; VarInfoFactory info_factory; mapoutput_map; - Dictionary *fdict = (Dictionary *) 0; - Dictionary *odict = (Dictionary *) 0; + Dictionary *fdict = (Dictionary *) nullptr; + Dictionary *odict = (Dictionary *) nullptr; Dictionary i_fdict, i_odict; InterpMthd mthd; @@ -869,7 +869,7 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, //////////////////////////////////////////////////////////////////////// void EnsembleStatVxOpt::parse_nc_info(Dictionary &odict) { - const DictionaryEntry * e = (const DictionaryEntry *) 0; + const DictionaryEntry * e = (const DictionaryEntry *) nullptr; e = odict.lookup(conf_key_nc_orank_flag); diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index c65ca49109..59495c569a 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -2608,7 +2608,7 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, n_masks = (apply_mask ? conf_info.vx_opt[i_vx].get_n_mask() : 1); // Allocate memory - float *data = (float *) 0; + float *data = (float *) nullptr; data = new float [grid.nx()*grid.ny()]; // Set the NetCDF compression level @@ -3070,7 +3070,7 @@ void clean_up() { //nc_out->close(); delete nc_out; - nc_out = (NcFile *) 0; + nc_out = (NcFile *) nullptr; } // Deallocate memory for data files diff --git a/src/tools/core/grid_stat/grid_stat.h b/src/tools/core/grid_stat/grid_stat.h index ec85cacffd..b5db513b57 100644 --- a/src/tools/core/grid_stat/grid_stat.h +++ b/src/tools/core/grid_stat/grid_stat.h @@ -127,7 +127,7 @@ static ConcatString out_dir; // Output Netcdf file static ConcatString out_nc_file; -static netCDF::NcFile *nc_out = (netCDF::NcFile *) 0; +static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; static netCDF::NcDim lat_dim; static netCDF::NcDim lon_dim; @@ -136,7 +136,7 @@ static StringArray nc_var_sa; // Output STAT file static ConcatString stat_file; -static std::ofstream *stat_out = (std::ofstream *) 0; +static std::ofstream *stat_out = (std::ofstream *) nullptr; static AsciiTable stat_at; static int i_stat_row; @@ -163,11 +163,11 @@ static DataPlane wgt_dp; // Data file factory and input files static Met2dDataFileFactory mtddf_factory; -static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) 0; -static Met2dDataFile *obs_mtddf = (Met2dDataFile *) 0; +static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) nullptr; +static Met2dDataFile *obs_mtddf = (Met2dDataFile *) nullptr; // Pointer to the random number generator to be used -static gsl_rng *rng_ptr = (gsl_rng *) 0; +static gsl_rng *rng_ptr = (gsl_rng *) nullptr; // Strings to be output in the STAT and optional text files static StatHdrColumns shc; diff --git a/src/tools/core/mode/mode_exec.cc b/src/tools/core/mode/mode_exec.cc index 9165051a6c..025177727c 100644 --- a/src/tools/core/mode/mode_exec.cc +++ b/src/tools/core/mode/mode_exec.cc @@ -87,8 +87,8 @@ void ModeExecutive::init_from_scratch() { - fcst_mtddf = (Met2dDataFile *) 0; - obs_mtddf = (Met2dDataFile *) 0; + fcst_mtddf = (Met2dDataFile *) nullptr; + obs_mtddf = (Met2dDataFile *) nullptr; clear(); @@ -111,8 +111,8 @@ void ModeExecutive::clear() fcst_file.clear(); obs_file.clear(); - if ( fcst_mtddf ) { delete fcst_mtddf; fcst_mtddf = (Met2dDataFile *) 0; } - if ( obs_mtddf ) { delete obs_mtddf; obs_mtddf = (Met2dDataFile *) 0; } + if ( fcst_mtddf ) { delete fcst_mtddf; fcst_mtddf = (Met2dDataFile *) nullptr; } + if ( obs_mtddf ) { delete obs_mtddf; obs_mtddf = (Met2dDataFile *) nullptr; } for (int j=0; jconv_thresh.get_str(5); const ConcatString obs_thresh = engine.conf_info.Obs->conv_thresh.get_str(5); - float *fcst_raw_data = (float *) 0; - float *fcst_obj_raw_data = (float *) 0; - int *fcst_obj_data = (int *) 0; - int *fcst_clus_data = (int *) 0; + float *fcst_raw_data = (float *) nullptr; + float *fcst_obj_raw_data = (float *) nullptr; + int *fcst_obj_data = (int *) nullptr; + int *fcst_clus_data = (int *) nullptr; - float *obs_raw_data = (float *) 0; - float *obs_obj_raw_data = (float *) 0; - int *obs_obj_data = (int *) 0; - int *obs_clus_data = (int *) 0; + float *obs_raw_data = (float *) nullptr; + float *obs_obj_raw_data = (float *) nullptr; + int *obs_obj_data = (int *) nullptr; + int *obs_clus_data = (int *) nullptr; - NcFile *f_out = (NcFile *) 0; + NcFile *f_out = (NcFile *) nullptr; NcDim lat_dim ; NcDim lon_dim ; @@ -1752,7 +1752,7 @@ void ModeExecutive::write_obj_netcdf(const ModeNcOutInfo & info) mlog << Error << "\nModeExecutive::write_obj_netcdf() -> trouble opening output file " << out_file << "\n\n"; delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; exit(1); } @@ -2094,15 +2094,15 @@ void ModeExecutive::write_obj_netcdf(const ModeNcOutInfo & info) // Delete allocated memory // - if (fcst_raw_data) { delete [] fcst_raw_data; fcst_raw_data = (float *) 0; } - if (fcst_obj_raw_data) { delete [] fcst_obj_raw_data; fcst_obj_raw_data = (float *) 0; } - if (fcst_obj_data) { delete [] fcst_obj_data; fcst_obj_data = (int *) 0; } - if (fcst_clus_data) { delete [] fcst_clus_data; fcst_clus_data = (int *) 0; } + if (fcst_raw_data) { delete [] fcst_raw_data; fcst_raw_data = (float *) nullptr; } + if (fcst_obj_raw_data) { delete [] fcst_obj_raw_data; fcst_obj_raw_data = (float *) nullptr; } + if (fcst_obj_data) { delete [] fcst_obj_data; fcst_obj_data = (int *) nullptr; } + if (fcst_clus_data) { delete [] fcst_clus_data; fcst_clus_data = (int *) nullptr; } - if (obs_raw_data) { delete [] obs_raw_data; obs_raw_data = (float *) 0; } - if (obs_obj_raw_data) { delete [] obs_obj_raw_data; obs_obj_raw_data = (float *) 0; } - if (obs_obj_data) { delete [] obs_obj_data; obs_obj_data = (int *) 0; } - if (obs_clus_data) { delete [] obs_clus_data; obs_clus_data = (int *) 0; } + if (obs_raw_data) { delete [] obs_raw_data; obs_raw_data = (float *) nullptr; } + if (obs_obj_raw_data) { delete [] obs_obj_raw_data; obs_obj_raw_data = (float *) nullptr; } + if (obs_obj_data) { delete [] obs_obj_data; obs_obj_data = (int *) nullptr; } + if (obs_clus_data) { delete [] obs_clus_data; obs_clus_data = (int *) nullptr; } // // Write out the values of the vertices of the polylines. @@ -2114,7 +2114,7 @@ void ModeExecutive::write_obj_netcdf(const ModeNcOutInfo & info) // Close the NetCDF file // delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; return; } @@ -2179,14 +2179,14 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) int i, j, x, y, n_pts, n_poly; double lat, lon; - Polyline **poly = (Polyline **) 0; + Polyline **poly = (Polyline **) nullptr; - int *poly_start = (int *) 0; - int *poly_npts = (int *) 0; - float *poly_lat = (float *) 0; - float *poly_lon = (float *) 0; - int *poly_x = (int *) 0; - int *poly_y = (int *) 0; + int *poly_start = (int *) nullptr; + int *poly_npts = (int *) nullptr; + float *poly_lat = (float *) nullptr; + float *poly_lon = (float *) nullptr; + int *poly_x = (int *) nullptr; + int *poly_y = (int *) nullptr; // Dimensions and variables for each object NcDim obj_dim ; @@ -2436,13 +2436,13 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) // // Delete allocated memory // - if(poly) { delete [] poly; poly = (Polyline **) 0; } - if(poly_start) { delete [] poly_start; poly_start = (int *) 0; } - if(poly_npts) { delete [] poly_npts; poly_npts = (int *) 0; } - if(poly_lat) { delete [] poly_lat; poly_lat = (float *) 0; } - if(poly_lon) { delete [] poly_lon; poly_lon = (float *) 0; } - if(poly_x) { delete [] poly_x; poly_x = (int *) 0; } - if(poly_y) { delete [] poly_y; poly_y = (int *) 0; } + if(poly) { delete [] poly; poly = (Polyline **) nullptr; } + if(poly_start) { delete [] poly_start; poly_start = (int *) nullptr; } + if(poly_npts) { delete [] poly_npts; poly_npts = (int *) nullptr; } + if(poly_lat) { delete [] poly_lat; poly_lat = (float *) nullptr; } + if(poly_lon) { delete [] poly_lon; poly_lon = (float *) nullptr; } + if(poly_x) { delete [] poly_x; poly_x = (int *) nullptr; } + if(poly_y) { delete [] poly_y; poly_y = (int *) nullptr; } return; } diff --git a/src/tools/core/mode/mode_ps_file.cc b/src/tools/core/mode/mode_ps_file.cc index 2a9c518599..66cba3b5d5 100644 --- a/src/tools/core/mode/mode_ps_file.cc +++ b/src/tools/core/mode/mode_ps_file.cc @@ -115,11 +115,11 @@ void ModePsFile::mpsf_init_from_scratch() { - Engine = (ModeFuzzyEngine *) 0; + Engine = (ModeFuzzyEngine *) nullptr; - ConfInfo = (ModeConfInfo *) 0; + ConfInfo = (ModeConfInfo *) nullptr; - grid = (Grid *) 0; + grid = (Grid *) nullptr; MetDataDir = replace_path("MET_BASE"); @@ -916,7 +916,7 @@ void ModePsFile::draw_colorbar(bool fcst) int i, n_colors; char label[max_str_len]; double bar_width, bar_height, x_ll, y_ll; - ColorTable * ct = (ColorTable *) 0; + ColorTable * ct = (ColorTable *) nullptr; Box b; Color c; @@ -1013,7 +1013,7 @@ void ModePsFile::render_ppm(ModeFuzzyEngine & eng, EngineType eng_type, const Sh double mag, v; Color c; Color fill_color; - ColorTable *ct = (ColorTable *) 0; + ColorTable *ct = (ColorTable *) nullptr; const int L = nint(XY_box.left()); const int B = nint(XY_box.bottom()); diff --git a/src/tools/core/mode_analysis/mode_analysis.cc b/src/tools/core/mode_analysis/mode_analysis.cc index 95e1bd43d1..e0ae0f8bb4 100644 --- a/src/tools/core/mode_analysis/mode_analysis.cc +++ b/src/tools/core/mode_analysis/mode_analysis.cc @@ -58,7 +58,7 @@ static const char * default_config_filename = "MET_BASE/config/MODEAnalysisConfi static ConcatString config_filename; -static BasicModeAnalysisJob * job = (BasicModeAnalysisJob *) 0; +static BasicModeAnalysisJob * job = (BasicModeAnalysisJob *) nullptr; static ModeAttributes config_atts; @@ -70,9 +70,9 @@ static StringArray mode_files; static StringArray lookin_dirs; -static ofstream * dumpfile = (ofstream *) 0; +static ofstream * dumpfile = (ofstream *) nullptr; -static ofstream * outfile = (ofstream *) 0; +static ofstream * outfile = (ofstream *) nullptr; //////////////////////////////////////////////////////////////////////// @@ -181,8 +181,8 @@ job->clear(); // done // -if ( dumpfile ) { delete dumpfile; dumpfile = (ofstream *) 0; } -if ( outfile ) { delete outfile; outfile = (ofstream *) 0; } +if ( dumpfile ) { delete dumpfile; dumpfile = (ofstream *) nullptr; } +if ( outfile ) { delete outfile; outfile = (ofstream *) nullptr; } return ( 0 ); diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 6c50ea880c..d950486015 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -414,7 +414,7 @@ void setup_txt_files() { max_col += n_header_columns + 1; // Initialize file stream - stat_out = (ofstream *) 0; + stat_out = (ofstream *) nullptr; // Build the file name stat_file << base_name << stat_file_ext; @@ -445,7 +445,7 @@ void setup_txt_files() { if(conf_info.output_flag[i] == STATOutputType_Both) { // Initialize file stream - txt_out[i] = (ofstream *) 0; + txt_out[i] = (ofstream *) nullptr; // Build the file name txt_file[i] << base_name << "_" << txt_file_abbr[i] diff --git a/src/tools/core/point_stat/point_stat.h b/src/tools/core/point_stat/point_stat.h index 510693068b..7d69a62b62 100644 --- a/src/tools/core/point_stat/point_stat.h +++ b/src/tools/core/point_stat/point_stat.h @@ -128,7 +128,7 @@ static int fcst_lead_sec = bad_data_int; // Output STAT file static ConcatString stat_file; -static std::ofstream *stat_out = (std::ofstream *) 0; +static std::ofstream *stat_out = (std::ofstream *) nullptr; static AsciiTable stat_at; static int i_stat_row; @@ -150,7 +150,7 @@ static bool is_first_pass = true; // Data file factory and input files static Met2dDataFileFactory mtddf_factory; -static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) 0; +static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) nullptr; // Pointer to the random number generator to be used static gsl_rng *rng_ptr = (gsl_rng *) nullptr; diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 223ce9ad65..5ce2b81d6d 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -378,7 +378,7 @@ void process_grid(const Grid &fcst_grid, const Grid &obs_grid) { Met2dDataFile *get_mtddf(const StringArray &file_list, const GrdFileType type) { int i; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // Find the first file that actually exists for(i=0; igrid(); // Close the data file - delete mtddf; mtddf = (Met2dDataFile *) 0; + delete mtddf; mtddf = (Met2dDataFile *) nullptr; return(found); } @@ -677,9 +677,9 @@ bool read_single_entry(VarInfo *info, const ConcatString &cur_file, void process_scores() { int i, x, y, i_read, i_series, i_point, i_fcst; - VarInfo *fcst_info = (VarInfo *) 0; - VarInfo *obs_info = (VarInfo *) 0; - PairDataPoint *pd_ptr = (PairDataPoint *) 0; + VarInfo *fcst_info = (VarInfo *) nullptr; + VarInfo *obs_info = (VarInfo *) nullptr; + PairDataPoint *pd_ptr = (PairDataPoint *) nullptr; DataPlane fcst_dp, obs_dp; const char *method_name = "process_scores() "; @@ -878,7 +878,7 @@ void process_scores() { add_att(nc_out, "obs_lead_end", (string)sec_to_hhmmss(obs_lead_end)); // Clean up - if(pd_ptr) { delete [] pd_ptr; pd_ptr = (PairDataPoint *) 0; } + if(pd_ptr) { delete [] pd_ptr; pd_ptr = (PairDataPoint *) nullptr; } // Print summary counts mlog << Debug(2) @@ -964,7 +964,7 @@ void do_cts(int n, const PairDataPoint *pd_ptr) { } // end for i // Deallocate memory - if(cts_info) { delete [] cts_info; cts_info = (CTSInfo *) 0; } + if(cts_info) { delete [] cts_info; cts_info = (CTSInfo *) nullptr; } return; } @@ -2238,12 +2238,12 @@ void clean_up() { mlog << Debug(1) << "Output file: " << out_file << "\n"; delete nc_out; - nc_out = (NcFile *) 0; + nc_out = (NcFile *) nullptr; } // Deallocate memory for data files - if(fcst_mtddf) { delete fcst_mtddf; fcst_mtddf = (Met2dDataFile *) 0; } - if(obs_mtddf) { delete obs_mtddf; obs_mtddf = (Met2dDataFile *) 0; } + if(fcst_mtddf) { delete fcst_mtddf; fcst_mtddf = (Met2dDataFile *) nullptr; } + if(obs_mtddf) { delete obs_mtddf; obs_mtddf = (Met2dDataFile *) nullptr; } // Deallocate memory for the random number generator rng_free(rng_ptr); diff --git a/src/tools/core/series_analysis/series_analysis.h b/src/tools/core/series_analysis/series_analysis.h index 51225c08ef..d50df6cb94 100644 --- a/src/tools/core/series_analysis/series_analysis.h +++ b/src/tools/core/series_analysis/series_analysis.h @@ -88,7 +88,7 @@ static SeriesAnalysisConfInfo conf_info; //////////////////////////////////////////////////////////////////////// // Output NetCDF file -static netCDF::NcFile *nc_out = (netCDF::NcFile *) 0; +static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; static netCDF::NcDim lat_dim; static netCDF::NcDim lon_dim ; @@ -113,11 +113,11 @@ static int n_reads = 1; // Initialize to at least one pass // Data file factory and input files static Met2dDataFileFactory mtddf_factory; -static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) 0; -static Met2dDataFile *obs_mtddf = (Met2dDataFile *) 0; +static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) nullptr; +static Met2dDataFile *obs_mtddf = (Met2dDataFile *) nullptr; // Pointer to the random number generator to be used -static gsl_rng *rng_ptr = (gsl_rng *) 0; +static gsl_rng *rng_ptr = (gsl_rng *) nullptr; // Enumeration of ways that a series can be defined enum SeriesType { diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.cc b/src/tools/core/series_analysis/series_analysis_conf_info.cc index 7d22d83643..08b97c1fd8 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.cc +++ b/src/tools/core/series_analysis/series_analysis_conf_info.cc @@ -46,8 +46,8 @@ SeriesAnalysisConfInfo::~SeriesAnalysisConfInfo() { void SeriesAnalysisConfInfo::init_from_scratch() { // Initialize pointers - fcst_info = (VarInfo **) 0; - obs_info = (VarInfo **) 0; + fcst_info = (VarInfo **) nullptr; + obs_info = (VarInfo **) nullptr; clear(); @@ -92,15 +92,15 @@ void SeriesAnalysisConfInfo::clear() { // Clear fcst_info if(fcst_info) { for(i=0; i::iterator it; @@ -220,8 +220,8 @@ void SeriesAnalysisConfInfo::process_config(GrdFileType ftype, obs_info = new VarInfo * [n_obs]; // Initialize pointers - for(i=0; ilookup_thresh_array(conf_key_cat_thresh); diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 99b5906429..b9c4df9a25 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -2377,8 +2377,8 @@ void aggr_isc_lines(LineDataFile &ldf, STATAnalysisJob &job, // if(m.count(key) == 0) { aggr.isc_info.clear(); - aggr.total_na = aggr.mse_na = aggr.fen_na = (NumArray *) 0; - aggr.oen_na = aggr.baser_na = aggr.fbias_na = (NumArray *) 0; + aggr.total_na = aggr.mse_na = aggr.fen_na = (NumArray *) nullptr; + aggr.oen_na = aggr.baser_na = aggr.fbias_na = (NumArray *) nullptr; aggr.hdr.clear(); m[key] = aggr; mlog << Debug(3) << "[Case " << m.size() @@ -2568,12 +2568,12 @@ void aggr_isc_lines(LineDataFile &ldf, STATAnalysisJob &job, // // Deallocate memory // - if(it->second.total_na) { delete [] it->second.total_na; it->second.total_na = (NumArray *) 0; } - if(it->second.mse_na ) { delete [] it->second.mse_na; it->second.mse_na = (NumArray *) 0; } - if(it->second.fen_na ) { delete [] it->second.fen_na; it->second.fen_na = (NumArray *) 0; } - if(it->second.oen_na ) { delete [] it->second.oen_na; it->second.oen_na = (NumArray *) 0; } - if(it->second.baser_na) { delete [] it->second.baser_na; it->second.baser_na = (NumArray *) 0; } - if(it->second.fbias_na) { delete [] it->second.fbias_na; it->second.fbias_na = (NumArray *) 0; } + if(it->second.total_na) { delete [] it->second.total_na; it->second.total_na = (NumArray *) nullptr; } + if(it->second.mse_na ) { delete [] it->second.mse_na; it->second.mse_na = (NumArray *) nullptr; } + if(it->second.fen_na ) { delete [] it->second.fen_na; it->second.fen_na = (NumArray *) nullptr; } + if(it->second.oen_na ) { delete [] it->second.oen_na; it->second.oen_na = (NumArray *) nullptr; } + if(it->second.baser_na) { delete [] it->second.baser_na; it->second.baser_na = (NumArray *) nullptr; } + if(it->second.fbias_na) { delete [] it->second.fbias_na; it->second.fbias_na = (NumArray *) nullptr; } } // end for it @@ -3878,7 +3878,7 @@ void mpr_to_ctc(STATAnalysisJob &job, const AggrMPRInfo &info, void mpr_to_cts(STATAnalysisJob &job, const AggrMPRInfo &info, int i_thresh, CTSInfo &cts_info, const char *tmp_dir, gsl_rng *rng_ptr) { - CTSInfo *cts_info_ptr = (CTSInfo *) 0; + CTSInfo *cts_info_ptr = (CTSInfo *) nullptr; // // Initialize diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index 57bc92eb46..47c91c099d 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -150,7 +150,7 @@ void parse_nbrctc_ctable(STATLine &l, TTContingencyTable &ct) { void parse_nx2_ctable(STATLine &l, Nx2ContingencyTable &pct) { int i, n, oy, on; char col_str[max_str_len]; - double *thresh = (double *) 0; + double *thresh = (double *) nullptr; // N_THRESH n = atoi(l.get_item("N_THRESH")); @@ -181,7 +181,7 @@ void parse_nx2_ctable(STATLine &l, Nx2ContingencyTable &pct) { thresh[n-1] = atof(l.get_item(col_str)); pct.set_thresholds(thresh); - if ( thresh ) { delete [] thresh; thresh = (double *) 0; } + if ( thresh ) { delete [] thresh; thresh = (double *) nullptr; } return; } diff --git a/src/tools/core/stat_analysis/stat_analysis.cc b/src/tools/core/stat_analysis/stat_analysis.cc index 912617a213..366dbab0a3 100644 --- a/src/tools/core/stat_analysis/stat_analysis.cc +++ b/src/tools/core/stat_analysis/stat_analysis.cc @@ -639,7 +639,7 @@ while((*f) >> line) { f->close(); -if(pldf) { delete pldf; pldf = (PyLineDataFile *) 0; } +if(pldf) { delete pldf; pldf = (PyLineDataFile *) nullptr; } return; diff --git a/src/tools/core/stat_analysis/stat_analysis.h b/src/tools/core/stat_analysis/stat_analysis.h index b4992e75b0..0fa44910db 100644 --- a/src/tools/core/stat_analysis/stat_analysis.h +++ b/src/tools/core/stat_analysis/stat_analysis.h @@ -70,7 +70,7 @@ static StringArray files; // Output file set with -out static ConcatString out_file; -static std::ofstream *sa_out = (std::ofstream *) 0; +static std::ofstream *sa_out = (std::ofstream *) nullptr; // Config file set with -config static ConcatString config_file; diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index dce6d0014f..a868b6b1d0 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -158,7 +158,7 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, const ConcatString &tmp_path, ofstream *sa_out) { LineDataFile f; int n_in, n_out; - gsl_rng *rng_ptr = (gsl_rng *) 0; + gsl_rng *rng_ptr = (gsl_rng *) nullptr; // // Open up the temp file for reading the intermediate STAT line data diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index b182a4538d..c1675cb365 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -506,12 +506,12 @@ void process_scores() { for(j=0; jclose(); delete nc_out; - nc_out = (NcFile *) 0; + nc_out = (NcFile *) nullptr; } // Close the output PSfile as long as it was opened @@ -1906,7 +1909,7 @@ void close_out_files() { mlog << Debug(1) << "Output file: " << out_ps_file << "\n"; ps_out->close(); delete ps_out; - ps_out = (PSfile *) 0; + ps_out = (PSfile *) nullptr; } return; @@ -2614,7 +2617,7 @@ void draw_colorbar(PSfile *p, Box &dim, int fcst, int raw) { int i; char label[max_str_len]; double bar_width, bar_height, x_ll, y_ll, step, v; - ColorTable *ct_ptr = (ColorTable *) 0; + ColorTable *ct_ptr = (ColorTable *) nullptr; Color c; // @@ -2814,8 +2817,8 @@ void render_image(PSfile *p, const DataPlane &dp, Box &dim, int fcst) { int x, y, grid_x, grid_y; double mag; Color c; - Color *c_fill_ptr = (Color *) 0; - ColorTable *ct_ptr = (ColorTable *) 0; + Color *c_fill_ptr = (Color *) nullptr; + ColorTable *ct_ptr = (ColorTable *) nullptr; // // Set up pointers to the appropriate colortable and fill color @@ -2904,8 +2907,8 @@ void render_tile(PSfile *p, const double *data, int n, int i_tile, int i, x, y; double mag; Color c; - Color *c_fill_ptr = (Color *) 0; - ColorTable *ct_ptr = (ColorTable *) 0; + Color *c_fill_ptr = (Color *) nullptr; + ColorTable *ct_ptr = (ColorTable *) nullptr; // // Set up pointers to the appropriate colortable and fill color diff --git a/src/tools/core/wavelet_stat/wavelet_stat.h b/src/tools/core/wavelet_stat/wavelet_stat.h index 0b42b68e39..470477fa6b 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.h +++ b/src/tools/core/wavelet_stat/wavelet_stat.h @@ -93,7 +93,7 @@ static ConcatString out_dir; // Output NetCDF file static ConcatString out_nc_file; -static netCDF::NcFile *nc_out = (netCDF::NcFile *) 0; +static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; static netCDF::NcDim x_dim ; static netCDF::NcDim y_dim ; static netCDF::NcDim scale_dim ; @@ -104,17 +104,17 @@ static netCDF::NcVar diff_var ; // Output PostScript file static ConcatString out_ps_file; -static PSfile *ps_out = (PSfile *) 0; +static PSfile *ps_out = (PSfile *) nullptr; // Output STAT file static ConcatString stat_file; -static std::ofstream *stat_out = (std::ofstream *) 0; +static std::ofstream *stat_out = (std::ofstream *) nullptr; static AsciiTable stat_at; static int i_stat_row; // Optional ISC output file static ConcatString isc_file; -static std::ofstream *isc_out = (std::ofstream *) 0; +static std::ofstream *isc_out = (std::ofstream *) nullptr; static AsciiTable isc_at; static int i_isc_row; @@ -177,8 +177,8 @@ static bool is_first_pass = true; // Data file factory and input files static Met2dDataFileFactory mtddf_factory; -static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) 0; -static Met2dDataFile *obs_mtddf = (Met2dDataFile *) 0; +static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) nullptr; +static Met2dDataFile *obs_mtddf = (Met2dDataFile *) nullptr; // Strings to be output in the STAT and optional text files static StatHdrColumns shc; diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index 8a2a896544..0d5ccedaa5 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -47,12 +47,12 @@ WaveletStatConfInfo::~WaveletStatConfInfo() { void WaveletStatConfInfo::init_from_scratch() { // Initialize pointers - fcst_info = (VarInfo **) 0; - obs_info = (VarInfo **) 0; - fcat_ta = (ThreshArray *) 0; - ocat_ta = (ThreshArray *) 0; - wvlt_ptr = (gsl_wavelet *) 0; - wvlt_work_ptr = (gsl_wavelet_workspace *) 0; + fcst_info = (VarInfo **) nullptr; + obs_info = (VarInfo **) nullptr; + fcat_ta = (ThreshArray *) nullptr; + ocat_ta = (ThreshArray *) nullptr; + wvlt_ptr = (gsl_wavelet *) nullptr; + wvlt_work_ptr = (gsl_wavelet_workspace *) nullptr; clear(); @@ -91,21 +91,21 @@ void WaveletStatConfInfo::clear() { // Deallocate memory if(wvlt_ptr) { wavelet_free(wvlt_ptr); } if(wvlt_work_ptr) { wavelet_workspace_free(wvlt_work_ptr); } - if(fcat_ta) { delete [] fcat_ta; fcat_ta = (ThreshArray *) 0; } - if(ocat_ta) { delete [] ocat_ta; ocat_ta = (ThreshArray *) 0; } + if(fcat_ta) { delete [] fcat_ta; fcat_ta = (ThreshArray *) nullptr; } + if(ocat_ta) { delete [] ocat_ta; ocat_ta = (ThreshArray *) nullptr; } // Clear fcst_info if(fcst_info) { for(i=0; ioutput_map; - Dictionary *fcst_dict = (Dictionary *) 0; - Dictionary *obs_dict = (Dictionary *) 0; - Dictionary *dict = (Dictionary *) 0; + Dictionary *fcst_dict = (Dictionary *) nullptr; + Dictionary *obs_dict = (Dictionary *) nullptr; + Dictionary *dict = (Dictionary *) nullptr; Dictionary i_fdict, i_odict; gsl_wavelet_type type; @@ -202,7 +202,7 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, ocat_ta = new ThreshArray [n_vx]; // Initialize pointers - for(i=0; i Date: Tue, 27 Feb 2024 16:52:25 +0000 Subject: [PATCH 010/114] #2673 Change 0 to nullptr --- src/tools/dev_utils/chk4copyright.cc | 4 +- src/tools/dev_utils/gen_climo_bin.cc | 14 ++-- src/tools/dev_utils/gribtab.dat_to_flat.cc | 6 +- src/tools/dev_utils/insitu_nc_file.cc | 6 +- src/tools/dev_utils/met_nc_file.cc | 8 +- src/tools/dev_utils/nceptab_to_flat.cc | 4 +- src/tools/other/ascii2nc/file_handler.cc | 2 +- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 34 ++++---- src/tools/other/gen_ens_prod/gen_ens_prod.h | 6 +- .../gen_ens_prod/gen_ens_prod_conf_info.cc | 2 +- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 24 +++--- src/tools/other/grid_diag/grid_diag.cc | 8 +- src/tools/other/grid_diag/grid_diag.h | 4 +- .../other/grid_diag/grid_diag_conf_info.cc | 12 +-- src/tools/other/gsi_tools/gsidens2orank.h | 2 +- src/tools/other/madis2nc/madis2nc.cc | 8 +- src/tools/other/madis2nc/madis2nc.h | 4 +- src/tools/other/mode_graphics/cgraph_font.cc | 4 +- src/tools/other/mode_graphics/cgraph_main.cc | 36 ++++---- .../cgraphbase_plottype_to_string.cc | 2 +- src/tools/other/mode_graphics/color_stack.cc | 10 +-- .../mode_graphics/mode_nc_output_file.cc | 26 +++--- src/tools/other/mode_time_domain/2d_att.cc | 2 +- .../other/mode_time_domain/2d_att_array.cc | 8 +- src/tools/other/mode_time_domain/3d_att.cc | 2 +- .../mode_time_domain/3d_att_pair_array.cc | 8 +- .../mode_time_domain/3d_att_single_array.cc | 8 +- .../other/mode_time_domain/fo_node_array.cc | 8 +- src/tools/other/mode_time_domain/mm_engine.cc | 2 +- .../other/mode_time_domain/mtd_config_info.cc | 34 ++++---- .../other/mode_time_domain/mtd_file_base.cc | 6 +- .../other/mode_time_domain/mtd_file_int.cc | 16 ++-- .../other/mode_time_domain/mtd_partition.cc | 22 ++--- .../mode_time_domain/mtdfiletype_to_string.cc | 2 +- .../other/mode_time_domain/nc_utils_local.cc | 2 +- .../other/modis_regrid/cloudsat_swath_file.cc | 84 +++++++++---------- src/tools/other/modis_regrid/data_averager.cc | 2 +- .../modis_regrid/data_plane_to_netcdf.cc | 10 +-- src/tools/other/modis_regrid/modis_file.cc | 2 +- src/tools/other/modis_regrid/modis_regrid.cc | 4 +- src/tools/other/pb2nc/pb2nc.cc | 4 +- src/tools/other/pb2nc/pb2nc_conf_info.cc | 4 +- .../plot_point_obs_conf_info.cc | 8 +- src/tools/other/point2grid/point2grid.cc | 30 +++---- .../other/point2grid/point2grid_conf_info.cc | 2 +- .../regrid_data_plane/regrid_data_plane.cc | 14 ++-- .../shift_data_plane/shift_data_plane.cc | 10 +-- src/tools/other/wwmca_tool/af_cp_file.cc | 4 +- src/tools/other/wwmca_tool/af_file.cc | 4 +- src/tools/other/wwmca_tool/af_pt_file.cc | 4 +- src/tools/other/wwmca_tool/ave_interp.cc | 2 +- src/tools/other/wwmca_tool/interp_base.cc | 4 +- src/tools/other/wwmca_tool/max_interp.cc | 2 +- src/tools/other/wwmca_tool/min_interp.cc | 2 +- src/tools/other/wwmca_tool/nc_output.cc | 4 +- src/tools/other/wwmca_tool/nearest_interp.cc | 2 +- src/tools/other/wwmca_tool/wwmca_plot.cc | 6 +- src/tools/other/wwmca_tool/wwmca_ref.cc | 36 ++++---- .../tc_utils/rmw_analysis/rmw_analysis.h | 4 +- .../rmw_analysis/rmw_analysis_conf_info.cc | 10 +-- src/tools/tc_utils/tc_diag/tc_diag.cc | 44 +++++----- .../tc_utils/tc_diag/tc_diag_conf_info.cc | 8 +- src/tools/tc_utils/tc_dland/tc_dland.cc | 12 +-- src/tools/tc_utils/tc_dland/tc_poly.cc | 10 +-- src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc | 12 +-- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 12 +-- .../tc_utils/tc_pairs/tc_pairs_conf_info.cc | 10 +-- src/tools/tc_utils/tc_rmw/tc_rmw.cc | 8 +- src/tools/tc_utils/tc_rmw/tc_rmw.h | 2 +- src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc | 10 +-- .../tc_utils/tc_rmw/tc_rmw_wind_converter.cc | 66 +++++++-------- src/tools/tc_utils/tc_stat/tc_stat.cc | 8 +- src/tools/tc_utils/tc_stat/tc_stat.h | 2 +- src/tools/tc_utils/tc_stat/tc_stat_job.cc | 10 +-- 74 files changed, 409 insertions(+), 409 deletions(-) diff --git a/src/tools/dev_utils/chk4copyright.cc b/src/tools/dev_utils/chk4copyright.cc index e145909d31..d61649b318 100644 --- a/src/tools/dev_utils/chk4copyright.cc +++ b/src/tools/dev_utils/chk4copyright.cc @@ -210,8 +210,8 @@ void set_quiet(const StringArray &) void process_directory(const char * dir_name) { - DIR *dir = (DIR *) 0; // pointer to a DIR structure - dirent *pde = (dirent *) 0; // pointer to a portable directory entry + DIR *dir = (DIR *) nullptr; // pointer to a DIR structure + dirent *pde = (dirent *) nullptr; // pointer to a portable directory entry ConcatString new_directory; ConcatString tmp_directory; ConcatString new_filename; diff --git a/src/tools/dev_utils/gen_climo_bin.cc b/src/tools/dev_utils/gen_climo_bin.cc index fea08a5d9d..997ff00abd 100644 --- a/src/tools/dev_utils/gen_climo_bin.cc +++ b/src/tools/dev_utils/gen_climo_bin.cc @@ -53,7 +53,7 @@ static ConcatString program_name; static Grid grid; static ConcatString out_file; -static NcFile *nc_out = (NcFile *) 0; +static NcFile *nc_out = (NcFile *) nullptr; static NcDim lat_dim, lon_dim, cdf_dim; static NcVar cdf_x_var, cdf_y_var; @@ -127,7 +127,7 @@ int met_main(int argc, char *argv[]) { mlog << Debug(1) << "Finished writing output file: " << out_file << "\n"; delete nc_out; - nc_out = (NcFile *) 0; + nc_out = (NcFile *) nullptr; return(0); } @@ -326,7 +326,7 @@ void write_nc_bin(const DataPlane &dp, int i_cdf, double cdf_y) { } // Deallocate and clean up - if(data) { delete [] data; data = (float *) 0; } + if(data) { delete [] data; data = (float *) nullptr; } return; } @@ -335,9 +335,9 @@ void write_nc_bin(const DataPlane &dp, int i_cdf, double cdf_y) { void get_field(const char *file, const char *config_str, DataPlane &dp) { GrdFileType ftype; - Met2dDataFile * mtddf_ptr = (Met2dDataFile * ) 0; + Met2dDataFile * mtddf_ptr = (Met2dDataFile * ) nullptr; Met2dDataFileFactory m_factory; - VarInfo * vi_ptr = (VarInfo * ) 0; + VarInfo * vi_ptr = (VarInfo * ) nullptr; VarInfoFactory v_factory; double dmin, dmax; @@ -416,8 +416,8 @@ void get_field(const char *file, const char *config_str, DataPlane &dp) { } // Clean up - if(mtddf_ptr) { delete mtddf_ptr; mtddf_ptr = (Met2dDataFile * ) 0; } - if(vi_ptr) { delete vi_ptr; vi_ptr = (VarInfo *) 0; } + if(mtddf_ptr) { delete mtddf_ptr; mtddf_ptr = (Met2dDataFile * ) nullptr; } + if(vi_ptr) { delete vi_ptr; vi_ptr = (VarInfo *) nullptr; } return; } diff --git a/src/tools/dev_utils/gribtab.dat_to_flat.cc b/src/tools/dev_utils/gribtab.dat_to_flat.cc index fbf84434e1..1fca331615 100644 --- a/src/tools/dev_utils/gribtab.dat_to_flat.cc +++ b/src/tools/dev_utils/gribtab.dat_to_flat.cc @@ -96,7 +96,7 @@ int j; int i[6]; const char i_delim [] = "{} ,\""; const char s_delim [] = ",\""; -const char * c = (const char *) 0; +const char * c = (const char *) nullptr; char line2[512]; char * s = line2; const char *method_name = "parse_line() -> "; @@ -113,7 +113,7 @@ for (j=0; j<6; ++j) { i[j] = atoi(c); - s = (char *) 0; + s = (char *) nullptr; } // while @@ -134,7 +134,7 @@ for (j=0; j<3; ++j) { cout << ' ' << '\"' << c << '\"'; - s = (char *) 0; + s = (char *) nullptr; } // while diff --git a/src/tools/dev_utils/insitu_nc_file.cc b/src/tools/dev_utils/insitu_nc_file.cc index 7566eb366f..83df32b874 100644 --- a/src/tools/dev_utils/insitu_nc_file.cc +++ b/src/tools/dev_utils/insitu_nc_file.cc @@ -75,7 +75,7 @@ void InsituNcFile::init_from_scratch() { // Initialize the pointers - _ncFile = (NcFile *) 0; + _ncFile = (NcFile *) nullptr; // Close any existing file @@ -96,7 +96,7 @@ void InsituNcFile::close() if (_ncFile) { delete _ncFile; - _ncFile = (NcFile *)0; + _ncFile = (NcFile *) nullptr; } // Reclaim the space used for the variables @@ -144,7 +144,7 @@ bool InsituNcFile::open(const char * filename) if (_ncFile) // close() is called already { delete _ncFile; - _ncFile = (NcFile *)0; + _ncFile = (NcFile *) nullptr; } return false; } diff --git a/src/tools/dev_utils/met_nc_file.cc b/src/tools/dev_utils/met_nc_file.cc index 0389f8e883..4a962f9e68 100644 --- a/src/tools/dev_utils/met_nc_file.cc +++ b/src/tools/dev_utils/met_nc_file.cc @@ -83,7 +83,7 @@ bool MetNcFile::readFile(const int desired_grib_code, << _filePath << "\n\n"; //_ncFile->close(); delete _ncFile; - _ncFile = (NcFile *) 0; + _ncFile = (NcFile *) nullptr; return false; } @@ -177,7 +177,7 @@ bool MetNcFile::readFile(const int desired_grib_code, char hdr_typ_str_full[hdr_buf_size][typ_len]; char hdr_sid_str_full[hdr_buf_size][sid_len]; char hdr_vld_str_full[hdr_buf_size][vld_len]; - //float **hdr_arr_full = (float **) 0, **obs_arr_block = (float **) 0; + //float **hdr_arr_full = (float **) nullptr, **obs_arr_block = (float **) nullptr; float hdr_arr_full[hdr_buf_size][hdr_arr_len]; float obs_arr_block[ buf_size][obs_arr_len]; @@ -327,8 +327,8 @@ bool MetNcFile::readFile(const int desired_grib_code, } // Cleanup - if (obs_arr) { delete [] obs_arr; obs_arr = (float *) 0; } - if (hdr_arr) { delete [] hdr_arr; hdr_arr = (float *) 0; } + if (obs_arr) { delete [] obs_arr; obs_arr = (float *) nullptr; } + if (hdr_arr) { delete [] hdr_arr; hdr_arr = (float *) nullptr; } return true; } diff --git a/src/tools/dev_utils/nceptab_to_flat.cc b/src/tools/dev_utils/nceptab_to_flat.cc index ab05cb7698..cfbf1378a2 100644 --- a/src/tools/dev_utils/nceptab_to_flat.cc +++ b/src/tools/dev_utils/nceptab_to_flat.cc @@ -243,7 +243,7 @@ bool parse_line(const char * line) int n, k; char line2[1024]; char * s = line2; -char * c = (char *) 0; +char * c = (char *) nullptr; const char *method_name = "parse_line() -> "; m_strncpy(line2, line, sizeof(line2), method_name); @@ -260,7 +260,7 @@ if ( ! strchr(line, '\"') ) return ( false ); c = strtok(s, " /*"); -s = (char *) 0; +s = (char *) nullptr; if ( !c ) return ( false ); diff --git a/src/tools/other/ascii2nc/file_handler.cc b/src/tools/other/ascii2nc/file_handler.cc index 6c2a686abd..6e2521f0c8 100644 --- a/src/tools/other/ascii2nc/file_handler.cc +++ b/src/tools/other/ascii2nc/file_handler.cc @@ -194,7 +194,7 @@ bool FileHandler::summarizeObs(const TimeSummaryInfo &summary_info) void FileHandler::_closeNetcdf() { delete _ncFile; - _ncFile = (NcFile *) 0; + _ncFile = (NcFile *) nullptr; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index dd6d003289..ea51bc749b 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -121,7 +121,7 @@ void process_command_line(int argc, char **argv) { int i; CommandLine cline; ConcatString default_config_file; - Met2dDataFile *ens_mtddf = (Met2dDataFile *) 0; + Met2dDataFile *ens_mtddf = (Met2dDataFile *) nullptr; // // Check for zero arguments @@ -250,7 +250,7 @@ void process_command_line(int argc, char **argv) { } // Deallocate memory for data files - if(ens_mtddf) { delete ens_mtddf; ens_mtddf = (Met2dDataFile *) 0; } + if(ens_mtddf) { delete ens_mtddf; ens_mtddf = (Met2dDataFile *) nullptr; } return; } @@ -626,7 +626,7 @@ void get_ens_mean_stdev(GenEnsProdVarInfo *ens_info, bool get_data_plane(const char *infile, GrdFileType ftype, VarInfo *info, DataPlane &dp) { bool found; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; // Read the current ensemble file if(!(mtddf = mtddf_factory.new_met_2d_data_file(infile, ftype))) { @@ -668,7 +668,7 @@ bool get_data_plane(const char *infile, GrdFileType ftype, } // end if found // Deallocate the data file pointer, if necessary - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } return(found); } @@ -1049,14 +1049,14 @@ void write_ens_nc(GenEnsProdVarInfo *ens_info, int n_ens_vld, } // Deallocate and clean up - if(ens_mean) { delete [] ens_mean; ens_mean = (float *) 0; } - if(ens_stdev) { delete [] ens_stdev; ens_stdev = (float *) 0; } - if(ens_minus) { delete [] ens_minus; ens_minus = (float *) 0; } - if(ens_plus) { delete [] ens_plus; ens_plus = (float *) 0; } - if(ens_min) { delete [] ens_min; ens_min = (float *) 0; } - if(ens_max) { delete [] ens_max; ens_max = (float *) 0; } - if(ens_range) { delete [] ens_range; ens_range = (float *) 0; } - if(ens_vld) { delete [] ens_vld; ens_vld = (int *) 0; } + if(ens_mean) { delete [] ens_mean; ens_mean = (float *) nullptr; } + if(ens_stdev) { delete [] ens_stdev; ens_stdev = (float *) nullptr; } + if(ens_minus) { delete [] ens_minus; ens_minus = (float *) nullptr; } + if(ens_plus) { delete [] ens_plus; ens_plus = (float *) nullptr; } + if(ens_min) { delete [] ens_min; ens_min = (float *) nullptr; } + if(ens_max) { delete [] ens_max; ens_max = (float *) nullptr; } + if(ens_range) { delete [] ens_range; ens_range = (float *) nullptr; } + if(ens_vld) { delete [] ens_vld; ens_vld = (int *) nullptr; } return; } @@ -1179,7 +1179,7 @@ void write_ens_data_plane(GenEnsProdVarInfo *ens_info, const DataPlane &ens_dp, write_ens_var_float(ens_info, ens_data, dp, type_str, long_name_str); // Cleanup - if(ens_data) { delete [] ens_data; ens_data = (float *) 0; } + if(ens_data) { delete [] ens_data; ens_data = (float *) nullptr; } return; } @@ -1226,7 +1226,7 @@ void clean_up() { mlog << Debug(1) << "Output file: " << out_file << "\n"; // Close the output NetCDF file - if(nc_out) { delete nc_out; nc_out = (NcFile *) 0; } + if(nc_out) { delete nc_out; nc_out = (NcFile *) nullptr; } // Deallocate threshold count arrays if(thresh_cnt_na) { @@ -1234,7 +1234,7 @@ void clean_up() { thresh_cnt_na[i].clear(); } delete [] thresh_cnt_na; - thresh_cnt_na = (NumArray *) 0; + thresh_cnt_na = (NumArray *) nullptr; } if(thresh_nbrhd_cnt_na) { for(i=0; i " @@ -452,7 +452,7 @@ void get_data_plane(const ConcatString &file_name, // Allocate new VarInfo object VarInfoFactory vi_factory; - VarInfo *vi_ptr = (VarInfo *) 0; + VarInfo *vi_ptr = (VarInfo *) nullptr; vi_ptr = vi_factory.new_var_info(mtddf_ptr->file_type()); if(!vi_ptr) { mlog << Error << "\nget_data_plane() -> " @@ -480,7 +480,7 @@ void get_data_plane(const ConcatString &file_name, << dmin << " to " << dmax << ".\n"; // Clean up - if(vi_ptr) { delete vi_ptr; vi_ptr = (VarInfo *) 0; } + if(vi_ptr) { delete vi_ptr; vi_ptr = (VarInfo *) nullptr; } } // end if @@ -488,7 +488,7 @@ void get_data_plane(const ConcatString &file_name, dp_grid = mtddf_ptr->grid(); // Clean up - if(mtddf_ptr) { delete mtddf_ptr; mtddf_ptr = (Met2dDataFile *) 0; } + if(mtddf_ptr) { delete mtddf_ptr; mtddf_ptr = (Met2dDataFile *) nullptr; } return; } @@ -1395,8 +1395,8 @@ void write_netcdf(const DataPlane &dp) { int n, x, y; ConcatString cs; - float *mask_data = (float *) 0; - NcFile *f_out = (NcFile *) 0; + float *mask_data = (float *) nullptr; + NcFile *f_out = (NcFile *) nullptr; NcDim lat_dim; NcDim lon_dim; NcVar mask_var; @@ -1409,7 +1409,7 @@ void write_netcdf(const DataPlane &dp) { << "trouble opening output file " << out_filename << "\n\n"; delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; exit(1); } @@ -1474,15 +1474,15 @@ void write_netcdf(const DataPlane &dp) { mlog << Error << "\nwrite_netcdf() -> " << "error with mask_var->put\n\n"; // Delete allocated memory - if(mask_data) { delete[] mask_data; mask_data = (float *) 0; } + if(mask_data) { delete[] mask_data; mask_data = (float *) nullptr; } exit(1); } // Delete allocated memory - if(mask_data) { delete[] mask_data; mask_data = (float *) 0; } + if(mask_data) { delete[] mask_data; mask_data = (float *) nullptr; } delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; mlog << Debug(1) << "Output File:\t\t" << out_filename << "\n"; @@ -1525,7 +1525,7 @@ MaskType string_to_masktype(const char *s) { //////////////////////////////////////////////////////////////////////// const char * masktype_to_string(const MaskType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case MaskType_Poly: s = "poly"; break; @@ -1541,7 +1541,7 @@ const char * masktype_to_string(const MaskType t) { case MaskType_Lon: s = "lon"; break; case MaskType_Shape: s = "shape"; break; case MaskType_None: s = na_str; break; - default: s = (const char *) 0; break; + default: s = (const char *) nullptr; break; } return(s); diff --git a/src/tools/other/grid_diag/grid_diag.cc b/src/tools/other/grid_diag/grid_diag.cc index 4a54b42ee2..a8c603fab4 100644 --- a/src/tools/other/grid_diag/grid_diag.cc +++ b/src/tools/other/grid_diag/grid_diag.cc @@ -207,7 +207,7 @@ void process_command_line(int argc, char **argv) { // Deallocate memory for data files if(data_mtddf) { delete data_mtddf; - data_mtddf = (Met2dDataFile *) 0; + data_mtddf = (Met2dDataFile *) nullptr; } } // end for i @@ -748,8 +748,8 @@ void write_joint_histograms(void) { Met2dDataFile *get_mtddf(const StringArray &file_list, const int i_field) { - Met2dDataFile *mtddf = (Met2dDataFile *) 0; - Dictionary *dict = (Dictionary *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; + Dictionary *dict = (Dictionary *) nullptr; Dictionary i_dict; GrdFileType file_type; int i; @@ -798,7 +798,7 @@ void clean_up() { mlog << Debug(1) << "Output file: " << out_file << "\n"; delete nc_out; - nc_out = (NcFile *) 0; + nc_out = (NcFile *) nullptr; } return; diff --git a/src/tools/other/grid_diag/grid_diag.h b/src/tools/other/grid_diag/grid_diag.h index 06f1c50895..5f661bdb22 100644 --- a/src/tools/other/grid_diag/grid_diag.h +++ b/src/tools/other/grid_diag/grid_diag.h @@ -85,7 +85,7 @@ static GridDiagConfInfo conf_info; //////////////////////////////////////////////////////////////////////// // Output NetCDF file -static netCDF::NcFile *nc_out = (netCDF::NcFile *) 0; +static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; vector data_var_dims; vector hist_vars; vector joint_hist_vars; @@ -107,7 +107,7 @@ static Grid grid; // Data file factory and input files static Met2dDataFileFactory mtddf_factory; -static Met2dDataFile *data_mtddf = (Met2dDataFile *) 0; +static Met2dDataFile *data_mtddf = (Met2dDataFile *) nullptr; // Variable min/max values vector var_mins; diff --git a/src/tools/other/grid_diag/grid_diag_conf_info.cc b/src/tools/other/grid_diag/grid_diag_conf_info.cc index b463db9081..d0d60908f0 100644 --- a/src/tools/other/grid_diag/grid_diag_conf_info.cc +++ b/src/tools/other/grid_diag/grid_diag_conf_info.cc @@ -44,7 +44,7 @@ GridDiagConfInfo::~GridDiagConfInfo() { void GridDiagConfInfo::init_from_scratch() { // Initialize pointers - data_info = (VarInfo **) 0; + data_info = (VarInfo **) nullptr; clear(); @@ -69,10 +69,10 @@ void GridDiagConfInfo::clear() { for(int i=0; i file_types) { ConcatString s; StringArray sa; VarInfoFactory info_factory; - Dictionary *dict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; Dictionary i_dict; GrdFileType file_type; @@ -143,7 +143,7 @@ void GridDiagConfInfo::process_config(vector file_types) { data_info = new VarInfo * [n_data]; // Initialize pointers - for(int i=0; i " << "trouble opening output file: " << ncfile << "\n\n"; delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; exit(1); } diff --git a/src/tools/other/madis2nc/madis2nc.h b/src/tools/other/madis2nc/madis2nc.h index a513946260..ab108d497c 100644 --- a/src/tools/other/madis2nc/madis2nc.h +++ b/src/tools/other/madis2nc/madis2nc.h @@ -132,7 +132,7 @@ static int rej_sid = 0; //////////////////////////////////////////////////////////////////////// // Output NetCDF file -NcFile *f_out = (NcFile *) 0; +NcFile *f_out = (NcFile *) nullptr; int processed_count; @@ -142,7 +142,7 @@ static Madis2NcConfInfo conf_info; static bool do_summary; static bool save_summary_only = false; -static SummaryObs *summary_obs = 0; +static SummaryObs *summary_obs = nullptr; #endif // __MADIS2NC_H__ diff --git a/src/tools/other/mode_graphics/cgraph_font.cc b/src/tools/other/mode_graphics/cgraph_font.cc index 451b6f9c90..e3ed2db3b2 100644 --- a/src/tools/other/mode_graphics/cgraph_font.cc +++ b/src/tools/other/mode_graphics/cgraph_font.cc @@ -108,7 +108,7 @@ void CgFont::init_from_scratch() { -afm = (Afm *) 0; +afm = (Afm *) nullptr; face = 0; @@ -147,7 +147,7 @@ ps_name.clear(); orig_ps_size = scaled_ps_size = 0.0; -if ( afm ) { delete afm; afm = (Afm *) 0; } +if ( afm ) { delete afm; afm = (Afm *) nullptr; } ps_font_number = -1; diff --git a/src/tools/other/mode_graphics/cgraph_main.cc b/src/tools/other/mode_graphics/cgraph_main.cc index baa2b3be01..2c85c7525e 100644 --- a/src/tools/other/mode_graphics/cgraph_main.cc +++ b/src/tools/other/mode_graphics/cgraph_main.cc @@ -167,15 +167,15 @@ void CgraphBase::cgraph_init_from_scratch() { -Surface = (cairo_surface_t *) 0; +Surface = (cairo_surface_t *) nullptr; -Cr = (cairo_t *) 0; +Cr = (cairo_t *) nullptr; Ptype = no_cgraph_plot_type; Filename.clear(); -Library = (FT_Library) 0; +Library = (FT_Library) nullptr; CurrentFont = 0; @@ -205,11 +205,11 @@ void CgraphBase::close() { -if ( Cr ) { cairo_destroy (Cr); Cr = (cairo_t *) 0; } +if ( Cr ) { cairo_destroy (Cr); Cr = (cairo_t *) nullptr; } if ( Ptype != no_cgraph_plot_type ) write(); -if ( Surface ) { cairo_surface_destroy (Surface); Surface = (cairo_surface_t *) 0; } +if ( Surface ) { cairo_surface_destroy (Surface); Surface = (cairo_surface_t *) nullptr; } Ptype = no_cgraph_plot_type; @@ -220,7 +220,7 @@ DoLigatures = true; Fonts.clear(); -if ( Library ) { FT_Done_FreeType(Library); Library = (FT_Library) 0; } +if ( Library ) { FT_Done_FreeType(Library); Library = (FT_Library) nullptr; } Family = default_font_family; @@ -794,7 +794,7 @@ double x_page, y_page; double x_char_origin; FT_Face face = CurrentFont->face; // this should be nonzero FT_UInt previous; -FT_Glyph_Metrics * metrics = (FT_Glyph_Metrics *) 0; +FT_Glyph_Metrics * metrics = (FT_Glyph_Metrics *) nullptr; FT_Vector k_delta; const bool use_kerning = DoKerning && FT_HAS_KERNING(face); const char * new_string = (const char *) nullptr; @@ -1036,7 +1036,7 @@ if ( render_flag ) { // if ( DoLigatures ) delete [] new_string; -new_string = (char *) 0; +new_string = (char *) nullptr; return; @@ -1126,8 +1126,8 @@ void CgraphBase::import_image(const Ppm & ppm, double x, double y, double u, dou { double x_ll, y_ll; -cairo_surface_t * i = (cairo_surface_t *) 0; -unsigned char * buf = (unsigned char *) 0; +cairo_surface_t * i = (cairo_surface_t *) nullptr; +unsigned char * buf = (unsigned char *) nullptr; gsave(); @@ -1155,7 +1155,7 @@ cairo_paint (Cr); // done // -cairo_surface_destroy (i); i = (cairo_surface_t *) 0; +cairo_surface_destroy (i); i = (cairo_surface_t *) nullptr; grestore(); @@ -1175,9 +1175,9 @@ int R, G, B, alpha; int row, col, n; int bytes_per_row; int error; -cairo_surface_t * i = (cairo_surface_t *) 0; -unsigned char * buf = (unsigned char *) 0; -unsigned char * d = (unsigned char *) 0; +cairo_surface_t * i = (cairo_surface_t *) nullptr; +unsigned char * buf = (unsigned char *) nullptr; +unsigned char * d = (unsigned char *) nullptr; const Color cc = current_color(); const int IR = (int) (cc.red()); const int IG = (int) (cc.green()); @@ -1262,7 +1262,7 @@ cairo_paint (Cr); // done // -cairo_surface_destroy (i); i = (cairo_surface_t *) 0; +cairo_surface_destroy (i); i = (cairo_surface_t *) nullptr; grestore(); @@ -1788,8 +1788,8 @@ void Cgraph::import_image(const Ppm & ppm, double x, double y, double u, double { double x_ll, y_ul, y_ll; -cairo_surface_t * i = (cairo_surface_t *) 0; -unsigned char * buf = (unsigned char *) 0; +cairo_surface_t * i = (cairo_surface_t *) nullptr; +unsigned char * buf = (unsigned char *) nullptr; const double scaled_nx = x_scale*(ppm.nx()); const double scaled_ny = y_scale*(ppm.ny()); @@ -1827,7 +1827,7 @@ cairo_paint (Cr); // done // -cairo_surface_destroy (i); i = (cairo_surface_t *) 0; +cairo_surface_destroy (i); i = (cairo_surface_t *) nullptr; grestore(); diff --git a/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc b/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc index 313b169ca4..15b2cb6aa1 100644 --- a/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc +++ b/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc @@ -39,7 +39,7 @@ ConcatString cgraphbase_plottype_to_string(const CgraphBase::PlotType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/tools/other/mode_graphics/color_stack.cc b/src/tools/other/mode_graphics/color_stack.cc index fb9d750364..8d53f2d0c8 100644 --- a/src/tools/other/mode_graphics/color_stack.cc +++ b/src/tools/other/mode_graphics/color_stack.cc @@ -93,7 +93,7 @@ void ColorStack::init_from_scratch() { -e = (Color **) 0; +e = (Color **) nullptr; AllocInc = 10; // default value @@ -117,11 +117,11 @@ if ( e ) { for (j=0; j 0 ) { - delete [] ObjVolume; ObjVolume = (int *) 0; + delete [] ObjVolume; ObjVolume = (int *) nullptr; ObjVolume = new_volumes; @@ -1442,7 +1442,7 @@ if ( n_new > 0 ) { // done // -if ( old_to_new ) { delete [] old_to_new; old_to_new = (int *) 0; } +if ( old_to_new ) { delete [] old_to_new; old_to_new = (int *) nullptr; } return; @@ -1616,7 +1616,7 @@ void MtdIntFile::set_volumes(int n, const int * V) { -if ( ObjVolume ) { delete [] ObjVolume; ObjVolume = (int *) 0; } +if ( ObjVolume ) { delete [] ObjVolume; ObjVolume = (int *) nullptr; } int j; diff --git a/src/tools/other/mode_time_domain/mtd_partition.cc b/src/tools/other/mode_time_domain/mtd_partition.cc index 57db83dde7..4e3d34d4a2 100644 --- a/src/tools/other/mode_time_domain/mtd_partition.cc +++ b/src/tools/other/mode_time_domain/mtd_partition.cc @@ -110,7 +110,7 @@ void EquivalenceClass::init_from_scratch() { -E = (int *) 0; +E = (int *) nullptr; clear(); @@ -126,7 +126,7 @@ void EquivalenceClass::clear() { -if ( E ) { delete [] E; E = (int *) 0; } +if ( E ) { delete [] E; E = (int *) nullptr; } Nelements = Nalloc = 0; @@ -182,11 +182,11 @@ if ( E ) { memcpy(u, E, Nelements*sizeof(int)); - delete [] E; E = (int *) 0; + delete [] E; E = (int *) nullptr; } -E = u; u = (int *) 0; +E = u; u = (int *) nullptr; Nalloc = n; @@ -393,7 +393,7 @@ void Mtd_Partition::init_from_scratch() { -C = (EquivalenceClass **) 0; +C = (EquivalenceClass **) nullptr; clear(); @@ -415,11 +415,11 @@ if ( C ) { for (j=0; j can't get attribute names\n\n"; - if ( att_buf ) { delete [] att_buf; att_buf = (char *) 0; } + if ( att_buf ) { delete [] att_buf; att_buf = (char *) nullptr; } exit ( 1 ); } if ( retval == 0 ) { - if ( att_buf ) { delete [] att_buf; att_buf = (char *) 0; } + if ( att_buf ) { delete [] att_buf; att_buf = (char *) nullptr; } return; } parse_csl(att_buf, a); @@ -1331,7 +1331,7 @@ for (j=0; j can't get info on attribute \"" << (a[j]) << "\"\n\n"; - if ( att_buf ) { delete [] att_buf; att_buf = (char *) 0; } + if ( att_buf ) { delete [] att_buf; att_buf = (char *) nullptr; } exit ( 1 ); } @@ -1345,7 +1345,7 @@ for (j=0; j can't get value for attribute \"" << (a[j]) << "\"\n\n"; - if ( att_buf ) { delete [] att_buf; att_buf = (char *) 0; } + if ( att_buf ) { delete [] att_buf; att_buf = (char *) nullptr; } exit ( 1 ); } @@ -1360,7 +1360,7 @@ for (j=0; j " << "trouble opening output file " << out_filename << "\n\n"; - delete f_out; f_out = (NcFile *) 0; + delete f_out; f_out = (NcFile *) nullptr; exit(1); } @@ -127,7 +127,7 @@ void write_grid_to_netcdf(const DataPlane & plane, const Grid & grid, const char // Close and clean up delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; return; } diff --git a/src/tools/other/modis_regrid/modis_file.cc b/src/tools/other/modis_regrid/modis_file.cc index c712f2330f..e478a867e1 100644 --- a/src/tools/other/modis_regrid/modis_file.cc +++ b/src/tools/other/modis_regrid/modis_file.cc @@ -557,7 +557,7 @@ FileId = -1; Filename.clear(); -if ( Swath ) { delete Swath; Swath = (CloudsatSwath *) 0; } +if ( Swath ) { delete Swath; Swath = (CloudsatSwath *) nullptr; } Latitude = 0; diff --git a/src/tools/other/modis_regrid/modis_regrid.cc b/src/tools/other/modis_regrid/modis_regrid.cc index 788898b60f..d98f42ef1b 100644 --- a/src/tools/other/modis_regrid/modis_regrid.cc +++ b/src/tools/other/modis_regrid/modis_regrid.cc @@ -270,7 +270,7 @@ void get_grid() // stole this code from plot_data_plane.cc // -Met2dDataFile * met_ptr = (Met2dDataFile * ) 0; +Met2dDataFile * met_ptr = (Met2dDataFile * ) nullptr; Met2dDataFileFactory m_factory; mlog << Debug(1) << "Opening data file: " << grid_data_file << "\n"; @@ -289,7 +289,7 @@ grid = met_ptr->grid(); // done // -delete met_ptr; met_ptr = (Met2dDataFile *) 0; +delete met_ptr; met_ptr = (Met2dDataFile *) nullptr; return; diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index 2922c23d0a..1eededdeef 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -2617,7 +2617,7 @@ void clean_up() { if(f_out) { delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; } return; @@ -3003,7 +3003,7 @@ int combine_tqz_and_uv(map pqtzuv_map_tq, // Select first record by 1) merging two records with the same pressure // level or 2) interpolate int tq_pres, uv_pres; - next_pqtzuv = (float *)0; + next_pqtzuv = (float *)nullptr; it_tq = pqtzuv_map_tq.begin(); it_uv = pqtzuv_map_uv.begin(); pqtzuv_tq = (float *)it_tq->second; diff --git a/src/tools/other/pb2nc/pb2nc_conf_info.cc b/src/tools/other/pb2nc/pb2nc_conf_info.cc index 69af15a22d..81aba47688 100644 --- a/src/tools/other/pb2nc/pb2nc_conf_info.cc +++ b/src/tools/other/pb2nc/pb2nc_conf_info.cc @@ -144,7 +144,7 @@ void PB2NCConfInfo::process_config() { ConcatString s, mask_name; StringArray sa; StringArray * sid_list = 0; - Dictionary *dict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; // Dump the contents of the config file if(mlog.verbosity_level() >= 5) conf.dump(cout); @@ -268,7 +268,7 @@ void PB2NCConfInfo::process_config() { obs_bufr_map = parse_conf_obs_bufr_map(&conf); message_type_map = parse_conf_message_type_map(&conf); - if ( sid_list ) { delete [] sid_list; sid_list = (StringArray *) 0; } + if ( sid_list ) { delete [] sid_list; sid_list = (StringArray *) nullptr; } return; } diff --git a/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc b/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc index 04b798e71a..78e998fafa 100644 --- a/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc +++ b/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc @@ -350,7 +350,7 @@ PlotPointObsConfInfo::~PlotPointObsConfInfo() { void PlotPointObsConfInfo::init_from_scratch() { // Initialize pointers - grid_data_info = (VarInfo *) 0; + grid_data_info = (VarInfo *) nullptr; clear(); @@ -405,12 +405,12 @@ void PlotPointObsConfInfo::read_config(const char *user_file_name) { void PlotPointObsConfInfo::process_config( const char *plot_grid_string) { - Dictionary *dict = (Dictionary *) 0; - Dictionary *fdict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; + Dictionary *fdict = (Dictionary *) nullptr; Dictionary i_fdict; StringArray sa; Met2dDataFileFactory m_factory; - Met2dDataFile *met_ptr = (Met2dDataFile *) 0; + Met2dDataFile *met_ptr = (Met2dDataFile *) nullptr; PlotPointObsOpt opt; int i, n_vx; diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 2737e125c9..e6b8718c2b 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -120,7 +120,7 @@ static bool do_gaussian_filter = false; static SingleThresh prob_cat_thresh; // Output NetCDF file -static NcFile *nc_out = (NcFile *) 0; +static NcFile *nc_out = (NcFile *) nullptr; static NcDim lat_dim ; static NcDim lon_dim ; @@ -338,7 +338,7 @@ void process_command_line(int argc, char **argv) { else var_names.add(vname); } // Clean up - if(vinfo) { delete vinfo; vinfo = (VarInfo *) 0; } + if(vinfo) { delete vinfo; vinfo = (VarInfo *) nullptr; } } // Check that the number of output names and fields match else if(VarNameSA.n() != FieldSA.n()) { @@ -367,7 +367,7 @@ void process_data_file() { Grid fr_grid, to_grid; GrdFileType ftype; ConcatString run_cs; - NcFile *nc_in = (NcFile *)0; + NcFile *nc_in = (NcFile *) nullptr; static const char *method_name = "process_data_file() -> "; // Initialize configuration object @@ -387,7 +387,7 @@ void process_data_file() { bool use_python = false; int obs_type; Met2dDataFileFactory m_factory; - Met2dDataFile *fr_mtddf = (Met2dDataFile *) 0; + Met2dDataFile *fr_mtddf = (Met2dDataFile *) nullptr; #ifdef WITH_PYTHON string python_command = InputFilename; bool use_xarray = (0 == python_command.find(conf_val_python_xarray)); @@ -496,8 +496,8 @@ void process_data_file() { // Clean up if(nc_in) { delete nc_in; nc_in = 0; } - if(fr_mtddf) { delete fr_mtddf; fr_mtddf = (Met2dDataFile *) 0; } - if(vinfo) { delete vinfo; vinfo = (VarInfo *) 0; } + if(fr_mtddf) { delete fr_mtddf; fr_mtddf = (Met2dDataFile *) nullptr; } + if(vinfo) { delete vinfo; vinfo = (VarInfo *) nullptr; } return; } @@ -745,7 +745,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI // Loop through the requested fields int obs_count_zero_to, obs_count_non_zero_to; int obs_count_zero_from, obs_count_non_zero_from; - IntArray *cellMapping = (IntArray *)0; + IntArray *cellMapping = (IntArray *) nullptr; obs_count_zero_to = obs_count_non_zero_to = 0; obs_count_zero_from = obs_count_non_zero_from = 0; @@ -1130,7 +1130,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI } // end for i if (cellMapping) { - delete [] cellMapping; cellMapping = (IntArray *)0; + delete [] cellMapping; cellMapping = (IntArray *) nullptr; } } @@ -1387,7 +1387,7 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, } // end for i delete [] cellMapping; - cellMapping = (IntArray *)0; + cellMapping = (IntArray *) nullptr; if( 0 < filtered_by_time ) { mlog << Debug(2) << method_name << "Filtered by time: " << filtered_by_time << " out of " << from_size @@ -1594,7 +1594,7 @@ void write_nc_data(const DataPlane &dp, const Grid &grid, NcVar *data_var) { } // Clean up - if(data) { delete [] data; data = (float *) 0; } + if(data) { delete [] data; data = (float *) nullptr; } return; } @@ -1624,7 +1624,7 @@ void write_nc_data_int(const DataPlane &dp, const Grid &grid, NcVar *data_var) { } // Clean up - if(data) { delete [] data; data = (int *) 0; } + if(data) { delete [] data; data = (int *) nullptr; } return; } @@ -1687,7 +1687,7 @@ void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, int global_attr_count; bool opt_all_attrs = false; clock_t start_clock = clock(); - NcFile *nc_adp = (NcFile *)0; + NcFile *nc_adp = (NcFile *) nullptr; static const char *method_name = "process_goes_file() -> "; ConcatString tmp_dir = config.get_tmp_dir(); @@ -1816,7 +1816,7 @@ void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, //copy_nc_atts(_nc_in, nc_out, opt_all_attrs); delete nc_adp; nc_adp = 0; - delete [] cellMapping; cellMapping = (IntArray *)0; + delete [] cellMapping; cellMapping = (IntArray *) nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; @@ -2184,7 +2184,7 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, } // Override the from nx & ny from NetCDF if exists - NcFile *coord_nc_in = (NcFile *)0; + NcFile *coord_nc_in = (NcFile *) nullptr; if (has_coord_input) { mlog << Debug(2) << method_name << "Reading coord file: " << cur_coord_name << "\n"; coord_nc_in = open_ncfile(cur_coord_name.c_str()); @@ -2720,7 +2720,7 @@ void close_nc() { // Clean up if(nc_out) { - delete nc_out; nc_out = (NcFile *) 0; + delete nc_out; nc_out = (NcFile *) nullptr; } // List the output file diff --git a/src/tools/other/point2grid/point2grid_conf_info.cc b/src/tools/other/point2grid/point2grid_conf_info.cc index 84cfec4a12..e9fa0e0392 100644 --- a/src/tools/other/point2grid/point2grid_conf_info.cc +++ b/src/tools/other/point2grid/point2grid_conf_info.cc @@ -83,7 +83,7 @@ void PointToGridConfInfo::read_config(const char *default_file_name, void PointToGridConfInfo::process_config() { ConcatString s; StringArray sa; - Dictionary *dict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; // Dump the contents of the config file if(mlog.verbosity_level() >= 5) conf.dump(cout); diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index 309aaf3d6a..dd9b85bb0b 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -78,7 +78,7 @@ static StringArray VarNameSA; static int compress_level = -1; // Output NetCDF file -static NcFile *nc_out = (NcFile *) 0; +static NcFile *nc_out = (NcFile *) nullptr; static NcDim lat_dim ; static NcDim lon_dim ; @@ -219,7 +219,7 @@ void process_data_file() { //Variables for GOES unixtime valid_time = 0; bool opt_all_attrs = false; - NcFile *nc_in = (NcFile *)0; + NcFile *nc_in = (NcFile *) nullptr; static const char *method_name = "process_data_file() "; // Initialize configuration object @@ -235,7 +235,7 @@ void process_data_file() { // Read the input data file Met2dDataFileFactory m_factory; - Met2dDataFile *fr_mtddf = (Met2dDataFile *) 0; + Met2dDataFile *fr_mtddf = (Met2dDataFile *) nullptr; // Determine the "from" grid mlog << Debug(1) << "Reading data file: " << InputFilename << "\n"; @@ -348,8 +348,8 @@ void process_data_file() { delete nc_in; nc_in = 0; // Clean up - if(fr_mtddf) { delete fr_mtddf; fr_mtddf = (Met2dDataFile *) 0; } - if(vinfo) { delete vinfo; vinfo = (VarInfo *) 0; } + if(fr_mtddf) { delete fr_mtddf; fr_mtddf = (Met2dDataFile *) nullptr; } + if(vinfo) { delete vinfo; vinfo = (VarInfo *) nullptr; } return; } @@ -408,7 +408,7 @@ void write_nc_data(const DataPlane &dp, const Grid &grid, NcVar *data_var) { } // Clean up - if(data) { delete [] data; data = (float *) 0; } + if(data) { delete [] data; data = (float *) nullptr; } return; } @@ -439,7 +439,7 @@ void close_nc() { // Clean up if(nc_out) { - delete nc_out; nc_out = (NcFile *) 0; + delete nc_out; nc_out = (NcFile *) nullptr; } // List the output file diff --git a/src/tools/other/shift_data_plane/shift_data_plane.cc b/src/tools/other/shift_data_plane/shift_data_plane.cc index 411f5dd10f..e14fff46fd 100644 --- a/src/tools/other/shift_data_plane/shift_data_plane.cc +++ b/src/tools/other/shift_data_plane/shift_data_plane.cc @@ -185,7 +185,7 @@ void process_data_file() { // Read the input data file Met2dDataFileFactory m_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; mlog << Debug(1) << "Reading input file: " << InputFilename << "\n"; mtddf = m_factory.new_met_2d_data_file(InputFilename.c_str(), ftype); @@ -271,8 +271,8 @@ void process_data_file() { write_netcdf(dp_shift, grid, vinfo, mtddf->file_type()); // Clean up - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - if(vinfo) { delete vinfo; vinfo = (VarInfo *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } + if(vinfo) { delete vinfo; vinfo = (VarInfo *) nullptr; } #ifdef WITH_PYTHON GP.finalize(); @@ -352,9 +352,9 @@ void write_netcdf(const DataPlane &dp, const Grid &grid, } // Clean up - if(data) { delete [] data; data = (float *) 0; } + if(data) { delete [] data; data = (float *) nullptr; } if(f_out) { - delete f_out; f_out = (NcFile *) 0; + delete f_out; f_out = (NcFile *) nullptr; } // List the output file diff --git a/src/tools/other/wwmca_tool/af_cp_file.cc b/src/tools/other/wwmca_tool/af_cp_file.cc index 70acdb4941..969e4d2238 100644 --- a/src/tools/other/wwmca_tool/af_cp_file.cc +++ b/src/tools/other/wwmca_tool/af_cp_file.cc @@ -109,7 +109,7 @@ void AFCloudPctFile::init_from_scratch() { -Buf = (unsigned char *) 0; +Buf = (unsigned char *) nullptr; clear(); @@ -125,7 +125,7 @@ void AFCloudPctFile::clear() { -if ( Buf ) { delete [] Buf; Buf = (unsigned char *) 0; } +if ( Buf ) { delete [] Buf; Buf = (unsigned char *) nullptr; } AFDataFile::clear(); diff --git a/src/tools/other/wwmca_tool/af_file.cc b/src/tools/other/wwmca_tool/af_file.cc index e0618a2b41..bcbce8a719 100644 --- a/src/tools/other/wwmca_tool/af_file.cc +++ b/src/tools/other/wwmca_tool/af_file.cc @@ -102,7 +102,7 @@ void AFDataFile::init_from_scratch() { -grid = (const Grid *) 0; +grid = (const Grid *) nullptr; clear(); @@ -118,7 +118,7 @@ void AFDataFile::clear() { -if ( grid ) { delete grid; grid = (const Grid *) 0; } +if ( grid ) { delete grid; grid = (const Grid *) nullptr; } Filename.clear(); diff --git a/src/tools/other/wwmca_tool/af_pt_file.cc b/src/tools/other/wwmca_tool/af_pt_file.cc index 4b875257d4..eebc9a9d5c 100644 --- a/src/tools/other/wwmca_tool/af_pt_file.cc +++ b/src/tools/other/wwmca_tool/af_pt_file.cc @@ -112,7 +112,7 @@ void AFPixelTimeFile::init_from_scratch() { -Buf = (unsigned char *) 0; +Buf = (unsigned char *) nullptr; clear(); @@ -128,7 +128,7 @@ void AFPixelTimeFile::clear() { -if ( Buf ) { delete [] Buf; Buf = (unsigned char *) 0; } +if ( Buf ) { delete [] Buf; Buf = (unsigned char *) nullptr; } AFDataFile::clear(); diff --git a/src/tools/other/wwmca_tool/ave_interp.cc b/src/tools/other/wwmca_tool/ave_interp.cc index a9a2cbcf32..e0b27b9834 100644 --- a/src/tools/other/wwmca_tool/ave_interp.cc +++ b/src/tools/other/wwmca_tool/ave_interp.cc @@ -135,7 +135,7 @@ Interpolator * Ave_Interp::copy() const { -Interpolator * i = (Interpolator *) 0; +Interpolator * i = (Interpolator *) nullptr; i = new Ave_Interp (*this); diff --git a/src/tools/other/wwmca_tool/interp_base.cc b/src/tools/other/wwmca_tool/interp_base.cc index 0b7dd9f182..cd41a5f94e 100644 --- a/src/tools/other/wwmca_tool/interp_base.cc +++ b/src/tools/other/wwmca_tool/interp_base.cc @@ -203,7 +203,7 @@ void Interpolator::init_from_scratch() { -Data = (InterpolationValue *) 0; +Data = (InterpolationValue *) nullptr; clear(); @@ -219,7 +219,7 @@ void Interpolator::clear() { -if ( Data ) { delete [] Data; Data = (InterpolationValue *) 0; } +if ( Data ) { delete [] Data; Data = (InterpolationValue *) nullptr; } Width = 0; diff --git a/src/tools/other/wwmca_tool/max_interp.cc b/src/tools/other/wwmca_tool/max_interp.cc index 42a1fe322c..2531579e27 100644 --- a/src/tools/other/wwmca_tool/max_interp.cc +++ b/src/tools/other/wwmca_tool/max_interp.cc @@ -135,7 +135,7 @@ Interpolator * Max_Interp::copy() const { -Interpolator * i = (Interpolator *) 0; +Interpolator * i = (Interpolator *) nullptr; i = new Max_Interp (*this); diff --git a/src/tools/other/wwmca_tool/min_interp.cc b/src/tools/other/wwmca_tool/min_interp.cc index 536aa90211..c82811fae2 100644 --- a/src/tools/other/wwmca_tool/min_interp.cc +++ b/src/tools/other/wwmca_tool/min_interp.cc @@ -136,7 +136,7 @@ Interpolator * Min_Interp::copy() const { -Interpolator * i = (Interpolator *) 0; +Interpolator * i = (Interpolator *) nullptr; i = new Min_Interp (*this); diff --git a/src/tools/other/wwmca_tool/nc_output.cc b/src/tools/other/wwmca_tool/nc_output.cc index 7e68c7ab11..808c974b48 100644 --- a/src/tools/other/wwmca_tool/nc_output.cc +++ b/src/tools/other/wwmca_tool/nc_output.cc @@ -47,7 +47,7 @@ void WwmcaRegridder::do_output(const char * output_filename) { - NcFile * ncfile = (NcFile *) 0; + NcFile * ncfile = (NcFile *) nullptr; NcDim lat_dim ; NcDim lon_dim ; NcVar data_var ; @@ -233,7 +233,7 @@ void WwmcaRegridder::do_output(const char * output_filename) // done // - if ( ncfile ) { delete ncfile; ncfile = (NcFile *) 0; } + if ( ncfile ) { delete ncfile; ncfile = (NcFile *) nullptr; } // // list output file name diff --git a/src/tools/other/wwmca_tool/nearest_interp.cc b/src/tools/other/wwmca_tool/nearest_interp.cc index 2951fdd635..6192a2145a 100644 --- a/src/tools/other/wwmca_tool/nearest_interp.cc +++ b/src/tools/other/wwmca_tool/nearest_interp.cc @@ -135,7 +135,7 @@ Interpolator * Nearest_Interp::copy() const { -Interpolator * i = (Interpolator *) 0; +Interpolator * i = (Interpolator *) nullptr; i = new Nearest_Interp (*this); diff --git a/src/tools/other/wwmca_tool/wwmca_plot.cc b/src/tools/other/wwmca_tool/wwmca_plot.cc index b960362156..a0a0141213 100644 --- a/src/tools/other/wwmca_tool/wwmca_plot.cc +++ b/src/tools/other/wwmca_tool/wwmca_plot.cc @@ -68,7 +68,7 @@ static CommandLine cline; static const Grid nh(wwmca_north_data); static const Grid sh(wwmca_south_data); -static const Grid * grid = (const Grid *) 0; +static const Grid * grid = (const Grid *) nullptr; static int Nx, Ny; @@ -243,7 +243,7 @@ AFCloudPctFile f_cp; AFPixelTimeFile f_pt; ConcatString short_name; ConcatString output_filename; -char * pt_filename = (char *) 0; +char * pt_filename = (char *) nullptr; Pgm image; RenderInfo info; PSfile plot; @@ -280,7 +280,7 @@ if ( !(f_pt.read(pt_filename, bad_data_char)) ) { } -if (pt_filename) { delete [] pt_filename; pt_filename = (char *) 0; } +if (pt_filename) { delete [] pt_filename; pt_filename = (char *) nullptr; } if ( output_directory.length() > 0 ) output_filename << output_directory << '/'; diff --git a/src/tools/other/wwmca_tool/wwmca_ref.cc b/src/tools/other/wwmca_tool/wwmca_ref.cc index ff66c54268..4937a18290 100644 --- a/src/tools/other/wwmca_tool/wwmca_ref.cc +++ b/src/tools/other/wwmca_tool/wwmca_ref.cc @@ -62,8 +62,8 @@ WwmcaRegridder::~WwmcaRegridder() clear(); -if ( NHgrid ) { delete NHgrid; NHgrid = (const Grid *) 0; } -if ( SHgrid ) { delete SHgrid; SHgrid = (const Grid *) 0; } +if ( NHgrid ) { delete NHgrid; NHgrid = (const Grid *) nullptr; } +if ( SHgrid ) { delete SHgrid; SHgrid = (const Grid *) nullptr; } } @@ -78,15 +78,15 @@ void WwmcaRegridder::init_from_scratch() NHgrid = new Grid (wwmca_north_data); SHgrid = new Grid (wwmca_south_data); -cp_nh = (const AFCloudPctFile *) 0; -cp_sh = (const AFCloudPctFile *) 0; +cp_nh = (const AFCloudPctFile *) nullptr; +cp_sh = (const AFCloudPctFile *) nullptr; -pt_nh = (const AFPixelTimeFile *) 0; -pt_sh = (const AFPixelTimeFile *) 0; +pt_nh = (const AFPixelTimeFile *) nullptr; +pt_sh = (const AFPixelTimeFile *) nullptr; -ToGrid = (const Grid *) 0; +ToGrid = (const Grid *) nullptr; -Config = (MetConfig *) 0; +Config = (MetConfig *) nullptr; interp_func = 0; @@ -106,19 +106,19 @@ void WwmcaRegridder::clear() { -if ( cp_nh ) { delete cp_nh; cp_nh = (const AFCloudPctFile *) 0; } -if ( cp_sh ) { delete cp_sh; cp_sh = (const AFCloudPctFile *) 0; } +if ( cp_nh ) { delete cp_nh; cp_nh = (const AFCloudPctFile *) nullptr; } +if ( cp_sh ) { delete cp_sh; cp_sh = (const AFCloudPctFile *) nullptr; } -if ( pt_nh ) { delete pt_nh; pt_nh = (const AFPixelTimeFile *) 0; } -if ( pt_sh ) { delete pt_sh; pt_sh = (const AFPixelTimeFile *) 0; } +if ( pt_nh ) { delete pt_nh; pt_nh = (const AFPixelTimeFile *) nullptr; } +if ( pt_sh ) { delete pt_sh; pt_sh = (const AFPixelTimeFile *) nullptr; } -if ( ToGrid ) { delete ToGrid; ToGrid = (const Grid *) 0; } +if ( ToGrid ) { delete ToGrid; ToGrid = (const Grid *) nullptr; } Hemi = no_hemisphere; grid_strings.clear(); -Config = (MetConfig *) 0; +Config = (MetConfig *) nullptr; ConfigFilename.clear(); @@ -230,7 +230,7 @@ if ( !(f->read(filename, 'N')) ) { } -cp_nh = (const AFCloudPctFile *) f; f = (AFCloudPctFile *) 0; +cp_nh = (const AFCloudPctFile *) f; f = (AFCloudPctFile *) nullptr; return; @@ -255,7 +255,7 @@ if ( !(f->read(filename, 'S')) ) { } -cp_sh = (const AFCloudPctFile *) f; f = (AFCloudPctFile *) 0; +cp_sh = (const AFCloudPctFile *) f; f = (AFCloudPctFile *) nullptr; return; @@ -282,7 +282,7 @@ if ( !(f->read(filename, 'N')) ) { f->set_swap_endian(swap); -pt_nh = (const AFPixelTimeFile *) f; f = (AFPixelTimeFile *) 0; +pt_nh = (const AFPixelTimeFile *) f; f = (AFPixelTimeFile *) nullptr; return; @@ -309,7 +309,7 @@ if ( !(f->read(filename, 'S')) ) { f->set_swap_endian(swap); -pt_sh = (const AFPixelTimeFile *) f; f = (AFPixelTimeFile *) 0; +pt_sh = (const AFPixelTimeFile *) f; f = (AFPixelTimeFile *) nullptr; return; diff --git a/src/tools/tc_utils/rmw_analysis/rmw_analysis.h b/src/tools/tc_utils/rmw_analysis/rmw_analysis.h index f5d5474610..87a9baf100 100644 --- a/src/tools/tc_utils/rmw_analysis/rmw_analysis.h +++ b/src/tools/tc_utils/rmw_analysis/rmw_analysis.h @@ -81,8 +81,8 @@ static ConcatString out_dir; ConcatString out_file; // NetCDF file information -static netCDF::NcFile* nc_in = (netCDF::NcFile*) 0; -static netCDF::NcFile* nc_out = (netCDF::NcFile*) 0; +static netCDF::NcFile* nc_in = (netCDF::NcFile*) nullptr; +static netCDF::NcFile* nc_out = (netCDF::NcFile*) nullptr; // Grid dimension information static netCDF::NcDim range_dim; diff --git a/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc b/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc index 6862e56cae..9104c30279 100644 --- a/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc +++ b/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc @@ -46,7 +46,7 @@ RMWAnalysisConfInfo::~RMWAnalysisConfInfo() { void RMWAnalysisConfInfo::init_from_scratch() { // Initialize pointers - data_info = (VarInfo**) 0; + data_info = (VarInfo**) nullptr; clear(); @@ -80,11 +80,11 @@ void RMWAnalysisConfInfo::clear() { if(data_info) { for(int i = 0; i < n_data; i++) { if(data_info[i]) { - data_info[i] = (VarInfo*) 0; + data_info[i] = (VarInfo*) nullptr; } } delete data_info; - data_info = (VarInfo**) 0; + data_info = (VarInfo**) nullptr; } // Reset field count @@ -115,7 +115,7 @@ void RMWAnalysisConfInfo::read_config(const char* default_file_name, void RMWAnalysisConfInfo::process_config() { VarInfoFactory info_factory; - Dictionary *fdict = (Dictionary *) 0; + Dictionary *fdict = (Dictionary *) nullptr; ConcatString poly_file; GrdFileType ftype = FileType_NcCF; @@ -184,7 +184,7 @@ void RMWAnalysisConfInfo::process_config() { // Initialize pointers for(int i = 0; i < n_data; i++) { - data_info[i] = (VarInfo*) 0; + data_info[i] = (VarInfo*) nullptr; } // Parse data field information diff --git a/src/tools/tc_utils/tc_diag/tc_diag.cc b/src/tools/tc_utils/tc_diag/tc_diag.cc index 332587b9eb..f5d0c106fb 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag.cc @@ -244,7 +244,7 @@ void process_command_line(int argc, char **argv) { void get_file_type() { Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; int i; // Build one long list of input data files @@ -284,7 +284,7 @@ void get_file_type() { file_type = mtddf->file_type(); // Clean up - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } return; } @@ -973,7 +973,7 @@ void process_fields(const TrackInfoArray &tracks, int i, j, i_pnt; Grid grid_dp; VarInfoFactory vi_factory; - VarInfo *vi = (VarInfo *) 0; + VarInfo *vi = (VarInfo *) nullptr; vector vi_list; DataPlane dp; vector dp_list; @@ -1063,7 +1063,7 @@ void process_fields(const TrackInfoArray &tracks, // Deallocate memory if(vi_list[i]) { delete vi_list[i]; - vi_list[i] = (VarInfo *) 0; + vi_list[i] = (VarInfo *) nullptr; } } // end for i @@ -1188,7 +1188,7 @@ void process_out_files(const TrackInfoArray& tracks) { //////////////////////////////////////////////////////////////////////// void merge_tmp_files(const vector tmp_files) { - NcFile *nc_out = (NcFile *) 0; + NcFile *nc_out = (NcFile *) nullptr; // Loop over temp files for(int i_tmp=0; i_tmpclose(); delete nc_diag_out; - nc_diag_out = (NcFile *) 0; + nc_diag_out = (NcFile *) nullptr; } nc_diag_file.clear(); @@ -1418,7 +1418,7 @@ void OutFileInfo::clear() { // Close the output file cira_diag_out->close(); delete cira_diag_out; - cira_diag_out = (ofstream *) 0; + cira_diag_out = (ofstream *) nullptr; } cira_diag_file.clear(); @@ -1706,7 +1706,7 @@ void OutFileInfo::write_nc_diag() { } // Clean up - if(prs_data) { delete [] prs_data; prs_data = (float *) 0; } + if(prs_data) { delete [] prs_data; prs_data = (float *) nullptr; } return; } @@ -2085,9 +2085,9 @@ TmpFileInfo::~TmpFileInfo() { void TmpFileInfo::init_from_scratch() { // Initialize pointers - trk_ptr = (TrackInfo *) 0; - pnt_ptr = (TrackPoint *) 0; - tmp_out = (NcFile *) 0; + trk_ptr = (TrackInfo *) nullptr; + pnt_ptr = (TrackPoint *) nullptr; + tmp_out = (NcFile *) nullptr; clear(); @@ -2127,7 +2127,7 @@ void TmpFileInfo::close() { << tmp_file << "\n"; delete tmp_out; - tmp_out = (NcFile *) 0; + tmp_out = (NcFile *) nullptr; } return; @@ -2137,8 +2137,8 @@ void TmpFileInfo::close() { void TmpFileInfo::clear() { - trk_ptr = (TrackInfo *) 0; - pnt_ptr = (TrackPoint *) 0; + trk_ptr = (TrackInfo *) nullptr; + pnt_ptr = (TrackPoint *) nullptr; // Clear the diagnostics keys and maps diag_storm_keys.clear(); @@ -2167,7 +2167,7 @@ void TmpFileInfo::clear() { remove_temp_file(tmp_file); - tmp_out = (NcFile *) 0; + tmp_out = (NcFile *) nullptr; } tmp_file.clear(); @@ -2267,8 +2267,8 @@ void TmpFileInfo::setup_nc_file(const DomainInfo &di, write_tc_track_point(tmp_out, vld_dim, *pnt_ptr); // Clean up - if(lat_arr) { delete[] lat_arr; lat_arr = (double *) 0; } - if(lon_arr) { delete[] lon_arr; lon_arr = (double *) 0; } + if(lat_arr) { delete[] lat_arr; lat_arr = (double *) nullptr; } + if(lon_arr) { delete[] lon_arr; lon_arr = (double *) nullptr; } return; } diff --git a/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc b/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc index 7684308b81..688308e356 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc @@ -81,7 +81,7 @@ void DomainInfo::clear() { data_files.clear(); domain.clear(); - data.name = (const char *) 0; + data.name = (const char *) nullptr; data.range_n = bad_data_int; data.azimuth_n = bad_data_int; data.range_max_km = bad_data_double; @@ -181,7 +181,7 @@ void TCDiagConfInfo::clear() { // Deallocate memory for(int i=0; i dmap) { int i, j; StringArray sa; - Dictionary *dict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; VarInfoFactory vi_factory; // Conf: version @@ -368,7 +368,7 @@ void TCDiagConfInfo::process_config(GrdFileType file_type, //////////////////////////////////////////////////////////////////////// void TCDiagConfInfo::parse_domain_info(map dmap) { - Dictionary *dict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; int i, j; bool found; diff --git a/src/tools/tc_utils/tc_dland/tc_dland.cc b/src/tools/tc_utils/tc_dland/tc_dland.cc index dbdc7d976a..5a360479f4 100644 --- a/src/tools/tc_utils/tc_dland/tc_dland.cc +++ b/src/tools/tc_utils/tc_dland/tc_dland.cc @@ -201,13 +201,13 @@ void process_land_data() { void process_distances() { int n, x, y, c, npts, nlog, imin; double lat, lon; - float *dland = (float *) 0; + float *dland = (float *) nullptr; // Instantiate the grid Grid grid(GridData); // NetCDF variables - NcFile *f_out = (NcFile *) 0; + NcFile *f_out = (NcFile *) nullptr; NcDim lat_dim ; NcDim lon_dim ; NcVar dland_var ; @@ -220,7 +220,7 @@ void process_distances() { << "trouble opening output file " << out_filename << "\n\n"; delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; exit(1); } @@ -293,18 +293,18 @@ void process_distances() { // Write the computed distances to the output file mlog << Debug(3) << "Writing distance to land variable.\n"; if(!put_nc_data_with_dims(&dland_var, &dland[0], grid.ny(), grid.nx())) { - if(dland) { delete [] dland; dland = (float *) 0; } + if(dland) { delete [] dland; dland = (float *) nullptr; } mlog << Error << "\nprocess_distances() -> " << "error with dland_var->put\n\n"; exit(1); } // Delete allocated memory - if(dland) { delete [] dland; dland = (float *) 0; } + if(dland) { delete [] dland; dland = (float *) nullptr; } // Close the output NetCDF file delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; // List the output file mlog << Debug(1) diff --git a/src/tools/tc_utils/tc_dland/tc_poly.cc b/src/tools/tc_utils/tc_dland/tc_poly.cc index 9f3f892097..1eb7ac1a48 100644 --- a/src/tools/tc_utils/tc_dland/tc_poly.cc +++ b/src/tools/tc_utils/tc_dland/tc_poly.cc @@ -168,7 +168,7 @@ TCPolyArray & TCPolyArray::operator=(const TCPolyArray & a) { void TCPolyArray::init_from_scratch() { - Poly = (TCPoly *) 0; + Poly = (TCPoly *) nullptr; clear(); @@ -179,7 +179,7 @@ void TCPolyArray::init_from_scratch() { void TCPolyArray::clear() { - if(Poly) { delete [] Poly; Poly = (TCPoly *) 0; } + if(Poly) { delete [] Poly; Poly = (TCPoly *) nullptr; } NPolys = NAlloc = 0; @@ -222,7 +222,7 @@ void TCPolyArray::extend(int n, bool exact) { n = k*tc_poly_array_alloc_inc; } - TCPoly * p = (TCPoly *) 0; + TCPoly * p = (TCPoly *) nullptr; p = new TCPoly [n]; @@ -234,10 +234,10 @@ void TCPolyArray::extend(int n, bool exact) { if(Poly) { for(i=0; iclose(); delete out; - out = (ofstream *) 0; + out = (ofstream *) nullptr; } return; @@ -2174,7 +2174,7 @@ void write_prob_rirw(const ProbRIRWPairInfoArray &p) { TcHdrColumns tchc; ConcatString out_file; AsciiTable out_at; - ofstream *out = (ofstream *) 0; + ofstream *out = (ofstream *) nullptr; // Set the track pair output file name out_file << out_base << "_PROBRIRW" << tc_stat_file_ext; @@ -2239,7 +2239,7 @@ void write_prob_rirw(const ProbRIRWPairInfoArray &p) { *out << out_at; out->close(); delete out; - out = (ofstream *) 0; + out = (ofstream *) nullptr; } return; diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc index cfd22631b5..6b2cb8254d 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc @@ -54,7 +54,7 @@ TCPairsConfInfo::~TCPairsConfInfo() { void TCPairsConfInfo::init_from_scratch() { // Initialize pointers - Consensus = (ConsensusInfo *) 0; + Consensus = (ConsensusInfo *) nullptr; clear(); @@ -66,7 +66,7 @@ void TCPairsConfInfo::init_from_scratch() { void TCPairsConfInfo::clear() { // Deallocate memory - if(Consensus) { delete [] Consensus; Consensus = (ConsensusInfo *) 0; } + if(Consensus) { delete [] Consensus; Consensus = (ConsensusInfo *) nullptr; } Desc.clear(); Model.clear(); @@ -139,7 +139,7 @@ void TCPairsConfInfo::process_config() { int i, j; StringArray sa; ConcatString poly_file; - Dictionary *dict = (Dictionary *) 0; + Dictionary *dict = (Dictionary *) nullptr; // Conf: Version Version = Conf.lookup_string(conf_key_version); @@ -395,7 +395,7 @@ void DiagInfo::clear() { void parse_conf_diag_info_map(Dictionary *dict, map &source_map) { int i; - Dictionary *map_dict = (Dictionary *) 0; + Dictionary *map_dict = (Dictionary *) nullptr; ConcatString diag_source; DiagInfo cur_info; @@ -445,7 +445,7 @@ void parse_conf_diag_info_map(Dictionary *dict, map &sour void parse_conf_diag_convert_map(Dictionary *dict, map< ConcatString,map > &source_map) { int i, j; - Dictionary *map_dict = (Dictionary *) 0; + Dictionary *map_dict = (Dictionary *) nullptr; map cur_map; ConcatString diag_source, key; StringArray sa; diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index 4520b1d5ca..dfcf84a9f9 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -214,7 +214,7 @@ GrdFileType get_file_type(const StringArray &file_list, const GrdFileType in_ftype) { int i; Met2dDataFileFactory mtddf_factory; - Met2dDataFile *mtddf = (Met2dDataFile *) 0; + Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; GrdFileType out_ftype; // Find the first file that actually exists @@ -239,7 +239,7 @@ GrdFileType get_file_type(const StringArray &file_list, out_ftype = mtddf->file_type(); // Clean up - if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } + if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } return(out_ftype); } @@ -561,7 +561,7 @@ void setup_grid() { //////////////////////////////////////////////////////////////////////// void setup_nc_file() { - VarInfo* data_info = (VarInfo*) 0; + VarInfo* data_info = (VarInfo*) nullptr; // Create NetCDF file nc_out = open_ncfile(out_file.c_str(), true); @@ -650,7 +650,7 @@ void compute_lat_lon(TcrmwGrid& tcrmw_grid, //////////////////////////////////////////////////////////////////////// void process_fields(const TrackInfoArray& tracks) { - VarInfo *data_info = (VarInfo *) 0; + VarInfo *data_info = (VarInfo *) nullptr; DataPlane data_dp; // Define latitude and longitude arrays diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.h b/src/tools/tc_utils/tc_rmw/tc_rmw.h index 10aded04c4..b97f136188 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.h @@ -97,7 +97,7 @@ static ConcatString out_prefix; // Output NetCDF file static ConcatString out_file; -static netCDF::NcFile* nc_out = (netCDF::NcFile*) 0; +static netCDF::NcFile* nc_out = (netCDF::NcFile*) nullptr; static netCDF::NcDim range_dim; static netCDF::NcDim azimuth_dim; static netCDF::NcDim pressure_dim; diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc index 19fa16a3c6..96f038f6ab 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc @@ -45,7 +45,7 @@ TCRMWConfInfo::~TCRMWConfInfo() { void TCRMWConfInfo::init_from_scratch() { // Initialize pointers - data_info = (VarInfo**) 0; + data_info = (VarInfo**) nullptr; clear(); @@ -86,11 +86,11 @@ void TCRMWConfInfo::clear() { if(data_info) { for(int i = 0; i < n_data; i++) { if(data_info[i]) { - data_info[i] = (VarInfo*) 0; + data_info[i] = (VarInfo*) nullptr; } } delete data_info; - data_info = (VarInfo**) 0; + data_info = (VarInfo**) nullptr; } // Reset field count @@ -122,7 +122,7 @@ void TCRMWConfInfo::process_config(GrdFileType ftype) { int i; StringArray sa; VarInfoFactory info_factory; - Dictionary *fdict = (Dictionary *) 0; + Dictionary *fdict = (Dictionary *) nullptr; // Conf: version check_met_version(Conf.lookup_string(conf_key_version).c_str()); @@ -212,7 +212,7 @@ void TCRMWConfInfo::process_config(GrdFileType ftype) { // Initialize pointers for(i=0; iget_n_data(); i_var++) { data_info = _conf->data_info[i_var]; string varname = data_info->name_attr().string(); @@ -128,8 +128,8 @@ void TCRMW_WindConverter::update_input(const string &variableName, const string //////////////////////////////////////////////////////////////////////// void TCRMW_WindConverter::append_nc_output_vars(map > &variable_levels, - map &variable_long_names, - map &variable_units) { + map &variable_long_names, + map &variable_units) { if (!_computeWinds) { return; } @@ -145,11 +145,11 @@ void TCRMW_WindConverter::append_nc_output_vars(map > &va else { if (!_foundUInInput) { mlog << Warning << "\nTCWRMW_WindConverter::checkInputs() -> " - << "field not found in input \"" << _conf->u_wind_field_name << "\"\n\n"; + << "field not found in input \"" << _conf->u_wind_field_name << "\"\n\n"; } if (!_foundVInInput) { mlog << Warning << "\nTCWRMW_WindConverter::checkInputs() -> " - << "field not found in input \"" << _conf->v_wind_field_name << "\"\n\n"; + << "field not found in input \"" << _conf->v_wind_field_name << "\"\n\n"; } mlog << Warning << "\nNot computing radial and tangential winds\n\n"; _computeWinds = false; @@ -159,24 +159,24 @@ void TCRMW_WindConverter::append_nc_output_vars(map > &va //////////////////////////////////////////////////////////////////////// bool TCRMW_WindConverter::compute_winds_if_input_is_u(int i_point, - const string &varName, - const string &varLevel, - unixtime valid_time, - const StringArray &data_files, - const GrdFileType &ftype, - const Grid &latlon_arr, - const double *lat_arr, - const double *lon_arr, - const Grid &grid, - const DataPlane &data_dp, - const TcrmwGrid &tcrmw_grid) { + const string &varName, + const string &varLevel, + unixtime valid_time, + const StringArray &data_files, + const GrdFileType &ftype, + const Grid &latlon_arr, + const double *lat_arr, + const double *lon_arr, + const Grid &grid, + const DataPlane &data_dp, + const TcrmwGrid &tcrmw_grid) { if (!_computeWinds) { return false; } int uIndex = -1; int vIndex = -1; - VarInfo *data_infoV = (VarInfo *) 0; + VarInfo *data_infoV = (VarInfo *) nullptr; if (varName == _conf->u_wind_field_name.string()) { uIndex = _uIndexMap[varLevel]; vIndex = _vIndexMap[varLevel]; @@ -191,7 +191,7 @@ bool TCRMW_WindConverter::compute_winds_if_input_is_u(int i_point, DataPlane data_dpV; Grid latlon_arrV; get_series_entry(i_point, data_infoV, data_files, ftype, data_dpV, - latlon_arrV); + latlon_arrV); double data_min, data_max; data_dpV.data_range(data_min, data_max); mlog << Debug(4) << "V data_min:" << data_min << "\n"; @@ -203,7 +203,7 @@ bool TCRMW_WindConverter::compute_winds_if_input_is_u(int i_point, // here's the conversion, at last wind_ne_to_ra(tcrmw_grid, data_dp, data_dpV, lat_arr, lon_arr, - _windR, _windT); + _windR, _windT); // _windR and _windT now set return true; } @@ -212,9 +212,9 @@ bool TCRMW_WindConverter::compute_winds_if_input_is_u(int i_point, //////////////////////////////////////////////////////////////////////// void wind_ne_to_ra(const TcrmwGrid& tcrmw_grid, - const DataPlane& u_dp, const DataPlane& v_dp, - const double* lat_arr, const double* lon_arr, - double* wind_r_arr, double* wind_t_arr) { + const DataPlane& u_dp, const DataPlane& v_dp, + const double* lat_arr, const double* lon_arr, + double* wind_r_arr, double* wind_t_arr) { // Transform (u, v) to (radial, azimuthal) for(int ir = 0; ir < tcrmw_grid.range_n(); ir++) { for(int ia = 0; ia < tcrmw_grid.azimuth_n(); ia++) { @@ -225,15 +225,15 @@ void wind_ne_to_ra(const TcrmwGrid& tcrmw_grid, double v = v_dp.data()[i]; double wind_r; double wind_t; - if(is_bad_data(u) || is_bad_data(v)) { - mlog << Debug(4) << "wind_ne_to_ra: latlon:" << lat << "," << lon << " winds are missing\n"; - wind_r = bad_data_double; - wind_t = bad_data_double; - } else { - tcrmw_grid.wind_ne_to_ra(lat, lon, u, v, wind_r, wind_t); - mlog << Debug(4) << "wind_ne_to_ra: latlon:" << lat << "," << lon << " uv:" << u << "," - << v << ", rt:" << wind_r << "," << wind_t <<"\n"; - } + if(is_bad_data(u) || is_bad_data(v)) { + mlog << Debug(4) << "wind_ne_to_ra: latlon:" << lat << "," << lon << " winds are missing\n"; + wind_r = bad_data_double; + wind_t = bad_data_double; + } else { + tcrmw_grid.wind_ne_to_ra(lat, lon, u, v, wind_r, wind_t); + mlog << Debug(4) << "wind_ne_to_ra: latlon:" << lat << "," << lon << " uv:" << u << "," + << v << ", rt:" << wind_r << "," << wind_t <<"\n"; + } wind_r_arr[i] = wind_r; wind_t_arr[i] = wind_t; } diff --git a/src/tools/tc_utils/tc_stat/tc_stat.cc b/src/tools/tc_utils/tc_stat/tc_stat.cc index d1e85b0855..3bfd0b13a4 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat.cc @@ -165,7 +165,7 @@ void process_search_dirs() { void process_jobs() { TCStatJobFactory factory; - TCStatJob *cur_job = (TCStatJob *) 0; + TCStatJob *cur_job = (TCStatJob *) nullptr; ConcatString jobstring; int i, n_jobs; TCPointCounts n; @@ -258,7 +258,7 @@ void process_jobs() { << "Rejected for out valid mask = " << n.RejOutValidMask << "\n"; // Deallocate current job - if(cur_job) { delete cur_job; cur_job = (TCStatJob *) 0; } + if(cur_job) { delete cur_job; cur_job = (TCStatJob *) nullptr; } } // end for i @@ -293,7 +293,7 @@ void open_out_file() { void close_out_file() { // Close the output file - if(tc_stat_out != (ofstream *) 0) { + if(tc_stat_out != (ofstream *) nullptr) { // List the file being closed mlog << Debug(1) @@ -302,7 +302,7 @@ void close_out_file() { // Close the output file tc_stat_out->close(); delete tc_stat_out; - tc_stat_out = (ofstream *) 0; + tc_stat_out = (ofstream *) nullptr; } return; diff --git a/src/tools/tc_utils/tc_stat/tc_stat.h b/src/tools/tc_utils/tc_stat/tc_stat.h index 1bf28f1610..64a3a214c0 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat.h +++ b/src/tools/tc_utils/tc_stat/tc_stat.h @@ -81,7 +81,7 @@ static ConcatString command_line_job; //////////////////////////////////////////////////////////////////////// // Output file stream -static std::ofstream *tc_stat_out = (std::ofstream *) 0; +static std::ofstream *tc_stat_out = (std::ofstream *) nullptr; //////////////////////////////////////////////////////////////////////// // diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index 197c4f2f12..9814f759c4 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -2703,7 +2703,7 @@ TCStatJobType string_to_tcstatjobtype(const ConcatString s) { //////////////////////////////////////////////////////////////////////// ConcatString tcstatjobtype_to_string(const TCStatJobType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case TCStatJobType_Filter: s = TCStatJobType_FilterStr; break; @@ -2936,7 +2936,7 @@ TCStatJobRIRW & TCStatJobRIRW::operator=(const TCStatJobRIRW &j) { void TCStatJobRIRW::init_from_scratch() { int i; - for(i=0; i<4; i++) DumpOutCTC[i] = (ofstream *) 0; + for(i=0; i<4; i++) DumpOutCTC[i] = (ofstream *) nullptr; TCStatJob::init_from_scratch(); @@ -3066,7 +3066,7 @@ void TCStatJobRIRW::close_dump_file() { DumpOutCTC[i]->close(); delete DumpOutCTC[i]; - DumpOutCTC[i] = (ofstream *) 0; + DumpOutCTC[i] = (ofstream *) nullptr; } } @@ -3977,7 +3977,7 @@ TCStatJobProbRIRW & TCStatJobProbRIRW::operator=(const TCStatJobProbRIRW &j) { void TCStatJobProbRIRW::init_from_scratch() { - StatOut = (ofstream *) 0; + StatOut = (ofstream *) nullptr; TCStatJob::init_from_scratch(); @@ -4081,7 +4081,7 @@ void TCStatJobProbRIRW::close_dump_file() { if(DumpOut) { DumpOut->close(); delete DumpOut; - DumpOut = (ofstream *) 0; + DumpOut = (ofstream *) nullptr; } // Prepare nicely formatted AsciiTable object From 83730cf63202081db6e78ca269e2056c80b0909c Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 01:31:58 +0000 Subject: [PATCH 011/114] #2673 Removed the redundant parentheses with return --- src/basic/enum_to_string/code.cc | 4 +- src/basic/enum_to_string/info.cc | 10 +-- src/basic/enum_to_string/my_enum_scanner.cc | 42 ++++----- src/basic/enum_to_string/scope.cc | 6 +- src/basic/vx_config/builtin.cc | 4 +- src/basic/vx_config/celltype_to_string.cc | 48 +++++----- src/basic/vx_config/config_file.cc | 4 +- src/basic/vx_config/config_util.cc | 6 +- src/basic/vx_config/dictionary.cc | 8 +- src/basic/vx_config/grdfiletype_to_string.cc | 34 +++---- src/basic/vx_config/my_config_scanner.cc | 88 +++++++++---------- src/basic/vx_config/number_stack.cc | 4 +- src/basic/vx_config/threshold.cc | 16 ++-- src/basic/vx_log/concat_string.cc | 88 +++++++++---------- src/basic/vx_log/file_fxns.cc | 10 +-- src/basic/vx_log/indent.cc | 6 +- src/basic/vx_log/logger.cc | 50 +++++------ src/basic/vx_log/string_array.cc | 32 +++---- src/basic/vx_math/affine.cc | 46 +++++----- src/basic/vx_math/angles.cc | 22 ++--- src/basic/vx_math/hist.cc | 18 ++-- src/basic/vx_math/legendre.cc | 10 +-- src/basic/vx_math/nint.cc | 2 +- src/basic/vx_math/nti.cc | 10 +-- src/basic/vx_math/ptile.cc | 24 ++--- src/basic/vx_math/pwl.cc | 16 ++-- src/basic/vx_math/viewgravity_to_string.cc | 2 +- src/basic/vx_math/vx_vector.cc | 54 ++++++------ src/basic/vx_util/ascii_header.cc | 22 ++--- src/basic/vx_util/ascii_table.cc | 54 ++++++------ src/basic/vx_util/asciitablejust_to_string.cc | 2 +- src/basic/vx_util/comma_string.cc | 2 +- src/basic/vx_util/command_line.cc | 36 ++++---- src/basic/vx_util/conversions.cc | 18 ++-- src/basic/vx_util/data_line.cc | 74 ++++++++-------- src/basic/vx_util/data_plane.cc | 42 ++++----- src/basic/vx_util/data_plane_util.cc | 12 +-- src/basic/vx_util/file_exists.cc | 10 +-- src/basic/vx_util/file_linecount.cc | 2 +- src/basic/vx_util/file_size.cc | 2 +- src/basic/vx_util/filename_suffix.cc | 6 +- src/basic/vx_util/get_filenames.cc | 10 +-- src/basic/vx_util/grib_constants.cc | 4 +- src/basic/vx_util/interp_mthd.cc | 4 +- src/basic/vx_util/interp_util.cc | 50 +++++------ src/basic/vx_util/is_number.cc | 64 +++++++------- src/basic/vx_util/long_array.cc | 10 +-- src/basic/vx_util/make_path.cc | 14 +-- src/basic/vx_util/mask_poly.cc | 10 +-- src/basic/vx_util/met_buffer.cc | 10 +-- src/basic/vx_util/normalize.cc | 2 +- src/basic/vx_util/num_array.cc | 62 ++++++------- src/basic/vx_util/polyline.cc | 36 ++++---- src/basic/vx_util/python_line.cc | 18 ++-- src/basic/vx_util/read_fortran_binary.cc | 24 ++--- src/basic/vx_util/smart_buffer.cc | 8 +- src/basic/vx_util/string_fxns.cc | 24 ++--- src/basic/vx_util/thresh_array.cc | 64 +++++++------- src/basic/vx_util/two_to_one.cc | 8 +- src/basic/vx_util_math/so3.cc | 34 +++---- 60 files changed, 701 insertions(+), 701 deletions(-) diff --git a/src/basic/enum_to_string/code.cc b/src/basic/enum_to_string/code.cc index 93f2b1e6c0..fb62ba003f 100644 --- a/src/basic/enum_to_string/code.cc +++ b/src/basic/enum_to_string/code.cc @@ -869,7 +869,7 @@ for (j=0; j= Nids) ) { } -return ( s[n] ); +return s[n]; } @@ -259,7 +259,7 @@ int EnumInfo::max_id_length() const { -if ( Nids == 0 ) return ( 0 ); +if ( Nids == 0 ) return 0; int j, k; int max_len; @@ -468,7 +468,7 @@ for (j=0; j<(e.Nids); ++j) { s.flush(); -return ( s ); +return s; } diff --git a/src/basic/enum_to_string/my_enum_scanner.cc b/src/basic/enum_to_string/my_enum_scanner.cc index 2d71fe65c0..40e1577c42 100644 --- a/src/basic/enum_to_string/my_enum_scanner.cc +++ b/src/basic/enum_to_string/my_enum_scanner.cc @@ -134,7 +134,7 @@ while ( 1 ) { t = next_token(); - if ( t == eof ) return ( 0 ); + if ( t == eof ) return 0; if ( t < 0 ) continue; @@ -186,7 +186,7 @@ while ( 1 ) { } // while -if ( c == eof ) return ( eof ); +if ( c == eof ) return eof; clear_lexeme(); @@ -196,11 +196,11 @@ switch ( c ) { // single character tokens // - case '{': { if ( do_left_curly() ) return ( token(L_CURLY) ); } break; - case '}': { if ( do_right_curly() ) return ( token(R_CURLY) ); } break; - case '=': { if ( do_equals() ) return ( token (EQ) ); } break; - case ';': { if ( do_semi() ) return ( token(';') ); } break; - case ',': { if ( do_comma() ) return ( token(',') ); } break; + case '{': { if ( do_left_curly() ) return token(L_CURLY); } break; + case '}': { if ( do_right_curly() ) return token(R_CURLY); } break; + case '=': { if ( do_equals() ) return token (EQ); } break; + case ';': { if ( do_semi() ) return token(';'); } break; + case ',': { if ( do_comma() ) return token(','); } break; default: break; @@ -215,13 +215,13 @@ if ( c == '/' ) { c2 = nextchar(); - if ( c2 == EOF ) return ( EOF ); + if ( c2 == EOF ) return EOF; if ( c2 == '*' ) do_c_comment(); else if ( c2 == '/' ) do_cpp_comment(); else ungetc(c2, yyin); - return ( skip ); + return skip; } @@ -231,7 +231,7 @@ if ( c == '/' ) { int k = char_class[c]; -if ( k == char_class_other ) return ( skip ); +if ( k == char_class_other ) return skip; // // from this point on, we're only interested in characters @@ -255,14 +255,14 @@ while ( count < max_lexeme_size ) { lexeme[max_lexeme_size] = (char) 0; -if ( count == 0 ) return ( skip ); +if ( count == 0 ) return skip; -if ( strncmp((char *) lexeme, "enum", max_lexeme_size) == 0 ) { do_enum(); return ( token(ENUM) ); } -if ( strncmp((char *) lexeme, "class", max_lexeme_size) == 0 ) { do_class(); return ( token(CLASS) ); } +if ( strncmp((char *) lexeme, "enum", max_lexeme_size) == 0 ) { do_enum(); return token(ENUM) ; } +if ( strncmp((char *) lexeme, "class", max_lexeme_size) == 0 ) { do_class(); return token(CLASS); } -if ( is_int() ) { if ( do_int() ) return ( token(INTEGER) ); } +if ( is_int() ) { if ( do_int() ) return token(INTEGER); } -if ( is_id() ) { if ( do_id() ) return ( token(ID) ); } +if ( is_id() ) { if ( do_id() ) return token(ID); } @@ -326,9 +326,9 @@ bool char_ok(int c) const int k = char_class[c]; -if ( k == char_class_digit ) return ( true ); +if ( k == char_class_digit ) return true; -if ( k == char_class_alpha ) return ( true ); +if ( k == char_class_alpha ) return true; return false; @@ -357,7 +357,7 @@ for (j=j_start; jlookup_bool(conf_key_flag); // If disabled, skip remainder of the dictionary. - if(!info.flag) return(info); + if(!info.flag) return info; // Conf: vld_thresh info.vld_thresh = hira_dict->lookup_double(conf_key_vld_thresh); @@ -3308,7 +3308,7 @@ StringArray parse_conf_ens_member_ids(Dictionary *dict) { << sa.n() << " entries.\n"; } - return(sa); + return sa; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/dictionary.cc b/src/basic/vx_config/dictionary.cc index bc1a34bff0..569b183629 100644 --- a/src/basic/vx_config/dictionary.cc +++ b/src/basic/vx_config/dictionary.cc @@ -1281,7 +1281,7 @@ scope = Name.split("."); if ( scope.n_elements() == 1 ) { - return ( lookup_simple(name, search_parent) ); + return lookup_simple(name, search_parent); } @@ -1505,7 +1505,7 @@ if ( !Entry || !is_correct_type ) { } - return ( false ); + return false; } @@ -1529,7 +1529,7 @@ for (int i=0; ipush_array(); return ( token(lexeme[0]) ); } - case '{': { do_single_char_token(lexeme[0]); is_lhs = true; dict_stack->push(); return ( token(lexeme[0]) ); } + case '[': { do_single_char_token(lexeme[0]); is_lhs = false; dict_stack->push_array(); return token(lexeme[0]); } + case '{': { do_single_char_token(lexeme[0]); is_lhs = true; dict_stack->push(); return token(lexeme[0]); } - case ']': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } - case '}': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } + case ']': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } + case '}': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } - case '(': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } - case ')': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } + case '(': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } + case ')': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } - case '+': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } + case '+': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } - case '-': { if ( ! need_number ) { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } } break; + case '-': { if ( ! need_number ) { do_single_char_token(lexeme[0]); return token(lexeme[0]); } } break; - case '*': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } - case '^': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } + case '*': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } + case '^': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } - // case '=': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } + // case '=': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } - case ';': { do_single_char_token(lexeme[0]); is_lhs = true; return ( token( ';' ) ); } - case ',': { do_single_char_token(lexeme[0]); return ( token(lexeme[0]) ); } + case ';': { do_single_char_token(lexeme[0]); is_lhs = true; return token( ';' ); } + case ',': { do_single_char_token(lexeme[0]); return token(lexeme[0]); } - case '\"': { do_quoted_string(); return ( token ( QUOTED_STRING ) ); } + case '\"': { do_quoted_string(); return token ( QUOTED_STRING ); } - case '\n': { ++LineNumber; Column = 1; return ( -1 ); } + case '\n': { ++LineNumber; Column = 1; return -1; } default: break; @@ -281,27 +281,27 @@ if ( c == '/' ) { c2 = nextchar(); - if ( c2 == eof ) return ( eof ); + if ( c2 == eof ) return eof; - if ( c2 == '*' ) { do_c_comment(); return ( skip ); } - else if ( c2 == '/' ) { do_cpp_comment(); return ( skip ); } + if ( c2 == '*' ) { do_c_comment(); return skip; } + else if ( c2 == '/' ) { do_cpp_comment(); return skip; } else putback(c2); - return ( token('/') ); + return token('/'); } c2 = nextchar(); - if ( strncmp(configtext, "<=", 2) == 0 ) { need_number = true; return ( do_comp() ); } -else if ( strncmp(configtext, ">=", 2) == 0 ) { need_number = true; return ( do_comp() ); } -else if ( strncmp(configtext, "==", 2) == 0 ) { need_number = true; return ( do_comp() ); } + if ( strncmp(configtext, "<=", 2) == 0 ) { need_number = true; return do_comp(); } +else if ( strncmp(configtext, ">=", 2) == 0 ) { need_number = true; return do_comp(); } +else if ( strncmp(configtext, "==", 2) == 0 ) { need_number = true; return do_comp(); } -else if ( strncmp(configtext, "!=", 2) == 0 ) { need_number = true; return ( do_comp() ); } -else if ( strncmp(configtext, "NA", 2) == 0 ) return ( do_comp() ); +else if ( strncmp(configtext, "!=", 2) == 0 ) { need_number = true; return do_comp(); } +else if ( strncmp(configtext, "NA", 2) == 0 ) return do_comp(); -else if ( strncmp(configtext, "&&", 2) == 0 ) { Column += 2; return ( LOGICAL_OP_AND ); } -else if ( strncmp(configtext, "||", 2) == 0 ) { Column += 2; return ( LOGICAL_OP_OR ); } +else if ( strncmp(configtext, "&&", 2) == 0 ) { Column += 2; return LOGICAL_OP_AND; } +else if ( strncmp(configtext, "||", 2) == 0 ) { Column += 2; return LOGICAL_OP_OR ; } else { @@ -310,10 +310,10 @@ else { } -if ( strncmp(configtext, "<" , 1) == 0 ) { need_number = true; return ( do_comp() ); } -if ( strncmp(configtext, ">" , 1) == 0 ) { need_number = true; return ( do_comp() ); } -if ( strncmp(configtext, "=" , 1) == 0 ) return ( token( '=' ) ); -if ( strncmp(configtext, "!" , 1) == 0 ) return ( token( LOGICAL_OP_NOT ) ); +if ( strncmp(configtext, "<" , 1) == 0 ) { need_number = true; return do_comp(); } +if ( strncmp(configtext, ">" , 1) == 0 ) { need_number = true; return do_comp(); } +if ( strncmp(configtext, "=" , 1) == 0 ) return token( '=' ); +if ( strncmp(configtext, "!" , 1) == 0 ) return token( LOGICAL_OP_NOT ); // putback(configtext[0]); @@ -324,7 +324,7 @@ if ( strncmp(configtext, "!" , 1) == 0 ) return ( token( LOGICAL_OP_NOT ) ); int k = char_class[c]; -if ( k == char_class_other ) return ( skip ); +if ( k == char_class_other ) return skip; // // quote? @@ -350,22 +350,22 @@ while ( pos < max_id_length ) { lexeme[max_id_length] = (char) 0; -if ( pos == 0 ) return ( skip ); +if ( pos == 0 ) return skip; -// if ( strncmp((char *) lexeme, "enum", max_id_length) == 0 ) { do_enum(); return ( token(ENUM) ); } -// if ( strncmp((char *) lexeme, "class", max_id_length) == 0 ) { do_class(); return ( token(CLASS) ); } +// if ( strncmp((char *) lexeme, "enum", max_id_length) == 0 ) { do_enum(); return token(ENUM) ; } +// if ( strncmp((char *) lexeme, "class", max_id_length) == 0 ) { do_class(); return token(CLASS); } -if ( is_int() ) { if ( do_int() ) return ( token(INTEGER) ); } +if ( is_int() ) { if ( do_int() ) return token(INTEGER); } -if ( is_float_v2() ) { if ( do_float() ) return ( token(FLOAT) ); } +if ( is_float_v2() ) { if ( do_float() ) return token(FLOAT); } -if ( is_fort_thresh_no_spaces() ) { return ( do_fort_thresh() ); } +if ( is_fort_thresh_no_spaces() ) { return do_fort_thresh(); } -if ( is_simple_perc_thresh() ) { return ( do_simple_perc_thresh() ); } +if ( is_simple_perc_thresh() ) { return do_simple_perc_thresh(); } int t; -if ( is_id() ) { t = do_id(); return ( token(t) ); } +if ( is_id() ) { t = do_id(); return token(t); } @@ -528,7 +528,7 @@ if ( is_lhs ) { // print? // -if ( strcmp(configtext, "print" ) == 0 ) { return ( PRINT ); } +if ( strcmp(configtext, "print" ) == 0 ) { return PRINT; } // // boolean? @@ -546,7 +546,7 @@ if ( strcmp(configtext, "FALSE" ) == 0 ) { configlval.bval = false; return BOO for (j=0; jcheck(x, cmn, csd); -return ( ! tf ); +return !tf; } @@ -796,7 +796,7 @@ bool Simple_Node::check(double x, double cmn, double csd) const { -if ( op == thresh_na ) return ( true ); +if ( op == thresh_na ) return true; double tval; @@ -1371,7 +1371,7 @@ SingleThresh & SingleThresh::operator=(const SingleThresh & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; assign(c); @@ -1389,9 +1389,9 @@ bool SingleThresh::operator==(const SingleThresh &st) const // return true when both null and false when only one is null -if ( !node && !(st.node) ) return ( true ); +if ( !node && !(st.node) ) return true; -if ( !node || !(st.node) ) return ( false ); +if ( !node || !(st.node) ) return false; // for complex thresholds, check the string representation @@ -1644,11 +1644,11 @@ bool SingleThresh::need_perc() const if ( node ) { - return ( node->need_perc() ); + return node->need_perc(); } -return ( false ); +return false; } diff --git a/src/basic/vx_log/concat_string.cc b/src/basic/vx_log/concat_string.cc index 353bd44c5d..233985802e 100644 --- a/src/basic/vx_log/concat_string.cc +++ b/src/basic/vx_log/concat_string.cc @@ -165,7 +165,7 @@ ConcatString & ConcatString::operator=(const std::string & Text) init_from_scratch(); if (s) s->assign(Text); - return(*this); + return *this; } @@ -192,7 +192,7 @@ if ( ! Text ) { (*s) = s2; - return(*this); + return *this; } @@ -455,7 +455,7 @@ ConcatString ConcatString::dirname() const c = c.s->substr(start, end-start); } - return(c); + return c; } @@ -483,7 +483,7 @@ ConcatString ConcatString::basename() const c = c.s->substr(start+1, end-start); } - return(c); + return c; } @@ -612,7 +612,7 @@ const string ConcatString::contents(const char * str) const if (s->empty() || *s == "") { return (str ? str : "(nul)"); } else { - return ( *s ); + return *s; } } @@ -655,7 +655,7 @@ ConcatString uc = cs; uc.set_upper(); -return ( uc ); +return uc; } @@ -671,7 +671,7 @@ ConcatString lc = cs; lc.set_lower(); -return ( lc ); +return lc; } @@ -700,7 +700,7 @@ ConcatString & operator<<(ConcatString & cs, const char c) cs.add(c); -return ( cs ); +return cs; } @@ -714,7 +714,7 @@ ConcatString & operator<<(ConcatString & cs, const char * s) cs.add(s); -return ( cs ); +return cs; } @@ -727,7 +727,7 @@ ConcatString & operator<<(ConcatString & cs, const std::string & s) cs.add(s); -return ( cs ); +return cs; } @@ -741,7 +741,7 @@ ConcatString & operator<<(ConcatString & a, const ConcatString & b) a.add(b); -return ( a ); +return a; } @@ -757,7 +757,7 @@ std::ostringstream sstream; sstream << k; a.add(sstream.str()); -return ( a ); +return a; } @@ -772,7 +772,7 @@ std::ostringstream sstream; sstream << k; a.add(sstream.str()); -return ( a ); +return a; } @@ -787,7 +787,7 @@ std::ostringstream sstream; sstream << k; a.add(sstream.str()); -return ( a ); +return a; } @@ -806,7 +806,7 @@ sstream << x; a.add(sstream.str()); -return ( a ); +return a; } @@ -831,7 +831,7 @@ switch ( c ) { } // switch -return ( a ); +return a; } @@ -857,7 +857,7 @@ for (j=0; jcompare(*(b.s)); @@ -899,7 +899,7 @@ bool ConcatString::operator==(const char * text) const { -if ( !text || empty() ) return ( false ); +if ( !text || empty() ) return false; int status = s->compare(text); @@ -915,7 +915,7 @@ bool operator==(const char * text, const ConcatString & a) { -if ( !text || !a.text() ) return ( false ); +if ( !text || !a.text() ) return false; int status = strcmp(text, a.text()); @@ -931,7 +931,7 @@ bool operator!=(const ConcatString & a, const ConcatString & b) { -return ( !(a == b) ); +return !(a == b); } @@ -943,7 +943,7 @@ bool operator!=(const ConcatString & a, const char * text) { -return ( !(a == text) ); +return !(a == text); } @@ -955,7 +955,7 @@ bool operator!=(const char * text, const ConcatString & a) { -return ( !(text == a) ); +return !(text == a); } @@ -967,8 +967,8 @@ bool operator>=(const ConcatString & a, const ConcatString & b) { -if ( a.empty() ) return ( false ); -if ( b.empty() ) return ( false ); +if ( a.empty() ) return false; +if ( b.empty() ) return false; int status = strcmp(a.text(), b.text()); @@ -984,7 +984,7 @@ bool operator>=(const ConcatString & a, const char * text) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(a.text(), text); @@ -1000,7 +1000,7 @@ bool operator>=(const char * text, const ConcatString & a) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(text, a.text()); @@ -1016,8 +1016,8 @@ bool operator<=(const ConcatString & a, const ConcatString & b) { -if ( a.empty() ) return ( false ); -if ( b.empty() ) return ( false ); +if ( a.empty() ) return false; +if ( b.empty() ) return false; int status = strcmp(a.text(), b.text()); @@ -1033,7 +1033,7 @@ bool operator<=(const ConcatString & a, const char * text) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(a.text(), text); @@ -1049,7 +1049,7 @@ bool operator<=(const char * text, const ConcatString & a) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(text, a.text()); @@ -1065,8 +1065,8 @@ bool operator>(const ConcatString & a, const ConcatString & b) { -if ( a.empty() ) return ( false ); -if ( b.empty() ) return ( false ); +if ( a.empty() ) return false; +if ( b.empty() ) return false; int status = strcmp(a.text(), b.text()); @@ -1082,7 +1082,7 @@ bool operator>(const ConcatString & a, const char * text) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(a.text(), text); @@ -1098,7 +1098,7 @@ bool operator>(const char * text, const ConcatString & a) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(text, a.text()); @@ -1114,8 +1114,8 @@ bool operator<(const ConcatString & a, const ConcatString & b) { -if ( a.empty() ) return ( false ); -if ( b.empty() ) return ( false ); +if ( a.empty() ) return false; +if ( b.empty() ) return false; int status = strcmp(a.text(), b.text()); @@ -1131,7 +1131,7 @@ bool operator<(const ConcatString & a, const char * text) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(a.text(), text); @@ -1147,7 +1147,7 @@ bool operator<(const char * text, const ConcatString & a) { -if ( a.empty() || !text ) return ( false ); +if ( a.empty() || !text ) return false; int status = strcmp(text, a.text()); @@ -1169,7 +1169,7 @@ for ( int i=0; i 0) { << env_name << " to \"" << env_value << "\"\n"; } -return(true); +return true; } diff --git a/src/basic/vx_log/file_fxns.cc b/src/basic/vx_log/file_fxns.cc index fd0e19938f..66f0fa6de2 100644 --- a/src/basic/vx_log/file_fxns.cc +++ b/src/basic/vx_log/file_fxns.cc @@ -28,7 +28,7 @@ using namespace std; bool is_regular_file(const char *path) { struct stat path_stat; - return(!stat(path, &path_stat) && S_ISREG(path_stat.st_mode)); + return (!stat(path, &path_stat) && S_ISREG(path_stat.st_mode)); } //////////////////////////////////////////////////////////////////////// @@ -51,7 +51,7 @@ ConcatString replace_path(const ConcatString path) { s.replace(met_base_str, met_base_val.c_str()); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -69,7 +69,7 @@ ConcatString replace_path(const char * path) { //////////////////////////////////////////////////////////////////////// int met_open(const char *path, int oflag) { - return(open(replace_path(path).c_str(), oflag)); + return open(replace_path(path).c_str(), oflag); } //////////////////////////////////////////////////////////////////////// @@ -89,13 +89,13 @@ void met_open(ofstream &out, const char *path) { //////////////////////////////////////////////////////////////////////// FILE *met_fopen(const char *path, const char *mode) { - return(fopen(replace_path(path).c_str(), mode)); + return fopen(replace_path(path).c_str(), mode); } //////////////////////////////////////////////////////////////////////// DIR *met_opendir(const char *path) { - return(opendir(replace_path(path).c_str())); + return opendir(replace_path(path).c_str()); } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/indent.cc b/src/basic/vx_log/indent.cc index ce07dfbe29..46a4846c5a 100644 --- a/src/basic/vx_log/indent.cc +++ b/src/basic/vx_log/indent.cc @@ -72,11 +72,11 @@ Indent & Indent::operator=(const Indent & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -185,7 +185,7 @@ for (j=0; j= n()) ) { } -return ( s[len] ); +return s[len]; } @@ -427,7 +427,7 @@ string StringArray::serialize(const char *sep) const if((it+1) != s.end()) all_s.append(sep); } - return(all_s); + return all_s; } @@ -469,7 +469,7 @@ bool StringArray::has(const std::string text) const found = binary_search(s.begin(), s.end(), text); } else { - return ( has(text, forward) ); + return has(text, forward); } return found; @@ -483,7 +483,7 @@ bool StringArray::has(const std::string text, bool forward) const { int index; - return ( has(text, index, forward) ); + return has(text, index, forward); } //////////////////////////////////////////////////////////////////////// @@ -661,13 +661,13 @@ for (j=0; j= n()) ) { } -return ( s[k].length() ); +return s[k].length(); } @@ -818,7 +818,7 @@ const char ** cb = (const char **) b; status = strcmp(*ca, *cb); -return ( status ); +return status; } diff --git a/src/basic/vx_math/affine.cc b/src/basic/vx_math/affine.cc index c2dcc01cda..66f4fa13e7 100644 --- a/src/basic/vx_math/affine.cc +++ b/src/basic/vx_math/affine.cc @@ -105,11 +105,11 @@ Box & Box::operator=(const Box & b) { -if ( this == &b ) return ( * this ); +if ( this == &b ) return *this; assign(b); -return ( * this ); +return *this; } @@ -209,7 +209,7 @@ double Box::x_to_u(double x) const { -return ( (x - Left)/(Right - Left) ); +return (x - Left)/(Right - Left); } @@ -221,7 +221,7 @@ double Box::y_to_v(double y) const { -return ( (y - Bottom)/(Top - Bottom) ); +return (y - Bottom)/(Top - Bottom); } @@ -400,11 +400,11 @@ Affine & Affine::operator=(const Affine & g) { -if ( this == &g ) return ( * this ); +if ( this == &g ) return *this; assign(g); -return ( * this ); +return *this; } @@ -528,25 +528,25 @@ c = M22*M22 + M12*M12; // diagonal elements (nearly) equal? // -if ( fabs (a - c) > tol ) return ( false ); +if ( fabs (a - c) > tol ) return false; // // off-diagonal elements (nearly) zero? // -if ( fabs(b) > tol ) return ( false ); +if ( fabs(b) > tol ) return false; // // determinant positive? // -if ( Det < 0.0 ) return ( false ); +if ( Det < 0.0 ) return false; // // ok // -return ( true ); +return true; } @@ -750,7 +750,7 @@ GeneralAffine * Affine::copy() const Affine * a = new Affine ( *this ); -return ( a ); +return a; } @@ -842,11 +842,11 @@ ConformalAffine & ConformalAffine::operator=(const ConformalAffine & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; assign(c); -return ( * this ); +return *this; } @@ -995,7 +995,7 @@ ConformalAffine ca = *this; ca.invert(); -return ( ca ); +return ca; } @@ -1009,7 +1009,7 @@ GeneralAffine * ConformalAffine::copy() const ConformalAffine * ca = new ConformalAffine ( *this ); -return ( ca ); +return ca; } @@ -1203,7 +1203,7 @@ Affine a; a.set_mb(m11(), m12(), m21(), m22(), tx(), ty()); -return ( a ); +return a; } @@ -1264,7 +1264,7 @@ mag = min(rho, 1.0); mag *= (view_width)/(image_width); -return ( mag ); +return mag; } @@ -1280,7 +1280,7 @@ double mag; mag = calc_mag(image.width(), image.height(), view.width(), view.height()); -return ( mag ); +return mag; } @@ -1304,7 +1304,7 @@ a.forward(b.TX, b.TY, c.TX, c.TY); c.calc_det(); -return ( c ); +return c; } @@ -1331,7 +1331,7 @@ c.set_angle( a.Angle + b.Angle ); a.forward(b.TX, b.TY, c.TX, c.TY); -return ( c ); +return c; } @@ -1363,7 +1363,7 @@ bool bb_intersect(const Box &b1, const Box &b2) { intersect = true; } - return(intersect); + return intersect; } //////////////////////////////////////////////////////////////////////// @@ -1376,7 +1376,7 @@ bool is_inside_bb(const Box &bb, double x, double y) { inside = true; } - return(inside); + return inside; } //////////////////////////////////////////////////////////////////////// @@ -1389,7 +1389,7 @@ bool is_between(double a, double b, double x) { between = true; } - return(between); + return between; } diff --git a/src/basic/vx_math/angles.cc b/src/basic/vx_math/angles.cc index 71044245f5..bd14841c6f 100644 --- a/src/basic/vx_math/angles.cc +++ b/src/basic/vx_math/angles.cc @@ -41,7 +41,7 @@ double new_lon; // Check for bad data -if( is_bad_data(lon) ) return ( bad_data_double ); +if( is_bad_data(lon) ) return bad_data_double; new_lon = lon; @@ -57,7 +57,7 @@ if ( new_lon > 180.0 ) { } -return ( new_lon ); +return new_lon; } @@ -76,7 +76,7 @@ double new_deg; // Check for bad data -if ( is_bad_data(deg) ) return ( bad_data_double ); +if ( is_bad_data(deg) ) return bad_data_double; if ( ! is_eq(fabs(upper - lower), 360.0) || lower > upper ) { @@ -100,7 +100,7 @@ if ( new_deg > upper ) { } -return ( new_deg ); +return new_deg; } @@ -118,7 +118,7 @@ double d, d1, d2; // Check for bad data -if ( is_bad_data(a) || is_bad_data(b) ) return(bad_data_double); +if ( is_bad_data(a) || is_bad_data(b) ) return bad_data_double; // Compute the difference between the angles, and rescale them from // 0 to 360 @@ -129,7 +129,7 @@ d2 = rescale_deg(b - a, 0.0, 360.0); if ( min(d1, d2) < 90.0 ) d = min(d1, d2); else d = max(d1, d2) - 180.0; -return ( d ); +return d; } @@ -149,7 +149,7 @@ double d, a, b; // Check for bad data -if ( is_bad_data(uf) || is_bad_data(vf) || is_bad_data(uo) || is_bad_data(vo) ) return ( bad_data_double ); +if ( is_bad_data(uf) || is_bad_data(vf) || is_bad_data(uo) || is_bad_data(vo) ) return bad_data_double; // Normalize the vectors to unit length @@ -158,7 +158,7 @@ convert_u_v_to_unit(uo, vo); // Check for bad data in the normalized vectors -if ( is_bad_data(uf) || is_bad_data(vf) || is_bad_data(uo) || is_bad_data(vo) ) return ( bad_data_double ); +if ( is_bad_data(uf) || is_bad_data(vf) || is_bad_data(uo) || is_bad_data(vo) ) return bad_data_double; // Compute sums @@ -170,7 +170,7 @@ b = uo*uf + vo*vf; if(is_eq(a, 0.0) && is_eq(b, 0.0)) d = bad_data_double; else d = atan2d(a, b); -return ( d ); +return d; } @@ -192,7 +192,7 @@ else { } -return ( wdir ); +return wdir; } @@ -213,7 +213,7 @@ else { } -return ( wind ); +return wind; } diff --git a/src/basic/vx_math/hist.cc b/src/basic/vx_math/hist.cc index fb3cfa52c6..6ddd0034dc 100644 --- a/src/basic/vx_math/hist.cc +++ b/src/basic/vx_math/hist.cc @@ -78,11 +78,11 @@ Histogram & Histogram::operator=(const Histogram & h) { -if ( this == &h ) return ( * this ); +if ( this == &h ) return *this; assign(h); -return ( * this ); +return *this; } @@ -208,7 +208,7 @@ if ( (k < 0) || (k >= Nbins) ) { } -return ( Count[k] ); +return Count[k]; } @@ -270,7 +270,7 @@ int Histogram::total_bin_count() const { -if ( Nbins == 0 ) return ( 0 ); +if ( Nbins == 0 ) return 0; int j, t; @@ -283,7 +283,7 @@ for (j=0; j 0.3 ) ++a; -return ( a ); +return a; } diff --git a/src/basic/vx_math/nti.cc b/src/basic/vx_math/nti.cc index f89f3aa6a7..2fd4db712b 100644 --- a/src/basic/vx_math/nti.cc +++ b/src/basic/vx_math/nti.cc @@ -32,9 +32,9 @@ int gcdi(int a, int b) a = abs(a); b = abs(b); -if ( a == 0 ) return ( b ); +if ( a == 0 ) return b; -if ( b == 0 ) return ( a ); +if ( b == 0 ) return a; int c; @@ -51,7 +51,7 @@ do { -return ( a ); +return a; } @@ -66,7 +66,7 @@ int lcmi(int a, int b) a = abs(a); b = abs(b); -if ( (a == 0) || (b == 0) ) return ( 0 ); +if ( (a == 0) || (b == 0) ) return 0; int c, d; @@ -76,7 +76,7 @@ d = gcdi(a, b); c = (a/d)*b; -return ( c ); +return c; } diff --git a/src/basic/vx_math/ptile.cc b/src/basic/vx_math/ptile.cc index 31d3152284..dfeda84c14 100644 --- a/src/basic/vx_math/ptile.cc +++ b/src/basic/vx_math/ptile.cc @@ -91,7 +91,7 @@ if ( n > 0 ) { } -return ( p ); +return p; } @@ -150,7 +150,7 @@ if ( n > 0 ) { } -return ( p ); +return p; } @@ -166,12 +166,12 @@ const double *a = (const double *) p1; const double *b = (const double *) p2; -if ( (*a) < (*b) ) return ( -1 ); +if ( (*a) < (*b) ) return -1; -if ( (*a) > (*b) ) return ( 1 ); +if ( (*a) > (*b) ) return 1; -return ( 0 ); +return 0; } @@ -187,12 +187,12 @@ const float * a = (const float *) p1; const float * b = (const float *) p2; -if ( (*a) < (*b) ) return ( -1 ); +if ( (*a) < (*b) ) return -1; -if ( (*a) > (*b) ) return ( 1 ); +if ( (*a) > (*b) ) return 1; -return ( 0 ); +return 0; } @@ -211,7 +211,7 @@ int do_rank(const double *array, double *rank, int n) { -if ( n <= 1 ) return(0); +if ( n <= 1 ) return 0; int i, j, ties_current, ties_total, tie_rank_start = 0, tie_rank_end; double tie_rank_mean; @@ -314,11 +314,11 @@ int compare_rank(const void *p1, const void *p2) const RankInfo a = *((RankInfo *) p1); const RankInfo b = *((RankInfo *) p2); -if ( a.data[a.index] < b.data[b.index] ) return ( -1 ); +if ( a.data[a.index] < b.data[b.index] ) return -1; -if ( a.data[a.index] > b.data[b.index] ) return ( 1 ); +if ( a.data[a.index] > b.data[b.index] ) return 1; -return ( 0 ); +return 0; } diff --git a/src/basic/vx_math/pwl.cc b/src/basic/vx_math/pwl.cc index 0622c07312..26cf232dac 100644 --- a/src/basic/vx_math/pwl.cc +++ b/src/basic/vx_math/pwl.cc @@ -83,11 +83,11 @@ PiecewiseLinear & PiecewiseLinear::operator=(const PiecewiseLinear & pl) { -if ( this == &pl ) return ( *this ); +if ( this == &pl ) return *this; assign(pl); -return ( *this ); +return *this; } @@ -234,7 +234,7 @@ if ( k < 0 || k >= X.size() ) { } -return ( X[k] ); +return X[k]; } @@ -254,7 +254,7 @@ if ( k < 0 || k >= Y.size() ) { } -return ( Y[k] ); +return Y[k]; } @@ -283,9 +283,9 @@ double PiecewiseLinear::operator()(double t) const int N = X.size(); -if ( t < X[0] ) return ( Y[0] ); +if ( t < X[0] ) return Y[0]; -if ( t > X[N - 1] ) return ( Y[N - 1] ); +if ( t > X[N - 1] ) return Y[N - 1]; int j; @@ -293,7 +293,7 @@ for (j=0; j<(N - 1); ++j) { if ( (t >= X[j]) && (t <= X[j + 1]) ) { - return ( linear_interpolate(t, X[j], Y[j], X[j + 1], Y[j + 1]) ); + return linear_interpolate(t, X[j], Y[j], X[j + 1], Y[j + 1]); } @@ -335,7 +335,7 @@ m = (y_1 - y_0)/(x_1 - x_0); y = y_0 + (x - x_0)*m; -return ( y ); +return y; } diff --git a/src/basic/vx_math/viewgravity_to_string.cc b/src/basic/vx_math/viewgravity_to_string.cc index 9a7034fbcf..ad20fa7543 100644 --- a/src/basic/vx_math/viewgravity_to_string.cc +++ b/src/basic/vx_math/viewgravity_to_string.cc @@ -64,7 +64,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/basic/vx_math/vx_vector.cc b/src/basic/vx_math/vx_vector.cc index 3d9ea15a06..95a380baed 100644 --- a/src/basic/vx_math/vx_vector.cc +++ b/src/basic/vx_math/vx_vector.cc @@ -137,11 +137,11 @@ Vector & Vector::operator=(const Vector &v) { -if ( this == &v ) return ( * this ); +if ( this == &v ) return *this; assign(v); -return ( * this ); +return *this; } @@ -233,7 +233,7 @@ double Vector::abs() const { -return ( sqrt( X*X + Y*Y + Z*Z ) ); +return sqrt( X*X + Y*Y + Z*Z ); } @@ -602,7 +602,7 @@ double t; t = a.abs(); -return ( t ); +return t; } @@ -618,7 +618,7 @@ double t; t = a.abs_squared(); -return ( t ); +return t; } @@ -639,7 +639,7 @@ denom = (a.abs())*(b.abs()); deg = acosd(num/denom); -return ( deg ); +return deg; } @@ -655,7 +655,7 @@ double d; d = (a.x())*(b.x()) + (a.y())*(b.y()) + (a.z())*(b.z()); -return ( d ); +return d; } @@ -676,7 +676,7 @@ zz = (a.x())*(b.y()) - (a.y())*(b.x()); c.set_xyz(xx, yy, zz); -return ( c ); +return c; } @@ -692,7 +692,7 @@ double det; det = dot(cross(a, b), c); -return ( det ); +return det; } @@ -714,7 +714,7 @@ z = cosd(alt); v.set_xyz(x, y, z); -return ( v ); +return v; } @@ -736,7 +736,7 @@ z = 0.0; v.set_xyz(x, y, z); -return ( v ); +return v; } @@ -758,7 +758,7 @@ z = 0.0; v.set_xyz(x, y, z); -return ( v ); +return v; } @@ -782,7 +782,7 @@ z = cosd(lat); v.set_xyz(x, y, z); -return ( v ); +return v; } @@ -801,7 +801,7 @@ bn.normalize(); c = bn*dot(bn, a); -return ( c ); +return c; } @@ -817,7 +817,7 @@ Vector c; c = a - proj_onto(a, b); -return ( c ); +return c; } @@ -838,7 +838,7 @@ z = -(a.z()); c.set_xyz(x, y, z); -return ( c ); +return c; } @@ -859,7 +859,7 @@ z = t*(a.z()); b.set_xyz(x, y, z); -return ( b ); +return b; } @@ -881,7 +881,7 @@ z = t*(a.z()); b.set_xyz(x, y, z); -return ( b ); +return b; } @@ -911,7 +911,7 @@ z = (a.z())/t; b.set_xyz(x, y, z); -return ( b ); +return b; } @@ -942,7 +942,7 @@ z = (a.z())/t; b.set_xyz(x, y, z); -return ( b ); +return b; } @@ -963,7 +963,7 @@ z = t*(a.z()); b.set_xyz(x, y, z); -return ( b ); +return b; } @@ -985,7 +985,7 @@ z = t*(a.z()); b.set_xyz(x, y, z); -return ( b ); +return b; } @@ -1005,7 +1005,7 @@ z = (a.z()) + (b.z()); c.set_xyz(x, y, z); -return ( c ); +return c; } @@ -1026,7 +1026,7 @@ z = (a.z()) - (b.z()); c.set_xyz(x, y, z); -return ( c ); +return c; } @@ -1042,7 +1042,7 @@ Vector v; v.set_latlon(lat, lon); -return ( v ); +return v; } @@ -1097,7 +1097,7 @@ snprintf(junk, sizeof(junk), "%11.8f", v.z()); out << junk << " ]"; -return ( out ); +return out; } @@ -1113,7 +1113,7 @@ Vector b = a; b.normalize(); -return ( b ); +return b; } diff --git a/src/basic/vx_util/ascii_header.cc b/src/basic/vx_util/ascii_header.cc index f9a5228a98..639e50ed66 100644 --- a/src/basic/vx_util/ascii_header.cc +++ b/src/basic/vx_util/ascii_header.cc @@ -69,11 +69,11 @@ AsciiHeaderLine::AsciiHeaderLine(const AsciiHeaderLine &a) { AsciiHeaderLine & AsciiHeaderLine::operator=(const AsciiHeaderLine & a) { - if(this == &a) return(*this); + if(this == &a) return *this; assign(a); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -216,7 +216,7 @@ int AsciiHeaderLine::col_offset(const char *name, const int dim) const { if(!is_var_length()) { // Check for no match - if(!ColNames.has(name, offset)) return(bad_data_int); + if(!ColNames.has(name, offset)) return bad_data_int; } // Handle variable length lines @@ -232,7 +232,7 @@ int AsciiHeaderLine::col_offset(const char *name, const int dim) const { } // Check for no match - if(is_bad_data(match)) return(bad_data_int); + if(is_bad_data(match)) return bad_data_int; // Fixed columns before variable ones if(match < VarBegOffset) { @@ -277,7 +277,7 @@ int AsciiHeaderLine::col_offset(const char *name, const int dim) const { } } // end else - return(offset); + return offset; } //////////////////////////////////////////////////////////////////////// @@ -324,7 +324,7 @@ ConcatString AsciiHeaderLine::col_name(const int offset, int const dim) const { } // end else } - return(name); + return name; } //////////////////////////////////////////////////////////////////////// @@ -363,11 +363,11 @@ AsciiHeader::AsciiHeader(const char *version) { AsciiHeader & AsciiHeader::operator=(const AsciiHeader & a) { - if(this == &a) return(*this); + if(this == &a) return *this; assign(a); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -490,7 +490,7 @@ const AsciiHeaderLine * AsciiHeader::header(const char *version, exit(1); } - return(&(*it)); + return &(*it); } //////////////////////////////////////////////////////////////////////// @@ -500,7 +500,7 @@ int AsciiHeader::col_offset(const char *version, const char *data_type, const int dim) { const AsciiHeaderLine *line = header(version, data_type, line_type); - return(line->col_offset(name, dim)); + return line->col_offset(name, dim); } //////////////////////////////////////////////////////////////////////// @@ -510,7 +510,7 @@ ConcatString AsciiHeader::col_name(const char *version, const char *data_type, const int dim) { const AsciiHeaderLine *line = header(version, data_type, line_type); - return(line->col_name(offset, dim)); + return line->col_name(offset, dim); } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/ascii_table.cc b/src/basic/vx_util/ascii_table.cc index ff70dff926..1783a8b965 100644 --- a/src/basic/vx_util/ascii_table.cc +++ b/src/basic/vx_util/ascii_table.cc @@ -99,11 +99,11 @@ AsciiTable & AsciiTable::operator=(const AsciiTable & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -231,7 +231,7 @@ int n; n = r*Ncols + c; -return ( n ); +return n; } @@ -556,9 +556,9 @@ if ( (col_left < 0) || (col_left >= (Ncols - 1)) ) { } -if ( InterColumnSpace.empty() ) return ( 0 ); +if ( InterColumnSpace.empty() ) return 0; -return ( InterColumnSpace[col_left] ); +return InterColumnSpace[col_left]; } @@ -632,9 +632,9 @@ if ( (row_top < 0) || (row_top >= (Nrows - 1)) ) { } -if ( InterRowSpace.empty() ) return ( 0 ); +if ( InterRowSpace.empty() ) return 0; -return ( InterRowSpace[row_top] ); +return InterRowSpace[row_top]; } @@ -914,7 +914,7 @@ n = rc_to_n(r, c); // "rc_to_n" does range checking on r and c, // so we don't need to do that here -return ( Just[n] ); +return Just[n]; } @@ -1083,7 +1083,7 @@ int n; n = rc_to_n(r, c); // "rc_to_n" does range checking on r and c, // so we don't need to do that here -return ( e[n] ); // might be null +return e[n]; // might be null } @@ -1095,7 +1095,7 @@ int AsciiTable::col_width(int k) const { -if ( e.empty() ) return ( 0 ); +if ( e.empty() ) return 0; if ( (k < 0) || (k >= Ncols) ) { @@ -1105,7 +1105,7 @@ if ( (k < 0) || (k >= Ncols) ) { } -return ( ColWidth[k] ); +return ColWidth[k]; } @@ -1117,7 +1117,7 @@ int AsciiTable::max_col_width() const { -if ( e.empty() ) return ( 0 ); +if ( e.empty() ) return 0; int c, w, k; @@ -1131,7 +1131,7 @@ for (c=0; c " << "output header column " << to_upper(col_name) << " is empty!\n\n"; - return(na_string); + return na_string; } // Check for embedded whitespace @@ -1742,7 +1742,7 @@ ConcatString check_hdr_str(const ConcatString &col_name, exit(1); } - return(cs_tmp); + return cs_tmp; } diff --git a/src/basic/vx_util/asciitablejust_to_string.cc b/src/basic/vx_util/asciitablejust_to_string.cc index 50fbf4387e..d4bd88e02b 100644 --- a/src/basic/vx_util/asciitablejust_to_string.cc +++ b/src/basic/vx_util/asciitablejust_to_string.cc @@ -54,7 +54,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/basic/vx_util/comma_string.cc b/src/basic/vx_util/comma_string.cc index f7702df5f7..3caf47a931 100644 --- a/src/basic/vx_util/comma_string.cc +++ b/src/basic/vx_util/comma_string.cc @@ -77,7 +77,7 @@ ConcatString str; comma_string(i, str); -return ( str ); +return str; } diff --git a/src/basic/vx_util/command_line.cc b/src/basic/vx_util/command_line.cc index 2063d37d51..a4aecdd812 100644 --- a/src/basic/vx_util/command_line.cc +++ b/src/basic/vx_util/command_line.cc @@ -79,11 +79,11 @@ CLOptionInfo & CLOptionInfo::operator=(const CLOptionInfo & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -218,11 +218,11 @@ CLOptionInfoArray & CLOptionInfoArray::operator=(const CLOptionInfoArray & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -437,7 +437,7 @@ if ( (n < 0) || (n >= Nelements) ) { exit ( 1 ); } -return ( e[n] ); +return e[n]; } @@ -454,7 +454,7 @@ ConcatString cs = name; for (j=0; j= 0 ) return ( j ); + if ( option_index >= 0 ) return j; // // option not recognized @@ -804,7 +804,7 @@ for (j=0; j 100.0) rh = 100.0; } - return(rh); + return rh; } //////////////////////////////////////////////////////////////////////// @@ -181,7 +181,7 @@ double gop_by_lat(double lat) { 2.64e-3 * cos(2.0*lat) + 5.90e-10 * cos(2.0*lat) * cos(2.0*lat)); - return(gphi); + return gphi; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/data_line.cc b/src/basic/vx_util/data_line.cc index 0613376ff1..6c871d7a26 100644 --- a/src/basic/vx_util/data_line.cc +++ b/src/basic/vx_util/data_line.cc @@ -90,11 +90,11 @@ DataLine & DataLine::operator=(const DataLine & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -276,7 +276,7 @@ const char * DataLine::operator[](int k) const const char * c = get_item(k); -return ( c ); +return c; } @@ -288,7 +288,7 @@ int DataLine::max_item_width() const { -if ( Line.empty() ) return ( 0 ); +if ( Line.empty() ) return 0; int j, n, w; @@ -303,7 +303,7 @@ for (j=0; jlast_line_number() + 1; -return ( 1 ); +return 1; } @@ -373,7 +373,7 @@ clear(); ifstream & f = *(ldf->in); -if ( !f ) return ( 0 ); +if ( !f ) return 0; File = ldf; @@ -400,7 +400,7 @@ for( i=0; i 0) while ( f.get(c) ) { - if ( !f ) { clear(); return ( 0 ); } + if ( !f ) { clear(); return 0; } if ( c == '\n' ) break; } -if ( !f ) { clear(); return ( 0 ); } +if ( !f ) { clear(); return 0; } N_items = count; LineNumber = ldf->last_line_number() + 1; -return ( 1 ); +return 1; } @@ -484,9 +484,9 @@ bool DataLine::is_ok() const { -if ( N_items == 0 ) return ( false ); +if ( N_items == 0 ) return false; -return ( true ); +return true; } @@ -498,7 +498,7 @@ bool DataLine::is_header() const { -return ( IsHeader ); +return IsHeader; } @@ -522,7 +522,7 @@ bool DataLine::read_single_text_line(LineDataFile * ldf) { -if ( !ldf ) return ( false ); +if ( !ldf ) return false; #ifdef WITH_PYTHON @@ -532,7 +532,7 @@ if ( pldf ) { const bool status = read_py_single_text_line(pldf); - return ( status ); + return status; } @@ -540,7 +540,7 @@ if ( pldf ) { ifstream & f = *(ldf->in); -if ( !f ) return ( false ); +if ( !f ) return false; File = ldf; @@ -549,7 +549,7 @@ char c; while ( f.get(c) ) { - if ( !f ) return ( false ); + if ( !f ) return false; if ( c == '\n' ) { break; } @@ -557,10 +557,10 @@ while ( f.get(c) ) { } -if ( !f ) return ( false ); +if ( !f ) return false; -return ( true ); +return true; } @@ -579,11 +579,11 @@ ConcatString s; status = pldf->next_line(s); -if ( ! status ) return ( false ); +if ( ! status ) return false; Line = s.text(); -return ( true ); +return true; } @@ -697,7 +697,7 @@ met_open((*in), path); if ( !(*in) ) { - return ( 0 ); + return 0; } @@ -716,7 +716,7 @@ ShortFilename.assign(get_short_name(path)); Last_Line_Number = 0; -return ( 1 ); +return 1; } @@ -775,12 +775,12 @@ int LineDataFile::ok() const { -if ( !in ) return ( 0 ); +if ( !in ) return 0; -if ( !(*in) ) return ( 0 ); +if ( !(*in) ) return 0; -return ( 1 ); +return 1; } @@ -798,7 +798,7 @@ do { status = a.read_line(this); - if ( !status ) return ( 0 ); + if ( !status ) return 0; ++Last_Line_Number; @@ -807,7 +807,7 @@ do { } while ( !(a.is_ok()) ); -return ( 1 ); +return 1; } @@ -835,7 +835,7 @@ if ( ok() ) { } -return ( 1 ); +return 1; } @@ -876,14 +876,14 @@ do { status = a.read_fwf_line(this, wdth, n_wdth); - if ( !status ) return ( 0 ); + if ( !status ) return 0; ++Last_Line_Number; } while ( !(a.is_ok()) ); -return ( 1 ); +return 1; } @@ -903,7 +903,7 @@ ostream & operator<<(ostream & out, const DataLine & L) { -if ( L.n_items() == 0 ) return ( out ); +if ( L.n_items() == 0 ) return out; int j; @@ -918,7 +918,7 @@ out.put('\n'); out.flush(); -return ( out ); +return out; } @@ -930,7 +930,7 @@ Logger & operator<<(Logger & lgr, const DataLine & L) { -if ( L.n_items() == 0 ) return ( lgr ); +if ( L.n_items() == 0 ) return lgr; for (int j = 0; j < L.Items.size(); j++) { lgr << L.Items[j]; @@ -941,7 +941,7 @@ for (int j = 0; j < L.Items.size(); j++) { lgr << '\n'; -return ( lgr ); +return lgr; } diff --git a/src/basic/vx_util/data_plane.cc b/src/basic/vx_util/data_plane.cc index a46cb4664d..9a96e2358c 100644 --- a/src/basic/vx_util/data_plane.cc +++ b/src/basic/vx_util/data_plane.cc @@ -64,11 +64,11 @@ DataPlane::DataPlane(const DataPlane &d) { DataPlane & DataPlane::operator=(const DataPlane &d) { - if(this == &d) return(*this); + if(this == &d) return *this; assign(d); - return(*this); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -93,7 +93,7 @@ DataPlane & DataPlane::operator+=(const DataPlane &d) { Data[i] = v; } - return(*this); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -113,7 +113,7 @@ DataPlane & DataPlane::operator/=(const double v) { if(!is_bad_data(Data[i])) Data[i] /= v; } - return(*this); + return *this; } bool DataPlane::operator==(const DataPlane &d) const { @@ -451,7 +451,7 @@ int DataPlane::n_good_data() const { if(!is_bad_data(Data[j])) n++; } - return(n); + return n; } /////////////////////////////////////////////////////////////////////////////// @@ -640,7 +640,7 @@ int DataPlane::two_to_one(int x, int y, bool to_north) const { n = (to_north ? y : (Ny-1-y))*Nx + x; // don't change this! lots of downstream code depends on this! - return(n); + return n; } /////////////////////////////////////////////////////////////////////////////// @@ -680,15 +680,15 @@ bool DataPlane::f_is_on(int x, int y) const { // Return true if any corner of that box is non-zero. // - if( s_is_on(x, y) ) return(true); + if( s_is_on(x, y) ) return true; - if( (x > 0) && s_is_on(x - 1, y) ) return(true); + if( (x > 0) && s_is_on(x - 1, y) ) return true; - if( (x > 0) && (y > 0) && s_is_on(x - 1, y - 1) ) return(true); + if( (x > 0) && (y > 0) && s_is_on(x - 1, y - 1) ) return true; - if( (y > 0) && s_is_on(x, y - 1) ) return(true); + if( (y > 0) && s_is_on(x, y - 1) ) return true; - return(false); + return false; } /////////////////////////////////////////////////////////////////////////////// @@ -734,7 +734,7 @@ MaskPlane DataPlane::mask_plane() const { mp.buf()[i] = (is_bad_data(Data[i]) ? false : !is_eq(Data[i], 0.0)); } - return(mp); + return mp; } /////////////////////////////////////////////////////////////////////////////// @@ -934,7 +934,7 @@ const unsigned int mnw = (Nx + 1)/2; // for (j=0; j= Nplanes) ) { double value = Plane[p]->get(x, y); -return ( value ); +return value; } diff --git a/src/basic/vx_util/data_plane_util.cc b/src/basic/vx_util/data_plane_util.cc index 05bcf6736d..c6894ba54b 100644 --- a/src/basic/vx_util/data_plane_util.cc +++ b/src/basic/vx_util/data_plane_util.cc @@ -194,7 +194,7 @@ DataPlane smooth_field(const DataPlane &dp, smooth_field(dp, smooth_dp, mthd, width, shape, wrap_lon, t, gaussian); - return(smooth_dp); + return smooth_dp; } //////////////////////////////////////////////////////////////////////// @@ -495,7 +495,7 @@ DataPlane subtract(const DataPlane &dp1, const DataPlane &dp2) { } } - return(diff); + return diff; } //////////////////////////////////////////////////////////////////////// @@ -525,7 +525,7 @@ DataPlane normal_cdf(const DataPlane &dp, const DataPlane &mn, } } - return(cdf); + return cdf; } //////////////////////////////////////////////////////////////////////// @@ -561,7 +561,7 @@ DataPlane normal_cdf_inv(const double area, const DataPlane &mn, } } - return(cdf_inv); + return cdf_inv; } //////////////////////////////////////////////////////////////////////// @@ -597,7 +597,7 @@ DataPlane gradient(const DataPlane &dp, int dim, int delta) { } } - return(grad_dp); + return grad_dp; } //////////////////////////////////////////////////////////////////////// @@ -728,7 +728,7 @@ DataPlane distance_map(const DataPlane &dp) { // Mask the distance map with bad data values of the input field mask_bad_data(dm, dp); - return(dm); + return dm; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/file_exists.cc b/src/basic/vx_util/file_exists.cc index 9ffcde76fe..3c8831bcf5 100644 --- a/src/basic/vx_util/file_exists.cc +++ b/src/basic/vx_util/file_exists.cc @@ -38,9 +38,9 @@ int status; status = access(path, F_OK); -if ( status == 0 ) return ( true ); +if ( status == 0 ) return true; -return ( false ); +return false; } @@ -60,7 +60,7 @@ if ( empty(path) ) { } -if ( ! file_exists(path) ) return ( false ); +if ( ! file_exists(path) ) return false; struct stat s; @@ -73,9 +73,9 @@ if ( stat(path, &s) < 0 ) { } -if ( S_ISDIR(s.st_mode) ) return ( true ); +if ( S_ISDIR(s.st_mode) ) return true; -return ( false ); +return false; } diff --git a/src/basic/vx_util/file_linecount.cc b/src/basic/vx_util/file_linecount.cc index ad652df68d..f261540817 100644 --- a/src/basic/vx_util/file_linecount.cc +++ b/src/basic/vx_util/file_linecount.cc @@ -60,7 +60,7 @@ while ( in.get(c) ) { in.close(); -return ( count ); +return count; } diff --git a/src/basic/vx_util/file_size.cc b/src/basic/vx_util/file_size.cc index 95f2bccf16..be3c11c793 100644 --- a/src/basic/vx_util/file_size.cc +++ b/src/basic/vx_util/file_size.cc @@ -53,7 +53,7 @@ if ( status < 0 ) { // return the file size in bytes // -return( (long long) sbuf.st_size ); +return (long long) sbuf.st_size; } diff --git a/src/basic/vx_util/filename_suffix.cc b/src/basic/vx_util/filename_suffix.cc index 0e46663cc7..639a7bfc5a 100644 --- a/src/basic/vx_util/filename_suffix.cc +++ b/src/basic/vx_util/filename_suffix.cc @@ -35,7 +35,7 @@ ConcatString filename_suffix(const char * filename, bool make_lowercase) ConcatString suffix; char t; -if ( !filename || !(*filename) ) return ( suffix ); +if ( !filename || !(*filename) ) return suffix; const char * f = get_short_name(filename); // to avoid things like "./foo" @@ -51,7 +51,7 @@ const char * s = f + (m_strlen(f) - 1); while ( (s >= f) && (*s != '.') ) --s; -if ( s < f ) return ( suffix ); +if ( s < f ) return suffix; if ( make_lowercase ) { @@ -68,7 +68,7 @@ if ( make_lowercase ) { // done // -return ( suffix ); +return suffix; } diff --git a/src/basic/vx_util/get_filenames.cc b/src/basic/vx_util/get_filenames.cc index ae633f32f2..089e34788f 100644 --- a/src/basic/vx_util/get_filenames.cc +++ b/src/basic/vx_util/get_filenames.cc @@ -84,7 +84,7 @@ for (j=0; j " << "can't stat \"" << search_dir << "\"\n\n"; - return ( a ); + return a; } @@ -152,7 +152,7 @@ if ( S_ISDIR(sbuf.st_mode) ) { } } -return ( a ); +return a; } @@ -232,7 +232,7 @@ while ( (entry = readdir(directory)) != nullptr ) { closedir(directory); directory = (DIR *) 0; -return ( a ); +return a; } @@ -272,7 +272,7 @@ if ( keep && suffix ) { } -return(keep); +return keep; } diff --git a/src/basic/vx_util/grib_constants.cc b/src/basic/vx_util/grib_constants.cc index 9bf702f209..86d5a31089 100644 --- a/src/basic/vx_util/grib_constants.cc +++ b/src/basic/vx_util/grib_constants.cc @@ -41,7 +41,7 @@ bool is_precip_grib_code(int gc) { gc == apcp_grib_code || gc == ncpcp_grib_code || gc == acpcp_grib_code) match = true; - return(match); + return match; } /////////////////////////////////////////////////////////////////////////////// @@ -63,7 +63,7 @@ bool is_precip_grib_name(const char * grib_name) { 0 == strcmp(grib_name, ncpcp_grib_name) || 0 == strcmp(grib_name, acpcp_grib_name)); - return(match); + return match; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/interp_mthd.cc b/src/basic/vx_util/interp_mthd.cc index 06af350e9e..20d9dd3888 100644 --- a/src/basic/vx_util/interp_mthd.cc +++ b/src/basic/vx_util/interp_mthd.cc @@ -50,7 +50,7 @@ ConcatString interpmthd_to_string(const InterpMthd m) { default: out = interpmthd_none_str; break; } // switch - return(out); + return out; } /////////////////////////////////////////////////////////////////////////////// @@ -81,7 +81,7 @@ InterpMthd string_to_interpmthd(const char *mthd_str) { else if(strcmp(mthd_str, interpmthd_hira_str) == 0) m = InterpMthd_HiRA; else m = InterpMthd_None; - return(m); + return m; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index 4858682276..0840c29b6d 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -61,7 +61,7 @@ NumArray interp_points(const DataPlane &dp, const GridTemplate >, double x_dbl y = floor(y_dbl); } - return(interp_points(dp, gt, x, y)); + return interp_points(dp, gt, x, y); } //////////////////////////////////////////////////////////////////////// @@ -82,7 +82,7 @@ NumArray interp_points(const DataPlane &dp, const GridTemplate >, int x, int y } } - return(points); + return points; } //////////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ double interp_min_ll(const DataPlane &dp, int x_ll, int y_ll, int wdth, double t min_v = bad_data_double; } - return(min_v); + return min_v; } //////////////////////////////////////////////////////////////////////// @@ -218,7 +218,7 @@ double interp_max_ll(const DataPlane &dp, int x_ll, int y_ll, int wdth, double t max_v = bad_data_double; } - return(max_v); + return max_v; } //////////////////////////////////////////////////////////////////////// @@ -304,7 +304,7 @@ double interp_median_ll(const DataPlane &dp, int x_ll, int y_ll, int wdth, doubl if(data) { delete [] data; data = (double *) 0; } - return(median_v); + return median_v; } //////////////////////////////////////////////////////////////////////// @@ -377,7 +377,7 @@ double interp_uw_mean_ll(const DataPlane &dp, int x_ll, int y_ll, int wdth, doub uw_mean_v = sum/count; } - return(uw_mean_v); + return uw_mean_v; } //////////////////////////////////////////////////////////////////////// @@ -438,7 +438,7 @@ double interp_dw_mean(const DataPlane &dp, const GridTemplate >, return bad_data_double; } - return(numerator/wght_sum); + return numerator/wght_sum; } //////////////////////////////////////////////////////////////////////// @@ -533,7 +533,7 @@ double interp_ls_fit(const DataPlane &dp, const GridTemplate >, z = bad_data_double; } - return(z); + return z; } //////////////////////////////////////////////////////////////////////// @@ -624,7 +624,7 @@ double interp_gaussian(const DataPlane &dp, const DataPlane &g_dp, gaussian_value /= weight_sum; } - return(gaussian_value); + return gaussian_value; } //////////////////////////////////////////////////////////////////////// @@ -692,7 +692,7 @@ double interp_geog_match(const DataPlane &dp, const GridTemplate >, << interp_x << ", " << interp_y << ").\n"; } - return(interp_v); + return interp_v; } //////////////////////////////////////////////////////////////////////// @@ -729,7 +729,7 @@ double interp_nbrhd(const DataPlane &dp, const GridTemplate >, int x, int y, return bad_data_double; } - return((double) count_thr/count); + return (double) count_thr/count; } //////////////////////////////////////////////////////////////////////// @@ -756,7 +756,7 @@ double interp_bilin(const DataPlane &dp, bool wrap_lon, if(!(*mp)(x, y ) || !(*mp)(xp1, y ) || !(*mp)(x, y+1) || - !(*mp)(xp1, y+1)) return(bad_data_double); + !(*mp)(xp1, y+1)) return bad_data_double; } // Compute dx and dy @@ -831,7 +831,7 @@ double interp_bilin(const DataPlane &dp, bool wrap_lon, } } - return(bilin_v); + return bilin_v; } //////////////////////////////////////////////////////////////////////// @@ -849,13 +849,13 @@ double interp_xy(const DataPlane &dp, bool wrap_lon, int x, int y, // Check the optional mask if(mp) { - if(!(*mp)(x, y)) return(bad_data_double); + if(!(*mp)(x, y)) return bad_data_double; } if(x < 0 || x >= dp.nx() || y < 0 || y >= dp.ny()) v = bad_data_double; else v = dp.get(x, y); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -897,7 +897,7 @@ double interp_best(const DataPlane &dp, const GridTemplate >, return bad_data_double; } - return(min_v); + return min_v; } //////////////////////////////////////////////////////////////////////// @@ -1024,7 +1024,7 @@ double compute_sfc_interp(const DataPlane &dp, } delete gt; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -1082,7 +1082,7 @@ MaskPlane compute_sfc_mask(const GridTemplate >, int x, int y, mp.put((land_ok & topo_ok), gp->x, gp->y); } - return(mp); + return mp; } //////////////////////////////////////////////////////////////////////// @@ -1097,9 +1097,9 @@ double compute_horz_interp(const DataPlane &dp, const GridTemplateFactory::GridTemplates shape, bool wrap_lon, double interp_thresh, const SingleThresh *cat_thresh) { - return(compute_horz_interp(dp, obs_x, obs_y, obs_v, bad_data_double, + return compute_horz_interp(dp, obs_x, obs_y, obs_v, bad_data_double, bad_data_double, mthd, width, shape, wrap_lon, - interp_thresh, cat_thresh)); + interp_thresh, cat_thresh); } //////////////////////////////////////////////////////////////////////// @@ -1198,7 +1198,7 @@ double compute_horz_interp(const DataPlane &dp, } delete gt; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -1230,7 +1230,7 @@ double compute_vert_pinterp(double v1, double prs1, v_interp = v1 + ((v2-v1)*log(prs1/to_prs)/log(prs1/prs2)); - return(v_interp); + return v_interp; } //////////////////////////////////////////////////////////////////////// @@ -1266,7 +1266,7 @@ double compute_vert_zinterp(double v1, double lvl1, // Linearly interpolate betwen lvl_1 and lvl_2 v_interp = v1*(1.0 - d1/(d1+d2)) + v2*(1.0 - d2/(d1+d2)); - return(v_interp); + return v_interp; } //////////////////////////////////////////////////////////////////////// @@ -1285,7 +1285,7 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, dp2 = (in1.valid() > in2.valid() ? in1 : in2); // Check for matching valid times - if(dp1.valid() == dp2.valid()) return(dp1); + if(dp1.valid() == dp2.valid()) return dp1; // Range check the times if(dp1.valid() > to_ut || dp2.valid() < to_ut) { @@ -1372,7 +1372,7 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, } // end for y } // end for x - return(dp); + return dp; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/is_number.cc b/src/basic/vx_util/is_number.cc index f8f9f59388..0469b7d7c9 100644 --- a/src/basic/vx_util/is_number.cc +++ b/src/basic/vx_util/is_number.cc @@ -58,18 +58,18 @@ int is_number(const char * text) { -if ( !text ) return ( 0 ); +if ( !text ) return 0; -if ( text[0] == 0 ) return ( 0 ); +if ( text[0] == 0 ) return 0; -if ( is_integer(text) ) return ( 1 ); +if ( is_integer(text) ) return 1; -if ( is_float(text) ) return ( 1 ); +if ( is_float(text) ) return 1; -return ( 0 ); +return 0; } @@ -81,25 +81,25 @@ int is_integer(const char * text) { -if ( !text ) return ( 0 ); +if ( !text ) return 0; -if ( text[0] == 0 ) return ( 0 ); +if ( text[0] == 0 ) return 0; if ( is_sign_char(text[0]) ) { - if ( all_digits(text + 1) ) return ( 1 ); + if ( all_digits(text + 1) ) return 1; } else { - if ( all_digits(text) ) return ( 1 ); + if ( all_digits(text) ) return 1; } -return ( 0 ); +return 0; } @@ -111,11 +111,11 @@ int is_float(const char * text) { -if ( !text ) return ( 0 ); +if ( !text ) return 0; const int n = m_strlen(text); -if ( n == 0 ) return ( 0 ); +if ( n == 0 ) return 0; int j; @@ -130,7 +130,7 @@ const char * c = (const char *) 0; for (j=0; j 1 ) return ( 0 ); +if ( dp_count > 1 ) return 0; -return ( 1 ); +return 1; } @@ -229,7 +229,7 @@ char junk[128]; n = m_strlen(text); -if ( (exp_pos == 0) || (exp_pos == (n - 1)) ) return ( 0 ); +if ( (exp_pos == 0) || (exp_pos == (n - 1)) ) return 0; // // grab the mantissa @@ -242,7 +242,7 @@ substring(text, junk, 0, exp_pos - 1); // or a valid integer // -if ( !is_regular_float(junk) && !is_integer(junk) ) return ( 0 ); +if ( !is_regular_float(junk) && !is_integer(junk) ) return 0; // // grab the exponent @@ -254,12 +254,12 @@ substring(text, junk, exp_pos + 1, n - 1); // the exponent must be a valid integer // -if ( !is_integer(junk) ) return ( 0 ); +if ( !is_integer(junk) ) return 0; -return ( 1 ); +return 1; } @@ -271,9 +271,9 @@ int is_digit(const char c) { -if ( (c >= '0') && (c <= '9') ) return ( 1 ); +if ( (c >= '0') && (c <= '9') ) return 1; -return ( 0 ); +return 0; } @@ -285,20 +285,20 @@ int all_digits(const char * text) { -if ( text[0] == 0 ) return ( 0 ); +if ( text[0] == 0 ) return 0; const char * c = text; while ( *c ) { - if ( !(is_digit(*c)) ) return ( 0 ); + if ( !(is_digit(*c)) ) return 0; ++c; } -return ( 1 ); +return 1; } @@ -310,9 +310,9 @@ int is_sign_char(const char c) { -if ( (c == '+') || (c == '-') ) return ( 1 ); +if ( (c == '+') || (c == '-') ) return 1; -return ( 0 ); +return 0; } @@ -329,13 +329,13 @@ int j; for (j=0; j= Nelements) ) { exit ( 1 ); } -return ( e[n] ); +return e[n]; } diff --git a/src/basic/vx_util/make_path.cc b/src/basic/vx_util/make_path.cc index dd639112b6..b1d60feff0 100644 --- a/src/basic/vx_util/make_path.cc +++ b/src/basic/vx_util/make_path.cc @@ -42,7 +42,7 @@ int make_path(const char * path, int mode) { -if ( path_exists(path) ) return ( 1 ); +if ( path_exists(path) ) return 1; int j; int status; @@ -66,7 +66,7 @@ if (subpath) { if ( m_strlen(subpath) == 0 ) { if (subpath) { delete [] subpath; subpath = (char *) 0; } - return ( 0 ); + return 0; } if ( !(path_exists(subpath)) ) { @@ -79,9 +79,9 @@ status = mkdir(path, mode); if (subpath) { delete [] subpath; subpath = (char *) 0; } -if ( status < 0 ) return ( 0 ); +if ( status < 0 ) return 0; -return ( 1 ); +return 1; } @@ -109,7 +109,7 @@ if ( status < 0 ) { } - if ( errno == ENOENT ) return ( 0 ); + if ( errno == ENOENT ) return 0; // // must be some obscure error @@ -124,9 +124,9 @@ if ( status < 0 ) { status = S_ISDIR(sbuf.st_mode); -if ( status ) return ( 1 ); +if ( status ) return 1; -return ( 0 ); +return 0; } diff --git a/src/basic/vx_util/mask_poly.cc b/src/basic/vx_util/mask_poly.cc index e8786ae2d9..57d30dcedb 100644 --- a/src/basic/vx_util/mask_poly.cc +++ b/src/basic/vx_util/mask_poly.cc @@ -87,11 +87,11 @@ MaskPoly & MaskPoly::operator=(const MaskPoly & m) { -if ( this == &m ) return ( * this ); +if ( this == &m ) return *this; assign(m); -return ( * this ); +return *this; } @@ -229,7 +229,7 @@ if ( i < 0 || i >= Npoints ) { // done // -return ( Lat[i] ); +return Lat[i]; } @@ -257,7 +257,7 @@ adj_lon -= 360.0*floor((adj_lon + 180.0)/360.0); // done // -return ( adj_lon ); +return adj_lon; } @@ -520,7 +520,7 @@ for (j=0; j= 0) v = uniq_v[max_j]; else v = bad_data_double; - return(v); + return v; } @@ -912,7 +912,7 @@ double NumArray::min() const { - if(n_elements() == 0) return(bad_data_double); + if(n_elements() == 0) return bad_data_double; int j; @@ -923,7 +923,7 @@ double NumArray::min() const if(e[j] < min_v) min_v = e[j]; } - return(min_v); + return min_v; } @@ -935,7 +935,7 @@ double NumArray::max() const { - if(n_elements() == 0) return(bad_data_double); + if(n_elements() == 0) return bad_data_double; int j; @@ -946,7 +946,7 @@ double NumArray::max() const if(e[j] > max_v) max_v = e[j]; } - return(max_v); + return max_v; } @@ -964,7 +964,7 @@ double NumArray::range() const v2 = min(); v = (is_bad_data(v1) || is_bad_data(v2) ? bad_data_double : v1 - v2); - return(v); + return v; } @@ -982,7 +982,7 @@ int NumArray::n_valid() const if(!is_bad_data(e[j])) n_vld++; } - return(n_vld); + return n_vld; } @@ -996,14 +996,14 @@ ConcatString NumArray::serialize() const ConcatString s; - if(n_elements() == 0) return(s); + if(n_elements() == 0) return s; int j; s << e[0]; for(j=1; j= N ) return ( false ); +if ( index >= N ) return false; s_out = make_data_line(); -return ( true ); +return true; } @@ -612,7 +612,7 @@ bool is_na (PyObject * obj) { -if ( ! PyUnicode_Check(obj) ) return ( false ); +if ( ! PyUnicode_Check(obj) ) return false; // // now we know it's a string, the value had better be "NA" @@ -620,13 +620,13 @@ if ( ! PyUnicode_Check(obj) ) return ( false ); ConcatString s = pyobject_as_concat_string(obj); -if ( strcmp(s.text(), na_string.c_str()) == 0 ) return ( true ); +if ( strcmp(s.text(), na_string.c_str()) == 0 ) return true; // // done // -return ( false ); // control flow should never get here +return false; // control flow should never get here } diff --git a/src/basic/vx_util/read_fortran_binary.cc b/src/basic/vx_util/read_fortran_binary.cc index ae6e771bb4..86213ab2cb 100644 --- a/src/basic/vx_util/read_fortran_binary.cc +++ b/src/basic/vx_util/read_fortran_binary.cc @@ -84,9 +84,9 @@ int bytes; n_read = ::read(fd, local_buf, rec_pad_length); -if ( n_read == 0 ) return ( 0LL ); +if ( n_read == 0 ) return 0LL; -if ( n_read < 0 ) return ( (long long) (-1) ); +if ( n_read < 0 ) return (long long) (-1); if ( swap_endian ) shuffle(local_buf); @@ -149,7 +149,7 @@ if ( rec_size_2 != rec_size_1 ) { // done // -return ( rec_size_1 ); +return rec_size_1; } @@ -191,9 +191,9 @@ long long rec_size_1, rec_size_2; n_read = ::read(fd, local_buf, rec_pad_length); -if ( n_read == 0 ) return ( 0LL ); +if ( n_read == 0 ) return 0LL; -if ( n_read < 0 ) return ( (long long) (-1) ); +if ( n_read < 0 ) return (long long) (-1); if ( swap_endian ) shuffle(local_buf); @@ -272,7 +272,7 @@ if ( rec_size_2 != rec_size_1 ) { // done // -return ( rec_size_1 ); +return rec_size_1; } @@ -299,7 +299,7 @@ if ( rec_pad_length >= (int) sizeof(peek_buf) ) { n_read = read(fd, peek_buf, rec_pad_length); -if ( n_read == 0 ) return ( 0LL ); +if ( n_read == 0 ) return 0LL; switch ( rec_pad_length ) { @@ -335,7 +335,7 @@ if ( lseek(fd, -rec_pad_length, SEEK_CUR) < 0 ) { // done // -return ( size ); +return size; } @@ -368,7 +368,7 @@ if ( rec_pad_length == 4 ) { } -return ( s ); +return s; } @@ -450,7 +450,7 @@ if ( lseek(fd, 0, SEEK_SET) < 0 ) { // nope // -return ( status ); +return status; } @@ -518,7 +518,7 @@ if ( test_pad_len == 4 ) { } -if ( (rec_size_1 + 2*test_pad_len) > ((unsigned long long) file_size) ) return ( false ); +if ( (rec_size_1 + 2*test_pad_len) > ((unsigned long long) file_size) ) return false; // // lseek to the end of this data record @@ -575,7 +575,7 @@ if ( rec_size_1 == rec_size_2 ) status = true; // nope // -return ( status ); +return status; } diff --git a/src/basic/vx_util/smart_buffer.cc b/src/basic/vx_util/smart_buffer.cc index e8dfb9dced..63e277be90 100644 --- a/src/basic/vx_util/smart_buffer.cc +++ b/src/basic/vx_util/smart_buffer.cc @@ -84,11 +84,11 @@ SmartBuffer & SmartBuffer::operator=(const SmartBuffer & b) { -if ( this == &b ) return ( * this ); +if ( this == &b ) return *this; assign(b); -return ( * this ); +return *this; } @@ -206,7 +206,7 @@ n_read = ::read(fd, Buf, bytes); // done // -return ( n_read ); +return n_read; } @@ -236,7 +236,7 @@ n_written = ::write(fd, Buf, bytes); // done // -return ( n_written ); +return n_written; } diff --git a/src/basic/vx_util/string_fxns.cc b/src/basic/vx_util/string_fxns.cc index 3162cc0299..97284fb9bf 100644 --- a/src/basic/vx_util/string_fxns.cc +++ b/src/basic/vx_util/string_fxns.cc @@ -62,7 +62,7 @@ bool match_met_version(const char * check_version) { ConcatString check_major(parse_version_major(check_version)); ConcatString met_major(parse_version_major(met_version)); - return(check_major == met_major); + return (check_major == met_major); } @@ -105,7 +105,7 @@ ConcatString parse_version(const char * version, const int ndots) { cs = s.substr(0, i); - return(cs); + return cs; } @@ -113,7 +113,7 @@ ConcatString parse_version(const char * version, const int ndots) { ConcatString parse_version_major(const char * version) { - return(parse_version(version, 1)); + return parse_version(version, 1); } @@ -121,7 +121,7 @@ ConcatString parse_version_major(const char * version) { ConcatString parse_version_major_minor(const char * version) { - return(parse_version(version, 2)); + return parse_version(version, 2); } @@ -147,7 +147,7 @@ if ( path ) { } -return ( short_name ); +return short_name; } @@ -215,10 +215,10 @@ int num_tokens(const char *test_str, const char *separator) // // Check for an empty string // - if(!test_str) return(0); + if(!test_str) return 0; int buf_len = m_strlen(test_str); - if(buf_len <= 0) return(0); + if(buf_len <= 0) return 0; // // Initialize the temp string for use in tokenizing @@ -235,7 +235,7 @@ int num_tokens(const char *test_str, const char *separator) if(temp_str) { delete [] temp_str; temp_str = (char *) nullptr; } - return(n); + return n; } @@ -262,7 +262,7 @@ bool has_prefix(const char **prefix_list, int n_prefix, } } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -333,7 +333,7 @@ void regex_clean(char** &mat) ConcatString str_replace(const char* data, const char* old, const char* repl){ ConcatString ret; - if(!data) return(ret); + if(!data) return ret; string str = data; size_t pos = str.find( old ); @@ -348,7 +348,7 @@ ConcatString str_replace(const char* data, const char* old, const char* repl){ ConcatString str_replace_all(const char* data, const char* old, const char* repl){ ConcatString ret; - if(!data) return(ret); + if(!data) return ret; string str = data; while( string::npos != str.find(old) ) str = str_replace(str.c_str(), old, repl); @@ -400,7 +400,7 @@ int parse_thresh_index(const char *col_name) { exit(1); } - return(i); + return i; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index eae780063f..f32eca1053 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -54,11 +54,11 @@ ThreshArray::ThreshArray(const ThreshArray & a) { ThreshArray & ThreshArray::operator=(const ThreshArray & a) { - if(this == &a) return(*this); + if(this == &a) return *this; assign(a); - return(* this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -156,14 +156,14 @@ void ThreshArray::extend(int n, bool exact) { bool ThreshArray::operator==(const ThreshArray &ta) const { // Check for the same length - if(Nelements != ta.n()) return(false); + if(Nelements != ta.n()) return false; // Check for equality of individual elements for(int i=0; i tol ) return ( false ); +if ( t > tol ) return false; // // check diagonal elements @@ -504,13 +504,13 @@ if ( t > tol ) return ( false ); t = fabs(M11) + fabs(M22) + fabs(M33) - 3.0; -if ( t > tol ) return ( false ); +if ( t > tol ) return false; // // yup // -return ( true ); +return true; } @@ -641,7 +641,7 @@ bool SO3::is_z_axis() const { -if ( is_identity() ) return ( true ); +if ( is_identity() ) return true; double ax, ay, az; double angle; @@ -677,7 +677,7 @@ bool SO3::is_x_axis() const { -if ( is_identity() ) return ( true ); +if ( is_identity() ) return true; double ax, ay, az; double angle; @@ -713,7 +713,7 @@ bool SO3::is_y_axis() const { -if ( is_identity() ) return ( true ); +if ( is_identity() ) return true; double ax, ay, az; double angle; @@ -784,7 +784,7 @@ switch ( k ) { } -return ( x ); +return x; } @@ -821,7 +821,7 @@ c.M32 = (a.M31)*(b.M12) + (a.M32)*(b.M22) + (a.M33)*(b.M32); c.M33 = (a.M31)*(b.M13) + (a.M32)*(b.M23) + (a.M33)*(b.M33); -return ( c ); +return c; } @@ -852,11 +852,11 @@ int my_signum(double t) { -if ( t > 0.0 ) return ( 1 ); +if ( t > 0.0 ) return 1; -if ( t < 0.0 ) return ( -1 ); +if ( t < 0.0 ) return -1; -return ( 0 ); +return 0; } From 4d60e06abf4e55afde5b5594805ebf507e8fbb33 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 01:33:05 +0000 Subject: [PATCH 012/114] #2673 Removed the redundant parentheses with return --- src/libcode/vx_afm/afm.cc | 54 ++--- src/libcode/vx_afm/afm_keywords.cc | 4 +- src/libcode/vx_afm/afm_line.cc | 36 +-- src/libcode/vx_afm/afm_token.cc | 6 +- src/libcode/vx_afm/afmkeyword_to_string.cc | 2 +- src/libcode/vx_afm/afmtokentype_to_string.cc | 2 +- .../vx_analysis_util/analysis_utils.cc | 6 +- src/libcode/vx_analysis_util/by_case_info.cc | 4 +- src/libcode/vx_analysis_util/mode_atts.cc | 220 +++++++++--------- src/libcode/vx_analysis_util/mode_job.cc | 12 +- src/libcode/vx_analysis_util/mode_line.cc | 194 +++++++-------- src/libcode/vx_analysis_util/stat_job.cc | 130 +++++------ src/libcode/vx_analysis_util/stat_line.cc | 96 ++++---- src/libcode/vx_analysis_util/time_series.cc | 6 +- src/libcode/vx_bool_calc/bool_calc.cc | 2 +- src/libcode/vx_bool_calc/make_program.cc | 4 +- src/libcode/vx_bool_calc/token.cc | 8 +- src/libcode/vx_bool_calc/token_stack.cc | 16 +- src/libcode/vx_bool_calc/tokenizer.cc | 6 +- .../vx_bool_calc/tokentype_to_string.cc | 20 +- src/libcode/vx_color/color.cc | 24 +- src/libcode/vx_color/color_list.cc | 14 +- src/libcode/vx_color/color_table.cc | 58 ++--- src/libcode/vx_color/my_color_scanner.cc | 94 ++++---- src/libcode/vx_data2d/data2d_utils.cc | 12 +- src/libcode/vx_data2d/data_class.cc | 10 +- src/libcode/vx_data2d/level_info.cc | 4 +- src/libcode/vx_data2d/leveltype_to_string.cc | 18 +- src/libcode/vx_data2d/table_lookup.cc | 48 ++-- src/libcode/vx_data2d/var_info.cc | 14 +- .../vx_data2d_factory/data2d_factory.cc | 8 +- .../vx_data2d_factory/data2d_factory_utils.cc | 14 +- src/libcode/vx_data2d_factory/is_bufr_file.cc | 8 +- src/libcode/vx_data2d_factory/is_grib_file.cc | 8 +- .../vx_data2d_factory/parse_file_list.cc | 8 +- .../vx_data2d_factory/var_info_factory.cc | 8 +- src/libcode/vx_data2d_grib/data2d_grib.cc | 34 +-- .../vx_data2d_grib/data2d_grib_utils.cc | 56 ++--- src/libcode/vx_data2d_grib/grib_classes.cc | 80 +++---- src/libcode/vx_data2d_grib/grib_strings.cc | 22 +- src/libcode/vx_data2d_grib/grib_utils.cc | 4 +- src/libcode/vx_data2d_grib/var_info_grib.cc | 8 +- src/libcode/vx_data2d_grib2/data2d_grib2.cc | 6 +- src/libcode/vx_data2d_grib2/var_info_grib2.cc | 4 +- src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc | 12 +- src/libcode/vx_data2d_nc_cf/nc_cf_file.cc | 4 +- src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc | 24 +- src/libcode/vx_data2d_nc_met/data2d_nc_met.cc | 14 +- src/libcode/vx_data2d_nc_met/get_met_grid.cc | 26 +-- src/libcode/vx_data2d_nc_met/met_file.cc | 12 +- .../vx_data2d_nc_met/var_info_nc_met.cc | 24 +- src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc | 10 +- src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc | 14 +- .../vx_data2d_nc_wrf/var_info_nc_wrf.cc | 30 +-- src/libcode/vx_data2d_nc_wrf/wrf_file.cc | 48 ++-- src/libcode/vx_data2d_python/data2d_python.cc | 22 +- .../dataplane_from_numpy_array.cc | 2 +- .../vx_data2d_python/dataplane_from_xarray.cc | 2 +- .../vx_data2d_python/python_dataplane.cc | 22 +- .../vx_data2d_python/var_info_python.cc | 16 +- src/libcode/vx_data2d_ugrid/data2d_ugrid.cc | 14 +- src/libcode/vx_data2d_ugrid/var_info_ugrid.cc | 24 +- src/libcode/vx_geodesy/spheroid.cc | 28 +-- src/libcode/vx_gis/dbf_file.cc | 32 +-- src/libcode/vx_gis/shapetype_to_string.cc | 2 +- src/libcode/vx_gis/shp_file.cc | 24 +- src/libcode/vx_gis/shp_point_record.cc | 4 +- src/libcode/vx_gis/shp_poly_record.cc | 10 +- src/libcode/vx_gnomon/gnomon.cc | 8 +- src/libcode/vx_grid/earth_rotation.cc | 4 +- src/libcode/vx_grid/find_grid_by_name.cc | 38 +-- src/libcode/vx_grid/gaussian_grid.cc | 18 +- src/libcode/vx_grid/goes_grid.cc | 18 +- src/libcode/vx_grid/grid_base.cc | 6 +- src/libcode/vx_grid/latlon_grid.cc | 16 +- src/libcode/vx_grid/lc_grid.cc | 42 ++-- src/libcode/vx_grid/merc_grid.cc | 40 ++-- src/libcode/vx_grid/rot_latlon_grid.cc | 16 +- src/libcode/vx_grid/semilatlon_grid.cc | 18 +- src/libcode/vx_grid/st_grid.cc | 42 ++-- src/libcode/vx_grid/tcrmw_grid.cc | 4 +- src/libcode/vx_grid/unstructured_grid.cc | 2 +- src/libcode/vx_gsl_prob/gsl_bvn.cc | 6 +- src/libcode/vx_gsl_prob/gsl_cdf.cc | 28 +-- src/libcode/vx_gsl_prob/gsl_randist.cc | 6 +- src/libcode/vx_gsl_prob/gsl_statistics.cc | 4 +- src/libcode/vx_gsl_prob/gsl_wavelet2d.cc | 4 +- src/libcode/vx_nav/nav.cc | 20 +- src/libcode/vx_nc_util/nc_utils.cc | 6 +- src/libcode/vx_nc_util/nc_var_info.cc | 12 +- src/libcode/vx_pb_util/do_blocking.cc | 10 +- src/libcode/vx_pb_util/do_unblocking.cc | 4 +- src/libcode/vx_plot_util/map_region.cc | 12 +- src/libcode/vx_plot_util/vx_plot_util.cc | 4 +- .../pointdata_from_array.cc | 18 +- .../vx_pointdata_python/pointdata_python.cc | 2 +- .../vx_pointdata_python/python_pointdata.cc | 16 +- src/libcode/vx_ps/documentmedia_to_string.cc | 2 +- .../vx_ps/documentorientation_to_string.cc | 2 +- src/libcode/vx_ps/fontfamily_to_string.cc | 2 +- src/libcode/vx_ps/ps_text.cc | 14 +- src/libcode/vx_ps/table_helper.cc | 30 +-- src/libcode/vx_ps/vx_ps.cc | 30 +-- src/libcode/vx_pxm/pbm.cc | 28 +-- src/libcode/vx_pxm/pcm.cc | 46 ++-- src/libcode/vx_pxm/pgm.cc | 40 ++-- src/libcode/vx_pxm/ppm.cc | 30 +-- src/libcode/vx_pxm/pxm_base.cc | 6 +- src/libcode/vx_pxm/pxm_utils.cc | 2 +- src/libcode/vx_python3_utils/python3_dict.cc | 12 +- src/libcode/vx_python3_utils/python3_list.cc | 2 +- src/libcode/vx_python3_utils/python3_numpy.cc | 2 +- .../vx_python3_utils/python3_script.cc | 4 +- src/libcode/vx_python3_utils/python3_util.cc | 14 +- src/libcode/vx_regrid/vx_regrid.cc | 12 +- src/libcode/vx_regrid/vx_regrid_budget.cc | 2 +- src/libcode/vx_render/ps_filter.cc | 8 +- src/libcode/vx_render/renderinfo.cc | 6 +- src/libcode/vx_render/uc_queue.cc | 18 +- 119 files changed, 1274 insertions(+), 1274 deletions(-) diff --git a/src/libcode/vx_afm/afm.cc b/src/libcode/vx_afm/afm.cc index e40ac65256..ed39ff5611 100644 --- a/src/libcode/vx_afm/afm.cc +++ b/src/libcode/vx_afm/afm.cc @@ -99,11 +99,11 @@ AfmBBox & AfmBBox::operator=(const AfmBBox & b) { -if ( this == &b ) return ( * this ); +if ( this == &b ) return *this; assign(b); -return ( * this ); +return *this; } @@ -237,11 +237,11 @@ LigatureInfo & LigatureInfo::operator=(const LigatureInfo & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -408,11 +408,11 @@ AfmCharMetrics & AfmCharMetrics::operator=(const AfmCharMetrics & m) { -if ( this == &m ) return ( * this ); +if ( this == &m ) return *this; assign(m); -return ( * this ); +return *this; } @@ -606,11 +606,11 @@ PCC & PCC::operator=(const PCC & p) { -if ( this == &p ) return ( * this ); +if ( this == &p ) return *this; assign(p); -return ( * this ); +return *this; } @@ -746,11 +746,11 @@ AfmCompositeInfo & AfmCompositeInfo::operator=(const AfmCompositeInfo & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -910,11 +910,11 @@ KPX & KPX::operator=(const KPX & p) { -if ( this == &p ) return ( * this ); +if ( this == &p ) return *this; assign(p); -return ( * this ); +return *this; } @@ -1053,11 +1053,11 @@ Afm & Afm::operator=(const Afm & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -1448,7 +1448,7 @@ delete in; in = (ifstream *) 0; line_number = 0; -return ( 1 ); +return 1; } @@ -2133,13 +2133,13 @@ int j; for (j=0; j 0) && !(model.has(c)) ) return ( 0 ); +if ( (model.n_elements() > 0) && !(model.has(c)) ) return 0; c = L.desc(); -if ( (desc.n_elements() > 0) && !(desc.has(c)) ) return ( 0 ); +if ( (desc.n_elements() > 0) && !(desc.has(c)) ) return 0; c = L.fcst_thr(); -if ( (fcst_thr.n_elements() > 0) && !(fcst_thr.has(c)) ) return ( 0 ); +if ( (fcst_thr.n_elements() > 0) && !(fcst_thr.has(c)) ) return 0; c = L.obs_thr(); -if ( (obs_thr.n_elements() > 0) && !(obs_thr.has(c)) ) return ( 0 ); +if ( (obs_thr.n_elements() > 0) && !(obs_thr.has(c)) ) return 0; c = L.fcst_var(); -if ( (fcst_var.n_elements() > 0) && !(fcst_var.has(c)) ) return ( 0 ); +if ( (fcst_var.n_elements() > 0) && !(fcst_var.has(c)) ) return 0; c = L.fcst_units(); -if ( (fcst_units.n_elements() > 0) && !(fcst_units.has(c)) ) return ( 0 ); +if ( (fcst_units.n_elements() > 0) && !(fcst_units.has(c)) ) return 0; c = L.fcst_lev(); -if ( (fcst_lev.n_elements() > 0) && !(fcst_lev.has(c)) ) return ( 0 ); +if ( (fcst_lev.n_elements() > 0) && !(fcst_lev.has(c)) ) return 0; c = L.obs_var(); -if ( (obs_var.n_elements() > 0) && !(obs_var.has(c)) ) return ( 0 ); +if ( (obs_var.n_elements() > 0) && !(obs_var.has(c)) ) return 0; c = L.obs_units(); -if ( (obs_units.n_elements() > 0) && !(obs_units.has(c)) ) return ( 0 ); +if ( (obs_units.n_elements() > 0) && !(obs_units.has(c)) ) return 0; c = L.obs_lev(); -if ( (obs_lev.n_elements() > 0) && !(obs_lev.has(c)) ) return ( 0 ); +if ( (obs_lev.n_elements() > 0) && !(obs_lev.has(c)) ) return 0; // @@ -1450,43 +1450,43 @@ if ( (obs_lev.n_elements() > 0) && !(obs_lev.has(c)) ) return ( 0 ); i = L.fcst_lead(); -if ( (fcst_lead.n_elements() > 0) && !(fcst_lead.has(i)) ) return ( 0 ); +if ( (fcst_lead.n_elements() > 0) && !(fcst_lead.has(i)) ) return 0; i = L.fcst_valid_hour(); -if ( (fcst_valid_hour.n_elements() > 0) && !(fcst_valid_hour.has(i)) ) return ( 0 ); +if ( (fcst_valid_hour.n_elements() > 0) && !(fcst_valid_hour.has(i)) ) return 0; i = L.fcst_init_hour(); -if ( (fcst_init_hour.n_elements() > 0) && !(fcst_init_hour.has(i)) ) return ( 0 ); +if ( (fcst_init_hour.n_elements() > 0) && !(fcst_init_hour.has(i)) ) return 0; i = L.fcst_accum(); -if ( (fcst_accum.n_elements() > 0) && !(fcst_accum.has(i)) ) return ( 0 ); +if ( (fcst_accum.n_elements() > 0) && !(fcst_accum.has(i)) ) return 0; i = L.obs_lead(); -if ( (obs_lead.n_elements() > 0) && !(obs_lead.has(i)) ) return ( 0 ); +if ( (obs_lead.n_elements() > 0) && !(obs_lead.has(i)) ) return 0; i = L.obs_valid_hour(); -if ( (obs_valid_hour.n_elements() > 0) && !(obs_valid_hour.has(i)) ) return ( 0 ); +if ( (obs_valid_hour.n_elements() > 0) && !(obs_valid_hour.has(i)) ) return 0; i = L.obs_init_hour(); -if ( (obs_init_hour.n_elements() > 0) && !(obs_init_hour.has(i)) ) return ( 0 ); +if ( (obs_init_hour.n_elements() > 0) && !(obs_init_hour.has(i)) ) return 0; i = L.obs_accum(); -if ( (obs_accum.n_elements() > 0) && !(obs_accum.has(i)) ) return ( 0 ); +if ( (obs_accum.n_elements() > 0) && !(obs_accum.has(i)) ) return 0; i = L.fcst_rad(); -if ( (fcst_rad.n_elements() > 0) && !(fcst_rad.has(i)) ) return ( 0 ); +if ( (fcst_rad.n_elements() > 0) && !(fcst_rad.has(i)) ) return 0; i = L.obs_rad(); -if ( (obs_rad.n_elements() > 0) && !(obs_rad.has(i)) ) return ( 0 ); +if ( (obs_rad.n_elements() > 0) && !(obs_rad.has(i)) ) return 0; // @@ -1497,9 +1497,9 @@ if ( fcst_valid_min_set || fcst_valid_max_set ) { t = L.fcst_valid(); - if ( fcst_valid_min_set && (t < fcst_valid_min) ) return ( 0 ); + if ( fcst_valid_min_set && (t < fcst_valid_min) ) return 0; - if ( fcst_valid_max_set && (t > fcst_valid_max) ) return ( 0 ); + if ( fcst_valid_max_set && (t > fcst_valid_max) ) return 0; } @@ -1507,9 +1507,9 @@ if ( obs_valid_min_set || obs_valid_max_set ) { t = L.obs_valid(); - if ( obs_valid_min_set && (t < obs_valid_min) ) return ( 0 ); + if ( obs_valid_min_set && (t < obs_valid_min) ) return 0; - if ( obs_valid_max_set && (t > obs_valid_max) ) return ( 0 ); + if ( obs_valid_max_set && (t > obs_valid_max) ) return 0; } @@ -1517,9 +1517,9 @@ if ( fcst_init_min_set || fcst_init_max_set ) { t = L.fcst_init(); - if ( fcst_init_min_set && (t < fcst_init_min) ) return ( 0 ); + if ( fcst_init_min_set && (t < fcst_init_min) ) return 0; - if ( fcst_init_max_set && (t > fcst_init_max) ) return ( 0 ); + if ( fcst_init_max_set && (t > fcst_init_max) ) return 0; } @@ -1527,9 +1527,9 @@ if ( obs_init_min_set || obs_init_max_set ) { t = L.obs_init(); - if ( obs_init_min_set && (t < obs_init_min) ) return ( 0 ); + if ( obs_init_min_set && (t < obs_init_min) ) return 0; - if ( obs_init_max_set && (t > obs_init_max) ) return ( 0 ); + if ( obs_init_max_set && (t > obs_init_max) ) return 0; } @@ -1542,9 +1542,9 @@ if ( area_min_set || area_max_set ) { i = L.area(); - if ( !is_bad_data( i ) && area_min_set && (i < area_min) ) return ( 0 ); + if ( !is_bad_data( i ) && area_min_set && (i < area_min) ) return 0; - if ( !is_bad_data( i ) && area_max_set && (i > area_max) ) return ( 0 ); + if ( !is_bad_data( i ) && area_max_set && (i > area_max) ) return 0; } @@ -1552,9 +1552,9 @@ if ( area_thresh_min_set || area_thresh_max_set ) { i = L.area_thresh(); - if ( !is_bad_data( i ) && area_thresh_min_set && (i < area_thresh_min) ) return ( 0 ); + if ( !is_bad_data( i ) && area_thresh_min_set && (i < area_thresh_min) ) return 0; - if ( !is_bad_data( i ) && area_thresh_max_set && (i > area_thresh_max) ) return ( 0 ); + if ( !is_bad_data( i ) && area_thresh_max_set && (i > area_thresh_max) ) return 0; } @@ -1562,9 +1562,9 @@ if ( intersection_area_min_set || intersection_area_max_set ) { i = L.intersection_area(); - if ( !is_bad_data( i ) && intersection_area_min_set && (i < intersection_area_min) ) return ( 0 ); + if ( !is_bad_data( i ) && intersection_area_min_set && (i < intersection_area_min) ) return 0; - if ( !is_bad_data( i ) && intersection_area_max_set && (i > intersection_area_max) ) return ( 0 ); + if ( !is_bad_data( i ) && intersection_area_max_set && (i > intersection_area_max) ) return 0; } @@ -1572,9 +1572,9 @@ if ( union_area_min_set || union_area_max_set ) { i = L.union_area(); - if ( !is_bad_data( i ) && union_area_min_set && (i < union_area_min) ) return ( 0 ); + if ( !is_bad_data( i ) && union_area_min_set && (i < union_area_min) ) return 0; - if ( !is_bad_data( i ) && union_area_max_set && (i > union_area_max) ) return ( 0 ); + if ( !is_bad_data( i ) && union_area_max_set && (i > union_area_max) ) return 0; } @@ -1582,9 +1582,9 @@ if ( symmetric_diff_min_set || symmetric_diff_max_set ) { i = L.symmetric_diff(); - if ( !is_bad_data( i ) && symmetric_diff_min_set && (i < symmetric_diff_min) ) return ( 0 ); + if ( !is_bad_data( i ) && symmetric_diff_min_set && (i < symmetric_diff_min) ) return 0; - if ( !is_bad_data( i ) && symmetric_diff_max_set && (i > symmetric_diff_max) ) return ( 0 ); + if ( !is_bad_data( i ) && symmetric_diff_max_set && (i > symmetric_diff_max) ) return 0; } @@ -1597,9 +1597,9 @@ if ( centroid_x_min_set || centroid_x_max_set ) { x = L.centroid_x(); - if ( !is_bad_data( x ) && centroid_x_min_set && (x < centroid_x_min) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_x_min_set && (x < centroid_x_min) ) return 0; - if ( !is_bad_data( x ) && centroid_x_max_set && (x > centroid_x_max) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_x_max_set && (x > centroid_x_max) ) return 0; } @@ -1607,9 +1607,9 @@ if ( centroid_y_min_set || centroid_y_max_set ) { x = L.centroid_y(); - if ( !is_bad_data( x ) && centroid_y_min_set && (x < centroid_y_min) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_y_min_set && (x < centroid_y_min) ) return 0; - if ( !is_bad_data( x ) && centroid_y_max_set && (x > centroid_y_max) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_y_max_set && (x > centroid_y_max) ) return 0; } @@ -1617,9 +1617,9 @@ if ( centroid_lat_min_set || centroid_lat_max_set ) { x = L.centroid_lat(); - if ( !is_bad_data( x ) && centroid_lat_min_set && (x < centroid_lat_min) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_lat_min_set && (x < centroid_lat_min) ) return 0; - if ( !is_bad_data( x ) && centroid_lat_max_set && (x > centroid_lat_max) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_lat_max_set && (x > centroid_lat_max) ) return 0; } @@ -1627,9 +1627,9 @@ if ( centroid_lon_min_set || centroid_lon_max_set ) { x = L.centroid_lon(); - if ( !is_bad_data( x ) && centroid_lon_min_set && (x < centroid_lon_min) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_lon_min_set && (x < centroid_lon_min) ) return 0; - if ( !is_bad_data( x ) && centroid_lon_max_set && (x > centroid_lon_max) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_lon_max_set && (x > centroid_lon_max) ) return 0; } @@ -1637,9 +1637,9 @@ if ( axis_ang_min_set || axis_ang_max_set ) { x = L.axis_ang(); - if ( !is_bad_data( x ) && axis_ang_min_set && (x < axis_ang_min) ) return ( 0 ); + if ( !is_bad_data( x ) && axis_ang_min_set && (x < axis_ang_min) ) return 0; - if ( !is_bad_data( x ) && axis_ang_max_set && (x > axis_ang_max) ) return ( 0 ); + if ( !is_bad_data( x ) && axis_ang_max_set && (x > axis_ang_max) ) return 0; } @@ -1647,9 +1647,9 @@ if ( length_min_set || length_max_set ) { x = L.length(); - if ( !is_bad_data( x ) && length_min_set && (x < length_min) ) return ( 0 ); + if ( !is_bad_data( x ) && length_min_set && (x < length_min) ) return 0; - if ( !is_bad_data( x ) && length_max_set && (x > length_max) ) return ( 0 ); + if ( !is_bad_data( x ) && length_max_set && (x > length_max) ) return 0; } @@ -1657,9 +1657,9 @@ if ( width_min_set || width_max_set ) { x = L.width(); - if ( !is_bad_data( x ) && width_min_set && (x < width_min) ) return ( 0 ); + if ( !is_bad_data( x ) && width_min_set && (x < width_min) ) return 0; - if ( !is_bad_data( x ) && width_max_set && (x > width_max) ) return ( 0 ); + if ( !is_bad_data( x ) && width_max_set && (x > width_max) ) return 0; } @@ -1667,9 +1667,9 @@ if ( aspect_ratio_min_set || aspect_ratio_max_set ) { x = L.aspect_ratio(); - if ( !is_bad_data( x ) && aspect_ratio_min_set && (x < aspect_ratio_min) ) return ( 0 ); + if ( !is_bad_data( x ) && aspect_ratio_min_set && (x < aspect_ratio_min) ) return 0; - if ( !is_bad_data( x ) && aspect_ratio_max_set && (x > aspect_ratio_max) ) return ( 0 ); + if ( !is_bad_data( x ) && aspect_ratio_max_set && (x > aspect_ratio_max) ) return 0; } @@ -1677,9 +1677,9 @@ if ( curvature_min_set || curvature_max_set ) { x = L.curvature(); - if ( !is_bad_data( x ) && curvature_min_set && (x < curvature_min) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_min_set && (x < curvature_min) ) return 0; - if ( !is_bad_data( x ) && curvature_max_set && (x > curvature_max) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_max_set && (x > curvature_max) ) return 0; } @@ -1687,9 +1687,9 @@ if ( curvature_x_min_set || curvature_x_max_set ) { x = L.curvature_x(); - if ( !is_bad_data( x ) && curvature_x_min_set && (x < curvature_x_min) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_x_min_set && (x < curvature_x_min) ) return 0; - if ( !is_bad_data( x ) && curvature_x_max_set && (x > curvature_x_max) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_x_max_set && (x > curvature_x_max) ) return 0; } @@ -1697,9 +1697,9 @@ if ( curvature_y_min_set || curvature_y_max_set ) { x = L.curvature_y(); - if ( !is_bad_data( x ) && curvature_y_min_set && (x < curvature_y_min) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_y_min_set && (x < curvature_y_min) ) return 0; - if ( !is_bad_data( x ) && curvature_y_max_set && (x > curvature_y_max) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_y_max_set && (x > curvature_y_max) ) return 0; } @@ -1707,9 +1707,9 @@ if ( complexity_min_set || complexity_max_set ) { x = L.complexity(); - if ( !is_bad_data( x ) && complexity_min_set && (x < complexity_min) ) return ( 0 ); + if ( !is_bad_data( x ) && complexity_min_set && (x < complexity_min) ) return 0; - if ( !is_bad_data( x ) && complexity_max_set && (x > complexity_max) ) return ( 0 ); + if ( !is_bad_data( x ) && complexity_max_set && (x > complexity_max) ) return 0; } @@ -1717,9 +1717,9 @@ if ( intensity_10_min_set || intensity_10_max_set ) { x = L.intensity_10(); - if ( !is_bad_data( x ) && intensity_10_min_set && (x < intensity_10_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_10_min_set && (x < intensity_10_min) ) return 0; - if ( !is_bad_data( x ) && intensity_10_max_set && (x > intensity_10_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_10_max_set && (x > intensity_10_max) ) return 0; } @@ -1727,9 +1727,9 @@ if ( intensity_25_min_set || intensity_25_max_set ) { x = L.intensity_25(); - if ( !is_bad_data( x ) && intensity_25_min_set && (x < intensity_25_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_25_min_set && (x < intensity_25_min) ) return 0; - if ( !is_bad_data( x ) && intensity_25_max_set && (x > intensity_25_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_25_max_set && (x > intensity_25_max) ) return 0; } @@ -1737,9 +1737,9 @@ if ( intensity_50_min_set || intensity_50_max_set ) { x = L.intensity_50(); - if ( !is_bad_data( x ) && intensity_50_min_set && (x < intensity_50_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_50_min_set && (x < intensity_50_min) ) return 0; - if ( !is_bad_data( x ) && intensity_50_max_set && (x > intensity_50_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_50_max_set && (x > intensity_50_max) ) return 0; } @@ -1747,9 +1747,9 @@ if ( intensity_75_min_set || intensity_75_max_set ) { x = L.intensity_75(); - if ( !is_bad_data( x ) && intensity_75_min_set && (x < intensity_75_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_75_min_set && (x < intensity_75_min) ) return 0; - if ( !is_bad_data( x ) && intensity_75_max_set && (x > intensity_75_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_75_max_set && (x > intensity_75_max) ) return 0; } @@ -1757,9 +1757,9 @@ if ( intensity_90_min_set || intensity_90_max_set ) { x = L.intensity_90(); - if ( !is_bad_data( x ) && intensity_90_min_set && (x < intensity_90_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_90_min_set && (x < intensity_90_min) ) return 0; - if ( !is_bad_data( x ) && intensity_90_max_set && (x > intensity_90_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_90_max_set && (x > intensity_90_max) ) return 0; } @@ -1767,9 +1767,9 @@ if ( intensity_user_min_set || intensity_user_max_set ) { x = L.intensity_user(); - if ( !is_bad_data( x ) && intensity_user_min_set && (x < intensity_user_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_user_min_set && (x < intensity_user_min) ) return 0; - if ( !is_bad_data( x ) && intensity_user_max_set && (x > intensity_user_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_user_max_set && (x > intensity_user_max) ) return 0; } @@ -1777,9 +1777,9 @@ if ( intensity_sum_min_set || intensity_sum_max_set ) { x = L.intensity_sum(); - if ( !is_bad_data( x ) && intensity_sum_min_set && (x < intensity_sum_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_sum_min_set && (x < intensity_sum_min) ) return 0; - if ( !is_bad_data( x ) && intensity_sum_max_set && (x > intensity_sum_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intensity_sum_max_set && (x > intensity_sum_max) ) return 0; } @@ -1787,9 +1787,9 @@ if ( centroid_dist_min_set || centroid_dist_max_set ) { x = L.centroid_dist(); - if ( !is_bad_data( x ) && centroid_dist_min_set && (x < centroid_dist_min) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_dist_min_set && (x < centroid_dist_min) ) return 0; - if ( !is_bad_data( x ) && centroid_dist_max_set && (x > centroid_dist_max) ) return ( 0 ); + if ( !is_bad_data( x ) && centroid_dist_max_set && (x > centroid_dist_max) ) return 0; } @@ -1797,9 +1797,9 @@ if ( boundary_dist_min_set || boundary_dist_max_set ) { x = L.boundary_dist(); - if ( !is_bad_data( x ) && boundary_dist_min_set && (x < boundary_dist_min) ) return ( 0 ); + if ( !is_bad_data( x ) && boundary_dist_min_set && (x < boundary_dist_min) ) return 0; - if ( !is_bad_data( x ) && boundary_dist_max_set && (x > boundary_dist_max) ) return ( 0 ); + if ( !is_bad_data( x ) && boundary_dist_max_set && (x > boundary_dist_max) ) return 0; } @@ -1807,9 +1807,9 @@ if ( convex_hull_dist_min_set || convex_hull_dist_max_set ) { x = L.convex_hull_dist(); - if ( !is_bad_data( x ) && convex_hull_dist_min_set && (x < convex_hull_dist_min) ) return ( 0 ); + if ( !is_bad_data( x ) && convex_hull_dist_min_set && (x < convex_hull_dist_min) ) return 0; - if ( !is_bad_data( x ) && convex_hull_dist_max_set && (x > convex_hull_dist_max) ) return ( 0 ); + if ( !is_bad_data( x ) && convex_hull_dist_max_set && (x > convex_hull_dist_max) ) return 0; } @@ -1817,9 +1817,9 @@ if ( angle_diff_min_set || angle_diff_max_set ) { x = L.angle_diff(); - if ( !is_bad_data( x ) && angle_diff_min_set && (x < angle_diff_min) ) return ( 0 ); + if ( !is_bad_data( x ) && angle_diff_min_set && (x < angle_diff_min) ) return 0; - if ( !is_bad_data( x ) && angle_diff_max_set && (x > angle_diff_max) ) return ( 0 ); + if ( !is_bad_data( x ) && angle_diff_max_set && (x > angle_diff_max) ) return 0; } @@ -1827,9 +1827,9 @@ if ( aspect_diff_min_set || aspect_diff_max_set ) { x = L.aspect_diff(); - if ( !is_bad_data( x ) && aspect_diff_min_set && (x < aspect_diff_min) ) return ( 0 ); + if ( !is_bad_data( x ) && aspect_diff_min_set && (x < aspect_diff_min) ) return 0; - if ( !is_bad_data( x ) && aspect_diff_max_set && (x > aspect_diff_max) ) return ( 0 ); + if ( !is_bad_data( x ) && aspect_diff_max_set && (x > aspect_diff_max) ) return 0; } @@ -1837,9 +1837,9 @@ if ( area_ratio_min_set || area_ratio_max_set ) { x = L.area_ratio(); - if ( !is_bad_data( x ) && area_ratio_min_set && (x < area_ratio_min) ) return ( 0 ); + if ( !is_bad_data( x ) && area_ratio_min_set && (x < area_ratio_min) ) return 0; - if ( !is_bad_data( x ) && area_ratio_max_set && (x > area_ratio_max) ) return ( 0 ); + if ( !is_bad_data( x ) && area_ratio_max_set && (x > area_ratio_max) ) return 0; } @@ -1847,9 +1847,9 @@ if ( intersection_over_area_min_set || intersection_over_area_max_set ) { x = L.intersection_over_area(); - if ( !is_bad_data( x ) && intersection_over_area_min_set && (x < intersection_over_area_min) ) return ( 0 ); + if ( !is_bad_data( x ) && intersection_over_area_min_set && (x < intersection_over_area_min) ) return 0; - if ( !is_bad_data( x ) && intersection_over_area_max_set && (x > intersection_over_area_max) ) return ( 0 ); + if ( !is_bad_data( x ) && intersection_over_area_max_set && (x > intersection_over_area_max) ) return 0; } @@ -1857,9 +1857,9 @@ if ( curvature_ratio_min_set || curvature_ratio_max_set ) { x = L.curvature_ratio(); - if ( !is_bad_data( x ) && curvature_ratio_min_set && (x < curvature_ratio_min) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_ratio_min_set && (x < curvature_ratio_min) ) return 0; - if ( !is_bad_data( x ) && curvature_ratio_max_set && (x > curvature_ratio_max) ) return ( 0 ); + if ( !is_bad_data( x ) && curvature_ratio_max_set && (x > curvature_ratio_max) ) return 0; } @@ -1867,9 +1867,9 @@ if ( complexity_ratio_min_set || complexity_ratio_max_set ) { x = L.complexity_ratio(); - if ( !is_bad_data( x ) && complexity_ratio_min_set && (x < complexity_ratio_min) ) return ( 0 ); + if ( !is_bad_data( x ) && complexity_ratio_min_set && (x < complexity_ratio_min) ) return 0; - if ( !is_bad_data( x ) && complexity_ratio_max_set && (x > complexity_ratio_max) ) return ( 0 ); + if ( !is_bad_data( x ) && complexity_ratio_max_set && (x > complexity_ratio_max) ) return 0; } @@ -1877,9 +1877,9 @@ if ( percentile_intensity_ratio_min_set || percentile_intensity_ratio_max_set ) x = L.percentile_intensity_ratio(); - if ( !is_bad_data( x ) && percentile_intensity_ratio_min_set && (x < percentile_intensity_ratio_min) ) return ( 0 ); + if ( !is_bad_data( x ) && percentile_intensity_ratio_min_set && (x < percentile_intensity_ratio_min) ) return 0; - if ( !is_bad_data( x ) && percentile_intensity_ratio_max_set && (x > percentile_intensity_ratio_max) ) return ( 0 ); + if ( !is_bad_data( x ) && percentile_intensity_ratio_max_set && (x > percentile_intensity_ratio_max) ) return 0; } @@ -1887,9 +1887,9 @@ if ( interest_min_set || interest_max_set ) { x = L.interest(); - if ( !is_bad_data( x ) && interest_min_set && (x < interest_min) ) return ( 0 ); + if ( !is_bad_data( x ) && interest_min_set && (x < interest_min) ) return 0; - if ( !is_bad_data( x ) && interest_max_set && (x > interest_max) ) return ( 0 ); + if ( !is_bad_data( x ) && interest_max_set && (x > interest_max) ) return 0; } @@ -1900,7 +1900,7 @@ if ( interest_min_set || interest_max_set ) { if ( poly ) { - if ( !(poly->latlon_is_inside_dege(L.centroid_lat(), L.centroid_lon())) ) return ( 0 ); + if ( !(poly->latlon_is_inside_dege(L.centroid_lat(), L.centroid_lon())) ) return 0; } @@ -1910,7 +1910,7 @@ if ( poly ) { // ok, already // -return ( 1 ); +return 1; } diff --git a/src/libcode/vx_analysis_util/mode_job.cc b/src/libcode/vx_analysis_util/mode_job.cc index b2e0b1339f..cc291eb511 100644 --- a/src/libcode/vx_analysis_util/mode_job.cc +++ b/src/libcode/vx_analysis_util/mode_job.cc @@ -91,11 +91,11 @@ BasicModeAnalysisJob & BasicModeAnalysisJob::operator=(const BasicModeAnalysisJo { -if ( this == &aj ) return ( * this ); +if ( this == &aj ) return *this; assign_basic_job(aj); -return ( * this ); +return *this; } @@ -412,11 +412,11 @@ SummaryJob & SummaryJob::operator=(const SummaryJob & job) { -if ( this == &job ) return ( * this ); +if ( this == &job ) return *this; assign(job); -return ( * this ); +return *this; } @@ -740,11 +740,11 @@ ByCaseJob & ByCaseJob::operator=(const ByCaseJob & job) { -if ( this == &job ) return ( * this ); +if ( this == &job ) return *this; assign(job); -return ( * this ); +return *this; } diff --git a/src/libcode/vx_analysis_util/mode_line.cc b/src/libcode/vx_analysis_util/mode_line.cc index 5a7319565f..ef758dad20 100644 --- a/src/libcode/vx_analysis_util/mode_line.cc +++ b/src/libcode/vx_analysis_util/mode_line.cc @@ -87,11 +87,11 @@ ModeLine & ModeLine::operator=(const ModeLine & L) { -if ( this == &L ) return ( * this ); +if ( this == &L ) return *this; assign(L); -return ( * this ); +return *this; } @@ -219,7 +219,7 @@ if ( !status || n_items() == 0 ) { clear(); - return ( 0 ); + return 0; } @@ -231,7 +231,7 @@ if ( strcmp(get_item(0), "VERSION") == 0 ) { HdrFlag = true; - return ( 1 ); + return 1; } // @@ -240,7 +240,7 @@ if ( strcmp(get_item(0), "VERSION") == 0 ) { HdrLine = METHdrTable.header(get_item(0), "MODE", "OBJ"); -return ( 1 ); +return 1; } @@ -252,7 +252,7 @@ bool ModeLine::is_ok() const { -return ( DataLine::is_ok() ); +return DataLine::is_ok(); } @@ -264,7 +264,7 @@ bool ModeLine::is_header() const { -return ( HdrFlag ); +return HdrFlag; } @@ -296,8 +296,8 @@ if ( is_bad_data(offset) ) { // Return bad data string for no match // -if ( is_bad_data(offset) ) return ( bad_data_str ); -else return ( get_item(offset, check_na) ); +if ( is_bad_data(offset) ) return bad_data_str; +else return get_item(offset, check_na); } @@ -313,7 +313,7 @@ const char * ModeLine::get_item(int offset, bool check_na) const // Range check // -if ( offset < 0 || offset >= N_items ) return ( bad_data_str ); +if ( offset < 0 || offset >= N_items ) return bad_data_str; const char * c = DataLine::get_item(offset); @@ -321,8 +321,8 @@ const char * c = DataLine::get_item(offset); // Check for the NA string and interpret it as bad data // -if ( check_na && strcmp(c, na_str) == 0 ) return ( bad_data_str ); -else return ( c ); +if ( check_na && strcmp(c, na_str) == 0 ) return bad_data_str; +else return c; } @@ -336,7 +336,7 @@ const char * ModeLine::version() const const char * c = get_item("VERSION", false); -return ( c ); +return c; } @@ -350,7 +350,7 @@ const char * ModeLine::model() const const char * c = get_item("MODEL", false); -return ( c ); +return c; } @@ -364,7 +364,7 @@ const char * ModeLine::desc() const const char * c = get_item("DESC", false); -return ( c ); +return c; } @@ -382,7 +382,7 @@ const char * c = get_item("FCST_LEAD"); s = timestring_to_sec(c); -return ( s ); +return s; } @@ -400,7 +400,7 @@ const char * c = get_item("FCST_VALID"); t = timestring_to_unix(c); -return ( t ); +return t; } @@ -412,7 +412,7 @@ int ModeLine::fcst_valid_hour() const { -return ( unix_to_sec_of_day(fcst_valid()) ); +return unix_to_sec_of_day(fcst_valid()); } @@ -448,7 +448,7 @@ int ModeLine::fcst_init_hour() const { -return ( unix_to_sec_of_day(fcst_init()) ); +return unix_to_sec_of_day(fcst_init()); } @@ -466,7 +466,7 @@ const char * c = get_item("FCST_ACCUM"); s = timestring_to_sec(c); -return ( s ); +return s; } @@ -484,7 +484,7 @@ const char * c = get_item("OBS_LEAD"); s = timestring_to_sec(c); -return ( s ); +return s; } @@ -502,7 +502,7 @@ const char * c = get_item("OBS_VALID"); t = timestring_to_unix(c); -return ( t ); +return t; } @@ -514,7 +514,7 @@ int ModeLine::obs_valid_hour() const { -return ( unix_to_sec_of_day(obs_valid()) ); +return unix_to_sec_of_day(obs_valid()); } @@ -550,7 +550,7 @@ int ModeLine::obs_init_hour() const { -return ( unix_to_sec_of_day(obs_init()) ); +return unix_to_sec_of_day(obs_init()); } @@ -568,7 +568,7 @@ const char * c = get_item("OBS_ACCUM"); s = timestring_to_sec(c); -return ( s ); +return s; } @@ -586,7 +586,7 @@ const char * c = get_item("FCST_RAD"); i = atoi(c); -return ( i ); +return i; } @@ -600,7 +600,7 @@ const char * ModeLine::fcst_thr() const const char * c = get_item("FCST_THR", false); -return ( c ); +return c; } @@ -618,7 +618,7 @@ const char * c = get_item("OBS_RAD"); i = atoi(c); -return ( i ); +return i; } @@ -632,7 +632,7 @@ const char * ModeLine::obs_thr() const const char * c = get_item("OBS_THR", false); -return ( c ); +return c; } @@ -646,7 +646,7 @@ const char * ModeLine::fcst_var() const const char * c = get_item("FCST_VAR", false); -return ( c ); +return c; } @@ -660,7 +660,7 @@ const char * ModeLine::fcst_units() const const char * c = get_item("FCST_UNITS", false); -return ( c ); +return c; } @@ -674,7 +674,7 @@ const char * ModeLine::fcst_lev() const const char * c = get_item("FCST_LEV", false); -return ( c ); +return c; } @@ -688,7 +688,7 @@ const char * ModeLine::obs_var() const const char * c = get_item("OBS_VAR", false); -return ( c ); +return c; } @@ -702,7 +702,7 @@ const char * ModeLine::obs_units() const const char * c = get_item("OBS_UNITS", false); -return ( c ); +return c; } @@ -716,7 +716,7 @@ const char * ModeLine::obs_lev() const const char * c = get_item("OBS_LEV", false); -return ( c ); +return c; } @@ -732,7 +732,7 @@ const char * ModeLine::object_id() const const char * c = get_item("OBJECT_ID", false); -return ( c ); +return c; } @@ -748,7 +748,7 @@ const char * ModeLine::object_cat() const const char * c = get_item("OBJECT_CAT", false); -return ( c ); +return c; } @@ -764,7 +764,7 @@ int ModeLine::is_fcst() const // has to be a single object, not a pair // -if ( is_pair() ) return ( 0 ); +if ( is_pair() ) return 0; // // look for an "F" or "CF" at the start of the OBJECT_ID field @@ -774,11 +774,11 @@ if ( is_pair() ) return ( 0 ); const char * c = object_id(); -if ( c[0] == 'F' ) return ( 1 ); +if ( c[0] == 'F' ) return 1; -if ( strncmp(c, "CF", 2) == 0 ) return ( 1 ); +if ( strncmp(c, "CF", 2) == 0 ) return 1; -return ( 0 ); +return 0; } @@ -794,7 +794,7 @@ int ModeLine::is_obs() const // has to be a single object, not a pair // -if ( is_pair() ) return ( 0 ); +if ( is_pair() ) return 0; // // look for an "O" or "CO" at the start of the OBJECT_ID field @@ -804,15 +804,15 @@ if ( is_pair() ) return ( 0 ); const char * c = object_id(); -if ( c[0] == 'O' ) return ( 1 ); +if ( c[0] == 'O' ) return 1; -if ( strncmp(c, "CO", 2) == 0 ) return ( 1 ); +if ( strncmp(c, "CO", 2) == 0 ) return 1; // // nope // -return ( 0 ); +return 0; } @@ -832,9 +832,9 @@ int ModeLine::is_single() const const char * c = object_id(); -if ( strchr(c, '_') ) return ( 0 ); +if ( strchr(c, '_') ) return 0; -return ( 1 ); +return 1; } @@ -850,7 +850,7 @@ int status; status = is_single(); -return ( !status ); +return !status; } @@ -870,9 +870,9 @@ int ModeLine::is_simple() const const char * c = object_id(); -if ( c[0] == 'C' ) return ( 0 ); +if ( c[0] == 'C' ) return 0; -return ( 1 ); +return 1; } @@ -888,7 +888,7 @@ int status; status = is_simple(); -return ( !status ); +return !status; } @@ -904,7 +904,7 @@ int ModeLine::is_matched() const // has to be a single object (not a pair) // -if ( is_pair() ) return ( 0 ); +if ( is_pair() ) return 0; // // look for a number > 0 in the OBJECT_CAT field @@ -917,9 +917,9 @@ const char * c = object_cat(); k = atoi(c + 2); // skip the leading "CF" or "CO" in the OBJECT_CAT field -if ( k > 0 ) return ( 1 ); +if ( k > 0 ) return 1; -return ( 0 ); +return 0; } @@ -935,7 +935,7 @@ int status; status = is_matched(); -return ( !status ); +return !status; } @@ -947,8 +947,8 @@ int ModeLine::simple_obj_number() const { -if ( !is_single() ) return ( -1 ); -if ( !is_simple() ) return ( -1 ); +if ( !is_single() ) return -1; +if ( !is_simple() ) return -1; int k; @@ -959,7 +959,7 @@ k = atoi(c + 1); // skip leading 'F' or 'O' --k; // object numbers start at zero -return ( k ); +return k; } @@ -971,7 +971,7 @@ int ModeLine::cluster_obj_number() const { -if ( is_pair() ) return ( -1 ); +if ( is_pair() ) return -1; int k; @@ -982,7 +982,7 @@ k = atoi(c + 2); // skip leading "CF" or "CO" --k; // object numbers start at zero -return ( k ); +return k; } @@ -996,7 +996,7 @@ bool ModeLine::pair_obj_numbers(int & nfcst, int & nobs) const nfcst = nobs = -1; -if ( is_single() ) return ( false ); +if ( is_single() ) return false; const char * c = object_id(); const char * u = (const char *) 0; @@ -1036,7 +1036,7 @@ else nobs = atoi(u + 1); // ok // -return ( true ); +return true; } @@ -1054,7 +1054,7 @@ const char * c = get_item("CENTROID_X"); x = atof(c); -return ( x ); +return x; } @@ -1072,7 +1072,7 @@ const char * c = get_item("CENTROID_Y"); x = atof(c); -return ( x ); +return x; } @@ -1090,7 +1090,7 @@ const char * c = get_item("CENTROID_LAT"); x = atof(c); -return ( x ); +return x; } @@ -1108,7 +1108,7 @@ const char * c = get_item("CENTROID_LON"); x = atof(c); -return ( x ); +return x; } @@ -1126,7 +1126,7 @@ const char * c = get_item("AXIS_ANG"); x = atof(c); -return ( x ); +return x; } @@ -1144,7 +1144,7 @@ const char * c = get_item("LENGTH"); x = atof(c); -return ( x ); +return x; } @@ -1162,7 +1162,7 @@ const char * c = get_item("WIDTH"); x = atof(c); -return ( x ); +return x; } @@ -1181,7 +1181,7 @@ const char * w = get_item("WIDTH"); x = atof(w)/atof(l); -return ( x ); +return x; } @@ -1199,7 +1199,7 @@ const char * c = get_item("AREA"); a = atoi(c); -return ( a ); +return a; } @@ -1217,7 +1217,7 @@ const char * c = get_item("AREA_THRESH"); a = atoi(c); -return ( a ); +return a; } @@ -1234,7 +1234,7 @@ const char * c = get_item("CURVATURE"); x = atof(c); -return ( x ); +return x; } @@ -1252,7 +1252,7 @@ const char * c = get_item("CURVATURE_X"); x = atof(c); -return ( x ); +return x; } @@ -1270,7 +1270,7 @@ const char * c = get_item("CURVATURE_Y"); x = atof(c); -return ( x ); +return x; } @@ -1288,7 +1288,7 @@ const char * c = get_item("COMPLEXITY"); x = atof(c); -return ( x ); +return x; } @@ -1306,7 +1306,7 @@ const char * c = get_item("INTENSITY_10"); x = atof(c); -return ( x ); +return x; } @@ -1324,7 +1324,7 @@ const char * c = get_item("INTENSITY_25"); x = atof(c); -return ( x ); +return x; } @@ -1342,7 +1342,7 @@ const char * c = get_item("INTENSITY_50"); x = atof(c); -return ( x ); +return x; } @@ -1360,7 +1360,7 @@ const char * c = get_item("INTENSITY_75"); x = atof(c); -return ( x ); +return x; } @@ -1378,7 +1378,7 @@ const char * c = get_item("INTENSITY_90"); x = atof(c); -return ( x ); +return x; } @@ -1402,7 +1402,7 @@ const char * c = get_item(i+1); x = atof(c); -return ( x ); +return x; } @@ -1420,7 +1420,7 @@ const char * c = get_item("INTENSITY_SUM"); x = atof(c); -return ( x ); +return x; } @@ -1438,7 +1438,7 @@ const char * c = get_item("CENTROID_DIST"); x = atof(c); -return ( x ); +return x; } @@ -1456,7 +1456,7 @@ const char * c = get_item("BOUNDARY_DIST"); x = atof(c); -return ( x ); +return x; } @@ -1474,7 +1474,7 @@ const char * c = get_item("CONVEX_HULL_DIST"); x = atof(c); -return ( x ); +return x; } @@ -1492,7 +1492,7 @@ const char * c = get_item("ANGLE_DIFF"); x = atof(c); -return ( x ); +return x; } @@ -1510,7 +1510,7 @@ const char * c = get_item("ASPECT_DIFF"); x = atof(c); -return ( x ); +return x; } @@ -1528,7 +1528,7 @@ const char * c = get_item("AREA_RATIO"); x = atof(c); -return ( x ); +return x; } @@ -1546,7 +1546,7 @@ const char * c = get_item("INTERSECTION_AREA"); i = atoi(c); -return ( i ); +return i; } @@ -1564,7 +1564,7 @@ const char * c = get_item("UNION_AREA"); i = atoi(c); -return ( i ); +return i; } @@ -1582,7 +1582,7 @@ const char * c = get_item("SYMMETRIC_DIFF"); i = atoi(c); -return ( i ); +return i; } @@ -1600,7 +1600,7 @@ const char * c = get_item("INTERSECTION_OVER_AREA"); x = atof(c); -return ( x ); +return x; } @@ -1618,7 +1618,7 @@ const char * c = get_item("CURVATURE_RATIO"); x = atof(c); -return ( x ); +return x; } @@ -1636,7 +1636,7 @@ const char * c = get_item("COMPLEXITY_RATIO"); x = atof(c); -return ( x ); +return x; } @@ -1654,7 +1654,7 @@ const char * c = get_item("PERCENTILE_INTENSITY_RATIO"); x = atof(c); -return ( x ); +return x; } @@ -1672,7 +1672,7 @@ const char * c = get_item("INTEREST"); x = atof(c); -return ( x ); +return x; } diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 963271d905..fa7ab2bdd0 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -64,11 +64,11 @@ STATAnalysisJob::STATAnalysisJob(const STATAnalysisJob & aj) { STATAnalysisJob & STATAnalysisJob::operator=( const STATAnalysisJob & aj) { - if(this == &aj ) return ( * this ); + if(this == &aj ) return *this; assign(aj); - return (* this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -664,41 +664,41 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // model // if(model.n() > 0) { - if(!(model.has(L.model()))) return(0); + if(!(model.has(L.model()))) return 0; } // // desc // if(desc.n() > 0) { - if(!(desc.has(L.desc()))) return(0); + if(!(desc.has(L.desc()))) return 0; } // // fcst_lead (in seconds) // if(fcst_lead.n() > 0) { - if(!fcst_lead.has(L.fcst_lead())) return(0); + if(!fcst_lead.has(L.fcst_lead())) return 0; } // // fcst_valid_beg // if((fcst_valid_beg > 0) && (L.fcst_valid_beg() < fcst_valid_beg)) - return(0); + return 0; // // fcst_valid_end // if((fcst_valid_end > 0) && (L.fcst_valid_end() > fcst_valid_end)) - return(0); + return 0; // // fcst_valid_inc // if(fcst_valid_inc.n() > 0) { if(!fcst_valid_inc.has(L.fcst_valid_beg()) || - !fcst_valid_inc.has(L.fcst_valid_end())) return(0); + !fcst_valid_inc.has(L.fcst_valid_end())) return 0; } // @@ -706,7 +706,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // if(fcst_valid_exc.n() > 0) { if(fcst_valid_exc.has(L.fcst_valid_beg()) || - fcst_valid_exc.has(L.fcst_valid_end())) return(0); + fcst_valid_exc.has(L.fcst_valid_end())) return 0; } // @@ -716,29 +716,29 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { if(fcst_valid_hour.n() > 0) { // Check that fcst_valid_beg = fcst_valid_end - if(L.fcst_valid_beg() != L.fcst_valid_end()) return(0); + if(L.fcst_valid_beg() != L.fcst_valid_end()) return 0; - if(!fcst_valid_hour.has(L.fcst_valid_hour())) return(0); + if(!fcst_valid_hour.has(L.fcst_valid_hour())) return 0; } // // fcst_init_beg // if((fcst_init_beg > 0) && (L.fcst_init_beg() < fcst_init_beg)) - return(0); + return 0; // // fcst_init_end // if((fcst_init_end > 0) && (L.fcst_init_end() > fcst_init_end)) - return(0); + return 0; // // fcst_init_inc // if(fcst_init_inc.n() > 0) { if(!fcst_init_inc.has(L.fcst_init_beg()) || - !fcst_init_inc.has(L.fcst_init_end())) return(0); + !fcst_init_inc.has(L.fcst_init_end())) return 0; } // @@ -746,7 +746,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // if(fcst_init_exc.n() > 0) { if(fcst_init_exc.has(L.fcst_init_beg()) || - fcst_init_exc.has(L.fcst_init_end())) return(0); + fcst_init_exc.has(L.fcst_init_end())) return 0; } // @@ -756,36 +756,36 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { if(fcst_init_hour.n() > 0) { // Check that fcst_init_beg = fcst_init_end - if(L.fcst_init_beg() != L.fcst_init_end()) return(0); + if(L.fcst_init_beg() != L.fcst_init_end()) return 0; - if(!fcst_init_hour.has(L.fcst_init_hour())) return(0); + if(!fcst_init_hour.has(L.fcst_init_hour())) return 0; } // // obs_lead (in seconds) // if(obs_lead.n() > 0) { - if(!obs_lead.has(L.obs_lead())) return(0); + if(!obs_lead.has(L.obs_lead())) return 0; } // // obs_valid_beg // if((obs_valid_beg > 0) && (L.obs_valid_beg() < obs_valid_beg)) - return(0); + return 0; // // obs_valid_end // if((obs_valid_end > 0) && (L.obs_valid_end() > obs_valid_end)) - return(0); + return 0; // // obs_valid_inc // if(obs_valid_inc.n() > 0) { if(!obs_valid_inc.has(L.obs_valid_beg()) || - !obs_valid_inc.has(L.obs_valid_end())) return(0); + !obs_valid_inc.has(L.obs_valid_end())) return 0; } // @@ -793,7 +793,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // if(obs_valid_exc.n() > 0) { if(obs_valid_exc.has(L.obs_valid_beg()) || - obs_valid_exc.has(L.obs_valid_end())) return(0); + obs_valid_exc.has(L.obs_valid_end())) return 0; } // @@ -803,29 +803,29 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { if(obs_valid_hour.n() > 0) { // Check that obs_valid_beg = obs_valid_end - if(L.obs_valid_beg() != L.obs_valid_end()) return(0); + if(L.obs_valid_beg() != L.obs_valid_end()) return 0; - if(!obs_valid_hour.has(L.obs_valid_hour())) return(0); + if(!obs_valid_hour.has(L.obs_valid_hour())) return 0; } // // obs_init_beg // if((obs_init_beg > 0) && (L.obs_init_beg() < obs_init_beg)) - return(0); + return 0; // // obs_init_end // if((obs_init_end > 0) && (L.obs_init_end() > obs_init_end)) - return(0); + return 0; // // obs_init_inc // if(obs_init_inc.n() > 0) { if(!obs_init_inc.has(L.obs_init_beg()) || - !obs_init_inc.has(L.obs_init_end())) return(0); + !obs_init_inc.has(L.obs_init_end())) return 0; } // @@ -833,7 +833,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // if(obs_init_exc.n() > 0) { if(obs_init_exc.has(L.obs_init_beg()) || - obs_init_exc.has(L.obs_init_end())) return(0); + obs_init_exc.has(L.obs_init_end())) return 0; } // @@ -843,120 +843,120 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { if(obs_init_hour.n() > 0) { // Check that obs_init_beg = obs_init_end - if(L.obs_init_beg() != L.obs_init_end()) return(0); + if(L.obs_init_beg() != L.obs_init_end()) return 0; - if(!obs_init_hour.has(L.obs_init_hour())) return(0); + if(!obs_init_hour.has(L.obs_init_hour())) return 0; } // // fcst_var // if(fcst_var.n() > 0) { - if(!(fcst_var.has(L.fcst_var()))) return(0); + if(!(fcst_var.has(L.fcst_var()))) return 0; } // // fcst_units // if(fcst_units.n() > 0) { - if(!(fcst_units.has(L.fcst_units()))) return(0); + if(!(fcst_units.has(L.fcst_units()))) return 0; } // // fcst_lev // if(fcst_lev.n() > 0) { - if(!(fcst_lev.has(L.fcst_lev()))) return(0); + if(!(fcst_lev.has(L.fcst_lev()))) return 0; } // // obs_var // if(obs_var.n() > 0) { - if(!(obs_var.has(L.obs_var()))) return(0); + if(!(obs_var.has(L.obs_var()))) return 0; } // // obs_units // if(obs_units.n() > 0) { - if(!(obs_units.has(L.obs_units()))) return(0); + if(!(obs_units.has(L.obs_units()))) return 0; } // // obs_lev // if(obs_lev.n() > 0) { - if(!(obs_lev.has(L.obs_lev()))) return(0); + if(!(obs_lev.has(L.obs_lev()))) return 0; } // // obtype // if(obtype.n() > 0) { - if(!(obtype.has(L.obtype()))) return(0); + if(!(obtype.has(L.obtype()))) return 0; } // // vx_mask // if(vx_mask.n() > 0) { - if(!(vx_mask.has(L.vx_mask()))) return(0); + if(!(vx_mask.has(L.vx_mask()))) return 0; } // // interp_mthd // if(interp_mthd.n() > 0) { - if(!(interp_mthd.has(L.interp_mthd()))) return(0); + if(!(interp_mthd.has(L.interp_mthd()))) return 0; } // // interp_pnts // if(interp_pnts.n() > 0) { - if(!interp_pnts.has(L.interp_pnts())) return(0); + if(!interp_pnts.has(L.interp_pnts())) return 0; } // // fcst_thresh // if(fcst_thresh.n() > 0) { - if(!check_thresh_column(fcst_thresh, L.fcst_thresh())) return(0); + if(!check_thresh_column(fcst_thresh, L.fcst_thresh())) return 0; } // // obs_thresh // if(obs_thresh.n() > 0) { - if(!check_thresh_column(obs_thresh, L.obs_thresh())) return(0); + if(!check_thresh_column(obs_thresh, L.obs_thresh())) return 0; } // // cov_thresh // if(cov_thresh.n() > 0) { - if(!check_thresh_column(cov_thresh, L.cov_thresh())) return(0); + if(!check_thresh_column(cov_thresh, L.cov_thresh())) return 0; } // // thresh_logic // if(thresh_logic != SetLogic_None && - thresh_logic != L.thresh_logic()) return(0); + thresh_logic != L.thresh_logic()) return 0; // // alpha // if(alpha.n() > 0) { - if(!alpha.has(L.alpha())) return(0); + if(!alpha.has(L.alpha())) return 0; } // // line_type // if(line_type.n() > 0) { - if(!(line_type.has(L.line_type()))) return(0); + if(!(line_type.has(L.line_type()))) return 0; } // @@ -973,7 +973,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // Check the column threshold // - if(!thr_it->second.check_dbl(v_dbl)) return(0); + if(!thr_it->second.check_dbl(v_dbl)) return 0; } // @@ -985,7 +985,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // Check if the current value is in the list for the column // - if(!str_it->second.has(L.get_item(str_it->first.c_str(), false))) return(0); + if(!str_it->second.has(L.get_item(str_it->first.c_str(), false))) return 0; } // @@ -997,7 +997,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // Check if the current value is not in the list for the column // - if(str_it->second.has(L.get_item(str_it->first.c_str(), false))) return(0); + if(str_it->second.has(L.get_item(str_it->first.c_str(), false))) return 0; } // @@ -1009,10 +1009,10 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { if(!is_in_mask_grid(lat, lon) || !is_in_mask_poly(lat, lon) || - !is_in_mask_sid (L.get_item("OBS_SID"))) return(0); + !is_in_mask_sid (L.get_item("OBS_SID"))) return 0; } - return(1); + return 1; } //////////////////////////////////////////////////////////////////////// @@ -1059,7 +1059,7 @@ double STATAnalysisJob::get_column_double(const STATLine &L, // Apply absolute value, if requested if(abs_flag && !is_bad_data(v)) v = fabs(v); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -1704,8 +1704,8 @@ int STATAnalysisJob::set_job_type(const char *c) { job_type = string_to_statjobtype(c); - if(job_type == no_stat_job_type) return(1); - else return(0); + if(job_type == no_stat_job_type) return 1; + else return 0; } //////////////////////////////////////////////////////////////////////// @@ -2333,7 +2333,7 @@ ConcatString STATAnalysisJob::get_case_info(const STATLine & L) const { key << (i == 0 ? "" : ":") << cs; } - return(key); + return key; } //////////////////////////////////////////////////////////////////////// @@ -2871,7 +2871,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { js << "-vif_flag " << vif_flag << " "; } - return(js); + return js; } //////////////////////////////////////////////////////////////////////// @@ -2899,7 +2899,7 @@ int STATAnalysisJob::is_in_mask_grid(double lat, double lon) const { } } - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -2914,7 +2914,7 @@ int STATAnalysisJob::is_in_mask_poly(double lat, double lon) const { r = mask_poly.latlon_is_inside_dege(lat, lon); } - return(r); + return r; } //////////////////////////////////////////////////////////////////////// @@ -2927,7 +2927,7 @@ int STATAnalysisJob::is_in_mask_sid(const char *sid) const { // if(mask_sid.n() > 0) r = mask_sid.has(sid); - return(r); + return r; } //////////////////////////////////////////////////////////////////////// @@ -2937,7 +2937,7 @@ int STATAnalysisJob::is_in_mask_sid(const char *sid) const { //////////////////////////////////////////////////////////////////////// const char * statjobtype_to_string(const STATJobType t) { - return(statjobtype_str[t]); + return statjobtype_str[t]; } //////////////////////////////////////////////////////////////////////// @@ -2974,7 +2974,7 @@ STATJobType string_to_statjobtype(const char *str) { else t = no_stat_job_type; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -2989,7 +2989,7 @@ ConcatString timestring(const unixtime t) { short_month_name[month], day, year, hour, minute, second); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -2997,15 +2997,15 @@ ConcatString timestring(const unixtime t) { bool check_thresh_column(const ThreshArray &list, const ThreshArray &item) { // Return true for an empty search list. - if(list.n() == 0) return(true); + if(list.n() == 0) return true; // If the item is a single threshold, search for it in the list. if(item.n() == 1) { - return(list.has(item[0])); + return list.has(item[0]); } // Otherwise, check that the list and item exactly match. - return(list == item); + return (list == item); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/stat_line.cc b/src/libcode/vx_analysis_util/stat_line.cc index faf5c409f3..5edf5519aa 100644 --- a/src/libcode/vx_analysis_util/stat_line.cc +++ b/src/libcode/vx_analysis_util/stat_line.cc @@ -89,11 +89,11 @@ STATLine & STATLine::operator=(const STATLine & L) { -if ( this == &L ) return ( * this ); +if ( this == &L ) return *this; assign(L); -return ( * this ); +return *this; } @@ -255,7 +255,7 @@ if ( !status || n_items() == 0 ) { clear(); - return ( 0 ); + return 0; } @@ -267,7 +267,7 @@ if ( strcmp(get_item(0), "VERSION") == 0 ) { Type = stat_header; - return ( 1 ); + return 1; } // @@ -280,7 +280,7 @@ if( is_bad_data(offset) || n_items() < (offset + 1) ) { Type = no_stat_line_type; - return ( 0 ); + return 0; } // @@ -291,7 +291,7 @@ HdrLine = METHdrTable.header(get_item(0), "STAT", get_item(offset)); Type = string_to_statlinetype(get_item(offset)); -return ( 1 ); +return 1; } @@ -303,7 +303,7 @@ bool STATLine::is_ok() const { -return ( DataLine::is_ok() ); +return DataLine::is_ok(); } @@ -327,7 +327,7 @@ bool STATLine::has(const char *col_str) const { -return ( !is_bad_data(get_offset(col_str)) ); +return !is_bad_data(get_offset(col_str)); } @@ -368,7 +368,7 @@ if ( is_bad_data(offset) ) { // Return the offset value // -return ( offset ); +return offset; } @@ -407,7 +407,7 @@ if ( cs == bad_data_str ) { } -return ( cs ); +return cs; } @@ -448,8 +448,8 @@ if ( is_bad_data(offset) ) { // Return bad data string for no match // -if ( is_bad_data(offset) ) return ( bad_data_str ); -else return ( get_item(offset, check_na) ); +if ( is_bad_data(offset) ) return bad_data_str; +else return get_item(offset, check_na); } @@ -465,7 +465,7 @@ const char * STATLine::get_item(int offset, bool check_na) const // Range check // -if ( offset < 0 || offset >= N_items ) return ( bad_data_str ); +if ( offset < 0 || offset >= N_items ) return bad_data_str; const char * c = DataLine::get_item(offset); @@ -473,8 +473,8 @@ const char * c = DataLine::get_item(offset); // Check for the NA string and interpret it as bad data // -if ( check_na && strcmp(c, na_str) == 0 ) return ( bad_data_str ); -else return ( c ); +if ( check_na && strcmp(c, na_str) == 0 ) return bad_data_str; +else return c; } @@ -488,7 +488,7 @@ const char * STATLine::version() const const char * c = get_item("VERSION", false); -return ( c ); +return c; } @@ -502,7 +502,7 @@ const char * STATLine::model() const const char * c = get_item("MODEL", false); -return ( c ); +return c; } @@ -516,7 +516,7 @@ const char * STATLine::desc() const const char * c = get_item("DESC", false); -return ( c ); +return c; } @@ -533,7 +533,7 @@ const char * c = get_item("FCST_LEAD"); j = timestring_to_sec(c); -return ( j ); +return j; } @@ -549,7 +549,7 @@ unixtime t; const char * c = get_item("FCST_VALID_BEG"); t = timestring_to_unix(c); -return ( t ); +return t; } @@ -565,7 +565,7 @@ unixtime t; const char * c = get_item("FCST_VALID_END"); t = timestring_to_unix(c); -return ( t ); +return t; } @@ -577,7 +577,7 @@ int STATLine::fcst_valid_hour() const { -return ( unix_to_sec_of_day(fcst_valid_beg()) ); +return unix_to_sec_of_day(fcst_valid_beg()); } @@ -594,7 +594,7 @@ const char * c = get_item("OBS_LEAD"); j = timestring_to_sec(c); -return ( j ); +return j; } @@ -610,7 +610,7 @@ unixtime t; const char * c = get_item("OBS_VALID_BEG"); t = timestring_to_unix(c); -return ( t ); +return t; } @@ -626,7 +626,7 @@ unixtime t; const char * c = get_item("OBS_VALID_END"); t = timestring_to_unix(c); -return ( t ); +return t; } @@ -638,7 +638,7 @@ int STATLine::obs_valid_hour() const { -return ( unix_to_sec_of_day(obs_valid_beg()) ); +return unix_to_sec_of_day(obs_valid_beg()); } @@ -652,7 +652,7 @@ const char * STATLine::fcst_var() const const char * c = get_item("FCST_VAR", false); -return ( c ); +return c; } @@ -666,7 +666,7 @@ const char * STATLine::fcst_units() const const char * c = get_item("FCST_UNITS", false); -return ( c ); +return c; } @@ -680,7 +680,7 @@ const char * STATLine::fcst_lev() const const char * c = get_item("FCST_LEV", false); -return ( c ); +return c; } @@ -694,7 +694,7 @@ const char * STATLine::obs_var() const const char * c = get_item("OBS_VAR", false); -return ( c ); +return c; } @@ -708,7 +708,7 @@ const char * STATLine::obs_units() const const char * c = get_item("OBS_UNITS", false); -return ( c ); +return c; } @@ -722,7 +722,7 @@ const char * STATLine::obs_lev() const const char * c = get_item("OBS_LEV", false); -return ( c ); +return c; } @@ -736,7 +736,7 @@ const char * STATLine::obtype() const const char * c = get_item("OBTYPE", false); -return ( c ); +return c; } @@ -750,7 +750,7 @@ const char * STATLine::vx_mask() const const char * c = get_item("VX_MASK", false); -return ( c ); +return c; } @@ -764,7 +764,7 @@ const char * STATLine::interp_mthd() const const char * c = get_item("INTERP_MTHD", false); -return ( c ); +return c; } @@ -781,7 +781,7 @@ const char * c = get_item("INTERP_PNTS", false); k = atoi(c); -return ( k ); +return k; } @@ -799,7 +799,7 @@ const char * c = get_item("FCST_THRESH", false); ta.add_css(c); -return ( ta ); +return ta; } @@ -817,7 +817,7 @@ const char * c = get_item("OBS_THRESH", false); ta.add_css(c); -return ( ta ); +return ta; } @@ -838,7 +838,7 @@ else if(cs.endswith(setlogic_symbol_intersection)) t = SetLogic_Intersection; else if(cs.endswith(setlogic_symbol_symdiff)) t = SetLogic_SymDiff; else t = SetLogic_None; -return ( t ); +return t; } @@ -856,7 +856,7 @@ const char * c = get_item("COV_THRESH", false); ta.add_css(c); -return ( ta ); +return ta; } @@ -874,7 +874,7 @@ const char * c = get_item("ALPHA"); a = atof(c); -return ( a ); +return a; } @@ -888,7 +888,7 @@ const char * STATLine::line_type() const const char * c = get_item("LINE_TYPE", false); -return ( c ); +return c; } @@ -909,7 +909,7 @@ s = fcst_lead(); t -= s; -return ( t ); +return t; } @@ -930,7 +930,7 @@ s = fcst_lead(); t -= s; -return ( t ); +return t; } @@ -942,7 +942,7 @@ int STATLine::fcst_init_hour() const { -return ( unix_to_sec_of_day(fcst_init_beg()) ); +return unix_to_sec_of_day(fcst_init_beg()); } @@ -963,7 +963,7 @@ s = obs_lead(); t -= s; -return ( t ); +return t; } @@ -984,7 +984,7 @@ s = obs_lead(); t -= s; -return ( t ); +return t; } @@ -996,7 +996,7 @@ int STATLine::obs_init_hour() const { -return ( unix_to_sec_of_day(obs_init_beg()) ); +return unix_to_sec_of_day(obs_init_beg()); } diff --git a/src/libcode/vx_analysis_util/time_series.cc b/src/libcode/vx_analysis_util/time_series.cc index a07c07debd..2ee96c92fd 100644 --- a/src/libcode/vx_analysis_util/time_series.cc +++ b/src/libcode/vx_analysis_util/time_series.cc @@ -78,11 +78,11 @@ TimeSeries & TimeSeries::operator=(const TimeSeries & ts) { -if ( this == &ts ) return ( * this ); +if ( this == &ts ) return *this; assign(ts); -return ( * this ); +return *this; } @@ -220,7 +220,7 @@ if ( (index < 0) || (index >= Nelements) ) { } -return ( Value[index] ); +return Value[index]; } diff --git a/src/libcode/vx_bool_calc/bool_calc.cc b/src/libcode/vx_bool_calc/bool_calc.cc index 21ccd83921..a2ac217ed5 100644 --- a/src/libcode/vx_bool_calc/bool_calc.cc +++ b/src/libcode/vx_bool_calc/bool_calc.cc @@ -247,7 +247,7 @@ result = s->top(); s->pop(); -return ( result ); +return result; } diff --git a/src/libcode/vx_bool_calc/make_program.cc b/src/libcode/vx_bool_calc/make_program.cc index 0072a3f658..a8945973f2 100644 --- a/src/libcode/vx_bool_calc/make_program.cc +++ b/src/libcode/vx_bool_calc/make_program.cc @@ -250,7 +250,7 @@ for (j=0; j<(int) program.size(); ++j) { } // for j -return ( n ); +return n; } @@ -295,7 +295,7 @@ for (j=0; j<(int) program.size(); ++j) { -return ( n ); +return n; } diff --git a/src/libcode/vx_bool_calc/token.cc b/src/libcode/vx_bool_calc/token.cc index d2bff4c067..57e81f19bc 100644 --- a/src/libcode/vx_bool_calc/token.cc +++ b/src/libcode/vx_bool_calc/token.cc @@ -68,11 +68,11 @@ Token & Token::operator=(const Token & t) { -if ( this == &t ) return ( * this ); +if ( this == &t ) return *this; assign(t); -return ( * this ); +return *this; } @@ -357,7 +357,7 @@ const bool tf = (type == tok_union) || (type == tok_negation); -return ( tf ); +return tf; } @@ -379,7 +379,7 @@ ostream & operator<<(ostream & out, const Token & t) t.dump(out); -return ( out ); +return out; } diff --git a/src/libcode/vx_bool_calc/token_stack.cc b/src/libcode/vx_bool_calc/token_stack.cc index cdcdb2f039..35737396f9 100644 --- a/src/libcode/vx_bool_calc/token_stack.cc +++ b/src/libcode/vx_bool_calc/token_stack.cc @@ -83,11 +83,11 @@ TokenStack & TokenStack::operator=(const TokenStack & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -292,7 +292,7 @@ Token _t = e[Nelements - 1]; --Nelements; -return ( _t ); +return _t; } @@ -314,7 +314,7 @@ if ( Nelements <= 0 ) { Token _t = e[Nelements - 1]; -return ( _t ); +return _t; } @@ -336,7 +336,7 @@ if ( Nelements <= 0 ) { int k = e[Nelements - 1].in_prec; -return ( k ); +return k; } @@ -358,7 +358,7 @@ if ( Nelements <= 0 ) { char c = e[Nelements - 1].value; -return ( c ); +return c; } */ @@ -381,7 +381,7 @@ if ( Nelements <= 0 ) { bool tf = e[Nelements - 1].is_mark(); -return ( tf ); +return tf; } @@ -403,7 +403,7 @@ ostream & operator<<(ostream & out, const TokenStack & ts) ts.dump(out); -return ( out ); +return out; } diff --git a/src/libcode/vx_bool_calc/tokenizer.cc b/src/libcode/vx_bool_calc/tokenizer.cc index 7b676f452e..960172b1ae 100644 --- a/src/libcode/vx_bool_calc/tokenizer.cc +++ b/src/libcode/vx_bool_calc/tokenizer.cc @@ -139,7 +139,7 @@ while ( (c = source[pos]) != 0 ) { } -return ( value ); +return value; } @@ -168,7 +168,7 @@ while ( 1 ) { tok.set_eof(); - return ( tok ); + return tok; } @@ -236,7 +236,7 @@ else { } -return ( tok ); +return tok; } diff --git a/src/libcode/vx_bool_calc/tokentype_to_string.cc b/src/libcode/vx_bool_calc/tokentype_to_string.cc index ef5df73887..eafea54a4c 100644 --- a/src/libcode/vx_bool_calc/tokentype_to_string.cc +++ b/src/libcode/vx_bool_calc/tokentype_to_string.cc @@ -72,20 +72,20 @@ bool string_to_tokentype(const char * text, TokenType & t) { - if ( strcmp(text, "tok_union" ) == 0 ) { t = tok_union; return ( true ); } -else if ( strcmp(text, "tok_intersection") == 0 ) { t = tok_intersection; return ( true ); } -else if ( strcmp(text, "tok_negation" ) == 0 ) { t = tok_negation; return ( true ); } -else if ( strcmp(text, "tok_local_var" ) == 0 ) { t = tok_local_var; return ( true ); } -else if ( strcmp(text, "tok_mark" ) == 0 ) { t = tok_mark; return ( true ); } - -else if ( strcmp(text, "tok_unmark" ) == 0 ) { t = tok_unmark; return ( true ); } -else if ( strcmp(text, "tok_eof" ) == 0 ) { t = tok_eof; return ( true ); } -else if ( strcmp(text, "no_token_type" ) == 0 ) { t = no_token_type; return ( true ); } + if ( strcmp(text, "tok_union" ) == 0 ) { t = tok_union; return true; } +else if ( strcmp(text, "tok_intersection") == 0 ) { t = tok_intersection; return true; } +else if ( strcmp(text, "tok_negation" ) == 0 ) { t = tok_negation; return true; } +else if ( strcmp(text, "tok_local_var" ) == 0 ) { t = tok_local_var; return true; } +else if ( strcmp(text, "tok_mark" ) == 0 ) { t = tok_mark; return true; } + +else if ( strcmp(text, "tok_unmark" ) == 0 ) { t = tok_unmark; return true; } +else if ( strcmp(text, "tok_eof" ) == 0 ) { t = tok_eof; return true; } +else if ( strcmp(text, "no_token_type" ) == 0 ) { t = no_token_type; return true; } // // nope // -return ( false ); +return false; } diff --git a/src/libcode/vx_color/color.cc b/src/libcode/vx_color/color.cc index 715968ecab..49508193e4 100644 --- a/src/libcode/vx_color/color.cc +++ b/src/libcode/vx_color/color.cc @@ -81,11 +81,11 @@ Color & Color::operator=(const Color &c) { -if ( this == &c ) return ( *this ); +if ( this == &c ) return *this; assign(c); -return ( *this ); +return *this; } @@ -288,11 +288,11 @@ int operator==(const Color &a, const Color &b) { -if ( a.R != b.R ) return ( 0 ); -if ( a.G != b.G ) return ( 0 ); -if ( a.B != b.B ) return ( 0 ); +if ( a.R != b.R ) return 0; +if ( a.G != b.G ) return 0; +if ( a.B != b.B ) return 0; -return ( 1 ); +return 1; } @@ -304,11 +304,11 @@ int operator!=(const Color &a, const Color &b) { -if ( a.R != b.R ) return ( 1 ); -if ( a.G != b.G ) return ( 1 ); -if ( a.B != b.B ) return ( 1 ); +if ( a.R != b.R ) return 1; +if ( a.G != b.G ) return 1; +if ( a.B != b.B ) return 1; -return ( 0 ); +return 0; } @@ -335,7 +335,7 @@ if ( j > 255 ) j = 255; a = (unsigned char) j; -return ( a ); +return a; } @@ -554,7 +554,7 @@ B = nint( t*(color1.blue() ) + omt*(color0.blue() ) ); result.set_rgb((unsigned char) R, (unsigned char) G, (unsigned char) B); -return ( result ); +return result; } diff --git a/src/libcode/vx_color/color_list.cc b/src/libcode/vx_color/color_list.cc index eb3c8cad18..08ef845cb4 100644 --- a/src/libcode/vx_color/color_list.cc +++ b/src/libcode/vx_color/color_list.cc @@ -77,11 +77,11 @@ ClistEntry & ClistEntry::operator=(const ClistEntry & e) { -if ( this == &e ) return ( * this ); +if ( this == &e ) return *this; assign(e); -return ( * this ); +return *this; } @@ -245,11 +245,11 @@ ColorList & ColorList::operator=(const ColorList & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; assign(c); -return ( * this ); +return *this; } @@ -412,7 +412,7 @@ for (j=0; j= Nelements) ) { } -return ( e[n] ); +return e[n]; } diff --git a/src/libcode/vx_color/color_table.cc b/src/libcode/vx_color/color_table.cc index 341a5f00d2..7fe08ea8a3 100644 --- a/src/libcode/vx_color/color_table.cc +++ b/src/libcode/vx_color/color_table.cc @@ -128,11 +128,11 @@ CtableEntry & CtableEntry::operator=(const CtableEntry & entry) { -if ( this == &entry ) return ( * this ); +if ( this == &entry ) return *this; assign(entry); -return ( * this ); +return *this; } @@ -292,11 +292,11 @@ ColorTable & ColorTable::operator=(const ColorTable & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; assign(c); -return ( * this ); +return *this; } @@ -395,11 +395,11 @@ Color color; double t = ( is_bad_data(t_in) ? bad_data_double : t_in ); -if ( Nentries == 0 ) return ( black ); +if ( Nentries == 0 ) return black; -if ( t <= Entry[0].value_low() ) return ( Entry[0].color() ); +if ( t <= Entry[0].value_low() ) return Entry[0].color(); -if ( t >= Entry[Nentries - 1].value_high() ) return ( Entry[Nentries - 1].color() ); +if ( t >= Entry[Nentries - 1].value_high() ) return Entry[Nentries - 1].color(); int j; double vlo, vhi; @@ -422,7 +422,7 @@ for (j=0; j= Entry[Nentries - 1].value_high() ) return ( Entry[Nentries - 1].color() ); +if ( z >= Entry[Nentries - 1].value_high() ) return Entry[Nentries - 1].color(); int j, k; @@ -496,7 +496,7 @@ for (j=0; j= Nentries) ) { } -return ( Entry[n] ); +return Entry[n]; } @@ -933,13 +933,13 @@ double ColorTable::data_min() const { -if ( Nentries == 0 ) return ( 0.0 ); +if ( Nentries == 0 ) return 0.0; double v; v = Entry[0].value_low(); -return ( v ); +return v; } @@ -956,7 +956,7 @@ double ColorTable::data_min(double bad_data_value) const { -if ( Nentries == 0 ) return ( 0.0 ); +if ( Nentries == 0 ) return 0.0; double v_low; int i; @@ -970,7 +970,7 @@ for(i=0; i= 4 ) { } -return ( true ); +return true; } diff --git a/src/libcode/vx_data2d/level_info.cc b/src/libcode/vx_data2d/level_info.cc index a02966fb95..d83fdeb0e5 100644 --- a/src/libcode/vx_data2d/level_info.cc +++ b/src/libcode/vx_data2d/level_info.cc @@ -57,11 +57,11 @@ LevelInfo::LevelInfo(const LevelInfo &f) { LevelInfo & LevelInfo::operator=(const LevelInfo &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/leveltype_to_string.cc b/src/libcode/vx_data2d/leveltype_to_string.cc index 1c7d52b24e..f66d4f2552 100644 --- a/src/libcode/vx_data2d/leveltype_to_string.cc +++ b/src/libcode/vx_data2d/leveltype_to_string.cc @@ -59,7 +59,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } @@ -71,19 +71,19 @@ bool string_to_leveltype(const char * text, LevelType & t) { - if ( strcmp(text, "LevelType_None" ) == 0 ) { t = LevelType_None; return ( true ); } -else if ( strcmp(text, "LevelType_Accum" ) == 0 ) { t = LevelType_Accum; return ( true ); } -else if ( strcmp(text, "LevelType_Vert" ) == 0 ) { t = LevelType_Vert; return ( true ); } -else if ( strcmp(text, "LevelType_Pres" ) == 0 ) { t = LevelType_Pres; return ( true ); } -else if ( strcmp(text, "LevelType_RecNumber") == 0 ) { t = LevelType_RecNumber; return ( true ); } + if ( strcmp(text, "LevelType_None" ) == 0 ) { t = LevelType_None; return true; } +else if ( strcmp(text, "LevelType_Accum" ) == 0 ) { t = LevelType_Accum; return true; } +else if ( strcmp(text, "LevelType_Vert" ) == 0 ) { t = LevelType_Vert; return true; } +else if ( strcmp(text, "LevelType_Pres" ) == 0 ) { t = LevelType_Pres; return true; } +else if ( strcmp(text, "LevelType_RecNumber") == 0 ) { t = LevelType_RecNumber; return true; } -else if ( strcmp(text, "LevelType_SFC" ) == 0 ) { t = LevelType_SFC; return ( true ); } -else if ( strcmp(text, "LevelType_Time" ) == 0 ) { t = LevelType_Time; return ( true ); } +else if ( strcmp(text, "LevelType_SFC" ) == 0 ) { t = LevelType_SFC; return true; } +else if ( strcmp(text, "LevelType_Time" ) == 0 ) { t = LevelType_Time; return true; } // // nope // -return ( false ); +return false; } diff --git a/src/libcode/vx_data2d/table_lookup.cc b/src/libcode/vx_data2d/table_lookup.cc index 0fba08a268..fdbb905ead 100644 --- a/src/libcode/vx_data2d/table_lookup.cc +++ b/src/libcode/vx_data2d/table_lookup.cc @@ -98,11 +98,11 @@ Grib1TableEntry & Grib1TableEntry::operator=(const Grib1TableEntry & e) { -if ( this == &e ) return ( * this ); +if ( this == &e ) return *this; assign(e); -return ( * this ); +return *this; } @@ -210,10 +210,10 @@ StringArray tok; tok.parse_wsss(line); -if (tok.n_elements() < 4) return (false); +if (tok.n_elements() < 4) return false; for (j=0; j<4; ++j) { - if(!is_number(tok[j].c_str())) return (false); + if(!is_number(tok[j].c_str())) return false; } code = atoi(tok[0].c_str()); @@ -227,7 +227,7 @@ subcenter = atoi(tok[3].c_str()); tok.parse_delim(line, "\""); -if (tok.n_elements() < 6) return (false); +if (tok.n_elements() < 6) return false; parm_name = tok[1]; full_name = tok[3]; @@ -246,7 +246,7 @@ if (units.empty()) units = na_str; // done // -return ( true ); +return true; } @@ -304,11 +304,11 @@ Grib2TableEntry & Grib2TableEntry::operator=(const Grib2TableEntry & e) { -if ( this == &e ) return ( * this ); +if ( this == &e ) return *this; assign(e); -return ( * this ); +return *this; } @@ -424,10 +424,10 @@ StringArray tok; tok.parse_wsss(line); -if (tok.n_elements() < 8) return (false); +if (tok.n_elements() < 8) return false; for (j=0; j<8; ++j) { - if(!is_number(tok[j].c_str())) return (false); + if(!is_number(tok[j].c_str())) return false; } index_a = atoi(tok[0].c_str()); @@ -445,7 +445,7 @@ index_c = atoi(tok[7].c_str()); tok.parse_delim(line, "\""); -if (tok.n_elements() < 6) return (false); +if (tok.n_elements() < 6) return false; parm_name = tok[1]; full_name = tok[3]; @@ -464,7 +464,7 @@ if (units.empty()) units = na_str; // done // -return ( true ); +return true; } @@ -817,7 +817,7 @@ else { in.close(); -return ( status ); +return status; } @@ -892,7 +892,7 @@ N_grib1_elements += j; // done // -return ( true ); +return true; } @@ -963,7 +963,7 @@ while ( line.read_line(in) ) { N_grib2_elements += j; -return ( true ); +return true; } @@ -985,13 +985,13 @@ for (j=0; jfile_type()); *vi_copy = *vi_in; - return(vi_copy); + return vi_copy; } diff --git a/src/libcode/vx_data2d_grib/data2d_grib.cc b/src/libcode/vx_data2d_grib/data2d_grib.cc index 09dc80815a..6b6c202bb4 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib.cc @@ -152,7 +152,7 @@ if ( ! (GF->open(_filename)) ) { close(); - return ( false ); + return false; } @@ -187,7 +187,7 @@ if ( ShiftRight != 0 ) Plane.shift_right(ShiftRight); // done // -return ( true ); +return true; } @@ -238,7 +238,7 @@ double MetGrib1DataFile::get(int x, int y) const double value = Plane.get(x, y); -return ( value ); +return value; } @@ -252,7 +252,7 @@ bool MetGrib1DataFile::data_ok(int x, int y) const const double value = get(x, y); -return ( !is_bad_data(value) ); +return !is_bad_data(value); } @@ -303,7 +303,7 @@ if ( ! ( (*GF) >> CurrentRecord) ) { mlog << Error << "\nMetGrib1DataFile::read_record() -> " << "trouble reading record number " << n << "\n\n"; -return (false); +return false; } @@ -314,7 +314,7 @@ if( read_plane ) get_data_plane(CurrentRecord, Plane); if ( ShiftRight != 0 ) Plane.shift_right(ShiftRight); -return (true); +return true; } @@ -331,7 +331,7 @@ if ( !GF ) { mlog << Error << "\nMetGrib1DataFile::read_record(const VarInfoGrib &) -> " << "no grib file open!\n\n"; - return ( -1 ); + return -1; } @@ -349,7 +349,7 @@ for (j=0; j<(GF->n_records()); ++j) { mlog << Error << "\nMetGrib1DataFile::read_record(const VarInfoGrib &) -> trouble reading record!\n\n"; - return ( -1 ); + return -1; } @@ -388,7 +388,7 @@ if ( j_match >= 0 ) { mlog << Error << "\nMetGrib1DataFile::read_record(const VarInfoGrib &) -> " << "trouble reading record!\n\n"; - return ( -1 ); + return -1; } @@ -398,7 +398,7 @@ if ( j_match >= 0 ) { // done // -return ( count ); +return count; } @@ -458,7 +458,7 @@ bool MetGrib1DataFile::data_plane(VarInfo &vinfo, DataPlane &plane) { << filename() << "\".\n\n"; } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -572,7 +572,7 @@ int MetGrib1DataFile::data_plane_array(VarInfo &vinfo, << u_plane_array.n_planes() << ") does not match the " << "number of V-wind records (" << v_plane_array.n_planes() << ") for GRIB file \"" << filename() << "\".\n\n"; - return(0); + return 0; } // Loop through each of the data planes @@ -590,7 +590,7 @@ int MetGrib1DataFile::data_plane_array(VarInfo &vinfo, << v_plane_array.lower(i) << ", " << v_plane_array.upper(i) << ") in GRIB file \"" << filename() << "\".\n\n"; plane_array.clear(); - return(0); + return 0; } // Derive wind direction @@ -616,7 +616,7 @@ int MetGrib1DataFile::data_plane_array(VarInfo &vinfo, << vinfo.magic_str() << "\" in GRIB file \"" << filename() << "\".\n"; - return(plane_array.n_planes()); + return plane_array.n_planes(); } //////////////////////////////////////////////////////////////////////// @@ -711,7 +711,7 @@ bool MetGrib1DataFile::data_plane_scalar(VarInfoGrib &vinfo_grib, << filename() << "\".\n\n"; } - return(status); + return status; } /////////////////////////////////////////////////////////////////////////////// @@ -780,9 +780,9 @@ int get_bit_from_octet(unsigned char u, int bit) { unsigned char mask = (unsigned char) (1 << (8 - bit)); - if(u & mask) return(1); + if(u & mask) return 1; - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc index 2f1f66385b..c0459daa1d 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc @@ -143,7 +143,7 @@ bool is_prelim_match( VarInfoGrib & vinfo, const GribRecord & g) if ( vinfo_ptv != ptv || vinfo_center != center || vinfo_subcenter != subcenter || - !isEnsMatch ) return ( false ); + !isEnsMatch ) return false; // if p_flag is 'on' (probability field) and the request name is set, // get the real name of the field from the begining of a request name @@ -168,7 +168,7 @@ bool is_prelim_match( VarInfoGrib & vinfo, const GribRecord & g) if( !GribTable.lookup_grib1(field_name.c_str(), default_grib1_ptv, code_for_lookup, default_grib1_center, default_grib1_subcenter, tab, tab_match) ) { // if the lookup still fails, then it's not a match - return ( false ); + return false; } } @@ -217,7 +217,7 @@ if ( !is_bad_data(vinfo.level().type_num()) && << ") does not match the current level type (" << (int) pds->type << ").\n"; - return ( false ); + return false; } // @@ -235,8 +235,8 @@ upper = nint ( vinfo.level().upper() ); if ( vinfo.level().type() == LevelType_RecNumber ) { if ( lower == g.rec_num && - vinfo.code() == g.gribcode() ) return ( true ); - else return ( false ); + vinfo.code() == g.gribcode() ) return true; + else return false; } @@ -244,7 +244,7 @@ if ( vinfo.level().type() == LevelType_RecNumber ) { // gribcode // -if ( vinfo.code() != g.gribcode() ) return ( false ); +if ( vinfo.code() != g.gribcode() ) return false; // // parse timing info from pds @@ -258,7 +258,7 @@ read_pds(g, bms_flag, init_ut, valid_ut, accum); ut = vinfo.init(); -if ( ut != 0 && ut != init_ut ) return ( false ); +if ( ut != 0 && ut != init_ut ) return false; // // valid time @@ -266,7 +266,7 @@ if ( ut != 0 && ut != init_ut ) return ( false ); ut = vinfo.valid(); -if ( ut != 0 && ut != valid_ut ) return ( false ); +if ( ut != 0 && ut != valid_ut ) return false; // // lead time @@ -274,7 +274,7 @@ if ( ut != 0 && ut != valid_ut ) return ( false ); k = vinfo.lead(); -if ( k >= 0 && k != ( valid_ut - init_ut) ) return ( false ); +if ( k >= 0 && k != ( valid_ut - init_ut) ) return false; // // accumulation interval @@ -286,20 +286,20 @@ if ( vinfo.level().type() == LevelType_Accum ) { // time range indicator of 4 for accumulation // - if ( pds->tri != 4 ) return ( false ); + if ( pds->tri != 4 ) return false; // // check that the accumulation seconds match the limits // - if ( lower != accum || upper != accum ) return ( false ); + if ( lower != accum || upper != accum ) return false; } // // time range indicator // -if ( !is_bad_data(vinfo.tri()) && pds->tri != vinfo.tri() ) return ( false ); +if ( !is_bad_data(vinfo.tri()) && pds->tri != vinfo.tri() ) return false; // // probability info @@ -320,21 +320,21 @@ if ( vinfo.p_flag() && // probabilistic gribcode // - if ( vinfo.p_code() != p_code ) return ( false ); + if ( vinfo.p_code() != p_code ) return false; // // lower probabiility threshold // if ( !is_bad_data ( p_thresh_lo ) && - !is_eq ( vinfo.p_thresh_lo().get_value(), p_thresh_lo, loose_tol ) ) return ( false ); + !is_eq ( vinfo.p_thresh_lo().get_value(), p_thresh_lo, loose_tol ) ) return false; // // upper probability threshold // if ( !is_bad_data ( p_thresh_hi ) && - !is_eq ( vinfo.p_thresh_hi().get_value(), p_thresh_hi, loose_tol ) ) return ( false ); + !is_eq ( vinfo.p_thresh_hi().get_value(), p_thresh_hi, loose_tol ) ) return false; } @@ -345,7 +345,7 @@ if ( vinfo.p_flag() && for ( j=0; jtype == grib_level_list[j].level ) break; } -if ( j == n_grib_level_list ) return ( false ); +if ( j == n_grib_level_list ) return false; // // check that the record level type is consistent with the @@ -353,16 +353,16 @@ if ( j == n_grib_level_list ) return ( false ); // if ( vinfo.level().type() == LevelType_Pres && - grib_level_list[j].type != 3 ) return ( false ); + grib_level_list[j].type != 3 ) return false; if ( vinfo.level().type() == LevelType_Vert && - grib_level_list[j].type != 2 ) return ( false ); + grib_level_list[j].type != 2 ) return false; // // done // -return ( true ); +return true; } @@ -378,7 +378,7 @@ int lower, upper, grib_lower, grib_upper, grib_type_num; // check common logic // -if ( !is_prelim_match(vinfo, g) ) return ( false ); +if ( !is_prelim_match(vinfo, g) ) return false; // // store requested lower and upper limits @@ -406,7 +406,7 @@ if ( !is_bad_data(vinfo.level().type_num()) && << ") does not match the current level type (" << grib_type_num << ").\n"; - return ( false ); + return false; } @@ -425,7 +425,7 @@ if ( ( vinfo.level().type() != LevelType_Accum ) && << ") do not match the current level values " << "(" << grib_lower << " and " << grib_upper << ").\n"; - return ( false ); + return false; } @@ -433,7 +433,7 @@ if ( ( vinfo.level().type() != LevelType_Accum ) && // done // -return ( true ); +return true; } @@ -451,7 +451,7 @@ int lower, upper, grib_lower, grib_upper, grib_type_num; // check common logic // -if ( !is_prelim_match(vinfo, g) ) return ( false ); +if ( !is_prelim_match(vinfo, g) ) return false; // // store requested lower and upper limits @@ -479,7 +479,7 @@ if ( !is_bad_data(vinfo.level().type_num()) && << ") does not match the current level type (" << grib_type_num << ").\n"; - return ( false ); + return false; } // // for non-accumulation intervals and specific record number, @@ -496,14 +496,14 @@ if ( ( vinfo.level().type() != LevelType_Accum ) && << ") do not fall within the current range of level values " << "(" << grib_lower << " and " << grib_upper << ").\n"; - return ( false ); + return false; } // // done // -return ( true ); +return true; } @@ -565,7 +565,7 @@ plane.set_accum ( accum ); // done // -return ( true ); +return true; } diff --git a/src/libcode/vx_data2d_grib/grib_classes.cc b/src/libcode/vx_data2d_grib/grib_classes.cc index 5954a6ed7d..7962db7b3f 100644 --- a/src/libcode/vx_data2d_grib/grib_classes.cc +++ b/src/libcode/vx_data2d_grib/grib_classes.cc @@ -223,7 +223,7 @@ GribRecord & GribRecord::operator=(const GribRecord &g) { -if ( this == &g ) return ( *this ); // check for a = a +if ( this == &g ) return *this; // check for a = a pds = new unsigned char [g.pds_len]; @@ -274,7 +274,7 @@ if ( g.bitmap.size() ) { TO = g.TO; -return ( *this ); +return *this; } @@ -350,7 +350,7 @@ shift = 32 - word_size - (k%8); value = (u >> shift) & mask; -return ( value ); +return value; } @@ -373,7 +373,7 @@ u = long_data_value(n); y = m_value*u + b_value; -return ( y ); +return y; } @@ -452,7 +452,7 @@ a = 0; if ( bitmap[byte] & uc_mask ) a = 1; -return ( a ); +return a; } @@ -469,7 +469,7 @@ Section1_Header *pds_ptr = (Section1_Header *) pds; j = (int) (pds_ptr->grib_code); -return ( j ); +return j; } @@ -723,13 +723,13 @@ if ( !(rep->buf = new unsigned char [default_gribfile_buf_size]) ) { rep->buf_size = default_gribfile_buf_size; -if(!skip_header()) return ( false ); +if(!skip_header()) return false; index_records(); lseek(rep->fd, rep->file_start, SEEK_SET); -return ( true ); +return true; } @@ -755,7 +755,7 @@ GribFile & GribFile::operator=(const GribFile &g) { -if ( this == &g ) return ( *this ); +if ( this == &g ) return *this; close(); @@ -763,7 +763,7 @@ rep = g.rep; if ( rep ) ++rep->referenceCount; -return ( *this ); +return *this; } @@ -789,11 +789,11 @@ int GribFile::operator>>(GribRecord &g) int j = read_record(g); -if ( j < 0 ) return ( -1 ); +if ( j < 0 ) return -1; -if ( j > 0 ) return ( 1 ); +if ( j > 0 ) return 1; -return ( 0 ); +return 0; } @@ -847,7 +847,7 @@ g.Sec0_offset_in_record = bytes_processed; bytes = sizeof(Section0_Header); -if ( (n_read = read(rep->buf, bytes)) == 0 ) return ( 0 ); +if ( (n_read = read(rep->buf, bytes)) == 0 ) return 0; memcpy(g.is, rep->buf, 8); @@ -855,7 +855,7 @@ if ( (n_read < 0) || (n_read != bytes) ) { mlog << Error << "\nGribFile::read_record() -> error reading section 0 header ... nread = " << n_read << "\n\n"; - return ( -1 ); + return -1; } @@ -867,7 +867,7 @@ if ( strncmp(g.is->grib_name, "GRIB", 4) != 0 ) { << " reading record number " << (rep->n_records) << ", bytes left in file = " << (pos2 - file_pos) << "\n\n"; - return ( 0 ); + return 0; } @@ -877,13 +877,13 @@ g.record_lseek_offset = file_pos; if ( s > (rep->buf_size) ) rep->realloc_buf(s); -if ( read(8, s - 8) == 0 ) return ( 0 ); +if ( read(8, s - 8) == 0 ) return 0; if ( strncmp((char *) (rep->buf + (s - 4)), "7777", 4) != 0 ) { mlog << Error << "\nGribFile::read_record(GribRecord &) -> trailing \"7777\" not found in grib record\n\n"; - return ( 0 ); + return 0; } bytes_processed += 8; @@ -1088,7 +1088,7 @@ for (j=0; j<(g.word_size); ++j) g.mask |= (1 << j); // Done // -return ( 1 ); +return 1; } @@ -1122,13 +1122,13 @@ if ( n_read == 0 ) { mlog << Error << "\nGribFile::skip_header() -> " << "\"GRIB\" magic cookie not found in grib file!!\n\n"; - return ( 0 ); + return 0; } if ( n_read < 0 ) { - return ( 0 ); + return 0; } @@ -1145,7 +1145,7 @@ if ( !found ) { mlog << Error << "\nGribFile::skip_header() -> " << "can't find \"GRIB\" magic cookie\n\n"; - return ( 0 ); + return 0; } @@ -1153,7 +1153,7 @@ rep->file_start = (long) (pos + j); lseek(rep->fd, rep->file_start, SEEK_SET); -return ( 1 ); +return 1; } @@ -1208,7 +1208,7 @@ if ( (n_read = ::read(rep->fd, (char *) rep->buf, rep->buf_size)) < 0 ) { } -return ( n_read ); +return n_read; } @@ -1239,7 +1239,7 @@ if ( (n_read = ::read(rep->fd, (char *) rep->buf, bytes)) < 0 ) { } -return ( n_read ); +return n_read; } @@ -1274,7 +1274,7 @@ if ( n_read != B ) { } -return ( n_read ); +return n_read; } @@ -1296,7 +1296,7 @@ if ( (n_read = ::read(rep->fd, c, bytes)) < 0 ) { } -return ( n_read ); +return n_read; } @@ -1475,7 +1475,7 @@ double char4_to_dbl(const unsigned char *c) value = value * mant / 16777216.0; if (positive == 0) value = -value; - return(value); + return value; } @@ -1492,7 +1492,7 @@ i = 0; for (j=0; j<3; ++j) i = i*256 + c[j]; -return ( i ); +return i; } @@ -1510,7 +1510,7 @@ i = 0; for (j=0; j<2; ++j) i = i*256 + c[j]; -return ( i ); +return i; } @@ -1618,7 +1618,7 @@ file << " Sec 4 (BDS) offset in file " << g.Sec4_offset_in_file << ", offse file << separator << "\n"; -return ( file ); +return file; } @@ -1657,7 +1657,7 @@ file << " length: " << char3_to_int(h.length) << "\n"; file << " ed_num: " << (int) (h.ed_num) << "\n\n"; -return ( file ); +return file; } @@ -1725,7 +1725,7 @@ file << " ens_number: " << (int) (h.ens_number) << "\n"; file << " d_value: " << char2_to_int(h.d_value) << "\n\n"; -return ( file ); +return file; } @@ -1844,7 +1844,7 @@ else if ((h.type == 10)) file << " rotation: " << char4_to_dbl(h.grid_type.rot_latlon_grid.rotation) << "\n\n"; } -return ( file ); +return file; } @@ -1883,7 +1883,7 @@ file << " num: " << (int) h.num << "\n"; file << " flag: " << char2_to_int(h.flag) << "\n\n"; -return ( file ); +return file; } @@ -1931,7 +1931,7 @@ file << " size: " << (int) h.size << "\n"; file << " data_start: " << (int) h.data_start << "\n\n"; -return ( file ); +return file; } @@ -1960,13 +1960,13 @@ while ( (n_read = read(fd, buf, sizeof(buf))) > 0 ) { lseek(fd, pos + 2, SEEK_SET); - return ( pos ); + return pos; } } // for j - if ( n_read < 10 ) return ( -1 ); + if ( n_read < 10 ) return -1; pos += n_read - 5; @@ -1974,7 +1974,7 @@ while ( (n_read = read(fd, buf, sizeof(buf))) > 0 ) { } // while -if ( n_read == 0 ) return ( -1 ); +if ( n_read == 0 ) return -1; if ( n_read < 0 ) { @@ -1984,7 +1984,7 @@ if ( n_read < 0 ) { } -return ( pos ); +return pos; } diff --git a/src/libcode/vx_data2d_grib/grib_strings.cc b/src/libcode/vx_data2d_grib/grib_strings.cc index f9b3edcdac..5af9e5227e 100644 --- a/src/libcode/vx_data2d_grib/grib_strings.cc +++ b/src/libcode/vx_data2d_grib/grib_strings.cc @@ -64,7 +64,7 @@ ConcatString get_grib_code_name(int grib_code, int ptv) ConcatString str = get_grib_code_list_str(0, grib_code, ptv); - return ( str ); + return str; } /////////////////////////////////////////////////////////////////////////////// @@ -75,7 +75,7 @@ ConcatString get_grib_code_unit(int grib_code, int ptv) ConcatString str = get_grib_code_list_str(1, grib_code, ptv); - return ( str ); + return str; } @@ -87,7 +87,7 @@ ConcatString get_grib_code_abbr(int grib_code, int ptv) ConcatString str = get_grib_code_list_str(2, grib_code, ptv); - return ( str ); + return str; } @@ -129,7 +129,7 @@ ConcatString get_grib_level_list_str(int k, int grib_level) } // if - return ( str ); + return str; } @@ -141,7 +141,7 @@ ConcatString get_grib_level_name(int grib_level) ConcatString str = get_grib_level_list_str(0, grib_level); -return ( str ); +return str; } @@ -153,7 +153,7 @@ ConcatString get_grib_level_abbr(int grib_level) ConcatString str = get_grib_level_list_str(1, grib_level); -return ( str ); +return str; } @@ -187,7 +187,7 @@ ConcatString get_grib_level_str(int grib_level, unsigned char *level_info) } - return ( str ); + return str; } /////////////////////////////////////////////////////////////////////////////// @@ -211,7 +211,7 @@ int str_to_grib_code(const char *c) if(is_bad_data(gc)) gc = str_to_grib_code(c, 140); if(is_bad_data(gc)) gc = str_to_grib_code(c, 141); - return(gc); + return gc; } /////////////////////////////////////////////////////////////////////////////// @@ -256,7 +256,7 @@ int str_to_grib_code(const char *c, int &pcode, double &pthresh_lo, double &pthr if(is_bad_data(gc)) gc = str_to_grib_code(c, pcode, pthresh_lo, pthresh_hi, 140); if(is_bad_data(gc)) gc = str_to_grib_code(c, pcode, pthresh_lo, pthresh_hi, 141); - return(gc); + return gc; } /////////////////////////////////////////////////////////////////////////////// @@ -298,7 +298,7 @@ int str_to_grib_code(const char *c, int &pcode, pthresh_lo = pthresh_hi = bad_data_double; } - return(gc); + return gc; } /////////////////////////////////////////////////////////////////////////////// @@ -363,7 +363,7 @@ int str_to_prob_info(const char *c, double &pthresh_lo, double &pthresh_hi, exit(1); } - return(gc); + return gc; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/grib_utils.cc b/src/libcode/vx_data2d_grib/grib_utils.cc index 095be46d0a..3dfaeb766b 100644 --- a/src/libcode/vx_data2d_grib/grib_utils.cc +++ b/src/libcode/vx_data2d_grib/grib_utils.cc @@ -696,11 +696,11 @@ int i; for (i=0; i listMatch.size() ) @@ -1649,7 +1649,7 @@ int MetGrib2DataFile::index( VarInfo &vinfo ){ //////////////////////////////////////////////////////////////////////// double scaled2dbl(int scale_factor, int scale_value) { - if (scale_factor == 0) return ( (double) scale_value ); + if (scale_factor == 0) return (double) scale_value; if (scale_factor < 0) return ( scale_value * pow(10.0, -scale_factor) ); return ( scale_value / pow(10.0, scale_factor) ); } @@ -1674,7 +1674,7 @@ int parse_int4(g2int i) { i_val = (c[0] << 24) + (c[1] << 16) + (c[2] << 8) + c[3]; } - return(i_val); + return i_val; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib2/var_info_grib2.cc b/src/libcode/vx_data2d_grib2/var_info_grib2.cc index 9d67ab1929..1a555e1027 100644 --- a/src/libcode/vx_data2d_grib2/var_info_grib2.cc +++ b/src/libcode/vx_data2d_grib2/var_info_grib2.cc @@ -68,11 +68,11 @@ VarInfoGrib2::VarInfoGrib2(const VarInfoGrib2 &f) { VarInfoGrib2 & VarInfoGrib2::operator=(const VarInfoGrib2 &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc index 72275ecd9f..0a50084ec1 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc @@ -128,7 +128,7 @@ bool MetNcCFDataFile::open(const char * _filename) { << "unable to open NetCDF file \"" << _filename << "\"\n\n"; close(); - return(false); + return false; } Filename = _filename; @@ -141,7 +141,7 @@ bool MetNcCFDataFile::open(const char * _filename) { (*Dest_Grid) = (*Raw_Grid); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -377,7 +377,7 @@ int MetNcCFDataFile::data_plane_array(VarInfo &vinfo, } } - return(n_rec); + return n_rec; } //////////////////////////////////////////////////////////////////////// @@ -397,7 +397,7 @@ LongArray MetNcCFDataFile::collect_time_offsets(VarInfo &vinfo) { mlog << Warning << "\n" << method_name << "can't find NetCDF variable \"" << vinfo_nc->req_name() << "\" in file \"" << Filename << "\".\n\n"; - return(time_offsets); + return time_offsets; } int time_dim_slot = info->t_slot; @@ -406,7 +406,7 @@ LongArray MetNcCFDataFile::collect_time_offsets(VarInfo &vinfo) { // The time dimension does not exist at the variable and the time // variable exists. Stop time slicing and set the time offset to 0. time_offsets.add(0); - return(time_offsets); + return time_offsets; } double time_lower = bad_data_double; @@ -584,7 +584,7 @@ LongArray MetNcCFDataFile::collect_time_offsets(VarInfo &vinfo) { exit(1); } - return(time_offsets); + return time_offsets; } diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index 84c147a749..eebf2ae1b6 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -2214,7 +2214,7 @@ double get_nc_var_att_double(const NcVar *nc_var, const char *att_name, bool is_ double att_val = get_att_value_double(nc_att); if (nc_att) delete nc_att; - return(att_val); + return att_val; } @@ -3450,7 +3450,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, swap_to_north = false; } - return(data); + return data; } diff --git a/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc index 00695d8da5..2d95ec8cf4 100644 --- a/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc @@ -67,11 +67,11 @@ VarInfoNcCF::VarInfoNcCF(const VarInfoNcCF &f) { VarInfoNcCF & VarInfoNcCF::operator=(const VarInfoNcCF &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -368,9 +368,9 @@ bool VarInfoNcCF::is_precipitation() const { // Check to see if the VarInfo name begins with the GRIB code abbreviation // for any precipitation variables. // - return(has_prefix(grib_precipitation_abbr, + return has_prefix(grib_precipitation_abbr, n_grib_precipitation_abbr, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -388,9 +388,9 @@ bool VarInfoNcCF::is_specific_humidity() const { // Check to see if the VarInfo name begins with the GRIB code abbreviation // for any specific humidity variables. // - return(has_prefix(grib_specific_humidity_abbr, + return has_prefix(grib_specific_humidity_abbr, n_grib_specific_humidity_abbr, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -404,7 +404,7 @@ bool VarInfoNcCF::is_u_wind() const { return(SetAttrIsUWind != 0); } - return(is_grib_code_abbr_match(Name, ugrd_grib_code)); + return is_grib_code_abbr_match(Name, ugrd_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -418,7 +418,7 @@ bool VarInfoNcCF::is_v_wind() const { return(SetAttrIsVWind != 0); } - return(is_grib_code_abbr_match(Name, vgrd_grib_code)); + return is_grib_code_abbr_match(Name, vgrd_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -432,7 +432,7 @@ bool VarInfoNcCF::is_wind_speed() const { return(SetAttrIsWindSpeed != 0); } - return(is_grib_code_abbr_match(Name, wind_grib_code)); + return is_grib_code_abbr_match(Name, wind_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -446,7 +446,7 @@ bool VarInfoNcCF::is_wind_direction() const { return(SetAttrIsWindDirection != 0); } - return(is_grib_code_abbr_match(Name, wdir_grib_code)); + return is_grib_code_abbr_match(Name, wdir_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -459,7 +459,7 @@ bool is_grib_code_abbr_match(const ConcatString &str, int grib_code) { ConcatString abbr_str; bool match = false; - if(str.empty()) return(false); + if(str.empty()) return false; // // Use the default GRIB1 parameter table version number 2 @@ -472,7 +472,7 @@ bool is_grib_code_abbr_match(const ConcatString &str, int grib_code) { // if(strncasecmp(str.c_str(), abbr_str.c_str(), abbr_str.length()) == 0) match = true; - return(match); + return match; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc index 40caecba95..b504207ad4 100644 --- a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc @@ -92,7 +92,7 @@ bool MetNcMetDataFile::open(const char * _filename) { << "unable to open NetCDF file \"" << _filename << "\"\n\n"; close(); - return(false); + return false; } Filename = _filename; @@ -105,7 +105,7 @@ bool MetNcMetDataFile::open(const char * _filename) { (*Dest_Grid) = (*Raw_Grid); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -188,7 +188,7 @@ bool MetNcMetDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) { if(info->units_att.length() > 0) vinfo.set_units(info->units_att.c_str()); } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -211,7 +211,7 @@ int MetNcMetDataFile::data_plane_array(VarInfo &vinfo, n_rec = 1; } - return(n_rec); + return n_rec; } //////////////////////////////////////////////////////////////////////// @@ -220,14 +220,14 @@ int MetNcMetDataFile::index(VarInfo &vinfo) { NcVarInfo *ncinfo = MetNc->find_var_name( vinfo.name().c_str() ); - if( !ncinfo ) return(-1); + if( !ncinfo ) return -1; if( ( vinfo.valid() != 0 && ncinfo->ValidTime != vinfo.valid() ) || ( vinfo.init() != 0 && ncinfo->InitTime != vinfo.init() ) || ( !is_bad_data(vinfo.lead()) && ncinfo->lead_time() != vinfo.lead() ) ) - return(-1); + return -1; - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_met/get_met_grid.cc b/src/libcode/vx_data2d_nc_met/get_met_grid.cc index 7ae924bd34..67fdd3ca1d 100644 --- a/src/libcode/vx_data2d_nc_met/get_met_grid.cc +++ b/src/libcode/vx_data2d_nc_met/get_met_grid.cc @@ -183,7 +183,7 @@ int has_variable(NcFile *f_in, const char *var_name) { // found = (has_var(f_in, var_name) ? 1 : 0); - return(found); + return found; } /////////////////////////////////////////////////////////////////////////////// @@ -216,7 +216,7 @@ LatLonData get_latlon_data(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -257,7 +257,7 @@ RotatedLatLonData get_rot_latlon_data(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -314,7 +314,7 @@ LambertData get_lambert_data(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -374,7 +374,7 @@ LaeaData get_laea_data(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -431,7 +431,7 @@ StereographicData get_stereographic_data(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -465,7 +465,7 @@ MercatorData get_mercator_data(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -498,7 +498,7 @@ LatLonData get_latlon_data_v2(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -550,7 +550,7 @@ LambertData get_lambert_data_v2(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -605,7 +605,7 @@ StereographicData get_stereographic_data_v2(NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -639,7 +639,7 @@ MercatorData get_mercator_data_v2(NcFile * ncfile) { data.dump(); - return(data); + return data; } @@ -663,7 +663,7 @@ GaussianData get_gaussian_data (NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// @@ -681,7 +681,7 @@ SemiLatLonData get_semilatlon_data (NcFile * ncfile) { data.dump(); - return(data); + return data; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_met/met_file.cc b/src/libcode/vx_data2d_nc_met/met_file.cc index 443fe6ff60..0f3a40fd4d 100644 --- a/src/libcode/vx_data2d_nc_met/met_file.cc +++ b/src/libcode/vx_data2d_nc_met/met_file.cc @@ -155,7 +155,7 @@ close(); Nc = open_ncfile(filename); -if ( IS_INVALID_NC_P(Nc) ) { close(); return ( false ); } +if ( IS_INVALID_NC_P(Nc) ) { close(); return false; } // // grid @@ -280,7 +280,7 @@ for (j=0; jvar, a, plane); @@ -653,7 +653,7 @@ plane.set_accum ( info->AccumTime ); // done // -return ( found ); +return found; } diff --git a/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc b/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc index 338d83e8f4..f263d5b399 100644 --- a/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc @@ -67,11 +67,11 @@ VarInfoNcMet::VarInfoNcMet(const VarInfoNcMet &f) { VarInfoNcMet & VarInfoNcMet::operator=(const VarInfoNcMet &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -257,9 +257,9 @@ bool VarInfoNcMet::is_precipitation() const { // Check to see if the VarInfo name begins with the GRIB code abbreviation // for any precipitation variables. // - return(has_prefix(grib_precipitation_abbr, + return has_prefix(grib_precipitation_abbr, n_grib_precipitation_abbr, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -277,9 +277,9 @@ bool VarInfoNcMet::is_specific_humidity() const { // Check to see if the VarInfo name begins with the GRIB code abbreviation // for any specific humidity variables. // - return(has_prefix(grib_specific_humidity_abbr, + return has_prefix(grib_specific_humidity_abbr, n_grib_specific_humidity_abbr, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -293,7 +293,7 @@ bool VarInfoNcMet::is_u_wind() const { return(SetAttrIsUWind != 0); } - return(is_grib_code_abbr_match(Name, ugrd_grib_code)); + return is_grib_code_abbr_match(Name, ugrd_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -307,7 +307,7 @@ bool VarInfoNcMet::is_v_wind() const { return(SetAttrIsVWind != 0); } - return(is_grib_code_abbr_match(Name, vgrd_grib_code)); + return is_grib_code_abbr_match(Name, vgrd_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -321,7 +321,7 @@ bool VarInfoNcMet::is_wind_speed() const { return(SetAttrIsWindSpeed != 0); } - return(is_grib_code_abbr_match(Name, wind_grib_code)); + return is_grib_code_abbr_match(Name, wind_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -335,7 +335,7 @@ bool VarInfoNcMet::is_wind_direction() const { return(SetAttrIsWindDirection != 0); } - return(is_grib_code_abbr_match(Name, wdir_grib_code)); + return is_grib_code_abbr_match(Name, wdir_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -348,7 +348,7 @@ bool is_grib_code_abbr_match(const ConcatString &str, int grib_code) { ConcatString abbr_str; bool match = false; - if(str.empty()) return(false); + if(str.empty()) return false; // // Use the default GRIB1 parameter table version number 2 @@ -361,7 +361,7 @@ bool is_grib_code_abbr_match(const ConcatString &str, int grib_code) { // if(strncasecmp(str.c_str(), abbr_str.c_str(), abbr_str.length()) == 0) match = true; - return(match); + return match; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc index e249856a7a..79f6f5683c 100644 --- a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc @@ -93,7 +93,7 @@ bool MetNcWrfDataFile::open(const char * _filename) { << "unable to open NetCDF file \"" << _filename << "\"\n\n"; close(); - return(false); + return false; } Filename = _filename; @@ -106,7 +106,7 @@ bool MetNcWrfDataFile::open(const char * _filename) { (*Dest_Grid) = (*Raw_Grid); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -191,7 +191,7 @@ bool MetNcWrfDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) { } } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -276,7 +276,7 @@ int MetNcWrfDataFile::data_plane_array(VarInfo &vinfo, } // Check for bad status - if(!status) return(0); + if(!status) return 0; // Add current plane to the data plane array plane_array.add(cur_plane, pressure, pressure); @@ -302,7 +302,7 @@ int MetNcWrfDataFile::data_plane_array(VarInfo &vinfo, << "-" << nint(min_level); vinfo.set_level_name(level_str.c_str()); - return(n_level); + return n_level; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc b/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc index 7f32821921..a6d6a28ca6 100644 --- a/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc +++ b/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc @@ -77,7 +77,7 @@ NcFile nc(wrf_filename, NcFile::read); status = get_wrf_grid(nc, grid); -return ( status ); +return status; } @@ -118,7 +118,7 @@ else { // done // -return ( status ); +return status; } @@ -199,7 +199,7 @@ grid.set(data); data.dump(); -return ( true ); +return true; } @@ -282,7 +282,7 @@ grid.set(data); data.dump(); -return ( true ); +return true; } @@ -387,7 +387,7 @@ grid.set(data); data.dump(); -return ( true ); +return true; } @@ -405,7 +405,7 @@ lon_rad = lon*rad_per_deg; u = -lon_rad; -return ( u ); +return u; } @@ -421,7 +421,7 @@ double v; v = log(tand(45.0 + 0.5*lat)); -return ( v ); +return v; } diff --git a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc index 62c1d9c834..e4be5ed3ba 100644 --- a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc @@ -63,11 +63,11 @@ VarInfoNcWrf::VarInfoNcWrf(const VarInfoNcWrf &f) { VarInfoNcWrf & VarInfoNcWrf::operator=(const VarInfoNcWrf &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -308,9 +308,9 @@ bool VarInfoNcWrf::is_precipitation() const { // Check to see if the VarInfo name matches any of expected Pinterp // precipitation variables. // - return(has_prefix(pinterp_precipitation_names, + return has_prefix(pinterp_precipitation_names, n_pinterp_precipitation_names, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -328,9 +328,9 @@ bool VarInfoNcWrf::is_specific_humidity() const { // Check to see if the VarInfo name matches any of expected Pinterp // specific humidity variables. // - return(has_prefix(pinterp_specific_humidity_names, + return has_prefix(pinterp_specific_humidity_names, n_pinterp_specific_humidity_names, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -353,9 +353,9 @@ bool VarInfoNcWrf::is_u_wind() const { // Check to see if the VarInfo name matches any of expected Pinterp // U-component of wind variables. // - return(has_prefix(pinterp_u_wind_names, + return has_prefix(pinterp_u_wind_names, n_pinterp_u_wind_names, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -378,9 +378,9 @@ bool VarInfoNcWrf::is_v_wind() const { // Check to see if the VarInfo name matches any of expected Pinterp // V-component of wind variables. // - return(has_prefix(pinterp_v_wind_names, + return has_prefix(pinterp_v_wind_names, n_pinterp_v_wind_names, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -398,9 +398,9 @@ bool VarInfoNcWrf::is_wind_speed() const { // Check to see if the VarInfo name matches any of expected Pinterp // wind speed variables. // - return(has_prefix(pinterp_wind_speed_names, + return has_prefix(pinterp_wind_speed_names, n_pinterp_wind_speed_names, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -414,7 +414,7 @@ bool VarInfoNcWrf::is_wind_direction() const { return(SetAttrIsWindDirection != 0); } - return(false); + return false; } @@ -426,9 +426,9 @@ bool VarInfoNcWrf::is_grid_relative() const { // Check to see if the VarInfo name matches any of expected Pinterp // variables that should be rotated from grid-relative to earth-relative. // - return(has_prefix(pinterp_grid_relative_names, + return has_prefix(pinterp_grid_relative_names, n_pinterp_grid_relative_names, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc index 19c99b6de8..922f7926e1 100644 --- a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc +++ b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc @@ -195,13 +195,13 @@ Nc = open_ncfile(filename); mlog << Debug(5) << "\n" << method_name << "open \"" << filename << "\".\n\n"; -if ( IS_INVALID_NC_P(Nc) ) { close(); return ( false ); } +if ( IS_INVALID_NC_P(Nc) ) { close(); return false; } // // grid // -if ( !get_wrf_grid(*Nc, grid) ) { close(); return ( false ); } +if ( !get_wrf_grid(*Nc, grid) ) { close(); return false; } // // dimensions @@ -224,7 +224,7 @@ for (j=0; j= Ntimes) ) { } -return ( Time [n] ); +return Time[n]; } @@ -496,7 +496,7 @@ if ( (n < 0) || (n >= Ntimes) ) { unixtime dt = Time[n] - InitTime; -return ( (int) dt ); +return (int) dt; } @@ -557,7 +557,7 @@ if ( !status ) { // done // -return ( d ); +return d; } @@ -575,7 +575,7 @@ if ( !args_ok(a) ) { a.dump(cerr); - return ( false ); + return false; } @@ -596,7 +596,7 @@ if (dim_count >= max_wrf_args ) { mlog << Warning << "\n" << method_name << " too may arguments for variable \"" << (var_name) << "\"\n\n"; - return ( false ); + return false; } @@ -628,7 +628,7 @@ if ( !found ) { mlog << Warning << "\n" << method_name << "variable " << (var_name) << " not found!\n\n"; - return ( false ); + return false; } @@ -658,7 +658,7 @@ if ( !found ) { mlog << Error << "\n" << method_name << "X Dimension \"" << x_dim_subgrid_name << "\" is not supported.\n\n"; - return ( false ); + return false; } @@ -682,7 +682,7 @@ if ( !found ) { mlog << Error << "\n" << method_name << "Y Dimension \"" << y_dim_subgrid_name << "\" is not supported.\n\n"; - return ( false ); + return false; } @@ -787,7 +787,7 @@ if ( var == nullptr || (var->x_slot < 0) || (var->y_slot < 0) ) { << "can't find needed dimensions(s) for variable \"" << var_name << "\" ... one of the dimensions may be staggered.\n\n"; - return ( false ); + return false; } @@ -807,7 +807,7 @@ for (j=0; j<(a.n_elements()); ++j) { mlog << Warning << "\n" << method_name << " star found in bad slot\n\n"; - return ( false ); + return false; } @@ -819,7 +819,7 @@ if ( count != 2 ) { mlog << Warning << "\n" << method_name << " bad star count ... " << count << "\n\n"; - return ( false ); + return false; } @@ -835,7 +835,7 @@ if ( (x_slot < 0) || (y_slot < 0) ) { mlog << Warning << "\n" << method_name << " bad x|y slot\n\n"; - return ( false ); + return false; } @@ -905,7 +905,7 @@ if ( P && z_slot > 0 ) { // done // -return ( true ); +return true; } @@ -922,7 +922,7 @@ bool WrfFile::data(const char * var_name, const LongArray & a, DataPlane & plane if (nullptr != info) found = true; else found = get_nc_var_info(var_name, info); - if ( !found ) return ( false ); + if ( !found ) return false; found = data(info->var, a, plane, pressure); @@ -955,7 +955,7 @@ bool WrfFile::data(const char * var_name, const LongArray & a, DataPlane & plane // done // - return ( found ); + return found; } @@ -1018,7 +1018,7 @@ if ( j != 6 ) { t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -1030,8 +1030,8 @@ bool is_bad_data_wrf(double v) { -if (v < wrf_missing ) return ( false ); -else return ( true ); +if (v < wrf_missing ) return false; +else return true; } @@ -1052,7 +1052,7 @@ for ( j=0; j " << "an error occurred initializing python\n\n"; - return ( false ); + return false; } @@ -435,7 +435,7 @@ if ( PyErr_Occurred() ) { << "an error occurred importing module " << '\"' << path << "\"\n\n"; - return ( false ); + return false; } @@ -444,7 +444,7 @@ if ( ! module_obj ) { mlog << Warning << "\ntmp_nc_dataplane() -> " << "error running python script\n\n"; - return ( false ); + return false; } @@ -495,7 +495,7 @@ remove_temp_file(tmp_nc_path); // done // -return ( true ); +return true; } diff --git a/src/libcode/vx_data2d_python/var_info_python.cc b/src/libcode/vx_data2d_python/var_info_python.cc index 62bbdcd7aa..02c4eb2daa 100644 --- a/src/libcode/vx_data2d_python/var_info_python.cc +++ b/src/libcode/vx_data2d_python/var_info_python.cc @@ -66,11 +66,11 @@ VarInfoPython::VarInfoPython(const VarInfoPython &f) { VarInfoPython & VarInfoPython::operator=(const VarInfoPython &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -196,7 +196,7 @@ bool VarInfoPython::is_precipitation() const { return(SetAttrIsPrecipitation != 0); } - return ( false ); + return false; } @@ -212,7 +212,7 @@ bool VarInfoPython::is_specific_humidity() const { return(SetAttrIsSpecificHumidity != 0); } - return ( false ); + return false; } @@ -228,7 +228,7 @@ bool VarInfoPython::is_u_wind() const { return(SetAttrIsUWind != 0); } - return ( false ); + return false; } @@ -244,7 +244,7 @@ bool VarInfoPython::is_v_wind() const { return(SetAttrIsVWind != 0); } - return ( false ); + return false; } @@ -260,7 +260,7 @@ bool VarInfoPython::is_wind_speed() const { return(SetAttrIsWindSpeed != 0); } - return ( false ); + return false; } @@ -276,7 +276,7 @@ bool VarInfoPython::is_wind_direction() const { return(SetAttrIsWindDirection != 0); } - return ( false ); + return false; } diff --git a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc index cc9f0debc2..25e5f3ef6f 100644 --- a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc +++ b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc @@ -152,7 +152,7 @@ bool MetUGridDataFile::open_metadata(const char * _filename) { (*Dest_Grid) = (*Raw_Grid); //Dest_Grid->set(*_file->grid.info().us); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -417,7 +417,7 @@ LongArray MetUGridDataFile::collect_time_offsets(VarInfo &vinfo) { mlog << Warning << "\n" << method_name << "can't find NetCDF variable \"" << vinfo_nc->req_name() << "\" in file \"" << Filename << "\".\n\n"; - return(time_offsets); + return time_offsets; } int time_dim_slot = info->t_slot; @@ -426,7 +426,7 @@ LongArray MetUGridDataFile::collect_time_offsets(VarInfo &vinfo) { // The time dimension does not exist at the variable and the time // variable exists. Stop time slicing and set the time offset to 0. time_offsets.add(0); - return(time_offsets); + return time_offsets; } double time_lower = bad_data_double; @@ -604,7 +604,7 @@ LongArray MetUGridDataFile::collect_time_offsets(VarInfo &vinfo) { exit(1); } - return(time_offsets); + return time_offsets; } @@ -626,7 +626,7 @@ LongArray MetUGridDataFile::collect_vertical_offsets(VarInfo &vinfo) { mlog << Warning << "\n" << method_name << "can't find NetCDF variable \"" << vinfo_nc->req_name() << "\" in file \"" << Filename << "\".\n\n"; - return(vertical_offsets); + return vertical_offsets; } int z_dim_slot = info->z_slot; @@ -635,7 +635,7 @@ LongArray MetUGridDataFile::collect_vertical_offsets(VarInfo &vinfo) { // The vertical dimension does not exist at the variable and the vertical // variable exists. Stop vertical slicing and set the vertical offset to 0. vertical_offsets.add(0); - return(vertical_offsets); + return vertical_offsets; } double z_lower = bad_data_double; @@ -815,7 +815,7 @@ LongArray MetUGridDataFile::collect_vertical_offsets(VarInfo &vinfo) { exit(1); } - return(vertical_offsets); + return vertical_offsets; } */ diff --git a/src/libcode/vx_data2d_ugrid/var_info_ugrid.cc b/src/libcode/vx_data2d_ugrid/var_info_ugrid.cc index d9784e713c..45c1cbdfbc 100644 --- a/src/libcode/vx_data2d_ugrid/var_info_ugrid.cc +++ b/src/libcode/vx_data2d_ugrid/var_info_ugrid.cc @@ -67,11 +67,11 @@ VarInfoUGrid::VarInfoUGrid(const VarInfoUGrid &f) { VarInfoUGrid & VarInfoUGrid::operator=(const VarInfoUGrid &f) { - if ( this == &f ) return ( *this ); + if ( this == &f ) return *this; assign(f); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -386,9 +386,9 @@ bool VarInfoUGrid::is_precipitation() const { // Check to see if the VarInfo name begins with the GRIB code abbreviation // for any precipitation variables. // - return(has_prefix(grib_precipitation_abbr, + return has_prefix(grib_precipitation_abbr, n_grib_precipitation_abbr, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -406,9 +406,9 @@ bool VarInfoUGrid::is_specific_humidity() const { // Check to see if the VarInfo name begins with the GRIB code abbreviation // for any specific humidity variables. // - return(has_prefix(grib_specific_humidity_abbr, + return has_prefix(grib_specific_humidity_abbr, n_grib_specific_humidity_abbr, - Name.c_str())); + Name.c_str()); } /////////////////////////////////////////////////////////////////////////////// @@ -422,7 +422,7 @@ bool VarInfoUGrid::is_u_wind() const { return(SetAttrIsUWind != 0); } - return(is_grib_code_abbr_match(Name, ugrd_grib_code)); + return is_grib_code_abbr_match(Name, ugrd_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -436,7 +436,7 @@ bool VarInfoUGrid::is_v_wind() const { return(SetAttrIsVWind != 0); } - return(is_grib_code_abbr_match(Name, vgrd_grib_code)); + return is_grib_code_abbr_match(Name, vgrd_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -450,7 +450,7 @@ bool VarInfoUGrid::is_wind_speed() const { return(SetAttrIsWindSpeed != 0); } - return(is_grib_code_abbr_match(Name, wind_grib_code)); + return is_grib_code_abbr_match(Name, wind_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -464,7 +464,7 @@ bool VarInfoUGrid::is_wind_direction() const { return(SetAttrIsWindDirection != 0); } - return(is_grib_code_abbr_match(Name, wdir_grib_code)); + return is_grib_code_abbr_match(Name, wdir_grib_code); } /////////////////////////////////////////////////////////////////////////////// @@ -477,7 +477,7 @@ bool is_grib_code_abbr_match(const ConcatString &str, int grib_code) { ConcatString abbr_str; bool match = false; - if(str.empty()) return(false); + if(str.empty()) return false; // // Use the default GRIB1 parameter table version number 2 @@ -490,7 +490,7 @@ bool is_grib_code_abbr_match(const ConcatString &str, int grib_code) { // if(strncasecmp(str.c_str(), abbr_str.c_str(), abbr_str.length()) == 0) match = true; - return(match); + return match; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_geodesy/spheroid.cc b/src/libcode/vx_geodesy/spheroid.cc index 6f71fcfe76..3f13de75be 100644 --- a/src/libcode/vx_geodesy/spheroid.cc +++ b/src/libcode/vx_geodesy/spheroid.cc @@ -160,11 +160,11 @@ Spheroid & Spheroid::operator=(const Spheroid & g) { -if ( this == &g ) return ( * this ); +if ( this == &g ) return *this; assign(g); -return ( * this ); +return *this; } @@ -435,7 +435,7 @@ q = t1 - t2; q *= 1.0 - E2; -return ( q ); +return q; } @@ -447,7 +447,7 @@ double Spheroid::qp_direct() const { -if ( is_sphere() ) return ( 2.0 ); +if ( is_sphere() ) return 2.0; double Qp; @@ -459,7 +459,7 @@ Qp = log( (1.0 - E)/(1.0 + E) ); Qp = 1.0 - ((1.0 - E*E)*Qp)/(2.0*E); -return ( Qp ); +return Qp; } @@ -471,7 +471,7 @@ double Spheroid::rq_km() const { -if ( is_sphere() ) return ( A_km ); +if ( is_sphere() ) return A_km; double r; @@ -483,7 +483,7 @@ r = sqrt(0.5*qp); r *= A_km; -return ( r ); +return r; } @@ -495,7 +495,7 @@ double Spheroid::beta(double lat) const { -if ( is_sphere() ) return ( lat ); +if ( is_sphere() ) return lat; double q, qp; @@ -507,7 +507,7 @@ q = q_func(lat); qp = qp_direct(); -return ( asind(q/qp) ); +return asind(q/qp); } @@ -529,7 +529,7 @@ m = sqrt( 1.0 - E*E*s*s ); m = c/m; -return ( m ); +return m; } @@ -557,7 +557,7 @@ t = b/a; e = sqrt( 1.0 - t*t ); -return ( e ); +return e; } @@ -577,7 +577,7 @@ t = b/a; f = 1.0 - t; -return ( f ); +return f; } @@ -595,7 +595,7 @@ double u; u = atan2d(b*sind(phi), a*cosd(phi)); -return ( u ); +return u; } @@ -613,7 +613,7 @@ double phi; phi = atan2d(a*sind(u), b*cosd(u)); -return ( phi ); +return phi; } diff --git a/src/libcode/vx_gis/dbf_file.cc b/src/libcode/vx_gis/dbf_file.cc index 66361dd7e4..248b2249a1 100644 --- a/src/libcode/vx_gis/dbf_file.cc +++ b/src/libcode/vx_gis/dbf_file.cc @@ -79,11 +79,11 @@ DbfHeader & DbfHeader::operator=(const DbfHeader & h) { -if ( this == &h ) return ( * this ); +if ( this == &h ) return *this; assign(h); -return ( * this ); +return *this; } @@ -383,7 +383,7 @@ for (j=0; j>(ShpFile &, ShpPointRecord &) -> trouble reading record header from shp file \"" @@ -160,7 +160,7 @@ record.set(xy_buf); // done // -return ( true ); +return true; } diff --git a/src/libcode/vx_gis/shp_poly_record.cc b/src/libcode/vx_gis/shp_poly_record.cc index 5a9c46749e..c86e11010c 100644 --- a/src/libcode/vx_gis/shp_poly_record.cc +++ b/src/libcode/vx_gis/shp_poly_record.cc @@ -249,7 +249,7 @@ if ( (k < 0) || (k >= n_points) ) { } -return ( points[k].y ); +return points[k].y; } @@ -272,7 +272,7 @@ if ( (k < 0) || (k >= n_points) ) { double t = points[k].x; -return ( -t ); +return -t; } @@ -294,7 +294,7 @@ if ( (partno < 0) || (partno >= n_parts) ) { } -return ( parts[partno] ); +return parts[partno]; } @@ -372,7 +372,7 @@ unsigned char rh_buf[shp_record_header_bytes]; if ( ! file.read(rh_buf, shp_record_header_bytes) ) { - if ( file.at_eof() ) return ( false ); + if ( file.at_eof() ) return false; mlog << Error << "\n\n operator>>(ShpFile &, ShpPolyRecord &) -> trouble reading record header from shp file \"" @@ -417,7 +417,7 @@ record.set((unsigned char *) Buf); // done // -return ( true ); +return true; } diff --git a/src/libcode/vx_gnomon/gnomon.cc b/src/libcode/vx_gnomon/gnomon.cc index 7e60ff86d3..5a95ff7e85 100644 --- a/src/libcode/vx_gnomon/gnomon.cc +++ b/src/libcode/vx_gnomon/gnomon.cc @@ -103,11 +103,11 @@ GnomonicProjection & GnomonicProjection::operator=(const GnomonicProjection & g) { -if ( this == &g ) return ( * this ); +if ( this == &g ) return *this; assign(g); -return ( * this ); +return *this; } @@ -215,7 +215,7 @@ pz = sind(lat); p_dot_b3 = px*Ux + py*Uy + pz*Uz; -if ( p_dot_b3 <= 0.0 ) return ( 0 ); +if ( p_dot_b3 <= 0.0 ) return 0; p_dot_b1 = px*Ex + py*Ey + pz*Ez; p_dot_b2 = px*Nx + py*Ny + pz*Nz; @@ -225,7 +225,7 @@ u = p_dot_b1/p_dot_b3; v = p_dot_b2/p_dot_b3; -return ( 1 ); +return 1; } diff --git a/src/libcode/vx_grid/earth_rotation.cc b/src/libcode/vx_grid/earth_rotation.cc index 09badf97d3..1b93c8743c 100644 --- a/src/libcode/vx_grid/earth_rotation.cc +++ b/src/libcode/vx_grid/earth_rotation.cc @@ -205,7 +205,7 @@ SO3::forward(V.x(), V.y(), V.z(), xx, yy, zz); VV.set_xyz(xx, yy, zz); -return ( VV ); +return VV; } */ @@ -225,7 +225,7 @@ SO3::reverse(V.x(), V.y(), V.z(), xx, yy, zz); VV.set_xyz(xx, yy, zz); -return ( VV ); +return VV; } */ diff --git a/src/libcode/vx_grid/find_grid_by_name.cc b/src/libcode/vx_grid/find_grid_by_name.cc index 30fda12c24..3b155585ef 100644 --- a/src/libcode/vx_grid/find_grid_by_name.cc +++ b/src/libcode/vx_grid/find_grid_by_name.cc @@ -51,7 +51,7 @@ bool status = false; status = find_grid_by_name(name, i); -if ( !status || !(i.ok()) ) return ( false ); +if ( !status || !(i.ok()) ) return false; status = false; @@ -69,7 +69,7 @@ if ( i.sl ) { g.set( *(i.sl) ); status = true; } if ( i.us ) { g.set( *(i.us) ); status = true; } #endif -return ( status ); +return status; } @@ -95,7 +95,7 @@ for (j=0; j " << "polar stereographic grid spec should have 10 entries\n\n"; - return ( false ); + return false; } @@ -493,7 +493,7 @@ if ( ToGrid ) { delete ToGrid; ToGrid = (Grid *) 0; } // -return ( true ); +return true; } @@ -573,7 +573,7 @@ if ( ToGrid ) { delete ToGrid; ToGrid = (Grid *) 0; } // -return ( true ); +return true; } @@ -664,7 +664,7 @@ if ( ToGrid ) { delete ToGrid; ToGrid = (Grid *) 0; } // -return ( true ); +return true; } @@ -745,7 +745,7 @@ if ( ToGrid ) { delete ToGrid; ToGrid = (Grid *) 0; } // -return ( true ); +return true; } @@ -814,7 +814,7 @@ if ( ToGrid ) { delete ToGrid; ToGrid = (Grid *) 0; } // -return ( true ); +return true; } diff --git a/src/libcode/vx_grid/gaussian_grid.cc b/src/libcode/vx_grid/gaussian_grid.cc index eccea8d55b..92cd493b41 100644 --- a/src/libcode/vx_grid/gaussian_grid.cc +++ b/src/libcode/vx_grid/gaussian_grid.cc @@ -290,7 +290,7 @@ area *= sind(lat_top) - sind(lat_bot); area *= earth_radius_km*earth_radius_km; -return ( area ); +return area; } @@ -302,7 +302,7 @@ int GaussianGrid::nx() const { -return ( Nx ); +return Nx; } @@ -314,7 +314,7 @@ int GaussianGrid::ny() const { -return ( Ny ); +return Ny; } @@ -326,7 +326,7 @@ ConcatString GaussianGrid::name() const { -return ( Name ); +return Name; } @@ -384,7 +384,7 @@ a << "Ny: " << Ny; // done // -return ( a ); +return a; } @@ -401,7 +401,7 @@ GridInfo i; i.set( Data ); -return ( i ); +return i; } @@ -419,7 +419,7 @@ double GaussianGrid::rot_grid_to_earth(int x, int y) const // need to be changed when support is added for GRIB2. // -return ( 0.0 ); +return 0.0; } @@ -431,7 +431,7 @@ bool GaussianGrid::wrap_lon() const { -return ( true ); +return true; } @@ -461,7 +461,7 @@ GaussianGrid * p = new GaussianGrid (Data); p->Name = Name; -return ( p ); +return p; } diff --git a/src/libcode/vx_grid/goes_grid.cc b/src/libcode/vx_grid/goes_grid.cc index 76c8f5e51d..5ffa5cbd90 100644 --- a/src/libcode/vx_grid/goes_grid.cc +++ b/src/libcode/vx_grid/goes_grid.cc @@ -172,7 +172,7 @@ double sum = 0; mlog << Error << "\n" << method_name << " -> " << "is not implemented.\n\n"; -return ( sum ); +return sum; } @@ -183,7 +183,7 @@ int GoesImagerGrid::nx() const { -return ( Nx ); +return Nx; } @@ -195,7 +195,7 @@ int GoesImagerGrid::ny() const { -return ( Ny ); +return Ny; } @@ -207,7 +207,7 @@ ConcatString GoesImagerGrid::name() const { -return ( Name ); +return Name; } @@ -268,7 +268,7 @@ a << "Ny: " << Ny; // done // -return ( a ); +return a; } @@ -284,7 +284,7 @@ GridInfo i; i.set(Data); -return ( i ); +return i; } @@ -301,7 +301,7 @@ double GoesImagerGrid::rot_grid_to_earth(int x, int y) const // for the Mercator projection in it's standard aspect // -return ( 0.0 ); +return 0.0; } @@ -313,7 +313,7 @@ bool GoesImagerGrid::wrap_lon() const { -return ( false ); +return false; } @@ -346,7 +346,7 @@ GoesImagerGrid * p = new GoesImagerGrid (Data); p->Name = Name; -return ( p ); +return p; } diff --git a/src/libcode/vx_grid/grid_base.cc b/src/libcode/vx_grid/grid_base.cc index d3b0cfee26..5a62372bd3 100644 --- a/src/libcode/vx_grid/grid_base.cc +++ b/src/libcode/vx_grid/grid_base.cc @@ -1042,7 +1042,7 @@ double Grid::calc_area(int x, int y) const { -if ( !rep ) return ( 0.0 ); +if ( !rep ) return 0.0; return rep->calc_area(x, y); @@ -1056,7 +1056,7 @@ int Grid::nx() const { -if ( !rep ) return ( 0 ); +if ( !rep ) return 0; return rep->nx(); @@ -1070,7 +1070,7 @@ int Grid::ny() const { -if ( !rep ) return ( 0 ); +if ( !rep ) return 0; return rep->ny(); diff --git a/src/libcode/vx_grid/latlon_grid.cc b/src/libcode/vx_grid/latlon_grid.cc index 4b9920d5e7..1e42a43963 100644 --- a/src/libcode/vx_grid/latlon_grid.cc +++ b/src/libcode/vx_grid/latlon_grid.cc @@ -207,7 +207,7 @@ area = ( sin(lat_top_rad) - sin(lat_bottom_rad) )*delta_lon_rad; area = fabs(area)*earth_radius_km*earth_radius_km; -return ( area ); +return area; } @@ -219,7 +219,7 @@ int LatLonGrid::nx() const { -return ( Nx ); +return Nx; } @@ -231,7 +231,7 @@ int LatLonGrid::ny() const { -return ( Ny ); +return Ny; } @@ -243,7 +243,7 @@ ConcatString LatLonGrid::name() const { -return ( Name ); +return Name; } @@ -311,7 +311,7 @@ snprintf(junk, sizeof(junk), "wrapLon: %s", bool_to_string(wrapLon)); a << jun // done // -return ( a ); +return a; } @@ -327,7 +327,7 @@ GridInfo i; i.set( Data ); -return ( i ); +return i; } @@ -345,7 +345,7 @@ double LatLonGrid::rot_grid_to_earth(int x, int y) const // need to be changed when support is added for GRIB2. // -return ( 0.0 ); +return 0.0; } @@ -403,7 +403,7 @@ LatLonGrid * p = new LatLonGrid (Data); p->Name = Name; -return ( p ); +return p; } diff --git a/src/libcode/vx_grid/lc_grid.cc b/src/libcode/vx_grid/lc_grid.cc index 7049f60d94..08b45f2510 100644 --- a/src/libcode/vx_grid/lc_grid.cc +++ b/src/libcode/vx_grid/lc_grid.cc @@ -226,7 +226,7 @@ double LambertGrid::f(double lat) const { -return ( lc_func(lat, Cone, IsNorthHemisphere) ); +return lc_func(lat, Cone, IsNorthHemisphere); } @@ -238,7 +238,7 @@ double LambertGrid::df(double lat) const { -return ( lc_der_func(lat, Cone, IsNorthHemisphere) ); +return lc_der_func(lat, Cone, IsNorthHemisphere); } @@ -349,7 +349,7 @@ sum = uv_closedpolyline_area(u, v, 4); sum *= earth_radius_km*earth_radius_km; -return ( sum ); +return sum; } @@ -361,7 +361,7 @@ int LambertGrid::nx() const { -return ( Nx ); +return Nx; } @@ -373,7 +373,7 @@ int LambertGrid::ny() const { -return ( Ny ); +return Ny; } @@ -385,7 +385,7 @@ ConcatString LambertGrid::name() const { -return ( Name ); +return Name; } @@ -413,7 +413,7 @@ for (j=0; jName = Name; -return ( p ); +return p; } @@ -719,7 +719,7 @@ r = tand(45.0 - 0.5*H*lat); r = pow(r, Cone); -return ( r ); +return r; } @@ -738,7 +738,7 @@ lat = 90.0 - 2.0*atand(pow(r, 1.0/Cone)); lat *= H; -return ( lat ); +return lat; } @@ -757,7 +757,7 @@ a = -(Cone/cosd(lat))*lc_func(lat, Cone, is_north); a *= H; -return ( a ); +return a; } @@ -849,7 +849,7 @@ rom = t[i]; rom *= (2.0/c)*(u0*v1 - u1*v0); -return ( rom ); +return rom; } @@ -875,7 +875,7 @@ e_top = e_bot - 1.0; answer = pow(r2, e_top)/(1.0 + pow(r2, e_bot)); -return ( answer ); +return answer; } @@ -938,7 +938,7 @@ if ( fabs(lat1 - lat2) < tol ) { cone = sind(H*lat1); - return ( cone ); + return cone; } @@ -955,7 +955,7 @@ b = tand(45.0 - 0.5*H*lat1)/tand(45.0 - 0.5*H*lat2); cone = log(t)/log(b); -return ( cone ); +return cone; } @@ -1025,7 +1025,7 @@ g_new.set(data); // done // -return ( g_new ); +return g_new; } diff --git a/src/libcode/vx_grid/merc_grid.cc b/src/libcode/vx_grid/merc_grid.cc index 015109db2c..2da8b88491 100644 --- a/src/libcode/vx_grid/merc_grid.cc +++ b/src/libcode/vx_grid/merc_grid.cc @@ -213,7 +213,7 @@ double MercatorGrid::f(double lat) const { -return ( merc_func(lat/deg_per_rad) ); +return merc_func(lat/deg_per_rad); } @@ -225,7 +225,7 @@ double MercatorGrid::df(double lat) const { -return ( merc_der_func(lat/deg_per_rad) ); +return merc_der_func(lat/deg_per_rad); } @@ -302,7 +302,7 @@ sum = uv_closedpolyline_area(u, v, 4); sum *= earth_radius_km*earth_radius_km; -return ( sum ); +return sum; } @@ -314,7 +314,7 @@ int MercatorGrid::nx() const { -return ( Nx ); +return Nx; } @@ -326,7 +326,7 @@ int MercatorGrid::ny() const { -return ( Ny ); +return Ny; } @@ -338,7 +338,7 @@ ConcatString MercatorGrid::name() const { -return ( Name ); +return Name; } @@ -366,7 +366,7 @@ for (j=0; jName = Name; -return ( p ); +return p; } @@ -623,7 +623,7 @@ double v; v = log(tan(piover4 + 0.5*lat_rad)); -return ( v ); +return v; } @@ -639,7 +639,7 @@ double lat_rad; lat_rad = 2.0*atan(exp(v)) - piover2; -return ( lat_rad ); +return lat_rad; } @@ -655,7 +655,7 @@ double a; a = 1.0/(cos(lat_rad)); -return ( a ); +return a; } @@ -688,7 +688,7 @@ if ( fabs(delta_v) < 1.0e-4 ) { answer = delta_u*(1.0 - tanh(v0)); - return ( answer ); + return answer; } @@ -705,7 +705,7 @@ answer = (delta_u/delta_v)*(b1 - b0); // done // -return ( answer ); +return answer; } @@ -723,7 +723,7 @@ lon_rad -= twopi*floor((lon_rad - lon_min)/twopi); u = -lon_rad; -return ( u ); +return u; } @@ -741,7 +741,7 @@ lon_rad = -u; lon_rad -= twopi*floor((lon_rad - lon_min)/twopi); -return ( lon_rad ); +return lon_rad; } diff --git a/src/libcode/vx_grid/rot_latlon_grid.cc b/src/libcode/vx_grid/rot_latlon_grid.cc index a5df5a3bfc..abd4ff0f38 100644 --- a/src/libcode/vx_grid/rot_latlon_grid.cc +++ b/src/libcode/vx_grid/rot_latlon_grid.cc @@ -235,7 +235,7 @@ double RotatedLatLonGrid::calc_area(int x, int y) const double area = LatLonGrid::calc_area(x, y); -return ( area ); +return area; } @@ -248,7 +248,7 @@ int RotatedLatLonGrid::nx() const { -return ( Nx ); +return Nx; } @@ -260,7 +260,7 @@ int RotatedLatLonGrid::ny() const { -return ( Ny ); +return Ny; } @@ -272,7 +272,7 @@ ConcatString RotatedLatLonGrid::name() const { -return ( Name ); +return Name; } @@ -330,7 +330,7 @@ snprintf(junk, sizeof(junk), "aux_rotation: %.3f", RData.aux_rotation); a << j // done // -return ( a ); +return a; } @@ -346,7 +346,7 @@ GridInfo i; i.set( RData ); -return ( i ); +return i; } @@ -364,7 +364,7 @@ double RotatedLatLonGrid::rot_grid_to_earth(int x, int y) const // need to be changed when support is added for GRIB2. // -return ( 0.0 ); +return 0.0; } @@ -397,7 +397,7 @@ RotatedLatLonGrid * p = new RotatedLatLonGrid (RData); p->Name = Name; -return ( p ); +return p; } diff --git a/src/libcode/vx_grid/semilatlon_grid.cc b/src/libcode/vx_grid/semilatlon_grid.cc index c188025882..5722a0a0f1 100644 --- a/src/libcode/vx_grid/semilatlon_grid.cc +++ b/src/libcode/vx_grid/semilatlon_grid.cc @@ -273,7 +273,7 @@ double SemiLatLonGrid::calc_area(int x, int y) const // Grid cell area is not defined for semilatlon grids -return ( bad_data_double ); +return bad_data_double; } @@ -285,7 +285,7 @@ int SemiLatLonGrid::nx() const { -return ( Nx ); +return Nx; } @@ -297,7 +297,7 @@ int SemiLatLonGrid::ny() const { -return ( Ny ); +return Ny; } @@ -309,7 +309,7 @@ ConcatString SemiLatLonGrid::name() const { -return ( Name ); +return Name; } @@ -383,7 +383,7 @@ a << "Times: " << Times.summarize() << sep; // done // -return ( a ); +return a; } @@ -399,7 +399,7 @@ GridInfo i; i.set(Data); -return ( i ); +return i; } @@ -416,7 +416,7 @@ double SemiLatLonGrid::rot_grid_to_earth(int x, int y) const // does not apply to semilatlon grids // -return ( 0.0 ); +return 0.0; } @@ -428,7 +428,7 @@ bool SemiLatLonGrid::wrap_lon() const { -return ( false ); +return false; } @@ -459,7 +459,7 @@ SemiLatLonGrid * p = new SemiLatLonGrid (Data); p->Name = Name; -return ( p ); +return p; } diff --git a/src/libcode/vx_grid/st_grid.cc b/src/libcode/vx_grid/st_grid.cc index c1299471e6..c37e5b48c2 100644 --- a/src/libcode/vx_grid/st_grid.cc +++ b/src/libcode/vx_grid/st_grid.cc @@ -163,7 +163,7 @@ double StereographicGrid::f(double lat) const { -return ( st_func(lat, is_north()) ); +return st_func(lat, is_north()); } @@ -175,7 +175,7 @@ double StereographicGrid::df(double lat) const { -return ( st_der_func(lat, is_north()) ); +return st_der_func(lat, is_north()); } @@ -281,7 +281,7 @@ sum = uv_closedpolyline_area(u, v, 4); sum *= earth_radius_km*earth_radius_km; -return ( sum ); +return sum; } @@ -293,7 +293,7 @@ int StereographicGrid::nx() const { -return ( Nx ); +return Nx; } @@ -305,7 +305,7 @@ int StereographicGrid::ny() const { -return ( Ny ); +return Ny; } @@ -333,7 +333,7 @@ for (j=0; jName = Name; -return ( p ); +return p; } @@ -620,7 +620,7 @@ else r = tand(45.0 + 0.5*lat); if (!is_eq(eccentricity, 0.)) { r *= pow(((1 + eccentricity*sind(lat)) / (1 - eccentricity*sind(lat))),(eccentricity/2)); } -return ( r ); +return r; } @@ -638,7 +638,7 @@ lat = 90.0 - 2.0*atand(r); if ( !is_north_hemisphere ) lat = -lat; -return ( lat ); +return lat; } @@ -655,7 +655,7 @@ double a; if ( is_north_hemisphere ) a = -1.0/(1.0 + sind(lat)); else a = 1.0/(1.0 - sind(lat)); -return ( a ); +return a; } @@ -753,7 +753,7 @@ if (is_eq(semi_minor_axis, bad_data_double)) { } eccentricity = sqrt(semi_major_axis*semi_major_axis - semi_minor_axis*semi_minor_axis) / semi_major_axis; -return ( eccentricity ); +return eccentricity; } @@ -777,7 +777,7 @@ else tF = tan(M_PI/4 + sp_rad/2) / temp2; mF = lat_cos / sqrt(1 - eccentricity*eccentricity * lat_sin*lat_sin); scale_factor = mF * sqrt(pow((1+eccentricity),(1+eccentricity)) * pow((1-eccentricity),(1-eccentricity))) / (2 * tF); -return ( scale_factor ); +return scale_factor; } @@ -794,7 +794,7 @@ double alpha; alpha = (1.0 + sind(fabs(scale_lat)))*((r_km)/(d_km)); -return ( alpha ); +return alpha; } @@ -835,7 +835,7 @@ answer = atan(t1) - atan(t2); answer *= 2.0*b*( u0*v1 - u1*v0 ); -return ( answer ); +return answer; } @@ -960,7 +960,7 @@ data.lon_orient = L; g_new.set(data); -return ( g_new ); +return g_new; } diff --git a/src/libcode/vx_grid/tcrmw_grid.cc b/src/libcode/vx_grid/tcrmw_grid.cc index 031c71c65e..9f80f1a814 100644 --- a/src/libcode/vx_grid/tcrmw_grid.cc +++ b/src/libcode/vx_grid/tcrmw_grid.cc @@ -102,11 +102,11 @@ TcrmwGrid & TcrmwGrid::operator=(const TcrmwGrid & tg) { -if ( this == &tg ) return ( * this ); +if ( this == &tg ) return *this; assign(tg); -return ( * this ); +return *this; } diff --git a/src/libcode/vx_grid/unstructured_grid.cc b/src/libcode/vx_grid/unstructured_grid.cc index 33db3fdcc7..9af740a233 100644 --- a/src/libcode/vx_grid/unstructured_grid.cc +++ b/src/libcode/vx_grid/unstructured_grid.cc @@ -165,7 +165,7 @@ double UnstructuredGrid::calc_area(int x, int y) const { double area = 0.; - return ( area ); + return area; } diff --git a/src/libcode/vx_gsl_prob/gsl_bvn.cc b/src/libcode/vx_gsl_prob/gsl_bvn.cc index 1cbb1b950c..1a2c92d74e 100644 --- a/src/libcode/vx_gsl_prob/gsl_bvn.cc +++ b/src/libcode/vx_gsl_prob/gsl_bvn.cc @@ -72,7 +72,7 @@ ellipse.b = radius*sqrt(fabs(d22)); // done // -return ( ellipse ); +return ellipse; } @@ -95,7 +95,7 @@ r2 = z_1*z_1 + z_2*z_2; q = 1.0 - exp(-0.5*r2); -return ( q ); +return q; } @@ -194,7 +194,7 @@ rho2 = Suv; angle_degrees = cf*0.5*atan2(rho2, rho1); -return ( angle_degrees ); +return angle_degrees; } diff --git a/src/libcode/vx_gsl_prob/gsl_cdf.cc b/src/libcode/vx_gsl_prob/gsl_cdf.cc index efd4a22a1a..beb0b53dec 100644 --- a/src/libcode/vx_gsl_prob/gsl_cdf.cc +++ b/src/libcode/vx_gsl_prob/gsl_cdf.cc @@ -36,7 +36,7 @@ double y; y = ( is_bad_data(x) ? bad_data_double : gsl_cdf_ugaussian_P(x) ); -return ( y ); +return y; } @@ -51,7 +51,7 @@ double x; x = ( is_bad_data(y) ? bad_data_double : gsl_cdf_ugaussian_Pinv(y) ); -return ( x ); +return x; } @@ -66,7 +66,7 @@ double y; y = ( is_bad_data(x) ? bad_data_double : gsl_ran_ugaussian_pdf(x) ); -return ( y ); +return y; } @@ -81,7 +81,7 @@ double y; y = ( is_bad_data(x) || is_bad_data(mu) || is_bad_data(sigma) ? bad_data_double : gsl_cdf_gaussian_P(x - mu, sigma) ); -return ( y ); +return y; } @@ -96,7 +96,7 @@ double x; x = ( is_bad_data(y) || is_bad_data(mu) || is_bad_data(sigma) ? bad_data_double : mu + gsl_cdf_gaussian_Pinv(y, sigma) ); -return ( x ); +return x; } @@ -111,7 +111,7 @@ double y; y = ( is_bad_data(x) || is_bad_data(sigma) ? bad_data_double : gsl_ran_gaussian_pdf(x, sigma) ); -return ( y ); +return y; } @@ -126,7 +126,7 @@ double y; y = ( is_bad_data(x) || is_bad_data(deg_freedom) ? bad_data_double : gsl_cdf_chisq_P(x, deg_freedom) ); -return ( y ); +return y; } @@ -139,7 +139,7 @@ double chi2_cdf_inv(double y, double deg_freedom) double x, cv_normal; double large_n = 50.0; -if(is_bad_data(y) || is_bad_data(deg_freedom)) return ( bad_data_double ); +if(is_bad_data(y) || is_bad_data(deg_freedom)) return bad_data_double; // // The following is a workaround for handling a GSL bug when the @@ -160,7 +160,7 @@ else { x = gsl_cdf_chisq_Pinv(y, deg_freedom); } -return ( x ); +return x; } @@ -175,7 +175,7 @@ double y; y = ( is_bad_data(x) || is_bad_data(deg_freedom) ? bad_data_double : gsl_cdf_tdist_P(x, deg_freedom) ); -return ( y ); +return y; } @@ -190,7 +190,7 @@ double x; x = ( is_bad_data(y) || is_bad_data(deg_freedom) ? bad_data_double : gsl_cdf_tdist_Pinv(y, deg_freedom) ); -return ( x ); +return x; } @@ -205,7 +205,7 @@ double y; y = ( is_bad_data(x) || is_bad_data(deg_freedom_1) || is_bad_data(deg_freedom_2) ? bad_data_double : gsl_cdf_fdist_P(x, deg_freedom_1, deg_freedom_2) ); -return ( y ); +return y; } @@ -219,7 +219,7 @@ double x, x_new, cor; const double tol = 1.0e-10; if(is_bad_data(y) || is_bad_data(deg_freedom_1) || is_bad_data(deg_freedom_2)) - return ( bad_data_double ); + return bad_data_double; x = 1.0; // starting value @@ -234,7 +234,7 @@ do { } while ( cor >= tol ); -return ( x ); +return x; } diff --git a/src/libcode/vx_gsl_prob/gsl_randist.cc b/src/libcode/vx_gsl_prob/gsl_randist.cc index 685fb63973..99a5a00edf 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.cc +++ b/src/libcode/vx_gsl_prob/gsl_randist.cc @@ -250,7 +250,7 @@ double ran_draw(const gsl_rng *r, DistType t, double p1, double p2) { } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -299,7 +299,7 @@ double dist_var(DistType t, double p1, double p2) { break; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -320,7 +320,7 @@ int get_seed() { u[1] = u[2]; u[2] = t; - return(curr_time); + return curr_time; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gsl_prob/gsl_statistics.cc b/src/libcode/vx_gsl_prob/gsl_statistics.cc index 2f1ac4afcc..70a2c1a878 100644 --- a/src/libcode/vx_gsl_prob/gsl_statistics.cc +++ b/src/libcode/vx_gsl_prob/gsl_statistics.cc @@ -38,7 +38,7 @@ double stats_lag1_autocorrelation(const NumArray &na) { if(src) { delete [] src; src = (double *) 0; } - return(corr); + return corr; } //////////////////////////////////////////////////////////////////////// @@ -57,7 +57,7 @@ double sf_lambert_W0(const double x) { w = lw.val; } - return(w); + return w; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc b/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc index fe5ad84188..11cf75d247 100644 --- a/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc +++ b/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc @@ -38,7 +38,7 @@ gsl_wavelet * wavelet_set(gsl_wavelet_type *t, int k) { exit(1); } - return(w); + return w; } //////////////////////////////////////////////////////////////////////// @@ -67,7 +67,7 @@ void wavelet_free(gsl_wavelet *w) { const char *wavelet_name(const gsl_wavelet *w) { - return(gsl_wavelet_name(w)); + return gsl_wavelet_name(w); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nav/nav.cc b/src/libcode/vx_nav/nav.cc index 8b81e679e8..38652e9f2c 100644 --- a/src/libcode/vx_nav/nav.cc +++ b/src/libcode/vx_nav/nav.cc @@ -82,7 +82,7 @@ x = haversine(dp) + cos(lat1_radians)*cos(lat2_radians)*haversine(dl); x = earth_radius_km*ahaversine(x); -return ( x ); +return x; } @@ -132,7 +132,7 @@ double ahaversine(double t) double a = 2.0*asin(sqrt(t)); -return ( a ); +return a; } @@ -164,7 +164,7 @@ if ( fabs(lat1 - lat2) < 0.0001 ) { d = earth_radius_km*cosd(lat1)*(lon1 - lon2) * rad_per_deg; // d = earth_radius_km*cos(lat1/cf)*((lon1 - lon2)/cf); - return ( fabs(d) ); + return fabs(d); } @@ -173,7 +173,7 @@ beta = rl_bearing(lat1, lon1, lat2, lon2); d = earth_radius_km*( rad_per_deg * (lat1 - lat2)/cosd(beta) ); //d = earth_radius_km*( ((lat1 - lat2)/cf)/cos(beta/cf) ); -return ( fabs(d) ); +return fabs(d); } @@ -207,7 +207,7 @@ mp2 = meridional_parts(lat2); beta = atan2d( rad_per_deg * (lon1 - lon2), mp2 - mp1); //beta = cf*atan2((lon1 - lon2)/cf, mp2 - mp1); -return ( beta ); +return beta; } @@ -233,7 +233,7 @@ double meridional_parts(double a) a = a * rad_per_deg; //a /= cf; -return ( log(tan(piover4 + (0.5*a))) ); +return log(tan(piover4 + (0.5*a))); } @@ -276,7 +276,7 @@ y = cosd(lat2)*sind(dl); beta = atan2d(y, x); //beta = cf*atan2(y, x); -return ( beta ); +return beta; } @@ -580,7 +580,7 @@ double gc_dist_to_line(double lat1, double lon1, gc_dist(lat2, lon2, lat3, lon3)); } - return(dist); + return dist; } ////////////////////////////////////////////////////////////////// @@ -592,7 +592,7 @@ Vector3D latlon_to_xyz(double lat, double lon) { v.y = cosd(lat) * sind(lon) * earth_radius_km; v.z = sind(lat) * earth_radius_km; - return(v); + return v; } ////////////////////////////////////////////////////////////////// @@ -621,7 +621,7 @@ Vector3D cross_product(Vector3D v1, Vector3D v2) { v.y = v2.x*v1.z - v1.x*v2.z; v.z = v1.x*v2.y - v1.y*v2.x; - return(v); + return v; } ////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_util/nc_utils.cc b/src/libcode/vx_nc_util/nc_utils.cc index dcd24b59b1..96441e3909 100644 --- a/src/libcode/vx_nc_util/nc_utils.cc +++ b/src/libcode/vx_nc_util/nc_utils.cc @@ -805,7 +805,7 @@ bool get_global_att(const NcFile *nc, const ConcatString& att_name, if (status) att_val = tmp_att_val; } - return (status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -1057,7 +1057,7 @@ ConcatString* get_string_val(NcFile * nc, const char * var_name, const int index const int len, ConcatString &tmp_cs) { NcVar var = get_var(nc, var_name); - return (get_string_val(&var, index, len, tmp_cs)); + return get_string_val(&var, index, len, tmp_cs); } //////////////////////////////////////////////////////////////////////// @@ -1101,7 +1101,7 @@ ConcatString* get_string_val(NcVar *var, const int index, // tmp_cs = tmp_str; - return (&tmp_cs); + return &tmp_cs; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_util/nc_var_info.cc b/src/libcode/vx_nc_util/nc_var_info.cc index 4d23e8e65b..9e53fa7342 100644 --- a/src/libcode/vx_nc_util/nc_var_info.cc +++ b/src/libcode/vx_nc_util/nc_var_info.cc @@ -99,11 +99,11 @@ assign(i); NcVarInfo & NcVarInfo::operator=(const NcVarInfo & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -244,7 +244,7 @@ return; int NcVarInfo::lead_time() const { -return ( (int) (ValidTime - InitTime) ); +return (int) (ValidTime - InitTime); } @@ -374,7 +374,7 @@ bool get_att_str(const NcVarInfo &info, const ConcatString att_name, // done // - return ( found ); + return found; } @@ -407,7 +407,7 @@ bool get_att_int(const NcVarInfo &info, const ConcatString att_name, // done // - return ( found ); + return found; } @@ -448,7 +448,7 @@ bool get_att_unixtime(const NcVar *var, const ConcatString att_name, // done // - return ( found ); + return found; } diff --git a/src/libcode/vx_pb_util/do_blocking.cc b/src/libcode/vx_pb_util/do_blocking.cc index a43b33a768..789b4baaae 100644 --- a/src/libcode/vx_pb_util/do_blocking.cc +++ b/src/libcode/vx_pb_util/do_blocking.cc @@ -174,13 +174,13 @@ while ( (n_read = read(fd, tempbuf, sizeof(tempbuf))) > 0 ) { // lseek(fd, pos + 2, SEEK_SET); lseek(fd, pos, SEEK_SET); - return ( pos ); + return pos; } } // for j - if ( n_read < 10 ) return ( -1 ); + if ( n_read < 10 ) return -1; pos += n_read - 5; @@ -188,7 +188,7 @@ while ( (n_read = read(fd, tempbuf, sizeof(tempbuf))) > 0 ) { } // while -if ( n_read == 0 ) return ( -1 ); +if ( n_read == 0 ) return -1; if ( n_read < 0 ) { @@ -199,7 +199,7 @@ if ( n_read < 0 ) { } -return ( pos ); +return pos; } @@ -295,7 +295,7 @@ if ( lseek(fd, pos, SEEK_SET) < 0 ) { // done // -return ( rec_size ); +return rec_size; } diff --git a/src/libcode/vx_pb_util/do_unblocking.cc b/src/libcode/vx_pb_util/do_unblocking.cc index 31e07e2631..bdb5396d62 100644 --- a/src/libcode/vx_pb_util/do_unblocking.cc +++ b/src/libcode/vx_pb_util/do_unblocking.cc @@ -105,7 +105,7 @@ switch ( padsize ) { n_read = read(fd, b, bytes); -if ( n_read == 0 ) return ( 0 ); +if ( n_read == 0 ) return 0; if ( (n_read < 0) || ((n_read > 0) && (n_read != bytes)) ) { @@ -138,7 +138,7 @@ switch ( padsize ) { // done // -return ( value ); +return value; } diff --git a/src/libcode/vx_plot_util/map_region.cc b/src/libcode/vx_plot_util/map_region.cc index daa54185e6..5856adc159 100644 --- a/src/libcode/vx_plot_util/map_region.cc +++ b/src/libcode/vx_plot_util/map_region.cc @@ -75,11 +75,11 @@ MapRegion & MapRegion::operator=(const MapRegion & r) { -if ( this == &r ) return ( * this ); +if ( this == &r ) return *this; assign(r); -return ( * this ); +return *this; } @@ -165,7 +165,7 @@ ConcatString line; StringArray a; // read the map region meta data - if(!line.read_line(in)) return (false); + if(!line.read_line(in)) return false; // split up the meta data line a = line.split(" "); @@ -177,7 +177,7 @@ StringArray a; << "found fewer than the expected number of elements (" << a.n_elements() << "<" << min_region_header_elements << ") in map region line:\n" << line << "\n\n"; - return(false); + return false; } // parse the region header line: @@ -203,7 +203,7 @@ StringArray a; // parse the lat/lon data lines for(j=0; j= grid_bb.x_ll()) && (x < grid_bb.x_ur()) && (y >= grid_bb.y_ll()) && (y < grid_bb.y_ur())) - return (true); + return true; } - return (false); + return false; } diff --git a/src/libcode/vx_pointdata_python/pointdata_from_array.cc b/src/libcode/vx_pointdata_python/pointdata_from_array.cc index 8b0ab54894..f3e8a486a1 100644 --- a/src/libcode/vx_pointdata_python/pointdata_from_array.cc +++ b/src/libcode/vx_pointdata_python/pointdata_from_array.cc @@ -113,7 +113,7 @@ else { // done // -return ( true ); +return true; } @@ -211,7 +211,7 @@ else { // done // -return ( true ); +return true; } @@ -310,7 +310,7 @@ else { // done // -return ( true ); +return true; } @@ -409,7 +409,7 @@ else { // done // -return ( true ); +return true; } @@ -433,7 +433,7 @@ data_out->add(a); // done // -return ( true ); +return true; } @@ -447,7 +447,7 @@ bool pointdata_from_python_list(PyObject * data_array, float *data_out) for (int idx=0; idxadd((float)PyFloat_AsDouble(PyList_GetItem(data_array, idx))); } - return ( true ); + return true; } @@ -485,7 +485,7 @@ bool pointdata_from_python_list(PyObject * data_array, int *data_out) // exit by caller with additional log message } - return ( status ); + return status; } //////////////////////////////////////////////////////////////////////// @@ -507,7 +507,7 @@ bool pointdata_from_python_list(PyObject * data_array, IntArray *data_out) // exit by caller with additional log message } - return ( status ); + return status; } diff --git a/src/libcode/vx_pointdata_python/pointdata_python.cc b/src/libcode/vx_pointdata_python/pointdata_python.cc index fdb1cb34a3..b77a0c6438 100644 --- a/src/libcode/vx_pointdata_python/pointdata_python.cc +++ b/src/libcode/vx_pointdata_python/pointdata_python.cc @@ -188,7 +188,7 @@ print_met_data(obs_data, hdr_data, method_name); // done // -return ( status ); +return status; } diff --git a/src/libcode/vx_pointdata_python/python_pointdata.cc b/src/libcode/vx_pointdata_python/python_pointdata.cc index c5585a6120..df27f81c9a 100644 --- a/src/libcode/vx_pointdata_python/python_pointdata.cc +++ b/src/libcode/vx_pointdata_python/python_pointdata.cc @@ -183,7 +183,7 @@ else { met_pd_out, filters); } -return ( status ); +return status; } @@ -274,7 +274,7 @@ MetPointHeader *header_data = met_pd_out.get_header_data(); // done // -return ( true ); +return true; } @@ -428,7 +428,7 @@ bool process_point_data_list(PyObject *python_point_data, MetPointDataPython &me // done // - return ( true ); + return true; } @@ -474,7 +474,7 @@ if ( PyErr_Occurred() ) { mlog << Warning << "\n" << method_name << "an error occurred initializing python\n\n"; - return ( false ); + return false; } @@ -602,7 +602,7 @@ if ( PyErr_Occurred() ) { mlog << Warning << "\n" << method_name << "an error occurred initializing python\n\n"; - return ( false ); + return false; } @@ -701,7 +701,7 @@ if ( PyErr_Occurred() ) { << "an error occurred importing module " << '\"' << path << "\"\n\n"; - return ( false ); + return false; } @@ -710,7 +710,7 @@ if ( ! module_obj ) { mlog << Warning << "\n" << method_name << "error running python script\n\n"; - return ( false ); + return false; } @@ -742,7 +742,7 @@ remove_temp_file(tmp_nc_path); // done // -return ( true ); +return true; } diff --git a/src/libcode/vx_ps/documentmedia_to_string.cc b/src/libcode/vx_ps/documentmedia_to_string.cc index d64d6b9123..2a740c866a 100644 --- a/src/libcode/vx_ps/documentmedia_to_string.cc +++ b/src/libcode/vx_ps/documentmedia_to_string.cc @@ -54,7 +54,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/libcode/vx_ps/documentorientation_to_string.cc b/src/libcode/vx_ps/documentorientation_to_string.cc index e98342f078..f4cd73c8d7 100644 --- a/src/libcode/vx_ps/documentorientation_to_string.cc +++ b/src/libcode/vx_ps/documentorientation_to_string.cc @@ -54,7 +54,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/libcode/vx_ps/fontfamily_to_string.cc b/src/libcode/vx_ps/fontfamily_to_string.cc index 4540a5afc9..4611c3523d 100644 --- a/src/libcode/vx_ps/fontfamily_to_string.cc +++ b/src/libcode/vx_ps/fontfamily_to_string.cc @@ -59,7 +59,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/libcode/vx_ps/ps_text.cc b/src/libcode/vx_ps/ps_text.cc index f4438e208b..0e16261336 100644 --- a/src/libcode/vx_ps/ps_text.cc +++ b/src/libcode/vx_ps/ps_text.cc @@ -89,11 +89,11 @@ VxpsTextNode & VxpsTextNode::operator=(const VxpsTextNode & n) { -if ( this == &n ) return ( * this ); +if ( this == &n ) return *this; assign(n); -return ( * this ); +return *this; } @@ -435,7 +435,7 @@ while ( n ) { } -return ( w ); +return w; } @@ -447,7 +447,7 @@ double VxpsTextNode::total_left() const { -return ( Left ); +return Left; } @@ -477,7 +477,7 @@ while ( n->next ) { r += n->Right; -return ( r ); +return r; } @@ -501,7 +501,7 @@ while ( n ) { } -return ( t ); +return t; } @@ -525,7 +525,7 @@ while ( n ) { } -return ( b ); +return b; } diff --git a/src/libcode/vx_ps/table_helper.cc b/src/libcode/vx_ps/table_helper.cc index 9e1eee2f87..8243f019bb 100644 --- a/src/libcode/vx_ps/table_helper.cc +++ b/src/libcode/vx_ps/table_helper.cc @@ -266,7 +266,7 @@ double TableHelper::col_width(int c) const range_check_c(c); -return ( ColWidth[c] ); +return ColWidth[c]; } @@ -280,7 +280,7 @@ double TableHelper::row_height(int r) const range_check_r(r); -return ( RowHeight[r] ); +return RowHeight[r]; } @@ -297,7 +297,7 @@ double w = 0.0; for (j=0; j 126 ) return ( true ); +if ( ascii_code > 126 ) return true; -return ( false ); +return false; } @@ -1931,11 +1931,11 @@ DocumentMedia default_media() ConcatString cs; -if ( !get_env(papersize_env, cs) ) return ( MediaLetter ); +if ( !get_env(papersize_env, cs) ) return MediaLetter; -if ( cs == "Letter" ) return ( MediaLetter ); +if ( cs == "Letter" ) return MediaLetter; -if ( cs == "A4" ) return ( MediaA4 ); +if ( cs == "A4" ) return MediaA4; mlog << Error << "\ndefault_media() -> " << "bad value \"" << cs << "\" for environment variable " @@ -1974,7 +1974,7 @@ switch ( f ) { } // switch -return ( n ); +return n; } @@ -2007,7 +2007,7 @@ switch ( f ) { } // switch -return ( n ); +return n; } @@ -2040,7 +2040,7 @@ switch ( f ) { } // switch -return ( n ); +return n; } @@ -2073,7 +2073,7 @@ switch ( f ) { } // switch -return ( n ); +return n; } diff --git a/src/libcode/vx_pxm/pbm.cc b/src/libcode/vx_pxm/pbm.cc index 8931af17b3..fb00e786a1 100644 --- a/src/libcode/vx_pxm/pbm.cc +++ b/src/libcode/vx_pxm/pbm.cc @@ -102,11 +102,11 @@ Pbm & Pbm::operator=(const Pbm & p) { -if ( this == &p ) return ( * this ); +if ( this == &p ) return *this; assign(p); -return ( * this ); +return *this; } @@ -196,7 +196,7 @@ j = ( (u & mask) ? 0 : 1 ); if ( j ) color.set_gray(255); else color.set_gray(0); -return ( color ); +return color; } @@ -218,7 +218,7 @@ r = Nrows - 1 - y; color = getrc(r, c); -return ( color ); +return color; } @@ -323,7 +323,7 @@ if ( !in ) { mlog << Warning << "\n" << method_name << "unable to read image file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -345,7 +345,7 @@ if ( !in ) { clear(); - return ( 0 ); + return 0; } @@ -355,7 +355,7 @@ if ( (c1 != 'P') || (c2 != '4') ) { clear(); - return ( 0 ); + return 0; } @@ -396,7 +396,7 @@ if ( !(data = new unsigned char [n]) ) { clear(); - return ( 0 ); + return 0; } @@ -406,7 +406,7 @@ if ( !in.read((char *) data, n) ) { clear(); - return ( 0 ); + return 0; } @@ -416,7 +416,7 @@ in.close(); // Done // -return ( 1 ); +return 1; } @@ -442,7 +442,7 @@ if ( !out ) { mlog << Warning << "\nPbm::write() -> unable to open output file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -472,7 +472,7 @@ if ( !out ) { mlog << Warning << "\nPbm::write() -> trouble writing header\n\n"; - return ( 0 ); + return 0; } @@ -488,7 +488,7 @@ if ( !out ) { mlog << Warning << "\nPbm::write() -> trouble writing data\n\n"; - return ( 0 ); + return 0; } @@ -498,7 +498,7 @@ if ( !out ) { out.close(); -return ( 1 ); +return 1; } diff --git a/src/libcode/vx_pxm/pcm.cc b/src/libcode/vx_pxm/pcm.cc index f1107ccf20..e11f5f7dca 100644 --- a/src/libcode/vx_pxm/pcm.cc +++ b/src/libcode/vx_pxm/pcm.cc @@ -104,11 +104,11 @@ Pcm & Pcm::operator=(const Pcm & p) { -if ( this == &p ) return ( * this ); +if ( this == &p ) return *this; assign(p); -return ( * this ); +return *this; } @@ -218,7 +218,7 @@ c = x; r = Nrows - 1 - y; -return ( data_getrc(r, c) ); +return data_getrc(r, c); } @@ -234,7 +234,7 @@ int n; n = rc_to_n(r, c); -return ( data[n] ); +return data[n]; } @@ -252,7 +252,7 @@ n = rc_to_n(r, c); k = (int) (data[n]); -return ( Colormap[k] ); +return Colormap[k]; } @@ -270,7 +270,7 @@ c = x; r = Nrows - 1 - y; -return ( getrc(r, c) ); +return getrc(r, c); } @@ -391,7 +391,7 @@ if ( !in ) { mlog << Warning << "\nPcm::read() -> unable to read image file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -407,7 +407,7 @@ if ( !Name ) { clear(); - return ( 0 ); + return 0; } @@ -426,7 +426,7 @@ if ( !in ) { clear(); - return ( 0 ); + return 0; } @@ -436,7 +436,7 @@ if ( (c1 != 'P') || (c2 != '9') ) { clear(); - return ( 0 ); + return 0; } @@ -475,7 +475,7 @@ if ( maxval != 255 ) { clear(); - return ( 0 ); + return 0; } */ @@ -492,7 +492,7 @@ if ( !Colormap ) { clear(); - return ( 0 ); + return 0; } @@ -512,7 +512,7 @@ for (j=0; j unable to open output file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -609,7 +609,7 @@ if ( !out ) { mlog << Warning << "\nPcm::write() -> trouble writing header\n\n"; - return ( 0 ); + return 0; } @@ -637,7 +637,7 @@ if ( !out ) { mlog << Warning << "\nPcm::write() -> trouble writing data\n\n"; - return ( 0 ); + return 0; } @@ -647,7 +647,7 @@ if ( !out ) { out.close(); -return ( 1 ); +return 1; } @@ -833,12 +833,12 @@ int j; for (j=0; j= Ncolors) ) { } -return ( Colormap[n] ); +return Colormap[n]; } diff --git a/src/libcode/vx_pxm/pgm.cc b/src/libcode/vx_pxm/pgm.cc index a38d4fd4e1..4695400a75 100644 --- a/src/libcode/vx_pxm/pgm.cc +++ b/src/libcode/vx_pxm/pgm.cc @@ -111,11 +111,11 @@ Pgm & Pgm::operator=(const Pgm & p) { -if ( this == &p ) return ( * this ); +if ( this == &p ) return *this; assign(p); -return ( * this ); +return *this; } @@ -181,7 +181,7 @@ u = data[n]; color.set_rgb(u, u, u); -return ( color ); +return color; } @@ -199,7 +199,7 @@ c = x; r = Nrows - 1 - y; -return ( getrc(r, c) ); +return getrc(r, c); } @@ -271,7 +271,7 @@ if ( !in ) { mlog << Warning << "\nPgm::read() -> unable to read image file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -287,7 +287,7 @@ if ( !Name ) { clear(); - return ( 0 ); + return 0; } @@ -306,7 +306,7 @@ if ( !in ) { clear(); - return ( 0 ); + return 0; } @@ -316,7 +316,7 @@ if ( (c1 != 'P') || (c2 != '5') ) { clear(); - return ( 0 ); + return 0; } @@ -352,7 +352,7 @@ if ( maxval != 255 ) { clear(); - return ( 0 ); + return 0; } @@ -368,7 +368,7 @@ if ( !(data = new unsigned char [n]) ) { clear(); - return ( 0 ); + return 0; } @@ -378,7 +378,7 @@ if ( !in.read((char *) data, n) ) { clear(); - return ( 0 ); + return 0; } @@ -388,7 +388,7 @@ in.close(); // Done // -return ( 1 ); +return 1; } @@ -414,7 +414,7 @@ if ( !out ) { mlog << Warning << "\nPgm::write() -> unable to open output file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -444,7 +444,7 @@ if ( !out ) { mlog << Warning << "\nPgm::write() -> trouble writing header\n\n"; - return ( 0 ); + return 0; } @@ -460,7 +460,7 @@ if ( !out ) { mlog << Warning << "\nPgm::write() -> trouble writing data\n\n"; - return ( 0 ); + return 0; } @@ -470,7 +470,7 @@ if ( !out ) { out.close(); -return ( 1 ); +return 1; } @@ -885,12 +885,12 @@ for (col=1; col unable to read image file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -287,7 +287,7 @@ if ( !Name ) { clear(); - return ( 0 ); + return 0; } @@ -306,7 +306,7 @@ if ( !in ) { clear(); - return ( 0 ); + return 0; } @@ -316,7 +316,7 @@ if ( (c1 != 'P') || (c2 != '6') ) { clear(); - return ( 0 ); + return 0; } @@ -353,7 +353,7 @@ if ( maxval != 255 ) { clear(); - return ( 0 ); + return 0; } @@ -369,7 +369,7 @@ if ( !(data = new unsigned char [n]) ) { clear(); - return ( 0 ); + return 0; } @@ -379,7 +379,7 @@ if ( !in.read((char *) data, n) ) { clear(); - return ( 0 ); + return 0; } @@ -389,7 +389,7 @@ in.close(); // Done // -return ( 1 ); +return 1; } @@ -415,7 +415,7 @@ if ( !out ) { mlog << Warning << "\nPpm::write() -> unable to open output file \"" << filename << "\"\n\n"; - return ( 0 ); + return 0; } @@ -448,7 +448,7 @@ if ( !out ) { << strerror(errno) << "\n\n"; - return ( 0 ); + return 0; } @@ -464,7 +464,7 @@ if ( !out ) { mlog << Warning << "\nPpm::write() -> trouble writing data\n\n"; - return ( 0 ); + return 0; } @@ -474,7 +474,7 @@ if ( !out ) { out.close(); -return ( 1 ); +return 1; } diff --git a/src/libcode/vx_pxm/pxm_base.cc b/src/libcode/vx_pxm/pxm_base.cc index bc52724b35..825cb47801 100644 --- a/src/libcode/vx_pxm/pxm_base.cc +++ b/src/libcode/vx_pxm/pxm_base.cc @@ -178,7 +178,7 @@ int n; n = r*Ncols + c; -return ( n ); +return n; } @@ -214,7 +214,7 @@ const char * PxmBase::short_name() const { -if ( !Name ) return ( (const char *) 0 ); +if ( !Name ) return (const char *) 0; int j; @@ -246,7 +246,7 @@ if ( (n < 0) || (n >= Ncomments) ) { } -return ( Comment[n] ); +return Comment[n]; } diff --git a/src/libcode/vx_pxm/pxm_utils.cc b/src/libcode/vx_pxm/pxm_utils.cc index 8d496b8082..f68873333a 100644 --- a/src/libcode/vx_pxm/pxm_utils.cc +++ b/src/libcode/vx_pxm/pxm_utils.cc @@ -40,7 +40,7 @@ j = 0; while ( isdigit(c = in.get()) ) j = 10*j + (c - '0'); -return ( j ); +return j; } diff --git a/src/libcode/vx_python3_utils/python3_dict.cc b/src/libcode/vx_python3_utils/python3_dict.cc index f623166a14..9a2aaa4f93 100644 --- a/src/libcode/vx_python3_utils/python3_dict.cc +++ b/src/libcode/vx_python3_utils/python3_dict.cc @@ -179,7 +179,7 @@ if ( ! PyLong_Check(a) ) { k = (int) PyLong_AS_LONG(a); -return ( k ); +return k; } @@ -216,7 +216,7 @@ if ( ! PyFloat_Check(a) ) { t = PyFloat_AS_DOUBLE(a); -return ( t ); +return t; } @@ -262,7 +262,7 @@ else { } -return ( s ); +return s; } @@ -287,7 +287,7 @@ if ( ! a ) { } -return ( a ); +return a; } @@ -322,7 +322,7 @@ if ( ! PyDict_Check(a) ) { } -return ( a ); +return a; } @@ -360,7 +360,7 @@ if ( ! PyList_Check(a) ) { } -return ( a ); +return a; } diff --git a/src/libcode/vx_python3_utils/python3_list.cc b/src/libcode/vx_python3_utils/python3_list.cc index 51b9c3078a..e90a195e95 100644 --- a/src/libcode/vx_python3_utils/python3_list.cc +++ b/src/libcode/vx_python3_utils/python3_list.cc @@ -182,7 +182,7 @@ if ( (n < 0) || (n >= Size) ) { a = PyList_GetItem(Object, n); -return ( a ); +return a; } diff --git a/src/libcode/vx_python3_utils/python3_numpy.cc b/src/libcode/vx_python3_utils/python3_numpy.cc index 961bcd0bfb..e779c0504f 100644 --- a/src/libcode/vx_python3_utils/python3_numpy.cc +++ b/src/libcode/vx_python3_utils/python3_numpy.cc @@ -164,7 +164,7 @@ if ( (k < 0) || (k >= N_Dims) ) { } -return ( Dim[k] ); +return Dim[k]; } diff --git a/src/libcode/vx_python3_utils/python3_script.cc b/src/libcode/vx_python3_utils/python3_script.cc index 34fc038d71..850646649c 100644 --- a/src/libcode/vx_python3_utils/python3_script.cc +++ b/src/libcode/vx_python3_utils/python3_script.cc @@ -160,7 +160,7 @@ PyObject * var = 0; var = PyDict_GetItemString (Dict, name); -return ( var ); +return var; } @@ -195,7 +195,7 @@ if ( ! PyList_Check(var) ) { } -return ( var ); +return var; } diff --git a/src/libcode/vx_python3_utils/python3_util.cc b/src/libcode/vx_python3_utils/python3_util.cc index 7c648edc88..94e9a25bb9 100644 --- a/src/libcode/vx_python3_utils/python3_util.cc +++ b/src/libcode/vx_python3_utils/python3_util.cc @@ -69,7 +69,7 @@ if ( buf ) { free(buf); buf = 0; } // done // -return ( out ); +return out; } @@ -81,11 +81,11 @@ PyObject * get_attribute(PyObject * obj, const char * attribute_name) { -if ( PyObject_HasAttrString(obj, attribute_name) == 0 ) return ( (PyObject *) 0 ); +if ( PyObject_HasAttrString(obj, attribute_name) == 0 ) return (PyObject *) 0; PyObject * att = PyObject_GetAttrString(obj, attribute_name); -return ( att ); +return att; } @@ -121,7 +121,7 @@ if ( PyLong_Check(obj) ) { // long? } -return ( k ); +return k; } @@ -169,7 +169,7 @@ if ( PyLong_Check(obj) ) { // long? } -return ( x ); +return x; } @@ -196,7 +196,7 @@ if ( PyUnicode_Check(obj) ) { // string? } -return ( s ); +return s; } @@ -223,7 +223,7 @@ if ( PyUnicode_Check(obj) ) { // string? } -return ( s ); +return s; } diff --git a/src/libcode/vx_regrid/vx_regrid.cc b/src/libcode/vx_regrid/vx_regrid.cc index 95063ac17c..4377f37c73 100644 --- a/src/libcode/vx_regrid/vx_regrid.cc +++ b/src/libcode/vx_regrid/vx_regrid.cc @@ -83,7 +83,7 @@ out.censor(info.censor_thresh, info.censor_val); // done // -return ( out ); +return out; } @@ -101,7 +101,7 @@ ri.method = InterpMthd_Nearest; ri.width = 1; ri.shape = GridTemplateFactory::GridTemplate_Square; -return ( met_regrid_generic(from_data, from_grid, to_grid, ri) ); +return met_regrid_generic(from_data, from_grid, to_grid, ri); } @@ -165,7 +165,7 @@ for (xt=0; xt<(to_grid.nx()); ++xt) { // done // -return ( to_data ); +return to_data; } @@ -268,7 +268,7 @@ for (xt=0; xt<(to_grid.nx()); ++xt) { // done // -return ( to_data ); +return to_data; } @@ -296,7 +296,7 @@ if ( from_grid.nx() != to_grid.nx() || from_grid.ny() != to_grid.ny() ) { } -return ( from_data ); +return from_data; } @@ -358,7 +358,7 @@ for (xt=0; xt<(to_grid.nx()); ++xt) { interp_gaussian_dp(to_data, info.gaussian, info.vld_thresh); -return ( to_data ); +return to_data; } diff --git a/src/libcode/vx_regrid/vx_regrid_budget.cc b/src/libcode/vx_regrid/vx_regrid_budget.cc index 425f989fdb..9fbedcfc81 100644 --- a/src/libcode/vx_regrid/vx_regrid_budget.cc +++ b/src/libcode/vx_regrid/vx_regrid_budget.cc @@ -101,7 +101,7 @@ for (ixt=0; ixt<(to_grid.nx()); ++ixt) { // done // -return ( to_data ); +return to_data; } diff --git a/src/libcode/vx_render/ps_filter.cc b/src/libcode/vx_render/ps_filter.cc index bfaade4aa9..bdae71846d 100644 --- a/src/libcode/vx_render/ps_filter.cc +++ b/src/libcode/vx_render/ps_filter.cc @@ -150,7 +150,7 @@ snprintf(junk, sizeof(junk), "%d", k); (*this) << junk; -return ( *this ); +return *this; } @@ -180,7 +180,7 @@ while ( *s ) { } -return ( *this ); +return *this; } @@ -194,7 +194,7 @@ PSFilter & PSFilter::operator<<(const ConcatString & s) operator<<(s.text()); -return ( *this ); +return *this; } @@ -212,7 +212,7 @@ PSFilter & PSFilter::operator<<(const double x) operator<<(junk); - return ( * this ); + return *this; } diff --git a/src/libcode/vx_render/renderinfo.cc b/src/libcode/vx_render/renderinfo.cc index 58912de6f6..940116190f 100644 --- a/src/libcode/vx_render/renderinfo.cc +++ b/src/libcode/vx_render/renderinfo.cc @@ -76,11 +76,11 @@ RenderInfo & RenderInfo::operator=(const RenderInfo & r) { -if ( this == &r ) return ( * this ); +if ( this == &r ) return *this; assign(r); -return ( * this ); +return *this; } @@ -256,7 +256,7 @@ if ( (n < 0) || (n >= Nfilters) ) { } -return ( Filter[n] ); +return Filter[n]; } diff --git a/src/libcode/vx_render/uc_queue.cc b/src/libcode/vx_render/uc_queue.cc index ef6fadfaf5..02d7fa1b82 100644 --- a/src/libcode/vx_render/uc_queue.cc +++ b/src/libcode/vx_render/uc_queue.cc @@ -74,11 +74,11 @@ UCQueue & UCQueue::operator=(const UCQueue &Q) { -if ( this == &Q ) return ( *this ); +if ( this == &Q ) return *this; assign(Q); -return ( *this ); +return *this; } @@ -136,7 +136,7 @@ int UCQueue::n_elements() const { -return ( NElements ); +return NElements; } @@ -148,9 +148,9 @@ int UCQueue::last_char() const { -if ( NElements == 0 ) return ( -1 ); +if ( NElements == 0 ) return -1; -return ( (int) (data[0]) ); +return (int) (data[0]); } @@ -162,7 +162,7 @@ int UCQueue::run_count() const { -return ( calc_run_count() ); +return calc_run_count(); } @@ -220,7 +220,7 @@ u = data[NElements - 1]; --NElements; -return ( u ); +return u; } @@ -234,7 +234,7 @@ int UCQueue::calc_run_count() const int j, count; -if ( NElements <= 1 ) return ( NElements ); +if ( NElements <= 1 ) return NElements; count = 1; @@ -247,7 +247,7 @@ for (j=1; j Date: Wed, 28 Feb 2024 01:34:39 +0000 Subject: [PATCH 013/114] #2673 Removed the redundant parentheses with return --- src/tools/core/ensemble_stat/ensemble_stat.cc | 8 +++---- .../ensemble_stat/ensemble_stat_conf_info.cc | 18 +++++++-------- src/tools/core/grid_stat/grid_stat.cc | 4 ++-- .../core/grid_stat/grid_stat_conf_info.cc | 22 +++++++++---------- src/tools/core/mode/mode.cc | 2 +- src/tools/core/mode/mode_frontend.cc | 2 +- src/tools/core/mode/mode_ps_file.cc | 2 +- src/tools/core/mode/multivar_frontend.cc | 4 ++-- src/tools/core/mode_analysis/mode_analysis.cc | 2 +- src/tools/core/pcp_combine/pcp_combine.cc | 10 ++++----- .../core/series_analysis/series_analysis.cc | 8 +++---- .../core/stat_analysis/aggr_stat_line.cc | 8 +++---- .../stat_analysis/skill_score_index_job.cc | 12 +++++----- src/tools/core/stat_analysis/stat_analysis.cc | 2 +- src/tools/core/wavelet_stat/wavelet_stat.cc | 12 +++++----- .../wavelet_stat/wavelet_stat_conf_info.cc | 6 ++--- src/tools/dev_utils/chk4copyright.cc | 4 ++-- src/tools/dev_utils/gen_climo_bin.cc | 2 +- src/tools/dev_utils/gribtab.dat_to_flat.cc | 2 +- src/tools/dev_utils/nceptab_to_flat.cc | 14 ++++++------ src/tools/dev_utils/pbtime.cc | 2 +- src/tools/dev_utils/reformat_county_data.cc | 2 +- src/tools/dev_utils/reformat_map_data.cc | 2 +- .../dev_utils/shapefiles/make_mapfiles.cc | 4 ++-- 24 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 8b86abcec5..1ff34d29e5 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -187,7 +187,7 @@ int met_main(int argc, char *argv[]) { // Close the text files and deallocate memory clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -681,7 +681,7 @@ bool get_data_plane(const char *infile, GrdFileType ftype, // Deallocate the data file pointer, if necessary if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -741,7 +741,7 @@ bool get_data_plane_array(const char *infile, GrdFileType ftype, // Deallocate the data file pointer, if necessary if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -1116,7 +1116,7 @@ bool process_point_ens(int i_vx, int i_ens, DataPlaneArray &fcst_dpa) { mlog << Debug(2) << "For " << info->magic_str() << " found " << fcst_dpa.n_planes() << " forecast levels.\n"; - return(status); + return status; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 8da7df73c6..edc0c1b132 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -494,7 +494,7 @@ int EnsembleStatConfInfo::n_txt_row(int i_txt_row) const { // Loop over the tasks and sum the line counts for this line type for(i=0, n=0; ip_flag()) rescale_probability(dp); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// 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 399913036f..076e35cb37 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -439,7 +439,7 @@ int GridStatConfInfo::n_txt_row(int i_txt_row) const { // Loop over the tasks and sum the line counts for this line type for(int i=0; iclear(); if ( dumpfile ) { delete dumpfile; dumpfile = (ofstream *) 0; } if ( outfile ) { delete outfile; outfile = (ofstream *) 0; } -return ( 0 ); +return 0; } diff --git a/src/tools/core/pcp_combine/pcp_combine.cc b/src/tools/core/pcp_combine/pcp_combine.cc index 67bf2f50bc..7adf584e07 100644 --- a/src/tools/core/pcp_combine/pcp_combine.cc +++ b/src/tools/core/pcp_combine/pcp_combine.cc @@ -816,7 +816,7 @@ int search_pcp_dir(const char *cur_dir, const unixtime cur_ut, if(dp) met_closedir(dp); - return(i_rec); + return i_rec; } //////////////////////////////////////////////////////////////////////// @@ -1488,17 +1488,17 @@ ConcatString parse_config_str(const char *s) { config_str = s; } - return(config_str); + return config_str; } //////////////////////////////////////////////////////////////////////// bool is_timestring(const char * text) { - if(is_hh(text)) return(true); - if(is_hhmmss(text)) return(true); + if(is_hh(text)) return true; + if(is_hhmmss(text)) return true; - return(false); + return false; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 223ce9ad65..3df79a1595 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -135,7 +135,7 @@ int met_main(int argc, char *argv[]) { // Close the text files and deallocate memory clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -398,7 +398,7 @@ Met2dDataFile *get_mtddf(const StringArray &file_list, exit(1); } - return(mtddf); + return mtddf; } //////////////////////////////////////////////////////////////////////// @@ -655,7 +655,7 @@ bool read_single_entry(VarInfo *info, const ConcatString &cur_file, if(!file_is_ok(cur_file, type)) { mlog << Warning << "\nread_single_entry() -> " << "File does not exist: " << cur_file << "\n\n"; - return(false); + return false; } // Open the data file @@ -670,7 +670,7 @@ bool read_single_entry(VarInfo *info, const ConcatString &cur_file, // Close the data file delete mtddf; mtddf = (Met2dDataFile *) 0; - return(found); + return found; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 99b5906429..cb2d637e69 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -525,7 +525,7 @@ StatHdrColumns StatHdrInfo::get_shc(const ConcatString &cur_case, // LINE_TYPE shc.set_line_type(statlinetype_to_string(lt)); - return(shc); + return shc; } //////////////////////////////////////////////////////////////////////// @@ -576,7 +576,7 @@ ConcatString StatHdrInfo::get_shc_str(const ConcatString &cur_case, shc_str = css; } - return(shc_str); + return shc_str; } //////////////////////////////////////////////////////////////////////// @@ -4203,7 +4203,7 @@ double compute_vif(NumArray &na) { // Compute the variance inflation factor vif = 1 + 2.0*fabs(corr) - 2.0*fabs(corr)/na.n(); - return(vif); + return vif; } //////////////////////////////////////////////////////////////////////// @@ -4215,7 +4215,7 @@ bool is_precip_var_name(const ConcatString &s) { has_prefix(grib_precipitation_abbr, n_grib_precipitation_abbr, s.c_str()); - return(match); + return match; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/stat_analysis/skill_score_index_job.cc b/src/tools/core/stat_analysis/skill_score_index_job.cc index a023cd8dfc..2595886c19 100644 --- a/src/tools/core/stat_analysis/skill_score_index_job.cc +++ b/src/tools/core/stat_analysis/skill_score_index_job.cc @@ -61,11 +61,11 @@ SSIndexJobInfo::SSIndexJobInfo(const SSIndexJobInfo &c) { SSIndexJobInfo & SSIndexJobInfo::operator=(const SSIndexJobInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -168,7 +168,7 @@ bool SSIndexJobInfo::is_keeper(const STATLine &line) { } } - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -224,7 +224,7 @@ bool SSIndexJobInfo::add(STATLine &line) { init_time.add(line.fcst_init_beg()); } - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -345,7 +345,7 @@ SSIDXData SSIndexJobInfo::compute_ss_index() { << " since the ratio of valid terms " << n_vld << "/" << n_term << " < " << ss_index_vld_thresh << "!\n\n"; data.n_vld = 0; - return(data); + return data; } // Compute the weighted average of the skill scores @@ -370,7 +370,7 @@ SSIDXData SSIndexJobInfo::compute_ss_index() { << ss_index_name << " Weighted Average = " << ss_avg << "\n" << ss_index_name << " Skill Score Value = " << data.ss_index << "\n"; - return(data); + return data; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/stat_analysis/stat_analysis.cc b/src/tools/core/stat_analysis/stat_analysis.cc index 912617a213..4e7fbea4e3 100644 --- a/src/tools/core/stat_analysis/stat_analysis.cc +++ b/src/tools/core/stat_analysis/stat_analysis.cc @@ -240,7 +240,7 @@ int met_main(int argc, char * argv []) { // clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index b182a4538d..ffbaf108ae 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -151,7 +151,7 @@ int met_main(int argc, char *argv[]) { // Close the text files and deallocate memory clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -798,7 +798,7 @@ double get_fill_value(const DataPlane &dp, int i_vx) { else fill_val = 0.0; } - return(fill_val); + return fill_val; } //////////////////////////////////////////////////////////////////////// @@ -942,7 +942,7 @@ int get_tile_tot_count() { } // end for y } // end for x - return(count); + return count; } //////////////////////////////////////////////////////////////////////// @@ -1920,7 +1920,7 @@ double sum_array(double *d, int n) { for(i=0, sum=0.0; i 1) n += (n_scale + 2) * fcat_ta[i].n(); } - return(n); + return n; } //////////////////////////////////////////////////////////////////////// int WaveletStatConfInfo::n_stat_row() { - return(n_isc_row()); + return n_isc_row(); } //////////////////////////////////////////////////////////////////////// @@ -693,7 +693,7 @@ int get_pow2(double n) { if(fabs(nint(a) - a) > 10E-5) p = -1; else p = nint(a); - return(p); + return p; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/chk4copyright.cc b/src/tools/dev_utils/chk4copyright.cc index e145909d31..0171fb000c 100644 --- a/src/tools/dev_utils/chk4copyright.cc +++ b/src/tools/dev_utils/chk4copyright.cc @@ -437,7 +437,7 @@ int get_line(int & fd, ConcatString & s) while (read(fd, buf, n_bytes_to_read) > 0) { if (buf[0] == '\n') - return (1); + return 1; s.add(buf); @@ -446,7 +446,7 @@ int get_line(int & fd, ConcatString & s) // // end of file // - return (0); + return 0; } diff --git a/src/tools/dev_utils/gen_climo_bin.cc b/src/tools/dev_utils/gen_climo_bin.cc index fea08a5d9d..3f7ca5d68e 100644 --- a/src/tools/dev_utils/gen_climo_bin.cc +++ b/src/tools/dev_utils/gen_climo_bin.cc @@ -129,7 +129,7 @@ int met_main(int argc, char *argv[]) { delete nc_out; nc_out = (NcFile *) 0; - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/gribtab.dat_to_flat.cc b/src/tools/dev_utils/gribtab.dat_to_flat.cc index fbf84434e1..077eefd6c9 100644 --- a/src/tools/dev_utils/gribtab.dat_to_flat.cc +++ b/src/tools/dev_utils/gribtab.dat_to_flat.cc @@ -72,7 +72,7 @@ while ( in.getline(line, sizeof(line)) ) { in.close(); -return ( 0 ); +return 0; } diff --git a/src/tools/dev_utils/nceptab_to_flat.cc b/src/tools/dev_utils/nceptab_to_flat.cc index ab05cb7698..78e45b82e7 100644 --- a/src/tools/dev_utils/nceptab_to_flat.cc +++ b/src/tools/dev_utils/nceptab_to_flat.cc @@ -99,7 +99,7 @@ for (j=0; j<(cline.n()); ++j) { // j starts at one, here // done // -return ( 0 ); +return 0; } @@ -252,7 +252,7 @@ m_strncpy(line2, line, sizeof(line2), method_name); // check to make sure it's got a double quote in it // -if ( ! strchr(line, '\"') ) return ( false ); +if ( ! strchr(line, '\"') ) return false; // // index and table number @@ -262,7 +262,7 @@ c = strtok(s, " /*"); s = (char *) 0; -if ( !c ) return ( false ); +if ( !c ) return false; n = atoi(c); @@ -274,7 +274,7 @@ cout << n << ' ' << table_number << ' '; c = strtok(s, " /*{\""); -if ( !c ) return ( false ); +if ( !c ) return false; cout << '\"' << c << "\" "; @@ -289,7 +289,7 @@ k = m_strlen(c) - 1; if ( c[k] == ' ' ) c[k] = (char) 0; -if ( !c ) return ( false ); +if ( !c ) return false; cout << '\"' << c << "\" "; @@ -305,7 +305,7 @@ if ( strcmp(c, "undefined") == 0 ) { c = strtok(s, "]\""); - if ( !c ) return ( false ); + if ( !c ) return false; if ( c[0] == '}' ) cout << "\"\" "; else cout << '\"' << c << "\" "; @@ -318,7 +318,7 @@ if ( strcmp(c, "undefined") == 0 ) { cout << '\n' << flush; -return ( true ); +return true; } diff --git a/src/tools/dev_utils/pbtime.cc b/src/tools/dev_utils/pbtime.cc index c7d30bc638..53f08387f8 100644 --- a/src/tools/dev_utils/pbtime.cc +++ b/src/tools/dev_utils/pbtime.cc @@ -92,7 +92,7 @@ int met_main(int argc, char *argv[]) { // Delete the temporary blocked file remove_temp_file(blk_file); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/reformat_county_data.cc b/src/tools/dev_utils/reformat_county_data.cc index 28ce0be968..6451534de6 100644 --- a/src/tools/dev_utils/reformat_county_data.cc +++ b/src/tools/dev_utils/reformat_county_data.cc @@ -56,7 +56,7 @@ reformat(input_filename, output_filename); // done // -return ( 0 ); +return 0; } diff --git a/src/tools/dev_utils/reformat_map_data.cc b/src/tools/dev_utils/reformat_map_data.cc index b1cdcde109..3f82abc4b2 100644 --- a/src/tools/dev_utils/reformat_map_data.cc +++ b/src/tools/dev_utils/reformat_map_data.cc @@ -56,7 +56,7 @@ if ( argc != 3 ) usage(); // done // -return ( 0 ); +return 0; } diff --git a/src/tools/dev_utils/shapefiles/make_mapfiles.cc b/src/tools/dev_utils/shapefiles/make_mapfiles.cc index 8a6fa87225..23d84caf31 100644 --- a/src/tools/dev_utils/shapefiles/make_mapfiles.cc +++ b/src/tools/dev_utils/shapefiles/make_mapfiles.cc @@ -180,7 +180,7 @@ if ( do_separate_files ) { // done // -return ( 0 ); +return 0; } @@ -550,7 +550,7 @@ if ( r.admin.nonempty() ) { } -return ( s ); +return s; } From 55f5d3ed8d6d0c3316d84c16c3b9dfceaa9e95e5 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 01:34:47 +0000 Subject: [PATCH 014/114] #2673 Removed the redundant parentheses with return --- src/tools/other/ascii2nc/ascii2nc.cc | 48 ++++++++-------- src/tools/other/ascii2nc/ismn_handler.cc | 22 ++++---- src/tools/other/ascii2nc/met_handler.cc | 2 +- src/tools/other/ascii2nc/python_handler.cc | 8 +-- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 4 +- .../gen_ens_prod/gen_ens_prod_conf_info.cc | 4 +- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 18 +++--- src/tools/other/gis_utils/gis_dump_dbf.cc | 2 +- src/tools/other/gis_utils/gis_dump_shp.cc | 4 +- src/tools/other/gis_utils/gis_dump_shx.cc | 2 +- src/tools/other/grid_diag/grid_diag.cc | 4 +- src/tools/other/gsi_tools/conv_record.cc | 16 +++--- src/tools/other/gsi_tools/gsi_record.cc | 2 +- src/tools/other/gsi_tools/gsi_util.cc | 14 ++--- src/tools/other/gsi_tools/gsid2mpr.cc | 4 +- src/tools/other/gsi_tools/gsidens2orank.cc | 6 +- src/tools/other/gsi_tools/rad_config.cc | 4 +- src/tools/other/gsi_tools/rad_record.cc | 18 +++--- src/tools/other/ioda2nc/ioda2nc.cc | 6 +- src/tools/other/lidar2nc/calipso_5km.cc | 16 +++--- src/tools/other/lidar2nc/hdf_utils.cc | 2 +- src/tools/other/lidar2nc/lidar2nc.cc | 4 +- src/tools/other/madis2nc/madis2nc.cc | 4 +- src/tools/other/mode_graphics/cgraph_font.cc | 26 ++++----- src/tools/other/mode_graphics/cgraph_main.cc | 14 ++--- .../cgraphbase_plottype_to_string.cc | 2 +- src/tools/other/mode_graphics/color_stack.cc | 8 +-- .../mode_graphics/mode_nc_output_file.cc | 56 +++++++++---------- .../other/mode_graphics/plot_mode_field.cc | 14 ++--- src/tools/other/mode_time_domain/2d_att.cc | 8 +-- .../other/mode_time_domain/2d_att_array.cc | 12 ++-- .../other/mode_time_domain/2d_moments.cc | 6 +- src/tools/other/mode_time_domain/3d_att.cc | 20 +++---- .../mode_time_domain/3d_att_pair_array.cc | 16 +++--- .../mode_time_domain/3d_att_single_array.cc | 4 +- src/tools/other/mode_time_domain/3d_conv.cc | 4 +- .../other/mode_time_domain/3d_moments.cc | 6 +- src/tools/other/mode_time_domain/fo_graph.cc | 12 ++-- src/tools/other/mode_time_domain/fo_node.cc | 4 +- .../other/mode_time_domain/fo_node_array.cc | 6 +- .../other/mode_time_domain/interest_calc.cc | 6 +- src/tools/other/mode_time_domain/mm_engine.cc | 24 ++++---- src/tools/other/mode_time_domain/mtd.cc | 6 +- .../other/mode_time_domain/mtd_config_info.cc | 2 +- .../other/mode_time_domain/mtd_file_base.cc | 8 +-- .../other/mode_time_domain/mtd_file_float.cc | 14 ++--- .../other/mode_time_domain/mtd_file_int.cc | 36 ++++++------ .../other/mode_time_domain/mtd_partition.cc | 32 +++++------ .../mode_time_domain/mtdfiletype_to_string.cc | 14 ++--- src/tools/other/mode_time_domain/nc_grid.cc | 12 ++-- .../other/mode_time_domain/nc_utils_local.cc | 12 ++-- .../other/modis_regrid/cloudsat_swath_file.cc | 38 ++++++------- src/tools/other/modis_regrid/data_averager.cc | 6 +- src/tools/other/modis_regrid/modis_file.cc | 56 +++++++++---------- src/tools/other/modis_regrid/modis_regrid.cc | 2 +- src/tools/other/modis_regrid/sat_utils.cc | 2 +- src/tools/other/pb2nc/pb2nc.cc | 14 ++--- .../other/plot_point_obs/plot_point_obs.cc | 2 +- .../plot_point_obs_conf_info.cc | 24 ++++---- src/tools/other/point2grid/point2grid.cc | 4 +- .../regrid_data_plane/regrid_data_plane.cc | 2 +- .../shift_data_plane/shift_data_plane.cc | 2 +- src/tools/other/wwmca_tool/af_cp_file.cc | 12 ++-- src/tools/other/wwmca_tool/af_file.cc | 14 ++--- src/tools/other/wwmca_tool/af_pt_file.cc | 12 ++-- src/tools/other/wwmca_tool/ave_interp.cc | 8 +-- src/tools/other/wwmca_tool/interp_base.cc | 12 ++-- src/tools/other/wwmca_tool/max_interp.cc | 8 +-- src/tools/other/wwmca_tool/min_interp.cc | 8 +-- src/tools/other/wwmca_tool/nearest_interp.cc | 8 +-- src/tools/other/wwmca_tool/wwmca_plot.cc | 6 +- src/tools/other/wwmca_tool/wwmca_regrid.cc | 4 +- .../tc_utils/rmw_analysis/rmw_analysis.cc | 2 +- src/tools/tc_utils/tc_diag/python_tc_diag.cc | 28 +++++----- src/tools/tc_utils/tc_diag/tc_diag.cc | 18 +++--- .../tc_utils/tc_diag/tc_diag_conf_info.cc | 2 +- src/tools/tc_utils/tc_dland/tc_dland.cc | 2 +- src/tools/tc_utils/tc_dland/tc_poly.cc | 22 ++++---- src/tools/tc_utils/tc_gen/tc_gen.cc | 2 +- src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc | 24 ++++---- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 18 +++--- src/tools/tc_utils/tc_rmw/tc_rmw.cc | 6 +- src/tools/tc_utils/tc_stat/tc_stat.cc | 2 +- src/tools/tc_utils/tc_stat/tc_stat_files.cc | 16 +++--- 84 files changed, 492 insertions(+), 492 deletions(-) diff --git a/src/tools/other/ascii2nc/ascii2nc.cc b/src/tools/other/ascii2nc/ascii2nc.cc index 3eb9135c1d..4d1a9bb7d9 100644 --- a/src/tools/other/ascii2nc/ascii2nc.cc +++ b/src/tools/other/ascii2nc/ascii2nc.cc @@ -217,7 +217,7 @@ int met_main(int argc, char *argv[]) { // FileHandler *file_handler = create_file_handler(ascii_format, asfile_list[0]); - if(file_handler == 0) return(0); + if(file_handler == 0) return 0; int deflate_level = compress_level; if(deflate_level < 0) deflate_level = config_info.get_compression_level(); @@ -259,9 +259,9 @@ int met_main(int argc, char *argv[]) { int status = file_handler->writeNetcdfFile(ncfile.text()); delete file_handler; - if(!status) return(1); + if(!status) return 1; - return(0); + return 0; } @@ -286,70 +286,70 @@ FileHandler *create_file_handler(const ASCIIFormat format, const ConcatString &a // switch(format) { case ASCIIFormat_MET: { - return((FileHandler *) new MetHandler(program_name)); + return (FileHandler *) new MetHandler(program_name); } case ASCIIFormat_Little_R: { - return((FileHandler *) new LittleRHandler(program_name)); + return (FileHandler *) new LittleRHandler(program_name); } case ASCIIFormat_SurfRad: { - return((FileHandler *) new SurfradHandler(program_name)); + return (FileHandler *) new SurfradHandler(program_name); } case ASCIIFormat_WWSIS: { - return((FileHandler *) new WwsisHandler(program_name)); + return (FileHandler *) new WwsisHandler(program_name); } case ASCIIFormat_Airnow_dailyv2: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_DAILYV2); - return((FileHandler *) handler); + return (FileHandler *) handler; } case ASCIIFormat_Airnow_hourlyaqobs: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_HOURLYAQOBS); - return((FileHandler *) handler); + return (FileHandler *) handler; } case ASCIIFormat_Airnow_hourly: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_HOURLY); - return((FileHandler *) handler); + return (FileHandler *) handler; } case ASCIIFormat_NDBC_standard: { NdbcHandler *handler = new NdbcHandler(program_name); handler->setFormatVersion(NdbcHandler::NDBC_FORMAT_VERSION_STANDARD); - return((FileHandler *) handler); + return (FileHandler *) handler; } case ASCIIFormat_ISMN: { - return((FileHandler *) new IsmnHandler(program_name)); + return (FileHandler *) new IsmnHandler(program_name); } case ASCIIFormat_Aeronet_v2: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(2); - return((FileHandler *) handler); + return (FileHandler *) handler; } case ASCIIFormat_Aeronet_v3: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(3); - return((FileHandler *) handler); + return (FileHandler *) handler; } #ifdef ENABLE_PYTHON case ASCIIFormat_Python: { setup_wrapper_path(); ph = new PythonHandler(program_name, ascii_filename.text()); - return((FileHandler *) ph); + return (FileHandler *) ph; } #endif default: { - return(determine_ascii_format(ascii_filename)); + return determine_ascii_format(ascii_filename); } } } @@ -382,7 +382,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if (met_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) met_file); + return (FileHandler *) met_file; } delete met_file; @@ -395,7 +395,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if (little_r_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) little_r_file); + return (FileHandler *) little_r_file; } delete little_r_file; @@ -408,7 +408,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if (surfrad_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) surfrad_file); + return (FileHandler *) surfrad_file; } delete surfrad_file; @@ -421,7 +421,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if(wwsis_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) wwsis_file); + return (FileHandler *) wwsis_file; } delete wwsis_file; @@ -434,7 +434,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if(aeronet_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) aeronet_file); + return (FileHandler *) aeronet_file; } delete aeronet_file; @@ -447,7 +447,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if(airnow_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) airnow_file); + return (FileHandler *) airnow_file; } delete airnow_file; @@ -460,7 +460,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if(ndbc_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) ndbc_file); + return (FileHandler *) ndbc_file; } delete ndbc_file; @@ -473,7 +473,7 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { if(ismn_file->isFileType(f_in)) { f_in.close(); - return((FileHandler *) ismn_file); + return (FileHandler *) ismn_file; } delete ismn_file; diff --git a/src/tools/other/ascii2nc/ismn_handler.cc b/src/tools/other/ascii2nc/ismn_handler.cc index e1b2e45759..729decb0a8 100644 --- a/src/tools/other/ascii2nc/ismn_handler.cc +++ b/src/tools/other/ascii2nc/ismn_handler.cc @@ -83,7 +83,7 @@ bool IsmnHandler::isFileType(LineDataFile &ascii_file) const { ascii_file >> dl; if(dl.n_items() != NUM_OBS_COLS) is_file_type = false; - return(is_file_type); + return is_file_type; } //////////////////////////////////////////////////////////////////////// @@ -93,11 +93,11 @@ bool IsmnHandler::isFileType(LineDataFile &ascii_file) const { bool IsmnHandler::_readObservations(LineDataFile &ascii_file) { // Read and save the header information - if(!_readHeaderInfo(ascii_file)) return(false); + if(!_readHeaderInfo(ascii_file)) return false; // Get the var_id to use int var_id = bad_data_int; - if(!_varNames.has(_obsVarInfo._varName, var_id)) return(false); + if(!_varNames.has(_obsVarInfo._varName, var_id)) return false; // Process the observation lines DataLine dl; @@ -110,12 +110,12 @@ bool IsmnHandler::_readObservations(LineDataFile &ascii_file) { << " != " << NUM_OBS_COLS << ") on line number " << dl.line_number() << " of ISMN file \"" << ascii_file.filename() << "\"!\n\n"; - return(false); + return false; } // Extract the valid time from the data line time_t valid_time = _getValidTime(dl); - if(valid_time == 0) return(false); + if(valid_time == 0) return false; // Store the observation value double obs_value = atof(dl[2]); @@ -153,7 +153,7 @@ bool IsmnHandler::_readObservations(LineDataFile &ascii_file) { } // end while - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -184,7 +184,7 @@ time_t IsmnHandler::_getValidTime(const DataLine &dl) const { time_struct.tm_min = stoi( hm_str.substr(3, 2)); } - return(timegm(&time_struct)); + return timegm(&time_struct); } //////////////////////////////////////////////////////////////////////// @@ -201,7 +201,7 @@ bool IsmnHandler::_readHeaderInfo(LineDataFile &ascii_file) { mlog << Error << "\nIsmnHandler::_readHeaderInfo() -> " << "unexpected ISMN file name \"" << ascii_file.filename() << "\"!\n\n"; - return(false); + return false; } // Validate the variable name @@ -210,7 +210,7 @@ bool IsmnHandler::_readHeaderInfo(LineDataFile &ascii_file) { << "unexpected variable name (" << sa[3] << ") found in ISMN file name \"" << ascii_file.filename() << "\"!\n\n"; - return(false); + return false; } // Store the observation variable info @@ -230,7 +230,7 @@ bool IsmnHandler::_readHeaderInfo(LineDataFile &ascii_file) { << dl.n_items() << " < " << MIN_NUM_HDR_COLS << ") in ISMN file \"" << ascii_file.filename() << "\"!\n\n"; - return(false); + return false; } // Store the header information @@ -249,7 +249,7 @@ bool IsmnHandler::_readHeaderInfo(LineDataFile &ascii_file) { _depth = (atof(dl[6]) + atof(dl[7]))/2.0; } - return(true); + return true; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/ascii2nc/met_handler.cc b/src/tools/other/ascii2nc/met_handler.cc index 5b19b8b0f6..f6c52fc671 100644 --- a/src/tools/other/ascii2nc/met_handler.cc +++ b/src/tools/other/ascii2nc/met_handler.cc @@ -184,7 +184,7 @@ bool MetHandler::_readObservations(LineDataFile &ascii_file) double parse_num(const char *s) { - if(!s) return(bad_data_double); + if(!s) return bad_data_double; return( (strcasecmp(s, na_str) == 0 ? bad_data_double : atof(s)) ); } diff --git a/src/tools/other/ascii2nc/python_handler.cc b/src/tools/other/ascii2nc/python_handler.cc index 28107fb1c7..f2a24d6db1 100644 --- a/src/tools/other/ascii2nc/python_handler.cc +++ b/src/tools/other/ascii2nc/python_handler.cc @@ -228,7 +228,7 @@ bool status = false; if ( use_tmp_ascii ) status = do_tmp_ascii (); else status = do_straight (); -return ( status ); +return status; } @@ -278,7 +278,7 @@ if ( PyErr_Occurred() ) { << "an error occurred importing module " << '\"' << user_base.text() << "\"\n\n"; - return ( false ); + return false; } @@ -303,7 +303,7 @@ PyObject * obj = md.lookup_list(list_name); load_python_obs(obj); -return ( true ); +return true; } @@ -403,7 +403,7 @@ remove_temp_file(tmp_ascii_path); // done // -return ( true ); +return true; } diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index dd6d003289..0b9375a274 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -104,7 +104,7 @@ int met_main(int argc, char *argv[]) { // Close output files and deallocate memory clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -670,7 +670,7 @@ bool get_data_plane(const char *infile, GrdFileType ftype, // Deallocate the data file pointer, if necessary if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - return(found); + return found; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc index cce3912742..b237c13fa8 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc @@ -377,7 +377,7 @@ GenEnsProdNcOutInfo GenEnsProdConfInfo::parse_nc_info(Dictionary *dict) { cur.do_climo_cdp = d->lookup_bool(conf_key_climo_cdp_flag); } - return(cur); + return cur; } //////////////////////////////////////////////////////////////////////// @@ -408,7 +408,7 @@ bool GenEnsProdNcOutInfo::all_false() const { do_vld || do_freq || do_nep || do_nmep || do_climo || do_climo_cdp; - return(!status); + return !status; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 3a2bf0224f..23cf43cf8e 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -96,7 +96,7 @@ int met_main(int argc, char *argv[]) { // Write out the mask file to NetCDF write_netcdf(dp_out); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -502,13 +502,13 @@ bool get_gen_vx_mask_config_str(MetNcMetDataFile *mnmdf_ptr, int i; // Check for null pointer - if(!mnmdf_ptr) return(status); + if(!mnmdf_ptr) ; // Check for the MET_tool global attribute - if(!get_global_att(mnmdf_ptr->MetNc->Nc, (string) "MET_tool", tool)) return(status); + if(!get_global_att(mnmdf_ptr->MetNc->Nc, (string) "MET_tool", tool)) return status; // Check for gen_vx_mask output - if(tool != program_name) return(status); + if(tool != program_name) return status; // Loop through the NetCDF variables for(i=0; iMetNc->Nvars; i++) { @@ -525,7 +525,7 @@ bool get_gen_vx_mask_config_str(MetNcMetDataFile *mnmdf_ptr, break; } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -689,7 +689,7 @@ bool is_shape_str_match(const int i_shape, const StringArray &names, const Strin } - return(match); + return match; } //////////////////////////////////////////////////////////////////////// @@ -1386,7 +1386,7 @@ DataPlane combine(const DataPlane &dp_data, const DataPlane &dp_mask, << " points inside\n"; } - return(dp); + return dp; } //////////////////////////////////////////////////////////////////////// @@ -1519,7 +1519,7 @@ MaskType string_to_masktype(const char *s) { exit(1); } - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -1544,7 +1544,7 @@ const char * masktype_to_string(const MaskType t) { default: s = (const char *) 0; break; } - return(s); + return s; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gis_utils/gis_dump_dbf.cc b/src/tools/other/gis_utils/gis_dump_dbf.cc index c9aab98c9f..6fd541baf3 100644 --- a/src/tools/other/gis_utils/gis_dump_dbf.cc +++ b/src/tools/other/gis_utils/gis_dump_dbf.cc @@ -151,7 +151,7 @@ for (j=0; j<(h.n_records); ++j) { close(fd); -return ( 0 ); +return 0; } diff --git a/src/tools/other/gis_utils/gis_dump_shp.cc b/src/tools/other/gis_utils/gis_dump_shp.cc index 5e95bacced..a4f86d68f5 100644 --- a/src/tools/other/gis_utils/gis_dump_shp.cc +++ b/src/tools/other/gis_utils/gis_dump_shp.cc @@ -116,7 +116,7 @@ f.header()->dump(cout, 1); cout << '\n' << flush; -if ( header_only ) return ( 0 ); +if ( header_only ) return 0; // // records @@ -150,7 +150,7 @@ switch ( shape_type ) { f.close(); -return ( 0 ); +return 0; } diff --git a/src/tools/other/gis_utils/gis_dump_shx.cc b/src/tools/other/gis_utils/gis_dump_shx.cc index 7fdda4be1f..593583c6bd 100644 --- a/src/tools/other/gis_utils/gis_dump_shx.cc +++ b/src/tools/other/gis_utils/gis_dump_shx.cc @@ -126,7 +126,7 @@ cout << "\n\n Read " << count << " records\n\n"; close(fd); -return ( 0 ); +return 0; } diff --git a/src/tools/other/grid_diag/grid_diag.cc b/src/tools/other/grid_diag/grid_diag.cc index 4a54b42ee2..b8a81261d2 100644 --- a/src/tools/other/grid_diag/grid_diag.cc +++ b/src/tools/other/grid_diag/grid_diag.cc @@ -100,7 +100,7 @@ int met_main(int argc, char *argv[]) { // Close files and deallocate memory clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -784,7 +784,7 @@ Met2dDataFile *get_mtddf(const StringArray &file_list, exit(1); } - return(mtddf); + return mtddf; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/conv_record.cc b/src/tools/other/gsi_tools/conv_record.cc index 92d5cb8904..81be4cad98 100644 --- a/src/tools/other/gsi_tools/conv_record.cc +++ b/src/tools/other/gsi_tools/conv_record.cc @@ -114,7 +114,7 @@ const int n = fortran_two_to_one(nreal, data_index, station); double value = (double) (rdiag[n]); -return ( value ); +return value; } @@ -152,7 +152,7 @@ for (j=7; j>=0; --j) { } -return ( ConcatString(localbuf) ); +return ConcatString(localbuf); } @@ -171,7 +171,7 @@ unix_to_mdyhms(date, month, day, year, hour, minute, second); snprintf(junk, sizeof(junk), "%04d%02d%02d_%02d0000", year, month, day, hour); -return ( ConcatString(junk) ); +return ConcatString(junk); } @@ -296,7 +296,7 @@ if ( (Fd = met_open(path, O_RDONLY)) < 0 ) { Fd = -1; - return ( false ); + return false; } @@ -320,7 +320,7 @@ if ( s <= 0 ) { mlog << Warning << "\nConvFile::open() -> " << "unable to read date from input file: " << Filename << "\n\n"; - return ( false ); + return false; } @@ -363,7 +363,7 @@ ::lseek(Fd, cur_pos, SEEK_SET); // done // -return ( true ); +return true; } @@ -393,7 +393,7 @@ r.extend(512); long long s = read_fortran_binary(f.Fd, r.Buf, 23, f.RecPadSize, f.SwapEndian); -if ( s == 0 ) return ( false ); +if ( s == 0 ) return false; if ( s != 19 && s != 23 ) { @@ -454,7 +454,7 @@ if ( f.SwapEndian ) { // done // -return ( true ); +return true; } diff --git a/src/tools/other/gsi_tools/gsi_record.cc b/src/tools/other/gsi_tools/gsi_record.cc index 0f9bf88897..7eb8fec34c 100644 --- a/src/tools/other/gsi_tools/gsi_record.cc +++ b/src/tools/other/gsi_tools/gsi_record.cc @@ -77,7 +77,7 @@ GsiRecord & GsiRecord::operator=(const GsiRecord & g) { -if ( this == &g ) return ( * this ); +if ( this == &g ) return *this; gsi_assign(g); diff --git a/src/tools/other/gsi_tools/gsi_util.cc b/src/tools/other/gsi_tools/gsi_util.cc index d56da8a71c..d9144c0c53 100644 --- a/src/tools/other/gsi_tools/gsi_util.cc +++ b/src/tools/other/gsi_tools/gsi_util.cc @@ -153,7 +153,7 @@ ConvData parse_conv_data(const ConvRecord &r, const int i) { d.n_use = 0; - return(d); + return d; } //////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ RadData parse_rad_data(const RadRecord &r, const int i, d.n_use = 0; - return(d); + return d; } @@ -239,7 +239,7 @@ ConcatString get_conv_key(const ConvData &d) { << unix_to_yyyymmdd_hhmmss(d.obs_ut) << key_sep << d.obs; - return(key); + return key; } //////////////////////////////////////////////////////////////////////// @@ -253,7 +253,7 @@ ConcatString get_rad_key(const RadData &d) { << unix_to_yyyymmdd_hhmmss(d.obs_ut) << key_sep << d.obs; - return(key); + return key; } //////////////////////////////////////////////////////////////////////// @@ -264,7 +264,7 @@ int key_to_integer(const char * key) { int_key += ((int)key[idx]) << (idx%3)*8; //int_key += (int)key[idx]; } - return(int_key); + return int_key; } //////////////////////////////////////////////////////////////////////// @@ -285,13 +285,13 @@ bool is_micro(const char *s) { } } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// bool is_retr(const char *s) { - return(false); + return false; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsid2mpr.cc b/src/tools/other/gsi_tools/gsid2mpr.cc index b12c853171..7fffb59004 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.cc +++ b/src/tools/other/gsi_tools/gsid2mpr.cc @@ -114,7 +114,7 @@ int met_main(int argc, char * argv []) { else process_rad (cline[i].c_str(), output_filename.c_str()); } - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -513,7 +513,7 @@ bool is_dup(const char *key) { key_array.add(key); obs_key_map[int_key] = key_array; } - return(dup); + return dup; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsidens2orank.cc b/src/tools/other/gsi_tools/gsidens2orank.cc index 91c1ce0671..c821d03bdc 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.cc +++ b/src/tools/other/gsi_tools/gsidens2orank.cc @@ -176,7 +176,7 @@ int met_main(int argc, char * argv []) { // Write the output write_orank(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -775,7 +775,7 @@ bool has_key(const ConcatString &key) { found_key = true; } } - return(found_key); + return found_key; } //////////////////////////////////////////////////////////////////////// @@ -796,7 +796,7 @@ bool has_key(const ConcatString &key, int & index) { } } } - return(found_key); + return found_key; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/rad_config.cc b/src/tools/other/gsi_tools/rad_config.cc index 86bb3af627..5ec7d33680 100644 --- a/src/tools/other/gsi_tools/rad_config.cc +++ b/src/tools/other/gsi_tools/rad_config.cc @@ -128,11 +128,11 @@ clear(); const bool status = Config.read(filename); -if ( ! status ) return ( status ); +if ( ! status ) return status; get_config_data(); -return ( status ); +return status; } diff --git a/src/tools/other/gsi_tools/rad_record.cc b/src/tools/other/gsi_tools/rad_record.cc index eac2a3bd68..fb872b3a7f 100644 --- a/src/tools/other/gsi_tools/rad_record.cc +++ b/src/tools/other/gsi_tools/rad_record.cc @@ -226,7 +226,7 @@ if ( (index < 0) || (index >= Ndiag) ) { } -return ( (double) (diag[index]) ); +return (double) (diag[index]); } @@ -258,7 +258,7 @@ if ( (channel < 0) || (channel >= N2) ) { const int n = fortran_two_to_one(N1, index, channel); -return ( (double) (diagchan[n]) ); +return (double) (diagchan[n]); } @@ -290,7 +290,7 @@ if ( (i < 0) || (i >= iextra) || (j < 0) || (j >= jextra) ) { const int n = fortran_two_to_one(iextra, i, j); -return ( (double) (extra[n]) ); +return (double) (extra[n]); } @@ -531,7 +531,7 @@ if ( (n < 0) || (n >= Nchannels) ) { } -return ( C_params[n].nuchan ); +return C_params[n].nuchan; } @@ -553,7 +553,7 @@ if ( (n < 0) || (n >= Nchannels) ) { } -return ( C_params[n].iuse ); +return C_params[n].iuse; } @@ -571,7 +571,7 @@ if ( (Fd = met_open(path, O_RDONLY)) < 0 ) { Fd = -1; - return ( false ); + return false; } @@ -651,7 +651,7 @@ ::lseek(Fd, cur_pos, SEEK_SET); // done // -return ( true ); +return true; } @@ -705,7 +705,7 @@ r.extend(s); n_read = read_fortran_binary(f.Fd, r.Buf, r.Nalloc, f.get_rec_pad_size(), f.get_swap_endian()); -if ( n_read == 0 ) return ( false ); +if ( n_read == 0 ) return false; if ( n_read != bytes ) { @@ -748,7 +748,7 @@ if ( f.get_swap_endian() ) { // done // -return ( true ); +return true; } diff --git a/src/tools/other/ioda2nc/ioda2nc.cc b/src/tools/other/ioda2nc/ioda2nc.cc index 552df4bde7..9c4233ded4 100644 --- a/src/tools/other/ioda2nc/ioda2nc.cc +++ b/src/tools/other/ioda2nc/ioda2nc.cc @@ -1164,7 +1164,7 @@ bool keep_message_type(const char *mt_str) { mlog << Debug(REJECT_DEBUG_LEVEL) << "The message type [" << mt_str << "] is rejected\n"; } - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -1178,7 +1178,7 @@ bool keep_station_id(const char *sid_str) { mlog << Debug(REJECT_DEBUG_LEVEL) << "The station ID [" << sid_str << "] is rejected\n"; } - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -1205,7 +1205,7 @@ bool keep_valid_time(const unixtime ut, << unix_to_yyyymmdd_hhmmss(ut) << "] is rejected\n"; } - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/lidar2nc/calipso_5km.cc b/src/tools/other/lidar2nc/calipso_5km.cc index a169627fa7..6ac6859350 100644 --- a/src/tools/other/lidar2nc/calipso_5km.cc +++ b/src/tools/other/lidar2nc/calipso_5km.cc @@ -38,7 +38,7 @@ static float ff[2]; inline float km_to_meters(float km) { - if ( km == FILL_VALUE ) return ( FILL_VALUE ); + if ( km == FILL_VALUE ) return FILL_VALUE; return ( km*1000.f ); @@ -336,7 +336,7 @@ t = k + jan_1_1993; // done // -return ( t ); +return t; } @@ -846,13 +846,13 @@ int Calipso_5km_Obs::get_feature_type_qa_value(int layer) { -if ( n_layers == 0 ) return ( -1 ); +if ( n_layers == 0 ) return -1; int k; k = extract_bits(fclass[layer], type_qa_mask, type_qa_shift); -return ( k ); +return k; } @@ -908,13 +908,13 @@ int Calipso_5km_Obs::get_ice_water_qa_value(int layer) { -if ( n_layers == 0 ) return ( -1 ); +if ( n_layers == 0 ) return -1; int k; k = extract_bits(fclass[layer], ice_water_qa_mask, ice_water_qa_shift); -return ( k ); +return k; } @@ -970,13 +970,13 @@ int Calipso_5km_Obs::get_cloud_aerosol_qa_value(int layer) { -if ( n_layers == 0 ) return ( -1 ); +if ( n_layers == 0 ) return -1; int k; k = extract_bits(fclass[layer], cloud_aerosol_qa_mask, cloud_aerosol_qa_shift); -return ( k ); +return k; } diff --git a/src/tools/other/lidar2nc/hdf_utils.cc b/src/tools/other/lidar2nc/hdf_utils.cc index fd5e66530e..df8c82f309 100644 --- a/src/tools/other/lidar2nc/hdf_utils.cc +++ b/src/tools/other/lidar2nc/hdf_utils.cc @@ -157,7 +157,7 @@ switch ( type ) { -return ( k ); +return k; } diff --git a/src/tools/other/lidar2nc/lidar2nc.cc b/src/tools/other/lidar2nc/lidar2nc.cc index b2e6573f44..7bbaa72351 100644 --- a/src/tools/other/lidar2nc/lidar2nc.cc +++ b/src/tools/other/lidar2nc/lidar2nc.cc @@ -148,7 +148,7 @@ nc_point_obs.close(); // done // -return ( 0 ); +return 0; } @@ -256,7 +256,7 @@ switch ( hdf_type ) { } // switch -return ( t ); +return t; } diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index 3a77ce8d72..3bb21b32ec 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -176,7 +176,7 @@ int met_main(int argc, char *argv[]) { // clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -673,7 +673,7 @@ MadisType get_madis_type(NcFile *&f_in) { else if (get_global_att(f_in, (string)"title", attr_value)) { if (attr_value.contents("MADIS ACARS") != "") madis_type = madis_acarsProfiles; } - return(madis_type); + return madis_type; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/cgraph_font.cc b/src/tools/other/mode_graphics/cgraph_font.cc index 451b6f9c90..8883eee633 100644 --- a/src/tools/other/mode_graphics/cgraph_font.cc +++ b/src/tools/other/mode_graphics/cgraph_font.cc @@ -92,11 +92,11 @@ CgFont & CgFont::operator=(const CgFont & p) { -if ( this == &p ) return ( * this ); +if ( this == &p ) return *this; assign(p); -return ( * this ); +return *this; } @@ -361,11 +361,11 @@ CgFontCollection & CgFontCollection::operator=(const CgFontCollection & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; assign(c); -return ( * this ); +return *this; } @@ -563,11 +563,11 @@ int j; for (j=0; j= Nelements) ) { } -return ( & e[k] ); +return &e[k]; } @@ -650,9 +650,9 @@ bool same_font(const CgFont & a, const CgFont & b) { -if ( a.ps_name == b.ps_name ) return ( true ); +if ( a.ps_name == b.ps_name ) return true; -return ( false ); +return false; } diff --git a/src/tools/other/mode_graphics/cgraph_main.cc b/src/tools/other/mode_graphics/cgraph_main.cc index baa2b3be01..81344815ce 100644 --- a/src/tools/other/mode_graphics/cgraph_main.cc +++ b/src/tools/other/mode_graphics/cgraph_main.cc @@ -377,7 +377,7 @@ if ( error ) { // done // -// return ( true ); +// return true; return; } @@ -657,7 +657,7 @@ if ( !CurrentFont ) { } -return ( CurrentFont->scaled_ps_size ); +return CurrentFont->scaled_ps_size; } @@ -732,7 +732,7 @@ if ( error ) { // done // -return ( face ); +return face; } @@ -1500,7 +1500,7 @@ Color c(0, 0, 0); if ( CS.depth() > 0 ) c = CS.peek(); -return ( c ); +return c; } @@ -2164,7 +2164,7 @@ info->cgraph->moveto(x, y); info->have_path = true; -return ( 0 ); +return 0; } @@ -2187,7 +2187,7 @@ info->cgraph->lineto(x, y); info->have_path = true; -return ( 0 ); +return 0; } @@ -2230,7 +2230,7 @@ info->cgraph->curveto(x1, y1, x2, y2, x3, y3); info->have_path = true; -return ( 0 ); +return 0; } diff --git a/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc b/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc index 313b169ca4..0d8983ff96 100644 --- a/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc +++ b/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc @@ -58,7 +58,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/tools/other/mode_graphics/color_stack.cc b/src/tools/other/mode_graphics/color_stack.cc index fb9d750364..cafaad3ded 100644 --- a/src/tools/other/mode_graphics/color_stack.cc +++ b/src/tools/other/mode_graphics/color_stack.cc @@ -77,11 +77,11 @@ ColorStack & ColorStack::operator=(const ColorStack & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -307,7 +307,7 @@ Color _t = *(e[Nelements - 1]); --Nelements; -return ( _t ); +return _t; } @@ -329,7 +329,7 @@ if ( Nelements <= 0 ) { Color _t = *(e[Nelements - 1]); -return ( _t ); +return _t; } diff --git a/src/tools/other/mode_graphics/mode_nc_output_file.cc b/src/tools/other/mode_graphics/mode_nc_output_file.cc index b958f30d6d..5d9c0dc2f7 100644 --- a/src/tools/other/mode_graphics/mode_nc_output_file.cc +++ b/src/tools/other/mode_graphics/mode_nc_output_file.cc @@ -84,7 +84,7 @@ ModeNcOutputFile & ModeNcOutputFile::operator=(const ModeNcOutputFile &) { -// if ( this == &m ) return ( * this ); +// if ( this == &m ) return *this; // // assign(m); @@ -183,7 +183,7 @@ if ( IS_INVALID_NC_P(f) ) { close(); - return ( false ); + return false; } @@ -279,7 +279,7 @@ for (x=0; x= Nx) ) return ( false ); +if ( (x < 0) || (x >= Nx) ) return false; int y; double v; @@ -839,11 +839,11 @@ for (y=0; y tol ) return ( true ); + if ( fabs(v - bad) > tol ) return true; } -return ( false ); +return false; } @@ -855,7 +855,7 @@ bool ModeNcOutputFile::y_line_valid (const int y) const { -if ( (y < 0) || (y >= Ny) ) return ( false ); +if ( (y < 0) || (y >= Ny) ) return false; int x; double v; @@ -866,11 +866,11 @@ for (x=0; x tol ) return ( true ); + if ( fabs(v - bad) > tol ) return true; } -return ( false ); +return false; } @@ -1012,7 +1012,7 @@ ConcatString s; s = get_short_name(Filename.c_str()); -return ( s ); +return s; } diff --git a/src/tools/other/mode_graphics/plot_mode_field.cc b/src/tools/other/mode_graphics/plot_mode_field.cc index e15bb31c7a..49cee17d08 100644 --- a/src/tools/other/mode_graphics/plot_mode_field.cc +++ b/src/tools/other/mode_graphics/plot_mode_field.cc @@ -252,7 +252,7 @@ for (j=0; j<(cline.n()); ++j) { } -return ( 0 ); +return 0; } @@ -1114,7 +1114,7 @@ if ( e->type() != StringType ) { s = e->string_value(); -return ( s ); +return s; } @@ -1144,7 +1144,7 @@ if ( !e ) { tf = e->b_value(); -return ( tf ); +return tf; } @@ -1174,7 +1174,7 @@ if ( !e ) { k = e->i_value(); -return ( k ); +return k; } @@ -1215,7 +1215,7 @@ else{ } -return ( t ); +return t; } @@ -1258,7 +1258,7 @@ for (j=0; j<3; ++j) { c.set_rgb(rgb[0], rgb[1], rgb[2]); -return ( c ); +return c; } @@ -1442,7 +1442,7 @@ s = target_width/(plot.LastTextWidth); if ( s > 1.0 ) s = 1.0; -return ( s ); +return s; } diff --git a/src/tools/other/mode_time_domain/2d_att.cc b/src/tools/other/mode_time_domain/2d_att.cc index 09533c9311..dda02837c0 100644 --- a/src/tools/other/mode_time_domain/2d_att.cc +++ b/src/tools/other/mode_time_domain/2d_att.cc @@ -90,11 +90,11 @@ SingleAtt2D & SingleAtt2D::operator=(const SingleAtt2D & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -405,7 +405,7 @@ if ( moments.N == 0 ) { // exit ( 1 ); - return ( a ); + return a; } @@ -472,7 +472,7 @@ a.Ptile_User = percentile_f(values, n, (double) (a.Ptile_Value/100.0)); if ( values ) { delete [] values; values = 0; } -return ( a ); +return a; } diff --git a/src/tools/other/mode_time_domain/2d_att_array.cc b/src/tools/other/mode_time_domain/2d_att_array.cc index 04b5310414..e402cced6f 100644 --- a/src/tools/other/mode_time_domain/2d_att_array.cc +++ b/src/tools/other/mode_time_domain/2d_att_array.cc @@ -91,11 +91,11 @@ SingleAtt2DArray & SingleAtt2DArray::operator=(const SingleAtt2DArray & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -305,7 +305,7 @@ if ( (N < 0) || (N >= Nelements) ) { exit ( 1 ); } -return ( e[N] ); +return e[N]; } @@ -352,7 +352,7 @@ if ( (index < 0) || (index >= Nelements) ) { } -return ( e[index].valid_time() ); +return e[index].valid_time(); } @@ -373,7 +373,7 @@ if ( (index < 0) || (index >= Nelements) ) { } -return ( e[index].lead_time() ); +return e[index].lead_time(); } @@ -394,7 +394,7 @@ if ( (index < 0) || (index >= Nelements) ) { } -return ( e[index].time_index() ); +return e[index].time_index(); } diff --git a/src/tools/other/mode_time_domain/2d_moments.cc b/src/tools/other/mode_time_domain/2d_moments.cc index 8e4e2a972b..7b10db6b59 100644 --- a/src/tools/other/mode_time_domain/2d_moments.cc +++ b/src/tools/other/mode_time_domain/2d_moments.cc @@ -76,11 +76,11 @@ Mtd_2D_Moments & Mtd_2D_Moments::operator=(const Mtd_2D_Moments & m) { -if ( this == &m ) return ( * this ); +if ( this == &m ) return *this; assign(m); -return ( * this ); +return *this; } @@ -234,7 +234,7 @@ rho_2 = Sxy; angle = 0.5*atan2d(rho_2, rho_1); -return ( angle ); +return angle; } diff --git a/src/tools/other/mode_time_domain/3d_att.cc b/src/tools/other/mode_time_domain/3d_att.cc index b35b4d6116..dac46a7997 100644 --- a/src/tools/other/mode_time_domain/3d_att.cc +++ b/src/tools/other/mode_time_domain/3d_att.cc @@ -99,11 +99,11 @@ SingleAtt3D & SingleAtt3D::operator=(const SingleAtt3D & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -436,7 +436,7 @@ double s; s = sqrt( Xvelocity*Xvelocity + Yvelocity*Yvelocity ); -return ( s ); +return s; } @@ -452,7 +452,7 @@ int n; n = Tmax - Tmin + 1; -return ( n ); +return n; } @@ -745,11 +745,11 @@ PairAtt3D & PairAtt3D::operator=(const PairAtt3D & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -1398,7 +1398,7 @@ a.Ptile_User = percentile_f(values, n, (double) (a.Ptile_Value/100.0)); if ( values ) { delete [] values; values = 0; } -return ( a ); +return a; } @@ -1541,7 +1541,7 @@ p.set_duration_difference(t); // done // -return ( p ); +return p; } @@ -1723,7 +1723,7 @@ t = num/den; // done // -return ( t ); +return t; } */ @@ -1763,7 +1763,7 @@ dist = gc_dist(lat1, lon1, lat2, lon2); // done // -return ( dist ); +return dist; } diff --git a/src/tools/other/mode_time_domain/3d_att_pair_array.cc b/src/tools/other/mode_time_domain/3d_att_pair_array.cc index 6e2278889c..8010289812 100644 --- a/src/tools/other/mode_time_domain/3d_att_pair_array.cc +++ b/src/tools/other/mode_time_domain/3d_att_pair_array.cc @@ -78,11 +78,11 @@ PairAtt3DArray & PairAtt3DArray::operator=(const PairAtt3DArray & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -292,7 +292,7 @@ if ( (N < 0) || (N >= Nelements) ) { exit ( 1 ); } -return ( e[N] ); +return e[N]; } @@ -312,7 +312,7 @@ if ( (k < 0) || (k >= Nelements) ) { } -return ( e[k].fcst_obj_number() ); +return e[k].fcst_obj_number(); } @@ -332,7 +332,7 @@ if ( (k < 0) || (k >= Nelements) ) { } -return ( e[k].obs_obj_number() ); +return e[k].obs_obj_number(); } @@ -352,7 +352,7 @@ if ( (k < 0) || (k >= Nelements) ) { } -return ( e[k].fcst_cluster_number() ); +return e[k].fcst_cluster_number(); } @@ -372,7 +372,7 @@ if ( (k < 0) || (k >= Nelements) ) { } -return ( e[k].obs_cluster_number() ); +return e[k].obs_cluster_number(); } @@ -392,7 +392,7 @@ if ( (k < 0) || (k >= Nelements) ) { } -return ( e[k].total_interest() ); +return e[k].total_interest(); } diff --git a/src/tools/other/mode_time_domain/3d_att_single_array.cc b/src/tools/other/mode_time_domain/3d_att_single_array.cc index 120747e92f..16630fc06f 100644 --- a/src/tools/other/mode_time_domain/3d_att_single_array.cc +++ b/src/tools/other/mode_time_domain/3d_att_single_array.cc @@ -78,11 +78,11 @@ SingleAtt3DArray & SingleAtt3DArray::operator=(const SingleAtt3DArray & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } diff --git a/src/tools/other/mode_time_domain/3d_conv.cc b/src/tools/other/mode_time_domain/3d_conv.cc index a0ad85c12a..ae3069c0e1 100644 --- a/src/tools/other/mode_time_domain/3d_conv.cc +++ b/src/tools/other/mode_time_domain/3d_conv.cc @@ -76,7 +76,7 @@ struct DataHandle { } - return ( k ); + return k; } @@ -439,7 +439,7 @@ if ( conv_data ) { delete [] conv_data; conv_data = (double *) nullptr; } if ( sum_plane_buf ) { delete [] sum_plane_buf; sum_plane_buf = nullptr; } if ( ok_sum_plane_buf ) { delete [] ok_sum_plane_buf; ok_sum_plane_buf = nullptr; } -return ( out ); +return out; } diff --git a/src/tools/other/mode_time_domain/3d_moments.cc b/src/tools/other/mode_time_domain/3d_moments.cc index 2f58298bc0..1a8349395b 100644 --- a/src/tools/other/mode_time_domain/3d_moments.cc +++ b/src/tools/other/mode_time_domain/3d_moments.cc @@ -76,11 +76,11 @@ Mtd_3D_Moments & Mtd_3D_Moments::operator=(const Mtd_3D_Moments & m) { -if ( this == &m ) return ( * this ); +if ( this == &m ) return *this; assign(m); -return ( * this ); +return *this; } @@ -280,7 +280,7 @@ bot = (Sxx - Syy)*Stt + Syt*Syt - Sxt*Sxt; angle = 0.5*atan2d(top, bot); -return ( angle ); +return angle; } diff --git a/src/tools/other/mode_time_domain/fo_graph.cc b/src/tools/other/mode_time_domain/fo_graph.cc index eebc762c26..be5124718c 100644 --- a/src/tools/other/mode_time_domain/fo_graph.cc +++ b/src/tools/other/mode_time_domain/fo_graph.cc @@ -78,11 +78,11 @@ FO_Graph & FO_Graph::operator=(const FO_Graph & g) { -if ( this == &g ) return ( * this ); +if ( this == &g ) return *this; assign(g); -return ( * this ); +return *this; } @@ -174,7 +174,7 @@ if ( (f_num < 0) || (f_num >= N_fcst) ) { } -return ( f_num ); +return f_num; } @@ -253,7 +253,7 @@ const int i_o = o_index(n_o); const int n = two_to_one(i_f, i_o); -return ( TheGraph[n].has_edge() ); +return TheGraph[n].has_edge(); } @@ -270,7 +270,7 @@ const int i_f_2 = f_index(n_f_2); const int n = two_to_one(i_f_1, i_f_2); -return ( TheGraph[n].has_edge() ); +return TheGraph[n].has_edge(); } @@ -287,7 +287,7 @@ const int i_o_2 = o_index(n_o_2); const int n = two_to_one(i_o_1, i_o_2); -return ( TheGraph[n].has_edge() ); +return TheGraph[n].has_edge(); } diff --git a/src/tools/other/mode_time_domain/fo_node.cc b/src/tools/other/mode_time_domain/fo_node.cc index bcad38ee9b..701580249b 100644 --- a/src/tools/other/mode_time_domain/fo_node.cc +++ b/src/tools/other/mode_time_domain/fo_node.cc @@ -76,11 +76,11 @@ FO_Node & FO_Node::operator=(const FO_Node & n) { -if ( this == &n ) return ( * this ); +if ( this == &n ) return *this; assign(n); -return ( * this ); +return *this; } diff --git a/src/tools/other/mode_time_domain/fo_node_array.cc b/src/tools/other/mode_time_domain/fo_node_array.cc index 045daaa0ba..2ad499ca94 100644 --- a/src/tools/other/mode_time_domain/fo_node_array.cc +++ b/src/tools/other/mode_time_domain/fo_node_array.cc @@ -78,11 +78,11 @@ FO_Node_Array & FO_Node_Array::operator=(const FO_Node_Array & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -292,7 +292,7 @@ if ( (N < 0) || (N >= Nelements) ) { exit ( 1 ); } -return ( e[N] ); +return e[N]; } diff --git a/src/tools/other/mode_time_domain/interest_calc.cc b/src/tools/other/mode_time_domain/interest_calc.cc index 9567f78caa..63263a853f 100644 --- a/src/tools/other/mode_time_domain/interest_calc.cc +++ b/src/tools/other/mode_time_domain/interest_calc.cc @@ -82,11 +82,11 @@ InterestCalculator & InterestCalculator::operator=(const InterestCalculator & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -353,7 +353,7 @@ for (j=0; jhas(fcst_num) ) return ( j ); + if ( eq->has(fcst_num) ) return j; } -return ( -1 ); +return -1; } @@ -360,11 +360,11 @@ for (j=0; jhas(obs_num) ) return ( j ); + if ( eq->has(obs_num) ) return j; } -return ( -1 ); +return -1; } @@ -388,7 +388,7 @@ for (j=0; j<(eq->n_elements()); ++j) { } -return ( a ); +return a; } @@ -412,7 +412,7 @@ for (j=0; j<(eq->n_elements()); ++j) { } -return ( a ); +return a; } @@ -433,12 +433,12 @@ j = part.which_class(k); for (m=0; m 0 ) { do_single_field(config); - return ( 0 ); + return 0; } @@ -913,7 +913,7 @@ do_mtd_nc_output(config.nc_info, engine, fcst_raw, obs_raw, fcst_obj, obs_obj, c // done // -return ( 0 ); +return 0; } @@ -1076,7 +1076,7 @@ prefix << junk; -return ( prefix ); +return prefix; } diff --git a/src/tools/other/mode_time_domain/mtd_config_info.cc b/src/tools/other/mode_time_domain/mtd_config_info.cc index ff6c6e0a9e..3468b38735 100644 --- a/src/tools/other/mode_time_domain/mtd_config_info.cc +++ b/src/tools/other/mode_time_domain/mtd_config_info.cc @@ -852,7 +852,7 @@ bool MtdNcOutInfo::all_false() const // bool status = do_latlon || do_raw || do_object_raw || do_object_id || do_cluster_id || do_polylines; bool status = do_latlon || do_raw || do_object_id || do_cluster_id; -return ( !status ); +return !status; } diff --git a/src/tools/other/mode_time_domain/mtd_file_base.cc b/src/tools/other/mode_time_domain/mtd_file_base.cc index fbd98dcf71..7381fed61d 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.cc +++ b/src/tools/other/mode_time_domain/mtd_file_base.cc @@ -245,7 +245,7 @@ if ( !G ) { } -return ( *G ); +return *G; } @@ -257,7 +257,7 @@ const Grid * MtdFileBase::grid_p() const { -return ( G ); +return G; } @@ -381,7 +381,7 @@ if ( (t < 0) || ( t >= (int)ActualValidTimes.size()) ) { } -return ( ActualValidTimes[t] ); +return ActualValidTimes[t]; } @@ -401,7 +401,7 @@ if ( (index < 0) || ( index >= Nt) ) { } -return ( Lead_Times[index] ); +return Lead_Times[index]; } diff --git a/src/tools/other/mode_time_domain/mtd_file_float.cc b/src/tools/other/mode_time_domain/mtd_file_float.cc index 0f0d3d6f7e..105dd23b2c 100644 --- a/src/tools/other/mode_time_domain/mtd_file_float.cc +++ b/src/tools/other/mode_time_domain/mtd_file_float.cc @@ -85,11 +85,11 @@ MtdFloatFile & MtdFloatFile::operator=(const MtdFloatFile & f) { -if ( this == &f ) return ( * this ); +if ( this == &f ) return *this; float_assign(f); -return ( * this ); +return *this; } @@ -439,7 +439,7 @@ MtdIntFile out; threshold(T, out); -return ( out ); +return out; } @@ -455,7 +455,7 @@ MtdIntFile out; threshold(t, out); -return ( out ); +return out; } @@ -611,13 +611,13 @@ bool MtdFloatFile::read(const char * _filename) NcFile f(_filename, NcFile::read); -if ( IS_INVALID_NC(f) ) return ( false ); +if ( IS_INVALID_NC(f) ) return false; Filename = _filename; MtdFloatFile::read(f); -return ( true ); +return true; } @@ -907,7 +907,7 @@ f.DataMax = fmax; // done // -return ( f ); +return f; } diff --git a/src/tools/other/mode_time_domain/mtd_file_int.cc b/src/tools/other/mode_time_domain/mtd_file_int.cc index 5964e4c5e2..dd68c47bbd 100644 --- a/src/tools/other/mode_time_domain/mtd_file_int.cc +++ b/src/tools/other/mode_time_domain/mtd_file_int.cc @@ -95,11 +95,11 @@ MtdIntFile & MtdIntFile::operator=(const MtdIntFile & f) { -if ( this == &f ) return ( * this ); +if ( this == &f ) return *this; int_assign(f); -return ( * this ); +return *this; } @@ -403,13 +403,13 @@ bool MtdIntFile::read(const char * _filename) NcFile f(_filename, NcFile::read); -if ( IS_INVALID_NC(f) ) return ( false ); +if ( IS_INVALID_NC(f) ) return false; Filename = _filename; MtdIntFile::read(f); -return ( true ); +return true; } @@ -736,7 +736,7 @@ f.DataMax = fmax; // done // -return ( f ); +return f; } @@ -813,7 +813,7 @@ f.set_volumes(1, &vol); // done // -return ( f ); +return f; } @@ -1195,7 +1195,7 @@ n_shapes = p.n_elements(); // done // -return ( q ); +return q; } @@ -1276,7 +1276,7 @@ if ( (k < 0) || (k >= Nobjects) ) { } -return ( ObjVolume[k] ); +return ObjVolume[k]; } @@ -1301,7 +1301,7 @@ int sum = 0; for (j=0; j=0; --x) { - if ( Data[mtd_three_to_one(Nx, Ny, Nt, x, y, 0)] ) return ( x ); + if ( Data[mtd_three_to_one(Nx, Ny, Nt, x, y, 0)] ) return x; } -return ( -1 ); +return -1; } @@ -1861,7 +1861,7 @@ for (t=0; t= Nelements) ) { } -return ( E[k] ); +return E[k]; } @@ -307,7 +307,7 @@ int EquivalenceClass::n_max() const { -if ( Nelements == 0 ) return ( 0 ); +if ( Nelements == 0 ) return 0; int j, n; @@ -319,7 +319,7 @@ for (j=1; jhas(k) ) return ( true ); + if ( (*c)->has(k) ) return true; } -return ( false ); +return false; } */ @@ -567,7 +567,7 @@ if ( (index < 0) || (index >= Nelements) ) { } -return ( C[index]->has(k) ); +return C[index]->has(k); } @@ -583,12 +583,12 @@ int j; for (j=0; jhas(k) ) return ( j ); + if ( C[j]->has(k) ) return j; } -return ( -1 ); +return -1; } @@ -718,7 +718,7 @@ if ( (k < 0) || (k >= Nelements) ) { } -return ( C[k] ); +return C[k]; } @@ -780,7 +780,7 @@ for (j=0; j haven't written code to parse \"" << proj << "\" grids yet!\n\n"; - return ( false ); + return false; } @@ -80,7 +80,7 @@ bool read_nc_grid(NcFile & f, Grid & g) // done // -return ( status ); +return status; } @@ -117,7 +117,7 @@ else { // done // -return ( false ); +return false; } @@ -203,7 +203,7 @@ data.dy_km = data.d_km; g.set(data); -return ( true ); +return true; } @@ -281,7 +281,7 @@ data.so2_angle = 0.0; g.set(data); -return ( true ); +return true; } @@ -333,7 +333,7 @@ data.Nlon = string_att_as_int(f, "Nlon"); g.set(data); -return ( true ); +return true; } diff --git a/src/tools/other/mode_time_domain/nc_utils_local.cc b/src/tools/other/mode_time_domain/nc_utils_local.cc index d80d335f1b..d7cb55dbd8 100644 --- a/src/tools/other/mode_time_domain/nc_utils_local.cc +++ b/src/tools/other/mode_time_domain/nc_utils_local.cc @@ -67,7 +67,7 @@ if (att) { delete att; att = 0; } // done // -return ( cbuf ); +return cbuf; } @@ -83,7 +83,7 @@ const char * c = string_att(Nc, name); double value = atof(c); -return ( value ); +return value; } @@ -99,7 +99,7 @@ const char * c = string_att(Nc, name); int k = atoi(c); -return ( k ); +return k; } @@ -115,7 +115,7 @@ const char * c = string_att(Nc, name); long long k = atoll(c); -return ( k ); +return k; } @@ -162,7 +162,7 @@ t = mdyhms_to_unix(month, day, year, hour, minute, second); // done // -return ( t ); +return t; } @@ -181,7 +181,7 @@ unix_to_mdyhms(t, month, day, year, hour, minute, second); snprintf(junk, sizeof(junk), "%04d%02d%02d_%02d%02d%02d", year, month, day, hour, minute, second); -return ( ConcatString(junk) ); +return ConcatString(junk); } diff --git a/src/tools/other/modis_regrid/cloudsat_swath_file.cc b/src/tools/other/modis_regrid/cloudsat_swath_file.cc index 233cdea2b0..4344f4c9ea 100644 --- a/src/tools/other/modis_regrid/cloudsat_swath_file.cc +++ b/src/tools/other/modis_regrid/cloudsat_swath_file.cc @@ -96,11 +96,11 @@ SatDimension & SatDimension::operator=(const SatDimension & d) { -if ( this == &d ) return ( * this ); +if ( this == &d ) return *this; assign(d); -return ( * this ); +return *this; } @@ -266,11 +266,11 @@ SatAttribute & SatAttribute::operator=(const SatAttribute & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -641,11 +641,11 @@ SwathDataField & SwathDataField::operator=(const SwathDataField & df) { -if ( this == &df ) return ( * this ); +if ( this == &df ) return *this; assign(df); -return ( * this ); +return *this; } @@ -891,7 +891,7 @@ if ( (k < 0) || (k >= Ndimensions) ) { int m = Dimensions[k]->size(); -return ( m ); +return m; } @@ -949,11 +949,11 @@ CloudsatSwath & CloudsatSwath::operator=(const CloudsatSwath & s) { -if ( this == &s ) return ( * this ); +if ( this == &s ) return *this; assign(s); -return ( * this ); +return *this; } @@ -1709,7 +1709,7 @@ for (j=0; j 1 ) { close(); - return ( false ); + return false; } @@ -301,7 +301,7 @@ if ( (k = SWattach(FileId, (char *) a[0].c_str())) < 0 ) { close(); - return ( false ); + return false; } @@ -326,7 +326,7 @@ if ( ! dim ) { close(); - return ( false ); + return false; } @@ -341,7 +341,7 @@ if ( ! dim ) { close(); - return ( false ); + return false; } @@ -375,7 +375,7 @@ if ( !status || (dt < 0.0) ) { close(); - return ( false ); + return false; } @@ -386,7 +386,7 @@ ScanStartTime = ut_modis_start + nint(dt); // done // -return ( true ); +return true; } @@ -597,7 +597,7 @@ if ( (n0 < 0) || (n0 >= Dim0) || (n1 < 0) || (n1 >= Dim1) ) { mlog << Error << "\n\n ModisFile::get_float_data() -> range check error ... " << n0 << ", " << n1 << "\n\n"; - return ( false ); + return false; } @@ -617,7 +617,7 @@ if ( status < 0 ) { // exit ( 1 ); - return ( false ); + return false; } @@ -627,7 +627,7 @@ value = d[0]; // done // -return ( true ); +return true; } @@ -650,7 +650,7 @@ if ( (n0 < 0) || (n0 >= Dim0) || (n1 < 0) || (n1 >= Dim1) ) { // exit ( 1 ); - return ( false ); + return false; } @@ -668,7 +668,7 @@ if ( status < 0 ) { mlog << Error << "\n\n CloudsatSwath::get_float_data(int, int) const -> bad SWreadfield status\n\n"; - return ( false ); + return false; } @@ -678,7 +678,7 @@ if ( status < 0 ) { value = f[0]; -return ( true ); +return true; } @@ -699,7 +699,7 @@ if ( (n0 < 0) || (n0 >= Dim0) || (n1 < 0) || (n1 >= Dim1) ) { mlog << Error << "\n\n ModisFile::get_int16_data() -> range check error\n\n"; - return ( false ); + return false; } @@ -719,7 +719,7 @@ if ( status < 0 ) { // exit ( 1 ); - return ( false ); + return false; } @@ -729,7 +729,7 @@ if ( status < 0 ) { value = s[0]; -return ( true ); +return true; } @@ -752,7 +752,7 @@ if ( (n0 < 0) || (n0 >= Dim0) || (n1 < 0) || (n1 >= Dim1) ) { // exit ( 1 ); - return ( false ); + return false; } @@ -772,7 +772,7 @@ if ( status < 0 ) { // exit ( 1 ); - return ( false ); + return false; } @@ -782,7 +782,7 @@ if ( status < 0 ) { value = c[0]; -return ( true ); +return true; } @@ -799,7 +799,7 @@ float f[2]; if (get_float_data(Latitude, n0, n1, f[0])) v = f[0]; -return ( v ); +return v; } @@ -822,7 +822,7 @@ if (get_float_data(Longitude, n0, n1, f[0])) { } -return ( v ); +return v; } @@ -910,9 +910,9 @@ switch ( NumberType ) { } // switch -if ( !status ) return ( false ); +if ( !status ) return false; -if ( value == DataFillValue ) return ( false ); +if ( value == DataFillValue ) return false; value = DataScale*(value - DataOffset); @@ -920,7 +920,7 @@ value = DataScale*(value - DataOffset); // done // -return ( true ); +return true; } @@ -936,7 +936,7 @@ ConcatString s; if ( Filename.nonempty() ) s = get_short_name(Filename.c_str()); -return ( s ); +return s; } @@ -948,7 +948,7 @@ CloudsatSwath * ModisFile::swath() const { -return ( Swath ); +return Swath; } @@ -960,7 +960,7 @@ unixtime ModisFile::scan_start_time() const { -return ( ScanStartTime ); +return ScanStartTime; } diff --git a/src/tools/other/modis_regrid/modis_regrid.cc b/src/tools/other/modis_regrid/modis_regrid.cc index 788898b60f..774ff1a6c3 100644 --- a/src/tools/other/modis_regrid/modis_regrid.cc +++ b/src/tools/other/modis_regrid/modis_regrid.cc @@ -152,7 +152,7 @@ process(modis_filename.c_str()); // done // -return ( 0 ); +return 0; } diff --git a/src/tools/other/modis_regrid/sat_utils.cc b/src/tools/other/modis_regrid/sat_utils.cc index 55402459b9..de7963d5ce 100644 --- a/src/tools/other/modis_regrid/sat_utils.cc +++ b/src/tools/other/modis_regrid/sat_utils.cc @@ -115,7 +115,7 @@ switch ( nt ) { } // switch -return ( s ); +return s; } diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index 2922c23d0a..4d10508d50 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -2649,7 +2649,7 @@ int get_event_index(int flag, int i_var, int i_lvl) { if(ev < 0) ev = 0; } - return(ev); + return ev; } //////////////////////////////////////////////////////////////////////// @@ -2687,7 +2687,7 @@ int get_event_index_temp(int flag, int i_var, int i_lvl) { if(is_eq(evns[i_var][i][i_lvl][2], virtmp_prog_code)) { // Skip this observation if the reason code is 3 - if(is_eq(evns[i_var][i][i_lvl][3], 3.0)) return(bad_data_int); + if(is_eq(evns[i_var][i][i_lvl][3], 3.0)) return bad_data_int; // Use the next entry in the event stack but keep searching ev = i+1; @@ -2702,10 +2702,10 @@ int get_event_index_temp(int flag, int i_var, int i_lvl) { ev = get_event_index(flag, i_var, i_lvl); // Check for the VIRTMP program code - if(is_eq(evns[i_var][ev][i_lvl][2], virtmp_prog_code)) return(bad_data_int); + if(is_eq(evns[i_var][ev][i_lvl][2], virtmp_prog_code)) return bad_data_int; } - return(ev); + return ev; } //////////////////////////////////////////////////////////////////////// @@ -2743,7 +2743,7 @@ bool keep_message_type(const char *mt_str) { keep = conf_info.message_type.n_elements() == 0 || conf_info.message_type.has(mt_str, false); - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -2773,7 +2773,7 @@ bool keep_valid_time(const unixtime ut, if(ut > max_ut) keep = false; } - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -2884,7 +2884,7 @@ float derive_grib_code(int gc, float *pqtzuv, float *pqtzuv_qty, break; } // end switch - return(result); + return result; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/plot_point_obs/plot_point_obs.cc b/src/tools/other/plot_point_obs/plot_point_obs.cc index 66eb91ee0d..16a4728c84 100644 --- a/src/tools/other/plot_point_obs/plot_point_obs.cc +++ b/src/tools/other/plot_point_obs/plot_point_obs.cc @@ -128,7 +128,7 @@ int met_main(int argc, char *argv[]) { // Plot the result create_plot(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc b/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc index 04b798e71a..e5fa1457bb 100644 --- a/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc +++ b/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc @@ -231,48 +231,48 @@ bool PlotPointObsOpt::add(const Observation &obs) { // message type if(msg_typ.n() > 0 && !msg_typ.has(obs.getHeaderType())) { - return(false); + return false; } // station id if((sid_inc.n() > 0 && !sid_inc.has(obs.getStationId())) || (sid_exc.n() > 0 && sid_exc.has(obs.getStationId()))) { - return(false); + return false; } // observation variable if(obs_var.n() > 0 && !obs_var.has(obs.getVarName())) { - return(false); + return false; } // observation GRIB code if(obs_gc.n() > 0 && !obs_gc.has(obs.getGribCode())) { - return(false); + return false; } // quality control string if(obs_qty.n() > 0 && !obs_qty.has(obs.getQualityFlag())) { - return(false); + return false; } // valid time unixtime ut = obs.getValidTime(); if((valid_beg > 0 && ut < valid_beg) || (valid_end > 0 && ut > valid_end)) { - return(false); + return false; } // lat, lon if(!lat_thresh.check(obs.getLatitude()) || !lon_thresh.check(obs.getLongitude())) { - return(false); + return false; } // elevation, height, pressure if(!elv_thresh.check(obs.getElevation()) || !hgt_thresh.check(obs.getHeight()) || !prs_thresh.check(obs.getPressureLevel())) { - return(false); + return false; } // store the current observation value @@ -293,7 +293,7 @@ bool PlotPointObsOpt::add(const Observation &obs) { // observation value if(!obs_thresh.check(cur_val)) { - return(false); + return false; } // Store this matching point location @@ -308,7 +308,7 @@ bool PlotPointObsOpt::add(const Observation &obs) { n_obs++; if(!has(cur_loc)) locations.push_back(cur_loc); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -324,7 +324,7 @@ bool PlotPointObsOpt::has(const LocationInfo &loc) { } } - return(match); + return match; } //////////////////////////////////////////////////////////////////////// @@ -608,7 +608,7 @@ bool PlotPointObsConfInfo::add(const Observation &obs) { if((match = it->add(obs))) break; } - return(match); + return match; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 2737e125c9..cbb2187de1 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -219,7 +219,7 @@ int met_main(int argc, char *argv[]) { // Process the input data file process_data_file(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -2740,7 +2740,7 @@ bool keep_message_type(const int mt_index) { keep = message_type_list.n() == 0 || message_type_list.has(mt_index); - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index 309aaf3d6a..7f153ce572 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -116,7 +116,7 @@ int met_main(int argc, char *argv[]) { // Process the input data file process_data_file(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/shift_data_plane/shift_data_plane.cc b/src/tools/other/shift_data_plane/shift_data_plane.cc index 411f5dd10f..18785a395a 100644 --- a/src/tools/other/shift_data_plane/shift_data_plane.cc +++ b/src/tools/other/shift_data_plane/shift_data_plane.cc @@ -105,7 +105,7 @@ int met_main(int argc, char *argv[]) { // Process the input data file process_data_file(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/af_cp_file.cc b/src/tools/other/wwmca_tool/af_cp_file.cc index 70acdb4941..e0426d8b44 100644 --- a/src/tools/other/wwmca_tool/af_cp_file.cc +++ b/src/tools/other/wwmca_tool/af_cp_file.cc @@ -93,11 +93,11 @@ AFCloudPctFile & AFCloudPctFile::operator=(const AFCloudPctFile & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -177,7 +177,7 @@ if ( (fd = met_open(filename, O_RDONLY)) < 0 ) { mlog << Error << "\nAFCloudPctFile::read(const char *) -> " << "can't open file \"" << filename << "\"\n\n"; - return ( false ); + return false; } @@ -192,7 +192,7 @@ if ( ::read(fd, Buf, bytes) != bytes ) { ::close(fd); - return ( false ); + return false; } @@ -204,7 +204,7 @@ Filename = get_short_name(filename); ::close(fd); -return ( true ); +return true; } @@ -222,7 +222,7 @@ n = two_to_one(x, y); // this function does range checking on x and y for us k = (int) (Buf[n]); -return ( k ); +return k; } diff --git a/src/tools/other/wwmca_tool/af_file.cc b/src/tools/other/wwmca_tool/af_file.cc index e0618a2b41..6af9876d84 100644 --- a/src/tools/other/wwmca_tool/af_file.cc +++ b/src/tools/other/wwmca_tool/af_file.cc @@ -86,11 +86,11 @@ AFDataFile & AFDataFile::operator=(const AFDataFile & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -228,7 +228,7 @@ if ( Valid == (unixtime) 0 ) { if ( Hemisphere == 'N' ) grid = new Grid(wwmca_north_data); else grid = new Grid(wwmca_south_data); -return ( true ); +return true; } @@ -243,10 +243,10 @@ double lat, lon; grid->xy_to_latlon((double) x, (double) y, lat, lon); -if ( (Hemisphere == 'N') && (lat < 0.0) ) return ( false ); -if ( (Hemisphere == 'S') && (lat > 0.0) ) return ( false ); +if ( (Hemisphere == 'N') && (lat < 0.0) ) return false; +if ( (Hemisphere == 'S') && (lat > 0.0) ) return false; -return ( true ); +return true; } @@ -272,7 +272,7 @@ yy = af_ny - 1 - y; n = yy*af_nx + x; -return ( n ); +return n; } diff --git a/src/tools/other/wwmca_tool/af_pt_file.cc b/src/tools/other/wwmca_tool/af_pt_file.cc index 4b875257d4..ee61fc4e1c 100644 --- a/src/tools/other/wwmca_tool/af_pt_file.cc +++ b/src/tools/other/wwmca_tool/af_pt_file.cc @@ -96,11 +96,11 @@ AFPixelTimeFile & AFPixelTimeFile::operator=(const AFPixelTimeFile & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -184,7 +184,7 @@ if ( (fd = met_open(filename, O_RDONLY)) < 0 ) { mlog << Error << "\nAFPixelTimeFile::read(const char *) -> " << "can't open file \"" << filename << "\"\n\n"; - return ( false ); + return false; } @@ -199,7 +199,7 @@ if ( ::read(fd, Buf, bytes) != bytes ) { ::close(fd); - return ( false ); + return false; } @@ -212,7 +212,7 @@ Filename = get_short_name(filename); ::close(fd); -return ( true ); +return true; } @@ -246,7 +246,7 @@ else { } -return ( k ); +return k; } diff --git a/src/tools/other/wwmca_tool/ave_interp.cc b/src/tools/other/wwmca_tool/ave_interp.cc index a9a2cbcf32..0b78a70027 100644 --- a/src/tools/other/wwmca_tool/ave_interp.cc +++ b/src/tools/other/wwmca_tool/ave_interp.cc @@ -75,11 +75,11 @@ Ave_Interp & Ave_Interp::operator=(const Ave_Interp & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -139,7 +139,7 @@ Interpolator * i = (Interpolator *) 0; i = new Ave_Interp (*this); -return ( i ); +return i; } @@ -217,7 +217,7 @@ if ( (good_count > 0) && (good_count >= NgoodNeeded) ) { // -return ( I ); +return I; } diff --git a/src/tools/other/wwmca_tool/interp_base.cc b/src/tools/other/wwmca_tool/interp_base.cc index 0b7dd9f182..ecfb648ea1 100644 --- a/src/tools/other/wwmca_tool/interp_base.cc +++ b/src/tools/other/wwmca_tool/interp_base.cc @@ -75,11 +75,11 @@ InterpolationValue & InterpolationValue::operator=(const InterpolationValue & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -314,7 +314,7 @@ int n; n = y*Width + x; -return ( n ); +return n; } @@ -444,7 +444,7 @@ for (j=0; j= NgoodNeeded ) { // -return ( I ); +return I; } diff --git a/src/tools/other/wwmca_tool/min_interp.cc b/src/tools/other/wwmca_tool/min_interp.cc index 536aa90211..1023d20c0b 100644 --- a/src/tools/other/wwmca_tool/min_interp.cc +++ b/src/tools/other/wwmca_tool/min_interp.cc @@ -76,11 +76,11 @@ Min_Interp & Min_Interp::operator=(const Min_Interp & m) { -if ( this == &m ) return ( * this ); +if ( this == &m ) return *this; assign(m); -return ( * this ); +return *this; } @@ -140,7 +140,7 @@ Interpolator * i = (Interpolator *) 0; i = new Min_Interp (*this); -return ( i ); +return i; } @@ -226,7 +226,7 @@ if ( good_count >= NgoodNeeded ) { // -return ( I ); +return I; } diff --git a/src/tools/other/wwmca_tool/nearest_interp.cc b/src/tools/other/wwmca_tool/nearest_interp.cc index 2951fdd635..e3cc25b568 100644 --- a/src/tools/other/wwmca_tool/nearest_interp.cc +++ b/src/tools/other/wwmca_tool/nearest_interp.cc @@ -75,11 +75,11 @@ Nearest_Interp & Nearest_Interp::operator=(const Nearest_Interp & n) { -if ( this == &n ) return ( * this ); +if ( this == &n ) return *this; assign(n); -return ( * this ); +return *this; } @@ -139,7 +139,7 @@ Interpolator * i = (Interpolator *) 0; i = new Nearest_Interp (*this); -return ( i ); +return i; } @@ -196,7 +196,7 @@ I = Data[n]; // -return ( I ); +return I; } diff --git a/src/tools/other/wwmca_tool/wwmca_plot.cc b/src/tools/other/wwmca_tool/wwmca_plot.cc index b960362156..7bf810e4b1 100644 --- a/src/tools/other/wwmca_tool/wwmca_plot.cc +++ b/src/tools/other/wwmca_tool/wwmca_plot.cc @@ -162,7 +162,7 @@ for (j=0; j<(cline.n()); ++j) { // done // -return ( 0 ); +return 0; } @@ -472,7 +472,7 @@ k = ((gray_max - gray_min)*value)/100 + gray_min; c.set_gray(k); -return ( c ); +return c; } @@ -505,7 +505,7 @@ bool region_ok(const MapRegion & r, const char hemisphere) { -return ( true ); +return true; } diff --git a/src/tools/other/wwmca_tool/wwmca_regrid.cc b/src/tools/other/wwmca_tool/wwmca_regrid.cc index e25929420b..e66dbe1564 100644 --- a/src/tools/other/wwmca_tool/wwmca_regrid.cc +++ b/src/tools/other/wwmca_tool/wwmca_regrid.cc @@ -167,7 +167,7 @@ regridder.do_output(output_filename.c_str()); // done // -return ( 0 ); +return 0; } @@ -294,7 +294,7 @@ int get_compress() { -return ( compress_level ); +return compress_level; } diff --git a/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc b/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc index f2d2b3b5cf..11d5b0e9fd 100644 --- a/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc +++ b/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc @@ -66,7 +66,7 @@ int met_main(int argc, char *argv[]) { clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_diag/python_tc_diag.cc b/src/tools/tc_utils/tc_diag/python_tc_diag.cc index 2a6f5b5ce2..991295370f 100644 --- a/src/tools/tc_utils/tc_diag/python_tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/python_tc_diag.cc @@ -173,7 +173,7 @@ bool straight_python_tc_diag(const ConcatString &diag_script, } // Parse the diagnostics from python - return(parse_python_diag_data(module_obj, tmp_info)); + return parse_python_diag_data(module_obj, tmp_info); } //////////////////////////////////////////////////////////////////////// @@ -233,7 +233,7 @@ bool user_python_tc_diag(const ConcatString &diag_script, PyErr_Print(); mlog << Warning << "\n" << method_name << "an error occurred initializing python\n\n"; - return(false); + return false; } run_python_string("import sys"); @@ -270,13 +270,13 @@ bool user_python_tc_diag(const ConcatString &diag_script, mlog << Warning << "\n" << method_name << "an error occurred importing module " << "\"" << path << "\"\n\n"; - return(false); + return false; } if(!module_obj) { mlog << Warning << "\n" << method_name << "error running python script\n\n"; - return(false); + return false; } // Parse the diagnostics from python @@ -285,7 +285,7 @@ bool user_python_tc_diag(const ConcatString &diag_script, // Cleanup remove_temp_file(tmp_file_name); - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -301,7 +301,7 @@ bool parse_python_diag_data(PyObject *module_obj, if(!module_dict_obj || !PyDict_Check(module_dict_obj)) { mlog << Warning << "\n" << method_name << "python module is not a dictionary.\n\n"; - return(false); + return false; } // Get the diag_data item @@ -312,7 +312,7 @@ bool parse_python_diag_data(PyObject *module_obj, mlog << Warning << "\n" << method_name << "trouble parsing the \"" << diag_data_dict_name << "\" python dictionary.\n\n"; - return(false); + return false; } // Storm data @@ -365,7 +365,7 @@ bool parse_python_diag_data(PyObject *module_obj, } } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -390,7 +390,7 @@ bool parse_python_string_value_map(PyObject *dict, mlog << Warning << "\n" << method_name << "trouble parsing the \"" << name << "\" python dictionary.\n\n"; - return(false); + return false; } // Initialize @@ -436,7 +436,7 @@ bool parse_python_string_value_map(PyObject *dict, } } // end while - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -458,7 +458,7 @@ bool parse_python_string_string_map(PyObject *dict, mlog << Warning << "\n" << method_name << "trouble parsing the \"" << name << "\" python dictionary.\n\n"; - return(false); + return false; } // Initialize @@ -492,7 +492,7 @@ bool parse_python_string_string_map(PyObject *dict, } } // end while - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -509,13 +509,13 @@ bool parse_python_string(PyObject *dict, mlog << Warning << "\n" << method_name << "trouble parsing the \"" << name << "\" python string.\n\n"; - return(false); + return false; } // Store the string s = PyUnicode_AsUTF8(data_obj); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_diag/tc_diag.cc b/src/tools/tc_utils/tc_diag/tc_diag.cc index 332587b9eb..c60aa5df6a 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag.cc @@ -133,7 +133,7 @@ int met_main(int argc, char *argv[]) { // Process the output files process_out_files(tracks); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -521,7 +521,7 @@ bool is_keeper(const ATCFLineBase * line) { } // Return the keep status - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -670,7 +670,7 @@ ConcatString get_out_key(const TrackInfo &track) { << track.technique() << "_" << unix_to_yyyymmddhh(track.init()); - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// @@ -686,7 +686,7 @@ ConcatString get_tmp_key(const TrackInfo &track, << point.lead() /sec_per_hour << "_" << domain; - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// @@ -703,7 +703,7 @@ ConcatString build_tmp_file_name(const TrackInfo *trk_ptr, << "/tmp_" << program_name << "_" << get_tmp_key(*trk_ptr, *pnt_ptr, domain); - return(make_temp_file_name(cs.text(), ".nc")); + return make_temp_file_name(cs.text(), ".nc"); } //////////////////////////////////////////////////////////////////////// @@ -774,7 +774,7 @@ ConcatString build_out_file_name(const TrackInfo *trk_ptr, } // end while - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// @@ -1429,7 +1429,7 @@ void OutFileInfo::clear() { NcFile *OutFileInfo::setup_nc_file(const string &out_file) { - if(!trk_ptr) return(nullptr); + if(!trk_ptr) return nullptr; // Open the output NetCDF file NcFile *nc_out = open_ncfile(out_file.c_str(), true); @@ -1458,7 +1458,7 @@ NcFile *OutFileInfo::setup_nc_file(const string &out_file) { write_tc_times(nc_out, vld_dim, trk_ptr, nullptr); - return(nc_out); + return nc_out; } //////////////////////////////////////////////////////////////////////// @@ -2061,7 +2061,7 @@ string OutFileInfo::get_diag_units(const string &s) { units = na_str; } - return(units); + return units; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc b/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc index 7684308b81..0e588f68af 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc @@ -43,7 +43,7 @@ DataOptInfo & DataOptInfo::operator+=(const DataOptInfo &info) { tech_ids.add(info.tech_ids); data_files.add(info.data_files); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_dland/tc_dland.cc b/src/tools/tc_utils/tc_dland/tc_dland.cc index dbdc7d976a..4e9ed02bd3 100644 --- a/src/tools/tc_utils/tc_dland/tc_dland.cc +++ b/src/tools/tc_utils/tc_dland/tc_dland.cc @@ -113,7 +113,7 @@ int met_main(int argc, char *argv[]) { // Process the MODE file process_distances(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_dland/tc_poly.cc b/src/tools/tc_utils/tc_dland/tc_poly.cc index 9f3f892097..961b2b6864 100644 --- a/src/tools/tc_utils/tc_dland/tc_poly.cc +++ b/src/tools/tc_utils/tc_dland/tc_poly.cc @@ -51,11 +51,11 @@ TCPoly::TCPoly(const TCPoly & p) { TCPoly & TCPoly::operator=(const TCPoly & p) { - if(this == &p) return(*this); + if(this == &p) return *this; assign(p); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -125,7 +125,7 @@ double TCPoly::min_dist(double lat, double lon) const { if(GnomonXY.is_inside(x, y)) dmin *= -1.0; } - return(dmin); + return dmin; } //////////////////////////////////////////////////////////////////////// @@ -157,11 +157,11 @@ TCPolyArray::TCPolyArray(const TCPolyArray & a) { TCPolyArray & TCPolyArray::operator=(const TCPolyArray & a) { - if(this == &a) return(*this); + if(this == &a) return *this; assign(a); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -254,7 +254,7 @@ TCPoly TCPolyArray::operator[](int n) const { exit(1); } - return(Poly[n]); + return Poly[n]; } //////////////////////////////////////////////////////////////////////// @@ -292,7 +292,7 @@ bool TCPolyArray::add_file(const char *filename) { << "Read " << n << " TC land regions from file: " << filename << "\n"; - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -341,7 +341,7 @@ double TCPolyArray::min_dist(double lat, double lon, int &imin) const { if(dcur < dmin) { dmin = dcur; imin = i; } } - return(dmin); + return dmin; } //////////////////////////////////////////////////////////////////////// @@ -362,7 +362,7 @@ bool operator>>(istream & in, TCPoly & p) { char name[9]; // Read the map region meta data - if(!line.read_line(in)) return (false); + if(!line.read_line(in)) return false; // Split up the meta data line a = line.split(" "); @@ -383,7 +383,7 @@ bool operator>>(istream & in, TCPoly & p) { // Parse the lat/lon data lines for(i=0; i>(istream & in, TCPoly & p) { p.GnomonXY.add_point(x, y); } - return(true); + return true; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index 27190434ca..9afc59a3d9 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -2588,7 +2588,7 @@ ConcatString string_to_basin_abbr(ConcatString cs) { else if(cs == "Central Pacific") abbr = "CP"; else abbr = cs; - return(abbr); + return abbr; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc index 9c0dd74890..60c3170c02 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc @@ -50,7 +50,7 @@ TCGenNcOutInfo & TCGenNcOutInfo::operator+=(const TCGenNcOutInfo &t) { if(t.do_best_fn_oy) do_best_fn_oy = true; - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -72,7 +72,7 @@ bool TCGenNcOutInfo::all_false() const { do_best_genesis || do_best_tracks || do_best_fy_oy || do_best_fn_oy; - return(!status); + return !status; } //////////////////////////////////////////////////////////////////////// @@ -458,7 +458,7 @@ bool TCGenVxOpt::is_keeper(const GenesisInfo &gi) const { keep = false; } - if(!keep) return(keep); + if(!keep) return keep; // Only check intialization and lead times for forecast and // operational tracks. @@ -481,7 +481,7 @@ bool TCGenVxOpt::is_keeper(const GenesisInfo &gi) const { keep = false; } - if(!keep) return(keep); + if(!keep) return keep; // Valid time window if((ValidBeg > 0 && ValidBeg > gi.valid_min()) || @@ -512,7 +512,7 @@ bool TCGenVxOpt::is_keeper(const GenesisInfo &gi) const { keep = false; // Return the keep status - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -568,7 +568,7 @@ bool TCGenVxOpt::is_keeper(const ProbGenInfo &gi) const { keep = false; // Return the keep status - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -622,13 +622,13 @@ bool TCGenVxOpt::is_keeper(const GenShapeInfo &gsi) const { // Distance to land does not apply // Return the keep status - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// STATOutputType TCGenVxOpt::output_map(STATLineType t) const { - return(OutputMap.at(t)); + return OutputMap.at(t); } //////////////////////////////////////////////////////////////////////// @@ -896,7 +896,7 @@ double TCGenConfInfo::compute_dland(double lat, double lon) { y < 0 || y >= DLandGrid.ny()) dist = bad_data_double; else dist = DLandData.get(x, y); - return(dist); + return dist; } //////////////////////////////////////////////////////////////////////// @@ -933,13 +933,13 @@ ConcatString TCGenConfInfo::compute_basin(double lat, double lon) { exit(1); } - return(BasinAbbr[i]); + return BasinAbbr[i]; } //////////////////////////////////////////////////////////////////////// STATOutputType TCGenConfInfo::output_map(STATLineType t) const { - return(OutputMap.at(t)); + return OutputMap.at(t); } //////////////////////////////////////////////////////////////////////// @@ -951,7 +951,7 @@ int TCGenConfInfo::get_max_n_prob_thresh() const { n = max(n, VxOpt[i].ProbGenThresh.n()); } - return(n); + return n; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/src/tools/tc_utils/tc_pairs/tc_pairs.cc index e25c43f64d..a3c3f4a6d5 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -182,7 +182,7 @@ int met_main(int argc, char *argv[]) { << "Output file: " << out_files[i] << "\n"; } - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -814,7 +814,7 @@ bool is_keeper(const ATCFLineBase * line) { keep = false; // Return the keep status - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -1267,7 +1267,7 @@ int derive_consensus(TrackInfoArray &tracks) { int n_add = 0; // If no consensus models are defined, nothing to do - if(conf_info.NConsensus == 0) return(0); + if(conf_info.NConsensus == 0) return 0; // Loop through the tracks to build a list of cases for(i=0; i= dland_grid.ny()) dist = bad_data_double; else dist = dland_dp.get(x, y); - return(dist); + return dist; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index 4520b1d5ca..74e4b275b8 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -100,7 +100,7 @@ int met_main(int argc, char *argv[]) { // Process gridded and track data process_rmw(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -241,7 +241,7 @@ GrdFileType get_file_type(const StringArray &file_list, // Clean up if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - return(out_ftype); + return out_ftype; } //////////////////////////////////////////////////////////////////////// @@ -486,7 +486,7 @@ bool is_keeper(const ATCFLineBase * line) { } // Return the keep status - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_stat/tc_stat.cc b/src/tools/tc_utils/tc_stat/tc_stat.cc index d1e85b0855..77f104b5c6 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat.cc @@ -73,7 +73,7 @@ int met_main(int argc, char *argv[]) { // Process the jobs in the config file process_jobs(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_stat/tc_stat_files.cc b/src/tools/tc_utils/tc_stat/tc_stat_files.cc index 61a2ed8681..676830ec40 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_files.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_files.cc @@ -58,11 +58,11 @@ TCStatFiles::TCStatFiles(const TCStatFiles &j) { TCStatFiles & TCStatFiles::operator=(const TCStatFiles &j) { - if(this == &j) return(*this); + if(this == &j) return *this; assign(j); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -137,7 +137,7 @@ bool TCStatFiles::operator>>(TrackPairInfo &pair) { CurFile++; // Check for the last file - if(CurFile == FileList.n()) return(false); + if(CurFile == FileList.n()) return false; else { // Open the next file for reading @@ -185,7 +185,7 @@ bool TCStatFiles::operator>>(TrackPairInfo &pair) { } } // end while - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -204,7 +204,7 @@ bool TCStatFiles::operator>>(ProbRIRWPairInfo &pair) { CurFile++; // Check for the last file - if(CurFile == FileList.n()) return(false); + if(CurFile == FileList.n()) return false; else { // Open the next file for reading @@ -238,7 +238,7 @@ bool TCStatFiles::operator>>(ProbRIRWPairInfo &pair) { } // end while - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -253,7 +253,7 @@ bool TCStatFiles::operator>>(TCStatLine &line) { CurFile++; // Check for the last file - if(CurFile == FileList.n()) return(false); + if(CurFile == FileList.n()) return false; else { // Open the next file for reading @@ -284,7 +284,7 @@ bool TCStatFiles::operator>>(TCStatLine &line) { } // end while - return(status); + return status; } //////////////////////////////////////////////////////////////////////// From 6bb41bc2f602abb5770119f03517e8ccbb694446 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 01:35:14 +0000 Subject: [PATCH 015/114] #2673 Removed the redundant parentheses with return --- src/libcode/vx_seeps/seeps.cc | 4 +- src/libcode/vx_series_data/series_data.cc | 12 +- src/libcode/vx_shapedata/engine.cc | 26 ++-- src/libcode/vx_shapedata/ihull.cc | 10 +- src/libcode/vx_shapedata/interest.cc | 12 +- src/libcode/vx_shapedata/mode_conf_info.cc | 10 +- src/libcode/vx_shapedata/mode_field_info.cc | 6 +- src/libcode/vx_shapedata/moments.cc | 8 +- src/libcode/vx_shapedata/node.cc | 22 +-- src/libcode/vx_shapedata/set.cc | 44 +++--- src/libcode/vx_solar/siderial.cc | 4 +- src/libcode/vx_stat_out/stat_columns.cc | 4 +- src/libcode/vx_stat_out/stat_hdr_columns.cc | 2 +- src/libcode/vx_statistics/apply_mask.cc | 6 +- src/libcode/vx_statistics/contable.cc | 132 +++++++++--------- src/libcode/vx_statistics/contable_nx2.cc | 58 ++++---- src/libcode/vx_statistics/contable_stats.cc | 116 +++++++-------- src/libcode/vx_statistics/ens_stats.cc | 16 +-- src/libcode/vx_statistics/grid_closed_poly.cc | 20 +-- src/libcode/vx_statistics/met_stats.cc | 100 ++++++------- src/libcode/vx_statistics/obs_error.cc | 60 ++++---- src/libcode/vx_statistics/pair_base.cc | 24 ++-- .../vx_statistics/pair_data_ensemble.cc | 28 ++-- src/libcode/vx_statistics/pair_data_point.cc | 34 ++--- src/libcode/vx_statistics/read_climo.cc | 14 +- src/libcode/vx_tc_util/atcf_line_base.cc | 60 ++++---- src/libcode/vx_tc_util/atcf_prob_line.cc | 12 +- src/libcode/vx_tc_util/atcf_track_line.cc | 52 +++---- src/libcode/vx_tc_util/diag_file.cc | 10 +- src/libcode/vx_tc_util/gen_shape_info.cc | 32 ++--- src/libcode/vx_tc_util/genesis_info.cc | 46 +++--- src/libcode/vx_tc_util/pair_data_genesis.cc | 26 ++-- src/libcode/vx_tc_util/prob_gen_info.cc | 16 +-- src/libcode/vx_tc_util/prob_info_array.cc | 20 +-- src/libcode/vx_tc_util/prob_info_base.cc | 20 +-- src/libcode/vx_tc_util/prob_rirw_info.cc | 16 +-- src/libcode/vx_tc_util/prob_rirw_pair_info.cc | 28 ++-- src/libcode/vx_tc_util/tc_stat_line.cc | 64 ++++----- src/libcode/vx_tc_util/track_info.cc | 62 ++++---- src/libcode/vx_tc_util/track_pair_info.cc | 42 +++--- src/libcode/vx_tc_util/track_point.cc | 32 ++--- .../vx_time_series/time_series_util.cc | 14 +- 42 files changed, 662 insertions(+), 662 deletions(-) diff --git a/src/libcode/vx_seeps/seeps.cc b/src/libcode/vx_seeps/seeps.cc index 103bb6e172..a9fca9c71d 100644 --- a/src/libcode/vx_seeps/seeps.cc +++ b/src/libcode/vx_seeps/seeps.cc @@ -121,7 +121,7 @@ void SeepsAggScore::clear() { SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { // Check for degenerate case - if(n_obs == 0 && c.n_obs == 0) return(*this); + if(n_obs == 0 && c.n_obs == 0) return *this; // Compute weights double w1 = (double) n_obs / (n_obs + c.n_obs); @@ -160,7 +160,7 @@ SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { score = weighted_average(score, w1, c.score, w2); weighted_score = weighted_average(weighted_score, w1, c.weighted_score, w2); - return(*this); + return *this; } diff --git a/src/libcode/vx_series_data/series_data.cc b/src/libcode/vx_series_data/series_data.cc index 03b227b0f2..a37fec2bdb 100644 --- a/src/libcode/vx_series_data/series_data.cc +++ b/src/libcode/vx_series_data/series_data.cc @@ -74,7 +74,7 @@ bool get_series_entry(int i_series, VarInfo* data_info, // Restore warnings to their original state mlog.set_print_warning(save_print_warning_state); - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -89,7 +89,7 @@ bool read_single_entry(VarInfo* info, const ConcatString& filename, if(!file_exists(filename.c_str())) { mlog << Warning << "\nread_single_entry() -> " << "File does not exist: " << filename << "\n\n"; - return(false); + return false; } // Open data file @@ -104,7 +104,7 @@ bool read_single_entry(VarInfo* info, const ConcatString& filename, // Cleanup if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; } - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -117,7 +117,7 @@ bool get_series_entries(int i_series, vector &vi_list, bool found; // Check for at least one field requested - if(vi_list.size() <= 0) return(false); + if(vi_list.size() <= 0) return false; // Save the log print warning state bool save_print_warning_state = mlog.print_warning(); @@ -156,7 +156,7 @@ bool get_series_entries(int i_series, vector &vi_list, // Restore warnings to their original state mlog.set_print_warning(save_print_warning_state); - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -171,7 +171,7 @@ bool read_all_entries(vector &vi_list, const ConcatString &filename, if(!file_exists(filename.c_str())) { mlog << Warning << "\nread_all_entries() -> " << "File does not exist: " << filename << "\n\n"; - return(false); + return false; } // Open data file diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index c393610c2f..c267c7b87f 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -29,7 +29,7 @@ static const int print_interest_log_level = 5; /////////////////////////////////////////////////////////////////////// -static inline double area_ratio_conf(double t) { return(t); } +static inline double area_ratio_conf(double t) { return t; } /////////////////////////////////////////////////////////////////////// // @@ -588,7 +588,7 @@ int ModeFuzzyEngine::two_to_one(int n_f, int n_o) const { n = n_o*n_fcst + n_f; - return(n); + return n; } @@ -2508,11 +2508,11 @@ int ModeFuzzyEngine::get_info_index(int pair_n) const { for(i=0; i<(info_singles.n()); i++) { - if(info_singles[i].pair_number == pair_n) return(i); + if(info_singles[i].pair_number == pair_n) return i; } - return(-1); + return -1; } /////////////////////////////////////////////////////////////////////// @@ -2530,7 +2530,7 @@ int ModeFuzzyEngine::get_matched_fcst(int area) const { } } - return(count); + return count; } /////////////////////////////////////////////////////////////////////// @@ -2548,7 +2548,7 @@ int ModeFuzzyEngine::get_unmatched_fcst(int area) const { } } - return(count); + return count; } /////////////////////////////////////////////////////////////////////// @@ -2566,7 +2566,7 @@ int ModeFuzzyEngine::get_matched_obs(int area) const { } } - return(count); + return count; } /////////////////////////////////////////////////////////////////////// @@ -2584,7 +2584,7 @@ int ModeFuzzyEngine::get_unmatched_obs(int area) const { } } - return(count); + return count; } /////////////////////////////////////////////////////////////////////// @@ -2631,7 +2631,7 @@ double total_interest(ModeConfInfo &mc, const PairFeature &p, << ") > Max Centroid Distance (" << mc.max_centroid_dist << ")\n"; } - return(total); + return total; } sum = 0.0; @@ -2917,7 +2917,7 @@ double total_interest(ModeConfInfo &mc, const PairFeature &p, << " = " << total << "\n\n"; } - return(total); + return total; } /////////////////////////////////////////////////////////////////////// @@ -2930,7 +2930,7 @@ double interest_percentile(ModeFuzzyEngine &eng, const double p, const int flag) if(eng.conf_info.match_flag == 0 || eng.n_fcst == 0 || - eng.n_obs == 0) return(0.0); + eng.n_obs == 0) return 0.0; // // Initialize the maximum interest value for each object to zero. @@ -2995,7 +2995,7 @@ double interest_percentile(ModeFuzzyEngine &eng, const double p, const int flag) if(v) { delete [] v; v = (double *) 0; } - return(ptile); + return ptile; } /////////////////////////////////////////////////////////////////////// @@ -4144,7 +4144,7 @@ double aspect_ratio_conf(double t) const double tm1 = t - 1.0; const double ratio = (tm1*tm1)/(t*t + 1.0); -return( pow(ratio, 0.3) ); +return pow(ratio, 0.3); } diff --git a/src/libcode/vx_shapedata/ihull.cc b/src/libcode/vx_shapedata/ihull.cc index 59208964ed..1898fdd9e4 100644 --- a/src/libcode/vx_shapedata/ihull.cc +++ b/src/libcode/vx_shapedata/ihull.cc @@ -147,22 +147,22 @@ int lex_compare(const void * _a, const void * _b) const IntPoint & a = *((const IntPoint *) _a); const IntPoint & b = *((const IntPoint *) _b); -if ( a.x < b.x ) return ( -1 ); -if ( a.x > b.x ) return ( 1 ); +if ( a.x < b.x ) return -1; +if ( a.x > b.x ) return 1; // // now we know that a.x = b.x // -if ( a.y < b.y ) return ( -1 ); -if ( a.y > b.y ) return ( 1 ); +if ( a.y < b.y ) return -1; +if ( a.y > b.y ) return 1; // // done // -return ( 0 ); +return 0; } diff --git a/src/libcode/vx_shapedata/interest.cc b/src/libcode/vx_shapedata/interest.cc index d33d32e426..7538233443 100644 --- a/src/libcode/vx_shapedata/interest.cc +++ b/src/libcode/vx_shapedata/interest.cc @@ -78,11 +78,11 @@ assign(s); SingleFeature & SingleFeature::operator=(const SingleFeature &s) { - if(this == &s) return(*this); + if(this == &s) return *this; assign(s); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -316,11 +316,11 @@ PairFeature & PairFeature::operator=(const PairFeature &p) { - if(this == &p) return(*this); + if(this == &p) return *this; assign(p); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -560,7 +560,7 @@ ostream & operator<<(ostream & out, const SingleFeature & s) out << "Intensity Sum = " << (s.intensity_ptile.sum) << "\n"; out.flush(); - return(out); + return out; } //////////////////////////////////////////////////////////////////////// @@ -588,7 +588,7 @@ ostream & operator<<(ostream & out, const PairFeature & p) out << "Percentile Intensity Ratio = " << (p.percentile_intensity_ratio) << "\n"; out.flush(); - return(out); + return out; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index 5852d9f51e..05321f071f 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -54,12 +54,12 @@ ModeConfInfo::~ModeConfInfo() ModeConfInfo & ModeConfInfo::operator=(const ModeConfInfo &s) { - if(this == &s) return(*this); + if(this == &s) return *this; clear(); assign(s); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1087,7 +1087,7 @@ for (int j=0; jn_points(); ++j) { } // for j -return ( pwl_if ); +return pwl_if; } @@ -1670,7 +1670,7 @@ switch ( e2->type() ) { } -return ( status ); +return status; } @@ -1860,7 +1860,7 @@ bool ModeNcOutInfo::all_false() const bool status = do_latlon || do_raw || do_object_raw || do_object_id || do_cluster_id || do_polylines; -return ( !status ); +return !status; } diff --git a/src/libcode/vx_shapedata/mode_field_info.cc b/src/libcode/vx_shapedata/mode_field_info.cc index 3068d38016..b49a805681 100644 --- a/src/libcode/vx_shapedata/mode_field_info.cc +++ b/src/libcode/vx_shapedata/mode_field_info.cc @@ -76,11 +76,11 @@ Mode_Field_Info & Mode_Field_Info::operator=(const Mode_Field_Info & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -405,7 +405,7 @@ bool Mode_Field_Info::need_merge_thresh () const bool status = (merge_flag == MergeType_Both) || (merge_flag == MergeType_Thresh); -return ( status ); +return status; } diff --git a/src/libcode/vx_shapedata/moments.cc b/src/libcode/vx_shapedata/moments.cc index d744871929..ab7425d75f 100644 --- a/src/libcode/vx_shapedata/moments.cc +++ b/src/libcode/vx_shapedata/moments.cc @@ -58,11 +58,11 @@ Moments::Moments(const Moments &m) { Moments & Moments::operator=(const Moments &m) { if ( this == &m ) { - return ( *this ); + return *this; } assign(m); - return ( *this ); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -277,7 +277,7 @@ double Moments::angle_degrees() const { // Compute axis angle using 2nd order moments deg = 0.5*deg_per_rad*atan2(2.0*(m.sxy), m.sxx - m.syy); - return(deg); + return deg; } /////////////////////////////////////////////////////////////////////////////// @@ -310,7 +310,7 @@ double Moments::curvature(double &xcurv, double &ycurv) const { xcurv = xcenter + xbar; ycurv = ycenter + ybar; - return(radius); + return radius; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_shapedata/node.cc b/src/libcode/vx_shapedata/node.cc index d344322bd5..d9ff8c1568 100644 --- a/src/libcode/vx_shapedata/node.cc +++ b/src/libcode/vx_shapedata/node.cc @@ -63,11 +63,11 @@ Node::Node(const Node &c) { Node & Node::operator=(const Node &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } /////////////////////////////////////////////////////////////////////////////// @@ -196,7 +196,7 @@ int Node::n_children() const { n_ptr = n_ptr->sibling; } - return(count); + return count; } /////////////////////////////////////////////////////////////////////////////// @@ -222,7 +222,7 @@ Node *Node::get_child(int n) const { for(i=0; isibling; - return(n_ptr); + return n_ptr; } /////////////////////////////////////////////////////////////////////////////// @@ -243,7 +243,7 @@ int Node::is_closed() const { n_ptr = n_ptr->sibling; } - return(closed); + return closed; } /////////////////////////////////////////////////////////////////////////////// @@ -321,7 +321,7 @@ double Node::angle() const { a = 0.5*deg_per_rad*atan2( 2.0*Ixy, Ixx - Iyy ); - return(a); + return a; } /////////////////////////////////////////////////////////////////////////////// @@ -372,7 +372,7 @@ double Node::uv_signed_area() const { n_ptr = n_ptr->sibling; } - return(sum); + return sum; } /////////////////////////////////////////////////////////////////////////////// @@ -404,7 +404,7 @@ int Node::is_inside(double u_test, double v_test) const { n_ptr = n_ptr->sibling; } - return(count); + return count; } /////////////////////////////////////////////////////////////////////////////// @@ -425,7 +425,7 @@ int Node::is_polyline_point(double u_test, double v_test) const { n_ptr = n_ptr->sibling; } - return(poly_point); + return poly_point; } /////////////////////////////////////////////////////////////////////////////// @@ -530,7 +530,7 @@ double node_dist(const Node &a, const Node &b) { } // end for i_b } // end for i_a - return(min_dist); + return min_dist; } /////////////////////////////////////////////////////////////////////////////// @@ -562,7 +562,7 @@ double node_polyline_dist(const Node &a, const Polyline &b) { } // end for i_a - return(min_dist); + return min_dist; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_shapedata/set.cc b/src/libcode/vx_shapedata/set.cc index c62637c69e..84a36f36ab 100644 --- a/src/libcode/vx_shapedata/set.cc +++ b/src/libcode/vx_shapedata/set.cc @@ -78,11 +78,11 @@ FcstObsSet & FcstObsSet::operator=(const FcstObsSet & s) { -if ( this == &s ) return ( * this ); +if ( this == &s ) return *this; assign(s); -return ( * this ); +return *this; } @@ -261,10 +261,10 @@ int FcstObsSet::has_fcst(int k) const int j; for(j=0; j 0) matched = 1; } - return(matched); + return matched; } /////////////////////////////////////////////////////////////////////////////// @@ -682,7 +682,7 @@ int SetCollection::is_obs_matched(int obs_number) const { if(set[j].n_fcst > 0) matched = 1; } - return(matched); + return matched; } /////////////////////////////////////////////////////////////////////////////// @@ -730,21 +730,21 @@ int fcst_obs_sets_overlap(const FcstObsSet &a, const FcstObsSet &b) { // check fcst's // for(j=0; j<(a.n_fcst); j++) { - if( b.has_fcst(a.fcst_number[j]) ) return(1); + if( b.has_fcst(a.fcst_number[j]) ) return 1; } // // check obs's // for(j=0; j<(a.n_obs); j++) { - if( b.has_obs(a.obs_number[j]) ) return(1); + if( b.has_obs(a.obs_number[j]) ) return 1; } // // // - return(0); + return 0; } /////////////////////////////////////////////////////////////////////////////// @@ -769,7 +769,7 @@ FcstObsSet union_fcst_obs_sets(const FcstObsSet &a, const FcstObsSet &b) { c.add_obs(b.obs_number[j]); } - return(c); + return c; } /////////////////////////////////////////////////////////////////////////////// @@ -815,7 +815,7 @@ ostream & operator<<(ostream &out, const FcstObsSet &set) { // // - return(out); + return out; } /////////////////////////////////////////////////////////////////////////////// @@ -828,7 +828,7 @@ ostream & operator<<(ostream &out, const SetCollection &c) { out << (c.set[j]); } - return(out); + return out; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_solar/siderial.cc b/src/libcode/vx_solar/siderial.cc index 9424772245..bb9434c7da 100644 --- a/src/libcode/vx_solar/siderial.cc +++ b/src/libcode/vx_solar/siderial.cc @@ -70,7 +70,7 @@ theta -= 360.0*floor(theta/360.0); // done // -return ( theta ); +return theta; } @@ -105,7 +105,7 @@ lst -= 360.0*floor(lst/360.0); // done // -return ( lst ); +return lst; } diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 034c3c1961..3cad89b397 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -86,7 +86,7 @@ void close_txt_file(ofstream *&out, const char *file_name) { ConcatString append_climo_bin(const ConcatString &mask_name, int i_bin, int n_bin) { - if(n_bin == 1) return(mask_name); + if(n_bin == 1) return mask_name; // Append the climo CDF bin number. ConcatString cs; @@ -94,7 +94,7 @@ ConcatString append_climo_bin(const ConcatString &mask_name, if(i_bin == -1) cs << "MEAN"; else cs << i_bin+1; - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.cc b/src/libcode/vx_stat_out/stat_hdr_columns.cc index 4304e87e9f..c21dcaec93 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.cc +++ b/src/libcode/vx_stat_out/stat_hdr_columns.cc @@ -353,7 +353,7 @@ ConcatString StatHdrColumns::get_fcst_thresh_str() const { cs << setlogic_to_symbol(thresh_logic); } } - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/apply_mask.cc b/src/libcode/vx_statistics/apply_mask.cc index 010c091825..b2b6a7c5bc 100644 --- a/src/libcode/vx_statistics/apply_mask.cc +++ b/src/libcode/vx_statistics/apply_mask.cc @@ -80,7 +80,7 @@ Grid parse_vx_grid(const RegridInfo info, const Grid *fgrid, const Grid *ogrid) mlog << Debug(3) << "Grid Definition: " << vx_grid.serialize() << "\n"; - return(vx_grid); + return vx_grid; } //////////////////////////////////////////////////////////////////////// @@ -125,7 +125,7 @@ Grid parse_grid_string(const char *grid_str) { if(met_ptr) { delete met_ptr; met_ptr = 0; } } - return(grid); + return grid; } //////////////////////////////////////////////////////////////////////// @@ -683,7 +683,7 @@ DataPlane parse_geog_data(Dictionary *dict, const Grid &vx_grid, exit(1); } - return(dp); + return dp; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/contable.cc b/src/libcode/vx_statistics/contable.cc index d01c264fb3..5dc7120bc8 100644 --- a/src/libcode/vx_statistics/contable.cc +++ b/src/libcode/vx_statistics/contable.cc @@ -85,11 +85,11 @@ ContingencyTable & ContingencyTable::operator=(const ContingencyTable & t) { -if ( this == &t ) return ( * this ); +if ( this == &t ) return *this; assign(t); -return ( * this ); +return *this; } @@ -125,7 +125,7 @@ if ( E ) { for ( int i=0; isize(); ++i ) (*E)[i] += (*t.E)[i]; } -return ( * this ); +return *this; } @@ -562,7 +562,7 @@ n = r*Ncols + c; -return ( n ); +return n; } @@ -615,7 +615,7 @@ int ContingencyTable::total() const const int n = Nrows*Ncols; -if ( n == 0 ) return ( 0 ); +if ( n == 0 ) return 0; int j, sum; @@ -625,7 +625,7 @@ for (j=0; j Thresholds[Nrows] && !is_eq(t, Thresholds[Nrows]) ) return ( -1 ); +if ( t > Thresholds[Nrows] && !is_eq(t, Thresholds[Nrows]) ) return -1; // Thresholds array is of size Nrows + 1, so // the last element has index Nrows, not Nrows - 1 @@ -227,13 +227,13 @@ int j; for (j=0; j Thresholds[j ] || is_eq(t, Thresholds[j ]) ) && - ( t < Thresholds[j + 1] && !is_eq(t, Thresholds[j + 1]) ) ) return ( j ); + ( t < Thresholds[j + 1] && !is_eq(t, Thresholds[j + 1]) ) ) return j; } if ( is_eq(t, Thresholds[Nrows]) ) return ( Nrows - 1 ); -return ( -1 ); +return -1; } @@ -287,7 +287,7 @@ if ( (k < 0) || (k > Nrows) ) { // there are Nrows + 1 thresholds } -return ( Thresholds[k] ); +return Thresholds[k]; } @@ -367,7 +367,7 @@ int k; k = entry(r, nx2_event_column); -return ( k ); +return k; } @@ -395,7 +395,7 @@ int k; k = entry(r, nx2_nonevent_column); -return ( k ); +return k; } @@ -414,7 +414,7 @@ double x; if(Ni == 0) x = bad_data_double; else x = ((double) obs_count)/((double) Ni); -return ( x ); +return x; } @@ -433,7 +433,7 @@ double x; if (N == 0) x = bad_data_double; else x = ((double) obs_count)/((double) N); -return ( x ); +return x; } @@ -458,7 +458,7 @@ double x; if ( use_center ) x = 0.5*(Thresholds[row] + Thresholds[row + 1]); else x = Thresholds[row]; -return ( x ); +return x; } @@ -468,7 +468,7 @@ return ( x ); double Nx2ContingencyTable::baser() const { - return ( (double) event_col_total()/n() ); + return (double) event_col_total()/n(); } @@ -483,7 +483,7 @@ double Nx2ContingencyTable::baser_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return ( v ); + return v; } @@ -527,7 +527,7 @@ for (row=0; row 1 so that degf > 0 in the call to gsl_cdf_tdist_Pinv() -if(is_bad_data(bs = brier_score()) || N <= 1) return ( bad_data_double ); +if(is_bad_data(bs = brier_score()) || N <= 1) return bad_data_double; degf = N - 1.0; @@ -963,7 +963,7 @@ var = ( af4 + ob*term - bs*bs )*Ninv; halfwidth = t*sqrt(var); -return ( halfwidth ); +return halfwidth; } diff --git a/src/libcode/vx_statistics/contable_stats.cc b/src/libcode/vx_statistics/contable_stats.cc index f103284ee0..15cfc21688 100644 --- a/src/libcode/vx_statistics/contable_stats.cc +++ b/src/libcode/vx_statistics/contable_stats.cc @@ -31,7 +31,7 @@ using namespace std; double TTContingencyTable::baser() const { - return(oy_tp()); + return oy_tp(); } //////////////////////////////////////////////////////////////////////// @@ -44,14 +44,14 @@ double TTContingencyTable::baser_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// double TTContingencyTable::fmean() const { - return(fy_tp()); + return fy_tp(); } //////////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ double TTContingencyTable::fmean_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -78,7 +78,7 @@ double TTContingencyTable::accuracy() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -91,7 +91,7 @@ double TTContingencyTable::accuracy_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -109,7 +109,7 @@ double TTContingencyTable::fbias() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -127,7 +127,7 @@ double TTContingencyTable::pod_yes() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -140,7 +140,7 @@ double TTContingencyTable::pod_yes_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -154,7 +154,7 @@ double TTContingencyTable::pod_no() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -167,7 +167,7 @@ double TTContingencyTable::pod_no_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -180,7 +180,7 @@ double TTContingencyTable::pofd() const { if(is_bad_data(d)) v = bad_data_double; else v = 1.0 - d; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -193,7 +193,7 @@ double TTContingencyTable::pofd_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -211,7 +211,7 @@ double TTContingencyTable::far() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -224,7 +224,7 @@ double TTContingencyTable::far_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -242,7 +242,7 @@ double TTContingencyTable::csi() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -255,7 +255,7 @@ double TTContingencyTable::csi_ci(double alpha, compute_proportion_ci(v, n(), alpha, 1.0, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -272,7 +272,7 @@ double TTContingencyTable::gss() const { b = (long long) fy_on(); c = (long long) fn_oy(); - if(n() == 0) return(bad_data_double); + if(n() == 0) return bad_data_double; q = (double) (a + b)*(a + c)/(n()); num = (double) (a - q); @@ -281,7 +281,7 @@ double TTContingencyTable::gss() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -296,14 +296,14 @@ double TTContingencyTable::bagss() const { double lf, lw, ha, num, den, v; if(n() == 0 || oy() == 0 || fn_oy() == 0 || fy_on() == 0) { - return(bad_data_double); + return bad_data_double; } lf = log((double) oy() / fn_oy()); lw = sf_lambert_W0((double) oy() / fy_on() * lf); if(is_bad_data(lw) || is_bad_data(lf) || is_eq(lf, 0.0)) { - return(bad_data_double); + return bad_data_double; } else { ha = (double) oy() - (fy_on() / lf) * lw; @@ -315,7 +315,7 @@ double TTContingencyTable::bagss() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -340,7 +340,7 @@ double TTContingencyTable::hk() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = (double) num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -354,7 +354,7 @@ double TTContingencyTable::hk_ci(double alpha, compute_hk_ci(v, alpha, 1.0, fy_oy(), fy_on(), fn_oy(), fn_on(), cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -379,7 +379,7 @@ double TTContingencyTable::hss() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = (double) num/den; - return(v); + return v; } @@ -396,7 +396,7 @@ double TTContingencyTable::odds() const { pn = pofd(); if(is_eq(py, 1.0) || is_bad_data(py) || - is_eq(pn, 1.0) || is_bad_data(pn)) return(bad_data_double); + is_eq(pn, 1.0) || is_bad_data(pn)) return bad_data_double; num = py/(1 - py); den = pn/(1 - pn); @@ -404,7 +404,7 @@ double TTContingencyTable::odds() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -418,7 +418,7 @@ double TTContingencyTable::odds_ci(double alpha, compute_woolf_ci(v, alpha, fy_oy(), fy_on(), fn_oy(), fn_on(), cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -434,7 +434,7 @@ double TTContingencyTable::lodds() const { log((double) fy_on()) - log((double) fn_oy()); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -450,7 +450,7 @@ double TTContingencyTable::slor2() const { v = 1.0/df; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -464,7 +464,7 @@ double TTContingencyTable::lodds_ci(double alpha, if(is_bad_data(v) || is_bad_data(s)) { cl = cu = bad_data_double; - return(v); + return v; } // @@ -474,7 +474,7 @@ double TTContingencyTable::lodds_ci(double alpha, compute_normal_ci(v, alpha, se, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -488,7 +488,7 @@ double TTContingencyTable::orss() const { if(den == 0) v = bad_data_double; else v = (double) num / den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -503,7 +503,7 @@ double TTContingencyTable::orss_ci(double alpha, if(is_bad_data(v) || is_bad_data(r) || is_bad_data(s)) { cl = cu = bad_data_double; - return(v); + return v; } // @@ -513,7 +513,7 @@ double TTContingencyTable::orss_ci(double alpha, compute_normal_ci(v, alpha, se, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -539,7 +539,7 @@ double TTContingencyTable::eds() const { else v = 2.0 * num / den - 1.0; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -555,7 +555,7 @@ double TTContingencyTable::eds_ci(double alpha, if(is_bad_data(v) || is_bad_data(b) || is_bad_data(h) || is_eq(b, 0.0) || is_eq(h, 0.0)) { cl = cu = bad_data_double; - return(v); + return v; } // @@ -567,7 +567,7 @@ double TTContingencyTable::eds_ci(double alpha, compute_normal_ci(v, alpha, se, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -588,7 +588,7 @@ double TTContingencyTable::seds() const { else v = num / den - 1.0; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -604,7 +604,7 @@ double TTContingencyTable::seds_ci(double alpha, if(is_bad_data(v) || is_bad_data(b) || is_bad_data(h) || is_eq(b, 0.0) || is_eq(h, 0.0)) { cl = cu = bad_data_double; - return(v); + return v; } // @@ -616,7 +616,7 @@ double TTContingencyTable::seds_ci(double alpha, compute_normal_ci(v, alpha, se, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -637,7 +637,7 @@ double TTContingencyTable::edi() const { else v = num/den; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -654,7 +654,7 @@ double TTContingencyTable::edi_ci(double alpha, if(is_bad_data(f) || is_bad_data(h) || is_bad_data(b) || is_eq(f, 0.0) || is_eq(h, 0.0) || is_eq(h, 1.0)) { cl = cu = bad_data_double; - return(v); + return v; } // @@ -666,7 +666,7 @@ double TTContingencyTable::edi_ci(double alpha, compute_normal_ci(v, alpha, se, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -689,7 +689,7 @@ double TTContingencyTable::sedi() const { else v = num/den; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -707,7 +707,7 @@ double TTContingencyTable::sedi_ci(double alpha, is_eq(f, 0.0) || is_eq(h, 0.0) || is_eq(f, 1.0) || is_eq(h, 1.0)) { cl = cu = bad_data_double; - return(v); + return v; } // @@ -724,7 +724,7 @@ double TTContingencyTable::sedi_ci(double alpha, compute_normal_ci(v, alpha, se, cl, cu); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -755,7 +755,7 @@ double TTContingencyTable::cost_loss(double r) const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -789,7 +789,7 @@ double ContingencyTable::gaccuracy() const { if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; - return(v); + return v; } @@ -815,7 +815,7 @@ const int N = total(); // MET #2542: return bad data for empty tables rather than erroring out // -if ( N == 0 ) return ( bad_data_double ); +if ( N == 0 ) return bad_data_double; const double DN = (double) N; int j, k, m, n; @@ -870,7 +870,7 @@ else ans = num/denom; // done // -return ( ans ); +return ans; } @@ -913,7 +913,7 @@ const int N = total(); // MET #2542: return bad data for empty tables rather than erroring out // -if ( N == 0 ) return ( bad_data_double ); +if ( N == 0 ) return bad_data_double; int j, sum; double num, denom, ans; @@ -948,7 +948,7 @@ else ans = num/denom; // done // -return ( ans ); +return ans; } @@ -975,7 +975,7 @@ const int N = total(); // MET #2542: return bad data for empty tables rather than erroring out // -if ( N == 0 ) return ( bad_data_double ); +if ( N == 0 ) return bad_data_double; const double DN = (double) N; int j, k, m, n; @@ -1044,7 +1044,7 @@ else ans = num/denom; // done // -return ( ans ); +return ans; } @@ -1072,7 +1072,7 @@ const int N = total(); // MET #2542: return bad data for empty tables rather than erroring out // -if ( N == 0 ) return ( bad_data_double ); +if ( N == 0 ) return bad_data_double; int j, k, m, n; const double DN = (double) N; @@ -1084,7 +1084,7 @@ double * s = (double *) 0; // can't compute gerrity when the first column contains all zeros // -if ( col_total(0) == 0 ) return ( bad_data_double ); +if ( col_total(0) == 0 ) return bad_data_double; p = new double [Nrows]; @@ -1143,7 +1143,7 @@ for (j=0; j u_max) return(0); + if(u_test < u_min) return 0; + if(u_test > u_max) return 0; - if(v_test < v_min) return(0); - if(v_test > v_max) return(0); + if(v_test < v_min) return 0; + if(v_test > v_max) return 0; // // test polyline @@ -145,7 +145,7 @@ int GridClosedPoly::is_inside(double u_test, double v_test) const { const int status = Polyline::is_inside(u_test, v_test); - return(status); + return status; } /////////////////////////////////////////////////////////////////////////////// @@ -156,7 +156,7 @@ int GridClosedPoly::is_inside(double u_test, double v_test) const { bool GridClosedPolyArray::is_inside(double u_test, double v_test) const { - if(Nelements == 0) return(false); + if(Nelements == 0) return false; int j, status; @@ -167,10 +167,10 @@ bool GridClosedPolyArray::is_inside(double u_test, double v_test) const { status = e[j]->is_inside(u_test, v_test); - if(status != 0) return(true); + if(status != 0) return true; } - return(false); + return false; } diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index a33f1adc73..f9a3534375 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -53,11 +53,11 @@ CIInfo::CIInfo(const CIInfo &c) { CIInfo & CIInfo::operator=(const CIInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -190,11 +190,11 @@ CTSInfo::CTSInfo(const CTSInfo &c) { CTSInfo & CTSInfo::operator=(const CTSInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -470,7 +470,7 @@ double CTSInfo::get_stat(const char *stat_name) { v = bad_data_double; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -502,11 +502,11 @@ MCTSInfo::MCTSInfo(const MCTSInfo &c) { MCTSInfo & MCTSInfo::operator=(const MCTSInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -696,11 +696,11 @@ CNTInfo::CNTInfo(const CNTInfo &c) { CNTInfo & CNTInfo::operator=(const CNTInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1085,7 +1085,7 @@ double CNTInfo::get_stat(const char *stat_name) { v = bad_data_double; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -1117,11 +1117,11 @@ SL1L2Info::SL1L2Info(const SL1L2Info &c) { SL1L2Info & SL1L2Info::operator=(const SL1L2Info &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1165,7 +1165,7 @@ SL1L2Info & SL1L2Info::operator+=(const SL1L2Info &c) { assign(s_info); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1346,11 +1346,11 @@ VL1L2Info::VL1L2Info(const VL1L2Info &c) { VL1L2Info & VL1L2Info::operator=(const VL1L2Info &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1400,7 +1400,7 @@ VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { assign(v_info); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2027,7 +2027,7 @@ double VL1L2Info::get_stat(const char *stat_name) { exit(1); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -2059,11 +2059,11 @@ NBRCTSInfo::NBRCTSInfo(const NBRCTSInfo &c) { NBRCTSInfo & NBRCTSInfo::operator=(const NBRCTSInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2141,11 +2141,11 @@ NBRCNTInfo::NBRCNTInfo(const NBRCNTInfo &c) { NBRCNTInfo & NBRCNTInfo::operator=(const NBRCNTInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2214,7 +2214,7 @@ NBRCNTInfo & NBRCNTInfo::operator+=(const NBRCNTInfo &c) { assign(n_info); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2354,11 +2354,11 @@ ISCInfo::ISCInfo(const ISCInfo &c) { ISCInfo & ISCInfo::operator=(const ISCInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2596,11 +2596,11 @@ PCTInfo::PCTInfo(const PCTInfo &c) { PCTInfo & PCTInfo::operator=(const PCTInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2808,11 +2808,11 @@ GRADInfo::GRADInfo(const GRADInfo &c) { GRADInfo & GRADInfo::operator=(const GRADInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2841,7 +2841,7 @@ GRADInfo & GRADInfo::operator+=(const GRADInfo &c) { assign(g_info); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2897,7 +2897,7 @@ double GRADInfo::s1() const { v = 100.0 * egbar / mgbar; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -2912,7 +2912,7 @@ double GRADInfo::s1_og() const { v = 100.0 * egbar / ogbar; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -2927,7 +2927,7 @@ double GRADInfo::fgog_ratio() const { v = fgbar / ogbar; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -3023,11 +3023,11 @@ DMAPInfo::DMAPInfo(const DMAPInfo &c) { DMAPInfo & DMAPInfo::operator=(const DMAPInfo &c) { - if(this == &c) return(*this); + if(this == &c) return *this; assign(c); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -3124,7 +3124,7 @@ double DMAPInfo::fbias() const { if(oy == 0) v = bad_data_double; else v = (double) fy / oy; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -3356,7 +3356,7 @@ int parse_message_type(const char *msg_typ_str, char **&msg_typ_arr) { n = num_tokens(msg_typ_str, " "); // Check for no tokens in string - if(n == 0) return(0); + if(n == 0) return 0; // Allocate space for the list of tokens msg_typ_arr = new char * [n]; @@ -3373,7 +3373,7 @@ int parse_message_type(const char *msg_typ_str, char **&msg_typ_arr) { msg_typ_arr[i] = m_strcpy2(c, method_name, a_var_name); } - return(n); + return n; } //////////////////////////////////////////////////////////////////////// @@ -3389,7 +3389,7 @@ int parse_dbl_list(const char *dbl_str, double *&dbl_arr) { n = num_tokens(dbl_str, " "); // Check for no tokens in string - if(n == 0) return(0); + if(n == 0) return 0; // Allocate space for the list of tokens dbl_arr = new double [n]; @@ -3400,7 +3400,7 @@ int parse_dbl_list(const char *dbl_str, double *&dbl_arr) { // Tokenize the string and store the double values for(int i=0; i v_max) v_max = v_int[i]; - return(v_max); + return v_max; } //////////////////////////////////////////////////////////////////////// @@ -3448,12 +3448,12 @@ int max_int(const int *v_int, int n) { int min_int(const int *v_int, int n) { int i, v_min; - if(n <= 0) return(0); + if(n <= 0) return 0; v_min = v_int[0]; for(i=1; i 0) { - if(strcasecmp(dl[0], "OBS_VAR") == 0) return(true); + if(strcasecmp(dl[0], "OBS_VAR") == 0) return true; } - return(false); + return false; } //////////////////////////////////////////////////////////////////////// @@ -283,28 +283,28 @@ bool ObsErrorEntry::is_match(const char *cur_var_name, double cur_val) { // Check array filters - if(var_name.n() > 0 && !var_name.reg_exp_match(cur_var_name)) return(false); - if(msg_type.n() > 0 && !msg_type.has(cur_msg_type)) return(false); - if(sid.n() > 0 && !sid.has(cur_sid)) return(false); - if(pb_rpt_type.n() > 0 && !pb_rpt_type.has(cur_pb_rpt)) return(false); - if(in_rpt_type.n() > 0 && !in_rpt_type.has(cur_in_rpt)) return(false); - if(inst_type.n() > 0 && !inst_type.has(cur_inst)) return(false); + if(var_name.n() > 0 && !var_name.reg_exp_match(cur_var_name)) return false; + if(msg_type.n() > 0 && !msg_type.has(cur_msg_type)) return false; + if(sid.n() > 0 && !sid.has(cur_sid)) return false; + if(pb_rpt_type.n() > 0 && !pb_rpt_type.has(cur_pb_rpt)) return false; + if(in_rpt_type.n() > 0 && !in_rpt_type.has(cur_in_rpt)) return false; + if(inst_type.n() > 0 && !inst_type.has(cur_inst)) return false; // Check ranges if(!is_bad_data(cur_hgt) && hgt_range.n() == 2) { if((cur_hgt < hgt_range[0] && !is_eq(cur_hgt, hgt_range[0])) || - (cur_hgt > hgt_range[1] && !is_eq(cur_hgt, hgt_range[1]))) return(false); + (cur_hgt > hgt_range[1] && !is_eq(cur_hgt, hgt_range[1]))) return false; } if(!is_bad_data(cur_prs) && prs_range.n() == 2) { if((cur_prs < prs_range[0] && !is_eq(cur_prs, prs_range[0])) || - (cur_prs > prs_range[1] && !is_eq(cur_prs, prs_range[1]))) return(false); + (cur_prs > prs_range[1] && !is_eq(cur_prs, prs_range[1]))) return false; } if(!is_bad_data(cur_val) && val_range.n() == 2) { if((cur_val < val_range[0] && !is_eq(cur_val, val_range[0])) || - (cur_val > val_range[1] && !is_eq(cur_val, val_range[1]))) return(false); + (cur_val > val_range[1] && !is_eq(cur_val, val_range[1]))) return false; } - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -495,7 +495,7 @@ bool ObsErrorTable::read(const char * file_name) { if(!f.open(file_name)) { mlog << Warning << "ObsErrorTable::read() -> " << "unable to open input file \"" << file_name << "\"\n\n"; - return(false); + return false; } // @@ -515,7 +515,7 @@ bool ObsErrorTable::read(const char * file_name) { f.close(); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -552,7 +552,7 @@ ObsErrorEntry *ObsErrorTable::lookup( << ", val = " << cur_val << "\n\n"; } - return(e_match); + return e_match; } //////////////////////////////////////////////////////////////////////// @@ -581,7 +581,7 @@ ObsErrorEntry *ObsErrorTable::lookup( << "\", val = " << cur_val << "\n\n"; } - return(e_match); + return e_match; } //////////////////////////////////////////////////////////////////////// @@ -591,10 +591,10 @@ bool ObsErrorTable::has(const char *cur_var_name, for(int i=0; ilookup_bool(conf_key_flag); // If set to NONE, no work to do - if(!info.flag) return(info); + if(!info.flag) return info; // Conf: dist_type - optional i = err_dict->lookup_int(conf_key_dist_type, false); @@ -693,7 +693,7 @@ ObsErrorInfo parse_conf_obs_error(Dictionary *dict, gsl_rng *rng_ptr) { info.entry.validate(); - return(info); + return info; } //////////////////////////////////////////////////////////////////////// @@ -704,7 +704,7 @@ double add_obs_error_inc(const gsl_rng *r, FieldType t, double v_new = v; // Check for null pointer or bad input value - if(!e || is_bad_data(v)) return(v); + if(!e || is_bad_data(v)) return v; // Apply the specified random perturbation if(e->dist_type != DistType_None) { @@ -737,7 +737,7 @@ double add_obs_error_inc(const gsl_rng *r, FieldType t, } } - return(v_new); + return v_new; } //////////////////////////////////////////////////////////////////////// @@ -780,7 +780,7 @@ DataPlane add_obs_error_inc(const gsl_rng *r, FieldType t, } } - return(out_dp); + return out_dp; } //////////////////////////////////////////////////////////////////////// @@ -790,7 +790,7 @@ double add_obs_error_bc(const gsl_rng *r, FieldType t, double v_new = v; // Check for null pointer or bad input value - if(!e || is_bad_data(v)) return(v); + if(!e || is_bad_data(v)) return v; // Apply instrument bias correction if(!is_bad_data(e->bias_scale)) v_new *= e->bias_scale; @@ -820,7 +820,7 @@ double add_obs_error_bc(const gsl_rng *r, FieldType t, } } - return(v_new); + return v_new; } //////////////////////////////////////////////////////////////////////// @@ -861,7 +861,7 @@ DataPlane add_obs_error_bc(const gsl_rng *r, FieldType t, } } - return(out_dp); + return out_dp; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_base.cc b/src/libcode/vx_statistics/pair_base.cc index 339861ac9b..cf5c1455c7 100644 --- a/src/libcode/vx_statistics/pair_base.cc +++ b/src/libcode/vx_statistics/pair_base.cc @@ -325,7 +325,7 @@ int PairBase::has_obs_rec(const char *sid, double lat, double lon, // // Only valid for point data // - if(!IsPointVx) return(false); + if(!IsPointVx) return false; // // Check for an existing record of this observation @@ -343,7 +343,7 @@ int PairBase::has_obs_rec(const char *sid, double lat, double lon, } } // end for - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -784,7 +784,7 @@ void PairBase::add_grid_obs(double x, double y, double PairBase::process_obs(VarInfo *vinfo, double v) { - if(!vinfo) return(v); + if(!vinfo) return v; double new_v = v; @@ -803,7 +803,7 @@ double PairBase::process_obs(VarInfo *vinfo, double v) { } } - return(new_v); + return new_v; } //////////////////////////////////////////////////////////////////////// @@ -885,7 +885,7 @@ double compute_interp(const DataPlaneArray &dpa, double v, v_blw, v_abv, t; // Check for no data - if(dpa.n_planes() == 0) return(bad_data_double); + if(dpa.n_planes() == 0) return bad_data_double; v_blw = compute_horz_interp(dpa[i_blw], obs_x, obs_y, obs_v, cmn, csd, method, width, shape, wrap_lon, @@ -901,7 +901,7 @@ double compute_interp(const DataPlaneArray &dpa, // Check for bad data prior to vertical interpolation if(is_bad_data(v_blw) || is_bad_data(v_abv)) { - return(bad_data_double); + return bad_data_double; } // If verifying specific humidity, do vertical interpolation in @@ -926,7 +926,7 @@ double compute_interp(const DataPlaneArray &dpa, } } - return(v); + return v; } @@ -1019,10 +1019,10 @@ bool set_climo_flag(const NumArray &f_na, const NumArray &c_na) { // The climo values must have non-zero, consistent length and // cannot all be bad data if(c_na.n() != f_na.n() || c_na.n() < 1 || is_bad_data(c_na.max())) { - return(false); + return false; } - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -1094,7 +1094,7 @@ NumArray derive_climo_prob(const ClimoCDFInfo *cdf_info_ptr, else if(n_mn > 0 && n_sd > 0) { // Need cdf_info_ptr set to proceed - if(!cdf_info_ptr) return(climo_prob); + if(!cdf_info_ptr) return climo_prob; // Derive climatological probabilities directly if(cdf_info_ptr->direct_prob) { @@ -1183,7 +1183,7 @@ NumArray derive_climo_prob(const ClimoCDFInfo *cdf_info_ptr, climo_prob = mn_na; } - return(climo_prob); + return climo_prob; } //////////////////////////////////////////////////////////////////////// @@ -1202,7 +1202,7 @@ double derive_prob(const NumArray &na, const SingleThresh &st) { if(n_vld == 0) prob = bad_data_double; else prob = (double) n_event / n_vld; - return(prob); + return prob; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index 41f527351b..485c8546ce 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -62,11 +62,11 @@ PairDataEnsemble::PairDataEnsemble(const PairDataEnsemble &pd) { PairDataEnsemble & PairDataEnsemble::operator=(const PairDataEnsemble &pd) { - if(this == &pd) return(*this); + if(this == &pd) return *this; assign(pd); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -304,7 +304,7 @@ void PairDataEnsemble::assign(const PairDataEnsemble &pd) { //////////////////////////////////////////////////////////////////////// bool PairDataEnsemble::has_obs_error() const { - return(obs_error_flag); + return obs_error_flag; } //////////////////////////////////////////////////////////////////////// @@ -830,7 +830,7 @@ void PairDataEnsemble::compute_ssvar() { PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &ot) const { // Check for no work to be done - if(ot.get_type() == thresh_na) return(*this); + if(ot.get_type() == thresh_na) return *this; int i, j; PairDataEnsemble pd; @@ -912,7 +912,7 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o << " ensemble pairs for observation filtering threshold " << ot.get_str() << ".\n"; - return(pd); + return pd; } //////////////////////////////////////////////////////////////////////// @@ -944,11 +944,11 @@ VxPairDataEnsemble::VxPairDataEnsemble(const VxPairDataEnsemble &vx_pd) { VxPairDataEnsemble & VxPairDataEnsemble::operator=(const VxPairDataEnsemble &vx_pd) { - if(this == &vx_pd) return(*this); + if(this == &vx_pd) return *this; assign(vx_pd); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1843,7 +1843,7 @@ int VxPairDataEnsemble::get_n_pair() const { } } - return(n); + return n; } //////////////////////////////////////////////////////////////////////// @@ -1970,7 +1970,7 @@ double compute_crps_emp(double obs, const NumArray &ens_na) { evals.sort_array(); // Check for bad or no data - if(is_bad_data(obs) || evals.n() == 0) return(bad_data_double); + if(is_bad_data(obs) || evals.n() == 0) return bad_data_double; // Initialize double obs_cdf = 0.0; @@ -1997,7 +1997,7 @@ double compute_crps_emp(double obs, const NumArray &ens_na) { // Handle obs being >= all ensemble members if(is_eq(obs_cdf, 0.0)) integral += (obs - fcst); - return(integral); + return integral; } //////////////////////////////////////////////////////////////////////// @@ -2017,7 +2017,7 @@ double compute_crps_gaus(double obs, double m, double s) { v = s*(z*(2.0*znorm(z) - 1) + 2.0*dnorm(z) - 1.0/sqrt(pi)); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -2036,7 +2036,7 @@ double compute_ens_ign(double obs, double m, double s) { v = 0.5*log(2.0*pi*s*s) + (obs - m)*(obs - m)/(2.0*s*s); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -2055,7 +2055,7 @@ double compute_ens_pit(double obs, double m, double s) { v = normal_cdf(obs, m, s); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -2109,7 +2109,7 @@ double compute_bias_ratio(double me_ge_obs, double me_lt_obs) { v = me_ge_obs / abs(me_lt_obs); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 15aa9133f0..da960f2870 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -57,11 +57,11 @@ PairDataPoint::PairDataPoint(const PairDataPoint &pd) { PairDataPoint & PairDataPoint::operator=(const PairDataPoint &pd) { - if(this == &pd) return(*this); + if(this == &pd) return *this; assign(pd); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -170,12 +170,12 @@ bool PairDataPoint::add_point_pair(const char *sid, double lat, double lon, double cmn, double csd, double wgt) { if(!add_point_obs(sid, lat, lon, x, y, ut, lvl, elv, o, qc, - cmn, csd, wgt)) return(false); + cmn, csd, wgt)) return false; f_na.add(f); seeps_mpr.push_back((SeepsScore *)nullptr); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -252,7 +252,7 @@ bool PairDataPoint::add_grid_pair(double f, double o, f_na.add(f); seeps_mpr.push_back(nullptr); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -285,7 +285,7 @@ bool PairDataPoint::add_grid_pair(const NumArray &f_in, const NumArray &o_in, // Increment the number of pairs n_obs += o_in.n(); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -321,7 +321,7 @@ PairDataPoint PairDataPoint::subset_pairs_cnt_thresh( // Check for no work to be done if(ft.get_type() == thresh_na && ot.get_type() == thresh_na) { - return(*this); + return *this; } int i; @@ -373,7 +373,7 @@ PairDataPoint PairDataPoint::subset_pairs_cnt_thresh( << ", observation filtering threshold " << ot.get_str() << ", and field logic " << setlogic_to_string(type) << ".\n"; - return(out_pd); + return out_pd; } //////////////////////////////////////////////////////////////////////// @@ -405,11 +405,11 @@ VxPairDataPoint::VxPairDataPoint(const VxPairDataPoint &vx_pd) { VxPairDataPoint & VxPairDataPoint::operator=(const VxPairDataPoint &vx_pd) { - if(this == &vx_pd) return(*this); + if(this == &vx_pd) return *this; assign(vx_pd); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1414,7 +1414,7 @@ int VxPairDataPoint::get_n_pair() const { } } - return(n); + return n; } //////////////////////////////////////////////////////////////////////// @@ -1626,7 +1626,7 @@ bool check_mpr_thresh(double f, double o, double cmn, double csd, if(reason_ptr) reason_ptr->erase(); // Check arrays - if(col_sa.n() == 0 || col_ta.n() == 0) return(true); + if(col_sa.n() == 0 || col_ta.n() == 0) return true; bool keep = true; bool absv = false; @@ -1684,7 +1684,7 @@ bool check_mpr_thresh(double f, double o, double cmn, double csd, } } // end for i - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -1712,7 +1712,7 @@ double get_mpr_column_value(double f, double o, double cmn, double csd, exit(1); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -1879,7 +1879,7 @@ PairDataPoint subset_climo_cdf_bin(const PairDataPoint &pd, const ThreshArray &ta, int i_bin) { // Check for no work to be done - if(ta.n() == 0) return(pd); + if(ta.n() == 0) return pd; int i; PairDataPoint out_pd; @@ -1926,7 +1926,7 @@ PairDataPoint subset_climo_cdf_bin(const PairDataPoint &pd, << "Using " << out_pd.n_obs << " of " << pd.n_obs << " pairs for climatology bin number " << i_bin+1 << ".\n"; - return(out_pd); + return out_pd; } //////////////////////////////////////////////////////////////////////// @@ -1956,7 +1956,7 @@ ConcatString point_obs_to_string(float *hdr_arr, const char *hdr_typ_str, << obs_arr[2] << " " << obs_arr[3] << " " << obs_qty << " " << obs_arr[4]; - return(obs_cs); + return obs_cs; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/read_climo.cc b/src/libcode/vx_statistics/read_climo.cc index 27fe9e5eae..db64d44a52 100644 --- a/src/libcode/vx_statistics/read_climo.cc +++ b/src/libcode/vx_statistics/read_climo.cc @@ -45,7 +45,7 @@ DataPlane read_climo_data_plane(Dictionary *dict, int i_vx, DataPlaneArray dpa; // Check for null - if(!dict) return(dp); + if(!dict) return dp; // Read array of climatology fields dpa = read_climo_data_plane_array(dict, i_vx, vld_ut, vx_grid); @@ -60,7 +60,7 @@ DataPlane read_climo_data_plane(Dictionary *dict, int i_vx, // Store the first match found if(dpa.n_planes() > 0) dp = dpa[0]; - return(dp); + return dp; } //////////////////////////////////////////////////////////////////////// @@ -77,7 +77,7 @@ DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, int i, day_ts, hour_ts; // Check for null - if(!dict) return(dpa); + if(!dict) return dpa; // Get the i-th array entry Dictionary i_dict = parse_conf_i_vx_dict(dict, i_vx); @@ -86,7 +86,7 @@ DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, climo_files = i_dict.lookup_string_array(conf_key_file_name, false); // Check for at least one file - if(climo_files.n() == 0) return(dpa); + if(climo_files.n() == 0) return dpa; // Regrid info regrid_info = parse_conf_regrid(&i_dict); @@ -140,7 +140,7 @@ DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, mlog << Debug(3) << "Found " << dpa.n_planes() << " climatology fields.\n"; - return(dpa); + return dpa; } //////////////////////////////////////////////////////////////////////// @@ -400,7 +400,7 @@ DataPlaneArray climo_time_interp(const DataPlaneArray &dpa, int day_ts, } // end else } // end for it - return(interp_dpa); + return interp_dpa; } //////////////////////////////////////////////////////////////////////// @@ -439,7 +439,7 @@ DataPlane climo_hms_interp(const DataPlaneArray &dpa, << unix_to_yyyymmdd_hhmmss(vld_ut) << " using the " << interpmthd_to_string(mthd) << " interpolation method.\n"; - return(valid_time_interp(dpa[i_prv], dpa[i_nxt], vld_ut, mthd)); + return valid_time_interp(dpa[i_prv], dpa[i_nxt], vld_ut, mthd); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/atcf_line_base.cc b/src/libcode/vx_tc_util/atcf_line_base.cc index 6db2d00651..e696bb6ee9 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.cc +++ b/src/libcode/vx_tc_util/atcf_line_base.cc @@ -56,11 +56,11 @@ ATCFLineBase::ATCFLineBase(const ATCFLineBase &l) { ATCFLineBase & ATCFLineBase::operator=(const ATCFLineBase &l) { - if(this == &l) return(*this); + if(this == &l) return *this; assign(l); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -167,7 +167,7 @@ int ATCFLineBase::read_line(LineDataFile * ldf) { // Check for bad return status or blank line if(!status || n_items() == 0) { clear(); - return(0); + return 0; } // Set the line type from the technique number column @@ -194,14 +194,14 @@ int ATCFLineBase::read_line(LineDataFile * ldf) { } } - return(1); + return 1; } //////////////////////////////////////////////////////////////////////// bool ATCFLineBase::is_header() const { - if(basin().comparecase(0, 5, "BASIN") == 0) return(true); - else return(false); + if(basin().comparecase(0, 5, "BASIN") == 0) return true; + else return false; } //////////////////////////////////////////////////////////////////////// @@ -224,7 +224,7 @@ ConcatString ATCFLineBase::get_item(int i) const { // Strip off any whitespace cs.ws_strip(); - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// @@ -232,42 +232,42 @@ ConcatString ATCFLineBase::get_item(int i) const { ConcatString ATCFLineBase::get_line() const { ConcatString cs; - if(N_items == 0) return(cs); + if(N_items == 0) return cs; for(int i=0; i 90.0) v = bad_data_double; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -449,7 +449,7 @@ double parse_lon(const char *s) { // Range check if(is_bad_data(v) || v < -360.0 || v > 360.0) v = bad_data_double; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -463,7 +463,7 @@ int parse_int(const char *s, const int bad_data) { // Check bad data value if(v == bad_data) v = bad_data_int; - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -473,7 +473,7 @@ int parse_int(const char *s, const int bad_data) { //////////////////////////////////////////////////////////////////////// int parse_int_check_zero(const char *s) { - return(parse_int(s, 0)); + return parse_int(s, 0); } //////////////////////////////////////////////////////////////////////// @@ -497,7 +497,7 @@ ATCFLineType string_to_atcflinetype(const char *s) { else if(strcasecmp(s, "ER") == 0) t = ATCFLineType_ProbER; else t = NoATCFLineType; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -521,7 +521,7 @@ ConcatString atcflinetype_to_string(const ATCFLineType t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// @@ -548,7 +548,7 @@ ConcatString define_storm_id(unixtime init_ut, unixtime min_valid_ut, storm_id << basin << cyclone << year; } - return(storm_id); + return storm_id; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/atcf_prob_line.cc b/src/libcode/vx_tc_util/atcf_prob_line.cc index 9cc97c4728..c8a3ee18f4 100644 --- a/src/libcode/vx_tc_util/atcf_prob_line.cc +++ b/src/libcode/vx_tc_util/atcf_prob_line.cc @@ -50,11 +50,11 @@ ATCFProbLine::ATCFProbLine(const ATCFProbLine &l) { ATCFProbLine & ATCFProbLine::operator=(const ATCFProbLine &l) { - if(this == &l) return(*this); + if(this == &l) return *this; assign(l); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -116,7 +116,7 @@ int ATCFProbLine::read_line(LineDataFile * ldf) { clear(); // Return bad status from the base class - if(!(status = ATCFLineBase::read_line(ldf))) return(0); + if(!(status = ATCFLineBase::read_line(ldf))) return 0; // Check the line type switch(Type) { @@ -150,19 +150,19 @@ int ATCFProbLine::read_line(LineDataFile * ldf) { } } - return(1); + return 1; } //////////////////////////////////////////////////////////////////////// int ATCFProbLine::prob() const { - return(parse_int(get_item(ProbOffset).c_str())); + return parse_int(get_item(ProbOffset).c_str()); } //////////////////////////////////////////////////////////////////////// int ATCFProbLine::prob_item() const { - return(parse_int(get_item(ProbItemOffset).c_str())); + return parse_int(get_item(ProbItemOffset).c_str()); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/atcf_track_line.cc b/src/libcode/vx_tc_util/atcf_track_line.cc index 106a646f88..ffc47dfacf 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.cc +++ b/src/libcode/vx_tc_util/atcf_track_line.cc @@ -50,11 +50,11 @@ ATCFTrackLine::ATCFTrackLine(const ATCFTrackLine &l) { ATCFTrackLine & ATCFTrackLine::operator=(const ATCFTrackLine &l) { - if(this == &l) return(*this); + if(this == &l) return *this; assign(l); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -140,7 +140,7 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { status = ATCFLineBase::read_line(ldf); // Check for bad return status or blank line - if(!status) return(0); + if(!status) return 0; // Check the line type if(Type != ATCFLineType_Track && @@ -149,7 +149,7 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { << "\nint ATCFTrackLine::read_line(LineDataFile * ldf) -> " << "unexpected ATCF line type (" << atcflinetype_to_string(Type) << ")\n\n"; - return(0); + return 0; } // Check for the minumum number of track line elements @@ -162,10 +162,10 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { << "found fewer than the expected number of elements (" << n_items() << ") in ATCF track line:\n" << DataLine::get_line() << "\n\n"; - return(0); + return 0; } - return(1); + return 1; } //////////////////////////////////////////////////////////////////////// @@ -269,13 +269,13 @@ int ATCFTrackLine::max_wind_radius() const { int ATCFTrackLine::storm_direction() const { if(Type == ATCFLineType_Track && StormDirectionOffset < N_items) { - return(parse_int(get_item(StormDirectionOffset).c_str())); + return parse_int(get_item(StormDirectionOffset).c_str()); } else if(Type == ATCFLineType_GenTrack && StormDirectionOffset < N_items) { - return(parse_int(get_item(GenStormDirectionOffset).c_str())); + return parse_int(get_item(GenStormDirectionOffset).c_str()); } - return(bad_data_int); + return bad_data_int; } //////////////////////////////////////////////////////////////////////// @@ -283,13 +283,13 @@ int ATCFTrackLine::storm_direction() const { int ATCFTrackLine::storm_speed() const { if(Type == ATCFLineType_Track && StormSpeedOffset < N_items) { - return(parse_int(get_item(StormSpeedOffset).c_str())); + return parse_int(get_item(StormSpeedOffset).c_str()); } else if(Type == ATCFLineType_GenTrack && StormSpeedOffset < N_items) { - return(parse_int(get_item(GenStormSpeedOffset).c_str())); + return parse_int(get_item(GenStormSpeedOffset).c_str()); } - return(bad_data_int); + return bad_data_int; } //////////////////////////////////////////////////////////////////////// @@ -309,7 +309,7 @@ bool ATCFTrackLine::warm_core() const { GenWarmCoreOffset < N_items) { return(get_item(GenWarmCoreOffset).comparecase("Y") == 0); } - return(false); + return false; } //////////////////////////////////////////////////////////////////////// @@ -514,7 +514,7 @@ WatchWarnType ww_max(const WatchWarnType t1, const WatchWarnType t2) { t2 == StormWarn ) t = StormWarn; else t = NoWatchWarnType; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -530,7 +530,7 @@ WatchWarnType int_to_watchwarntype(int i) { else if(i == 6) t = HurricaneWarn; else t = NoWatchWarnType; - return(t); + return t; } @@ -547,7 +547,7 @@ WatchWarnType string_to_watchwarntype(const char *s) { else if(strcasecmp(s, "HUWARN") == 0) t = HurricaneWarn; else t = NoWatchWarnType; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -566,7 +566,7 @@ ConcatString watchwarntype_to_string(const WatchWarnType t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// @@ -591,7 +591,7 @@ CycloneLevel string_to_cyclonelevel(const char *s) { else if(strcmp(s, "ET") == 0) l = Extrapolated; else /* "XX" */ l = NoCycloneLevel; - return(l); + return l; } //////////////////////////////////////////////////////////////////////// @@ -619,7 +619,7 @@ ConcatString cyclonelevel_to_string(const CycloneLevel t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// @@ -632,7 +632,7 @@ CycloneLevel wind_speed_to_cyclonelevel(int s) { else if(s <= 63) l = TropicalStorm; else l = Hurricane; - return(l); + return l; } //////////////////////////////////////////////////////////////////////// @@ -651,7 +651,7 @@ QuadrantType string_to_quadranttype(const char *s) { else if(strcmp(s, "NWQ") == 0) t = NW_Quadrant; else t = NoQuadrantType; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -673,7 +673,7 @@ ConcatString quadranttype_to_string(const QuadrantType t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// @@ -692,7 +692,7 @@ SubregionCode string_to_subregioncode(const char *s) { else if(strcmp(s, "W") == 0) c = Western_Pacific; else c = NoSubregionCode; - return(c); + return c; } //////////////////////////////////////////////////////////////////////// @@ -714,7 +714,7 @@ ConcatString subregioncode_to_string(const SubregionCode t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// @@ -727,7 +727,7 @@ SystemsDepth string_to_systemsdepth(const char *s) { else if(strcmp(s, "S") == 0) d = ShallowDepth; else d = NoSystemsDepth; - return(d); + return d; } //////////////////////////////////////////////////////////////////////// @@ -743,7 +743,7 @@ ConcatString systemsdepth_to_string(const SystemsDepth t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/diag_file.cc b/src/libcode/vx_tc_util/diag_file.cc index 95336c7765..96b85b7a35 100644 --- a/src/libcode/vx_tc_util/diag_file.cc +++ b/src/libcode/vx_tc_util/diag_file.cc @@ -66,7 +66,7 @@ int DiagFile::lead(int i) const { exit(1); } - return(LeadTime[i]); + return LeadTime[i]; } //////////////////////////////////////////////////////////////////////// @@ -95,7 +95,7 @@ double DiagFile::lat(int i) const { exit(1); } - return(Lat[i]); + return Lat[i]; } //////////////////////////////////////////////////////////////////////// @@ -109,13 +109,13 @@ double DiagFile::lon(int i) const { exit(1); } - return(Lon[i]); + return Lon[i]; } //////////////////////////////////////////////////////////////////////// bool DiagFile::has_diag(const string &str) const { - return(DiagName.has(str)); + return DiagName.has(str); } //////////////////////////////////////////////////////////////////////// @@ -130,7 +130,7 @@ const NumArray & DiagFile::diag_val(const string &str) const { exit(1); } - return(DiagVal[i]); + return DiagVal[i]; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/gen_shape_info.cc b/src/libcode/vx_tc_util/gen_shape_info.cc index cb8698c20e..1c258b2c78 100644 --- a/src/libcode/vx_tc_util/gen_shape_info.cc +++ b/src/libcode/vx_tc_util/gen_shape_info.cc @@ -46,11 +46,11 @@ GenShapeInfo::GenShapeInfo(const GenShapeInfo &g) { GenShapeInfo & GenShapeInfo::operator=(const GenShapeInfo &g) { - if(this == &g) return(*this); + if(this == &g) return *this; assign(g); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -85,7 +85,7 @@ ConcatString GenShapeInfo::serialize() const { << ", Lon = " << Poly.x_min() << " to " << Poly.x_max() << ", NProb = " << ProbVal.n(); - return(s); + return s; } @@ -157,7 +157,7 @@ void GenShapeInfo::add_prob(int sec, double prob) { //////////////////////////////////////////////////////////////////////// const ShpPolyRecord &GenShapeInfo::poly() const { - return(Poly); + return Poly; } //////////////////////////////////////////////////////////////////////// @@ -175,7 +175,7 @@ double GenShapeInfo::center_lon() const { //////////////////////////////////////////////////////////////////////// int GenShapeInfo::n_prob() const { - return(ProbVal.n()); + return ProbVal.n(); } //////////////////////////////////////////////////////////////////////// @@ -189,7 +189,7 @@ int GenShapeInfo::lead_sec(int i) const { exit(1); } - return(LeadSec[i]); + return LeadSec[i]; } //////////////////////////////////////////////////////////////////////// @@ -203,7 +203,7 @@ double GenShapeInfo::prob_val(int i) const { exit(1); } - return(ProbVal[i]); + return ProbVal[i]; } //////////////////////////////////////////////////////////////////////// @@ -237,11 +237,11 @@ GenShapeInfoArray::GenShapeInfoArray(const GenShapeInfoArray & t) { GenShapeInfoArray & GenShapeInfoArray::operator=(const GenShapeInfoArray & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -315,7 +315,7 @@ const GenShapeInfo & GenShapeInfoArray::operator[](int n) const { exit(1); } - return(GenShape[n]); + return GenShape[n]; } //////////////////////////////////////////////////////////////////////// @@ -338,7 +338,7 @@ bool GenShapeInfoArray::add(const GenShapeInfo &gsi, bool check_dup) { if(GenShape[i].file_time() == gsi.file_time()) { mlog << Debug(5) << "Skip exact duplicate " << gsi.serialize() << "\n"; - return(false); + return false; } // Replace older duplicates with more recent file time stamps else if(GenShape[i].file_time() < gsi.file_time()) { @@ -347,12 +347,12 @@ bool GenShapeInfoArray::add(const GenShapeInfo &gsi, bool check_dup) { << unix_to_yyyymmdd_hhmmss(GenShape[i].file_time()) << "\") with newer " << gsi.serialize() << "\n"; GenShape[i] = gsi; - return(false); + return false; } else { mlog << Debug(5) << "Skip older duplicate " << gsi.serialize() << "\n"; - return(false); + return false; } } } @@ -361,7 +361,7 @@ bool GenShapeInfoArray::add(const GenShapeInfo &gsi, bool check_dup) { // Store the genesis shape object GenShape.push_back(gsi); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -369,10 +369,10 @@ bool GenShapeInfoArray::add(const GenShapeInfo &gsi, bool check_dup) { bool GenShapeInfoArray::has(const GenShapeInfo &gsi) const { for(int i=0; ilookup_thresh(conf_key_mslp_thresh); - return(info); + return info; } //////////////////////////////////////////////////////////////////////// @@ -132,11 +132,11 @@ GenesisInfo::GenesisInfo(const GenesisInfo &g) { GenesisInfo & GenesisInfo::operator=(const GenesisInfo &g) { - if(this == &g) return(*this); + if(this == &g) return *this; assign(g); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -245,7 +245,7 @@ ConcatString GenesisInfo::serialize() const { << ", Lon = " << Lon << ", DLand = " << DLand; - return(s); + return s; } @@ -257,7 +257,7 @@ ConcatString GenesisInfo::serialize_r(int n, int indent_depth) const { s << prefix << "[" << n << "] " << serialize(); - return(s); + return s; } @@ -285,7 +285,7 @@ bool GenesisInfo::set(const TrackInfo &ti, } // Return bad status if genesis was not found - if(is_bad_data(GenesisIndex)) return(false); + if(is_bad_data(GenesisIndex)) return false; // Store the TrackInfo TrackInfo::assign(ti); @@ -299,7 +299,7 @@ bool GenesisInfo::set(const TrackInfo &ti, if(IsAnlyTrack) GenesisLead = 0; else GenesisLead = ti[GenesisIndex].lead(); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -369,11 +369,11 @@ GenesisInfoArray::GenesisInfoArray(const GenesisInfoArray & t) { GenesisInfoArray & GenesisInfoArray::operator=(const GenesisInfoArray & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -421,7 +421,7 @@ ConcatString GenesisInfoArray::serialize() const { s << "GenesisInfoArray: " << "NGenesis = " << (int) Genesis.size(); - return(s); + return s; } @@ -438,7 +438,7 @@ ConcatString GenesisInfoArray::serialize_r(int indent_depth) const { s << Genesis[i].serialize_r(i+1, indent_depth+1) << "\n"; } - return(s); + return s; } @@ -468,7 +468,7 @@ const GenesisInfo & GenesisInfoArray::operator[](int n) const { exit(1); } - return(Genesis[n]); + return Genesis[n]; } //////////////////////////////////////////////////////////////////////// @@ -480,13 +480,13 @@ bool GenesisInfoArray::add(const GenesisInfo &gi) { mlog << Warning << "\nGenesisInfoArray::add() -> " << "Skipping duplicate genesis event:\n" << gi.serialize() << "\n\n"; - return(false); + return false; } // Store the genesis object Genesis.push_back(gi); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -494,10 +494,10 @@ bool GenesisInfoArray::add(const GenesisInfo &gi) { bool GenesisInfoArray::has(const GenesisInfo &g) const { for(int i=0; i& gi_list, const GenesisInfo *gi, int &i) const { - if(!gi) return(false); + if(!gi) return false; // Search for a match for(i=0; i " << "skipping duplicate ATCF line:\n" << l.get_line() << "\n\n"; - return(false); + return false; } } @@ -203,7 +203,7 @@ bool ProbGenInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { if(Type == NoATCFLineType) initialize(l, dland); // Check for matching header information - if(!is_match(l)) return(false); + if(!is_match(l)) return false; // Add probability information NProb++; @@ -213,7 +213,7 @@ bool ProbGenInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { // Store the ATCFProbLine that was just added if(check_dup) ProbLines.add(l.get_line()); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_info_array.cc b/src/libcode/vx_tc_util/prob_info_array.cc index c162876567..f6db7d179b 100644 --- a/src/libcode/vx_tc_util/prob_info_array.cc +++ b/src/libcode/vx_tc_util/prob_info_array.cc @@ -52,11 +52,11 @@ ProbInfoArray::ProbInfoArray(const ProbInfoArray & t) { ProbInfoArray & ProbInfoArray::operator=(const ProbInfoArray & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -114,7 +114,7 @@ ConcatString ProbInfoArray::serialize() const { << "NProbRIRW = " << n_prob_rirw() << ", NProbGen = " << n_prob_gen(); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -139,7 +139,7 @@ ConcatString ProbInfoArray::serialize_r(int indent_depth) const { s << ProbGen[i].serialize_r(i+1, indent_depth+1); } - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -176,7 +176,7 @@ const ProbInfoBase * ProbInfoArray::operator[](int n) const { ptr = &ProbGen[n]; } - return(ptr); + return ptr; } //////////////////////////////////////////////////////////////////////// @@ -190,7 +190,7 @@ ProbRIRWInfo & ProbInfoArray::prob_rirw(int n) { exit(1); } - return(ProbRIRW[n]); + return ProbRIRW[n]; } //////////////////////////////////////////////////////////////////////// @@ -204,7 +204,7 @@ ProbGenInfo & ProbInfoArray::prob_gen(int n) { exit(1); } - return(ProbGen[n]); + return ProbGen[n]; } //////////////////////////////////////////////////////////////////////// @@ -224,7 +224,7 @@ int ProbInfoArray::n_technique() const { } } - return(sa.n()); + return sa.n(); } //////////////////////////////////////////////////////////////////////// @@ -238,7 +238,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { << "bool ProbInfoArray::add() -> " << "skipping probability value (" << l.prob() << ") outside of range (0, 100).\n"; - return(false); + return false; } // Store based on the input line type @@ -300,7 +300,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { status = false; } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_info_base.cc b/src/libcode/vx_tc_util/prob_info_base.cc index dc9a6cfc76..d341bb43a3 100644 --- a/src/libcode/vx_tc_util/prob_info_base.cc +++ b/src/libcode/vx_tc_util/prob_info_base.cc @@ -50,11 +50,11 @@ ProbInfoBase::ProbInfoBase(const ProbInfoBase & t) { ProbInfoBase & ProbInfoBase::operator=(const ProbInfoBase & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -135,7 +135,7 @@ ConcatString ProbInfoBase::serialize() const { << ", DLand = " << DLand << ", NProb = " << NProb; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -153,7 +153,7 @@ ConcatString ProbInfoBase::serialize_r(int n, int indent_depth) const { << "% probability for " << ProbItem[i] << "\n"; } - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -237,7 +237,7 @@ bool ProbInfoBase::is_match(const TrackInfo &t) const { match = false; // Check that technique is defined - if(Technique == "" || t.technique() == "") return(false); + if(Technique == "" || t.technique() == "") return false; // Check that init times match for non-BEST, non-analysis tracks if(!t.is_best_track() && @@ -246,7 +246,7 @@ bool ProbInfoBase::is_match(const TrackInfo &t) const { match = false; } - return(match); + return match; } //////////////////////////////////////////////////////////////////////// @@ -260,7 +260,7 @@ bool ProbInfoBase::add(const ATCFProbLine &l, double dland, bool check_dup) { << "\nProbInfoBase::add(const ATCFProbLine &l, bool check_dup) -> " << "skipping duplicate ATCFProbLine:\n" << l.get_line() << "\n\n"; - return(false); + return false; } } @@ -268,7 +268,7 @@ bool ProbInfoBase::add(const ATCFProbLine &l, double dland, bool check_dup) { if(Type == NoATCFLineType) initialize(l, dland); // Check for matching header information - if(!is_match(l)) return(false); + if(!is_match(l)) return false; // Add probability information NProb++; @@ -278,7 +278,7 @@ bool ProbInfoBase::add(const ATCFProbLine &l, double dland, bool check_dup) { // Store the ATCFProbLine that was just added if(check_dup) ProbLines.add(l.get_line()); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -324,7 +324,7 @@ void ProbInfoBase::set(const TCStatLine &l) { //////////////////////////////////////////////////////////////////////// bool ProbInfoBase::has(const ATCFProbLine &l) const { - return(ProbLines.has(l.get_line())); + return ProbLines.has(l.get_line()); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_rirw_info.cc b/src/libcode/vx_tc_util/prob_rirw_info.cc index 4745f18913..4b12925388 100644 --- a/src/libcode/vx_tc_util/prob_rirw_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_info.cc @@ -51,11 +51,11 @@ ProbRIRWInfo::ProbRIRWInfo(const ProbRIRWInfo & t) { ProbRIRWInfo & ProbRIRWInfo::operator=(const ProbRIRWInfo & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ ConcatString ProbRIRWInfo::serialize() const { << ", RIRWBeg = " << RIRWBeg << ", RIRWEnd = " << RIRWEnd; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -121,7 +121,7 @@ ConcatString ProbRIRWInfo::serialize_r(int n, int indent_depth) const { s << ProbInfoBase::serialize_r(n, indent_depth); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -167,7 +167,7 @@ void ProbRIRWInfo::initialize(const ATCFProbLine &l, double dland) { bool ProbRIRWInfo::is_match(const ATCFProbLine &l) const { - if(!ProbInfoBase::is_match(l)) return(false); + if(!ProbInfoBase::is_match(l)) return false; return(ValidTime == l.valid() && Value == parse_int(l.get_item(ProbRIRWValueOffset).c_str()) && @@ -186,7 +186,7 @@ bool ProbRIRWInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { << "\nProbRIRWInfo::add(const ATCFProbLine &l, bool check_dup) -> " << "skipping duplicate ATCF line:\n" << l.get_line() << "\n\n"; - return(false); + return false; } } @@ -194,7 +194,7 @@ bool ProbRIRWInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { if(Type == NoATCFLineType) initialize(l, dland); // Check for matching header information - if(!is_match(l)) return(false); + if(!is_match(l)) return false; // Add probability information NProb++; @@ -204,7 +204,7 @@ bool ProbRIRWInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { // Store the ATCFProbLine that was just added if(check_dup) ProbLines.add(l.get_line()); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc index 364e754035..d5d52d14d1 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc @@ -50,11 +50,11 @@ ProbRIRWPairInfo::ProbRIRWPairInfo(const ProbRIRWPairInfo & t) { ProbRIRWPairInfo & ProbRIRWPairInfo::operator=(const ProbRIRWPairInfo & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -132,7 +132,7 @@ ConcatString ProbRIRWPairInfo::case_info() const { << ", RIRW_BEG = " << ProbRIRW.rirw_beg() << ", RIRW_END = " << ProbRIRW.rirw_end(); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -157,7 +157,7 @@ ConcatString ProbRIRWPairInfo::serialize() const { << ", BMinV = " << BMinV << ", BMaxV = " << BMaxV; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -172,7 +172,7 @@ ConcatString ProbRIRWPairInfo::serialize_r(int n, int indent_depth) const { << prefix2 << "BDeck = " << (BDeck ? BDeck->serialize().text() : "(nul)") << "\n"; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -214,7 +214,7 @@ bool ProbRIRWPairInfo::set(const ProbRIRWInfo &prob_rirw_info, // Check for bad data if(prob_rirw_info.init() == (unixtime) 0 || is_bad_data(prob_rirw_info.rirw_beg()) || - is_bad_data(prob_rirw_info.rirw_end())) return(false); + is_bad_data(prob_rirw_info.rirw_end())) return false; // Define begin and end times unixtime beg_ut = prob_rirw_info.init() + (prob_rirw_info.rirw_beg() * sec_per_hour); @@ -227,7 +227,7 @@ bool ProbRIRWPairInfo::set(const ProbRIRWInfo &prob_rirw_info, } // Check for matching points - if(i_beg < 0 || i_end < 0) return(false); + if(i_beg < 0 || i_end < 0) return false; // Store the paired information ProbRIRW = prob_rirw_info; @@ -257,7 +257,7 @@ bool ProbRIRWPairInfo::set(const ProbRIRWInfo &prob_rirw_info, latlon_to_xytk_err(prob_rirw_info.lat(), prob_rirw_info.lon(), BLat, BLon, XErr, YErr, TrackErr); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -330,11 +330,11 @@ ProbRIRWPairInfoArray::ProbRIRWPairInfoArray(const ProbRIRWPairInfoArray & t) { ProbRIRWPairInfoArray & ProbRIRWPairInfoArray::operator=(const ProbRIRWPairInfoArray & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -382,7 +382,7 @@ ConcatString ProbRIRWPairInfoArray::serialize() const { s << "ProbRIRWPairInfoArray: " << "NPairs = " << n_pairs(); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -397,7 +397,7 @@ ConcatString ProbRIRWPairInfoArray::serialize_r(int indent_depth) const { s << Pairs[i].serialize_r(i+1, indent_depth+1); } - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -444,11 +444,11 @@ bool ProbRIRWPairInfoArray::add(const ProbRIRWInfo &p, const TrackInfo &t) { ProbRIRWPairInfo pair; // Attempt to set a new pair - if(!pair.set(p, t)) return(false); + if(!pair.set(p, t)) return false; Pairs.push_back(pair); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/tc_stat_line.cc b/src/libcode/vx_tc_util/tc_stat_line.cc index 78bd215196..0598a36c5f 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.cc +++ b/src/libcode/vx_tc_util/tc_stat_line.cc @@ -62,11 +62,11 @@ TCStatLine::TCStatLine(const TCStatLine & L) { TCStatLine & TCStatLine::operator=(const TCStatLine & L) { - if(this == &L) return(*this); + if(this == &L) return *this; assign(L); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { // if(!status || n_items() == 0) { clear(); - return(0); + return 0; } // @@ -127,7 +127,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { // if(strcmp(get_item(0), "VERSION") == 0) { Type = TCStatLineType_Header; - return(1); + return 1; } // @@ -137,7 +137,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { if(is_bad_data(offset) || n_items() < (offset + 1)) { Type = NoTCStatLineType; - return(0); + return 0; } // @@ -147,13 +147,13 @@ int TCStatLine::read_line(LineDataFile * ldf) { Type = string_to_tcstatlinetype(get_item(offset)); - return(1); + return 1; } //////////////////////////////////////////////////////////////////////// bool TCStatLine::is_ok() const { - return(DataLine::is_ok()); + return DataLine::is_ok(); } //////////////////////////////////////////////////////////////////////// @@ -179,7 +179,7 @@ ConcatString TCStatLine::get(const char *col_str, bool check_na) const { cs = sec_to_hhmmss(valid_hour()); } - return(cs); + return cs; } //////////////////////////////////////////////////////////////////////// @@ -210,8 +210,8 @@ const char * TCStatLine::get_item(const char *col_str, bool check_na) const { // // Return bad data string for no match // - if(is_bad_data(offset)) return(bad_data_str); - else return(get_item(offset, check_na)); + if(is_bad_data(offset)) return bad_data_str; + else return get_item(offset, check_na); } //////////////////////////////////////////////////////////////////////// @@ -219,61 +219,61 @@ const char * TCStatLine::get_item(const char *col_str, bool check_na) const { const char * TCStatLine::get_item(int offset, bool check_na) const { // Range check - if(offset < 0 || offset >= N_items) return(bad_data_str); + if(offset < 0 || offset >= N_items) return bad_data_str; const char * c = DataLine::get_item(offset); // Check for the NA string and interpret it as bad data - if(check_na && strcmp(c, na_str) == 0) return(bad_data_str); - else return(c); + if(check_na && strcmp(c, na_str) == 0) return bad_data_str; + else return c; } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::version() const { - return(get_item("VERSION", false)); + return get_item("VERSION", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::amodel() const { - return(get_item("AMODEL", false)); + return get_item("AMODEL", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::bmodel() const { - return(get_item("BMODEL", false)); + return get_item("BMODEL", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::desc() const { - return(get_item("DESC", false)); + return get_item("DESC", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::storm_id() const { - return(get_item("STORM_ID", false)); + return get_item("STORM_ID", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::basin() const { - return(get_item("BASIN", false)); + return get_item("BASIN", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::cyclone() const { - return(get_item("CYCLONE", false)); + return get_item("CYCLONE", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::storm_name() const { - return(get_item("STORM_NAME", false)); + return get_item("STORM_NAME", false); } //////////////////////////////////////////////////////////////////////// @@ -284,13 +284,13 @@ unixtime TCStatLine::init() const { t = timestring_to_unix(c); - return(t); + return t; } //////////////////////////////////////////////////////////////////////// int TCStatLine::init_hour() const { - return(init()%sec_per_day); + return init()%sec_per_day; } //////////////////////////////////////////////////////////////////////// @@ -301,7 +301,7 @@ int TCStatLine::lead() const { s = timestring_to_sec(c); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -312,7 +312,7 @@ unixtime TCStatLine::valid() const { t = timestring_to_unix(c); - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -324,25 +324,25 @@ int TCStatLine::valid_hour() const { //////////////////////////////////////////////////////////////////////// const char * TCStatLine::init_mask() const { - return(get_item("INIT_MASK", false)); + return get_item("INIT_MASK", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::valid_mask() const { - return(get_item("VALID_MASK", false)); + return get_item("VALID_MASK", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::initials() const { - return(get_item("INITIALS", false)); + return get_item("INITIALS", false); } //////////////////////////////////////////////////////////////////////// const char * TCStatLine::line_type() const { - return(get_item("LINE_TYPE", false)); + return get_item("LINE_TYPE", false); } //////////////////////////////////////////////////////////////////////// @@ -358,7 +358,7 @@ ConcatString TCStatLine::header() const { << (!is_bad_data(lead()) ? sec_to_hhmmss(lead()).text() : na_str) << sep << (valid() > 0 ? unix_to_yyyymmdd_hhmmss(valid()).text() : na_str); - return(hdr); + return hdr; } //////////////////////////////////////////////////////////////////////// @@ -376,7 +376,7 @@ TCStatLineType string_to_tcstatlinetype(const char *s) { else if(strcmp(s, TCStatLineType_Header_Str) == 0) t = TCStatLineType_Header; else t = NoTCStatLineType; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -392,7 +392,7 @@ ConcatString tcstatlinetype_to_string(const TCStatLineType t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_info.cc b/src/libcode/vx_tc_util/track_info.cc index 379d60faa1..d07b35aa0b 100644 --- a/src/libcode/vx_tc_util/track_info.cc +++ b/src/libcode/vx_tc_util/track_info.cc @@ -51,11 +51,11 @@ TrackInfo::TrackInfo(const TrackInfo & t) { TrackInfo & TrackInfo::operator=(const TrackInfo & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -183,7 +183,7 @@ ConcatString TrackInfo::serialize() const { << ", NAlloc = " << NAlloc << ", NTrackLines = " << TrackLines.n(); - return(s); + return s; } @@ -199,7 +199,7 @@ ConcatString TrackInfo::serialize_r(int n, int indent_depth) const { for(i=0; i " << "skipping duplicate ATCFTrackLine:\n" << l.get_line() << "\n\n"; - return(false); + return false; } } @@ -913,7 +913,7 @@ bool TrackInfoArray::add(const ATCFTrackLine &l, bool check_dup, bool check_anly status = true; } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -931,7 +931,7 @@ bool TrackInfoArray::has(const ATCFTrackLine &l) const { } // Return whether the TrackInfo matches - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -949,7 +949,7 @@ bool TrackInfoArray::erase_storm_id(const ConcatString &s) { } } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -962,7 +962,7 @@ int TrackInfoArray::add_diag_data(DiagFile &diag_file, const StringArray &diag_n if(Track[i].add_diag_data(diag_file, diag_name)) n_match++; } - return(n_match); + return n_match; } //////////////////////////////////////////////////////////////////////// @@ -1228,7 +1228,7 @@ TrackInfo consensus(const TrackInfoArray &tracks, } // end loop over lead times // Return the consensus track - return(tavg); + return tavg; } //////////////////////////////////////////////////////////////////////// @@ -1310,7 +1310,7 @@ bool has_storm_id(const StringArray &storm_id, break; } - return(match); + return match; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_pair_info.cc b/src/libcode/vx_tc_util/track_pair_info.cc index dd58b42e5f..ac5352febb 100644 --- a/src/libcode/vx_tc_util/track_pair_info.cc +++ b/src/libcode/vx_tc_util/track_pair_info.cc @@ -52,11 +52,11 @@ TrackPairInfo::TrackPairInfo(const TrackPairInfo & t) { TrackPairInfo & TrackPairInfo::operator=(const TrackPairInfo & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -146,7 +146,7 @@ ConcatString TrackPairInfo::case_info() const { << ", INIT = " << unix_to_yyyymmdd_hhmmss(ADeck.init()) << ", NPoints = " << NPoints; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -157,7 +157,7 @@ ConcatString TrackPairInfo::serialize() const { s << "TrackPairInfo: " << "NPoints = " << NPoints; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -185,7 +185,7 @@ ConcatString TrackPairInfo::serialize_r(int n, int indent_depth) const { << "\n"; } - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -545,7 +545,7 @@ unixtime TrackPairInfo::valid(int i) const { // Use the ADeck valid time, if defined. t = (ADeck[i].valid() > 0 ? ADeck[i].valid() : BDeck[i].valid()); - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -561,7 +561,7 @@ int TrackPairInfo::i_init() const { if(i < NPoints) i_match = i; - return(i_match); + return i_match; } //////////////////////////////////////////////////////////////////////// @@ -575,7 +575,7 @@ WatchWarnType TrackPairInfo::watch_warn(int i) const { ww_type = ww_max(ADeck[i].watch_warn(), BDeck[i].watch_warn()); } - return(ww_type); + return ww_type; } //////////////////////////////////////////////////////////////////////// @@ -621,7 +621,7 @@ int TrackPairInfo::check_water_only() { } } // end for i - return(n_rej); + return n_rej; } //////////////////////////////////////////////////////////////////////// @@ -642,7 +642,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, int acur, aprv, bcur, bprv; // Nothing to do. - if(track_type == TrackType_None) return(0); + if(track_type == TrackType_None) return 0; // Check threshold type for non-exact intensity differences. if(!exact_adeck && @@ -785,7 +785,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, } } // end for i - return(n_rej); + return n_rej; } //////////////////////////////////////////////////////////////////////// @@ -820,7 +820,7 @@ int TrackPairInfo::check_landfall(const int landfall_beg, } } - return(n_rej); + return n_rej; } //////////////////////////////////////////////////////////////////////// @@ -853,7 +853,7 @@ bool TrackPairInfo::landfall_window(unixtime beg_ut, unixtime end_ut) const { } } - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -888,7 +888,7 @@ TrackPairInfo TrackPairInfo::keep_subset() const { } } - return(tpi); + return tpi; } //////////////////////////////////////////////////////////////////////// @@ -922,11 +922,11 @@ TrackPairInfoArray::TrackPairInfoArray(const TrackPairInfoArray & t) { TrackPairInfoArray & TrackPairInfoArray::operator=(const TrackPairInfoArray & t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -979,7 +979,7 @@ ConcatString TrackPairInfoArray::serialize() const { << "NPairs = " << NPairs << ", NAlloc = " << NAlloc; - return(s); + return s; } @@ -995,7 +995,7 @@ ConcatString TrackPairInfoArray::serialize_r(int indent_depth) const { for(i=0; i n) n = Pair[i].adeck().n_diag(); } - return(n); + return n; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_point.cc b/src/libcode/vx_tc_util/track_point.cc index 1db936322e..a2c2b6adc1 100644 --- a/src/libcode/vx_tc_util/track_point.cc +++ b/src/libcode/vx_tc_util/track_point.cc @@ -52,11 +52,11 @@ QuadInfo::QuadInfo(const QuadInfo &t) { QuadInfo & QuadInfo::operator=(const QuadInfo &t) { - if(this == &t) return(*this); + if(this == &t) return *this; assign(t); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -82,7 +82,7 @@ QuadInfo & QuadInfo::operator+=(const QuadInfo &t) { if(is_bad_data(NWVal) || is_bad_data(t.NWVal)) NWVal = bad_data_double; else NWVal += t.NWVal; - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ ConcatString QuadInfo::serialize() const { << ", SWVal = " << SWVal << ", NWVal = " << NWVal; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -162,7 +162,7 @@ ConcatString QuadInfo::serialize_r(int n, int indent_depth) const { s << prefix << "[" << n << "] " << serialize() << "\n"; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -307,7 +307,7 @@ bool QuadInfo::is_match_wind(const ATCFTrackLine &l) const { // Parse the line into a QuadInfo object qi.set_wind(l); - return(*this == qi); + return (*this == qi); } //////////////////////////////////////////////////////////////////////// @@ -318,7 +318,7 @@ bool QuadInfo::is_match_seas(const ATCFTrackLine &l) const { // Parse the line into a QuadInfo object qi.set_seas(l); - return(*this == qi); + return (*this == qi); } //////////////////////////////////////////////////////////////////////// @@ -352,11 +352,11 @@ TrackPoint::TrackPoint(const TrackPoint &p) { TrackPoint & TrackPoint::operator=(const TrackPoint &p) { - if(this == &p) return(*this); + if(this == &p) return *this; assign(p); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -416,7 +416,7 @@ TrackPoint & TrackPoint::operator+=(const TrackPoint &p) { // Increment wind quadrants for(i=0; i " << "for non-exact differences the ramp threshold (" << thresh.get_str() << ") must be of type <, <=, >, or >=.\n\n"; - return(false); + return false; } // Loop over the times @@ -137,7 +137,7 @@ bool compute_dydt_ramps(const char *name, } } // end for i - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -165,14 +165,14 @@ bool compute_swing_ramps(const char *name, ramps.add(bad_data_double); slopes.add(bad_data_double); } - return(true); + return true; } mlog << Debug(4) << "Applying the swinging door algorithm.\n"; if(!compute_swinging_door_slopes(times, vals, width, slopes)) { - return(false); + return false; } // Apply the slope threshold to define ramps @@ -194,7 +194,7 @@ bool compute_swing_ramps(const char *name, } - return(true); + return true; } //////////////////////////////////////////////////////////////////////// From 481bb156949de2dd63a9f3c3254cec9203d5d29f Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 05:33:48 +0000 Subject: [PATCH 016/114] #2673 restored return statement --- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 6523846ea8..c6fbde206e 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -502,7 +502,7 @@ bool get_gen_vx_mask_config_str(MetNcMetDataFile *mnmdf_ptr, int i; // Check for null pointer - if(!mnmdf_ptr) ; + if(!mnmdf_ptr) return status; // Check for the MET_tool global attribute if(!get_global_att(mnmdf_ptr->MetNc->Nc, (string) "MET_tool", tool)) return status; From bc7af9929de9466617cf6f5b7e5b7836c05f52d7 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 20:59:07 +0000 Subject: [PATCH 017/114] #2673 Added std namespace --- src/libcode/vx_bool_calc/bool_calc.h | 4 ++-- src/libcode/vx_bool_calc/token.h | 4 ++-- src/libcode/vx_data2d_grib2/data2d_grib2.h | 12 ++++++------ src/libcode/vx_pxm/pxm_utils.h | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libcode/vx_bool_calc/bool_calc.h b/src/libcode/vx_bool_calc/bool_calc.h index a8604a6eed..2143d8e982 100644 --- a/src/libcode/vx_bool_calc/bool_calc.h +++ b/src/libcode/vx_bool_calc/bool_calc.h @@ -26,7 +26,7 @@ class BoolCalc { void init_from_scratch(); - stack * s; // allocated + std::stack * s; // allocated Program * program; // allocated @@ -52,7 +52,7 @@ class BoolCalc { void set(const char *); // algebraic boolean expression - bool run(const vector); + bool run(const std::vector); // return true if one of the operations is a union (or) bool has_union() const; diff --git a/src/libcode/vx_bool_calc/token.h b/src/libcode/vx_bool_calc/token.h index a63cce075c..717207160d 100644 --- a/src/libcode/vx_bool_calc/token.h +++ b/src/libcode/vx_bool_calc/token.h @@ -165,7 +165,7 @@ extern std::ostream & operator<<(std::ostream &, const Token &); //////////////////////////////////////////////////////////////////////// -inline int Token::prec () const { return ( out_prec ); } +inline int Token::prec () const { return out_prec; } inline bool Token::is_mark () const { return ( type == tok_mark ); } inline bool Token::is_unmark () const { return ( type == tok_unmark ); } @@ -178,7 +178,7 @@ inline bool Token::is_operand () const { return ( type == tok_local_var ); } //////////////////////////////////////////////////////////////////////// -typedef vector Program; +typedef std::vector Program; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.h b/src/libcode/vx_data2d_grib2/data2d_grib2.h index a37561fb03..46c50ee2f5 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.h +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.h @@ -39,7 +39,7 @@ typedef struct { int FieldNum; int Discipline; int PdsTmpl; - string ParmName; + std::string ParmName; int ParmCat; int Parm; int Process; @@ -84,10 +84,10 @@ class MetGrib2DataFile : public Met2dDataFile { FILE *FileGrib2; - vector RecList; + std::vector RecList; - map PairMap; - map NameRecMap; + std::map PairMap; + std::map NameRecMap; int ScanMode; @@ -98,8 +98,8 @@ class MetGrib2DataFile : public Met2dDataFile { void find_record_matches( VarInfoGrib2* vinfo, - vector &listMatchExact, - vector &listMatchRange + std::vector &listMatchExact, + std::vector &listMatchRange ); bool read_grib2_record_data_plane(Grib2Record *rec, DataPlane &plane); diff --git a/src/libcode/vx_pxm/pxm_utils.h b/src/libcode/vx_pxm/pxm_utils.h index d0717043dd..f5f764ba88 100644 --- a/src/libcode/vx_pxm/pxm_utils.h +++ b/src/libcode/vx_pxm/pxm_utils.h @@ -24,11 +24,11 @@ //////////////////////////////////////////////////////////////////////// -extern int parse_number (istream &); +extern int parse_number (std::istream &); -extern void skip_whitespace (istream &); +extern void skip_whitespace (std::istream &); -extern void get_comment (istream &, char *); +extern void get_comment (std::istream &, char *); //////////////////////////////////////////////////////////////////////// From e872917e8a561aa43fc8d233687d0392507036bd Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 28 Feb 2024 21:06:08 +0000 Subject: [PATCH 018/114] #2673 Moved down 'using namespace' statement. Removed trailing spaces --- src/tools/other/mode_time_domain/3d_conv.cc | 36 +++++++++------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/tools/other/mode_time_domain/3d_conv.cc b/src/tools/other/mode_time_domain/3d_conv.cc index a0ad85c12a..8bb11c7e3c 100644 --- a/src/tools/other/mode_time_domain/3d_conv.cc +++ b/src/tools/other/mode_time_domain/3d_conv.cc @@ -10,14 +10,6 @@ //////////////////////////////////////////////////////////////////////// -static const bool verbose = false; - -static const bool do_ppms = false; - - -//////////////////////////////////////////////////////////////////////// - - #include #include #include @@ -42,6 +34,10 @@ using namespace netCDF; //////////////////////////////////////////////////////////////////////// +static const bool verbose = false; + +static const bool do_ppms = false; + static int spatial_conv_radius = -1; static double * sum_plane_buf = nullptr; @@ -205,9 +201,9 @@ struct DataHandle { static void get_data_plane(const MtdFloatFile &, const int t, double * data_plane, bool * ok_plane); -static void calc_sum_plane(const int nx, const int ny, - const double * data_plane_in, const bool * ok_plane_in, - double * sum_plane_out, bool * ok_sum_plane_out); +static void calc_sum_plane(const int nx, const int ny, + const double * data_plane_in, const bool * ok_plane_in, + double * sum_plane_out, bool * ok_sum_plane_out); static void load_handle(DataHandle &, const MtdFloatFile & in, const int t, const int time_beg, const int time_end); @@ -245,8 +241,8 @@ const int trp1 = 2*spatial_R + 1; const double scale = 1.0/(trp1*trp1); -file_id = 1; // This is declared static in the netCDF library header file ncGroup.h, - // so we have to do **something** with this or the compiler complains +file_id = 1; // This is declared static in the netCDF library header file ncGroup.h, + // so we have to do **something** with this or the compiler complains // about an unused variable spatial_conv_radius = spatial_R; @@ -305,16 +301,16 @@ for (t=0; t Date: Fri, 1 Mar 2024 15:45:33 +0000 Subject: [PATCH 019/114] #2673 Moved down 'using namespace' statement. --- src/libcode/vx_afm/afm.cc | 6 ++--- src/libcode/vx_afm/afm_keywords.cc | 6 ++--- src/libcode/vx_afm/afm_token.cc | 6 ++--- src/libcode/vx_afm/afmkeyword_to_string.cc | 6 ++--- src/libcode/vx_afm/afmtokentype_to_string.cc | 6 ++--- .../vx_analysis_util/analysis_utils.cc | 4 +-- src/libcode/vx_analysis_util/by_case_info.cc | 5 ++-- src/libcode/vx_analysis_util/mode_atts.cc | 6 ++--- src/libcode/vx_analysis_util/mode_job.cc | 4 +-- src/libcode/vx_analysis_util/mode_line.cc | 4 +-- src/libcode/vx_analysis_util/stat_job.cc | 4 +-- src/libcode/vx_analysis_util/stat_line.cc | 4 +-- src/libcode/vx_analysis_util/time_series.cc | 4 +-- src/libcode/vx_bool_calc/bool_calc.cc | 11 ++++++-- src/libcode/vx_bool_calc/make_program.cc | 11 ++++++-- src/libcode/vx_bool_calc/token.cc | 15 ++++++----- src/libcode/vx_bool_calc/token_stack.cc | 8 +++--- src/libcode/vx_bool_calc/tokenizer.cc | 11 ++++++-- src/libcode/vx_color/color.cc | 4 +-- src/libcode/vx_color/color_list.cc | 4 +-- src/libcode/vx_color/color_table.cc | 6 ++--- src/libcode/vx_color/my_color_scanner.cc | 13 +++++++--- src/libcode/vx_data2d/data2d_utils.cc | 4 +-- src/libcode/vx_data2d/data_class.cc | 5 ++-- src/libcode/vx_data2d/level_info.cc | 4 +-- src/libcode/vx_data2d/leveltype_to_string.cc | 5 ++-- src/libcode/vx_data2d/mask_filters.cc | 4 +-- src/libcode/vx_data2d/table_lookup.cc | 4 +-- src/libcode/vx_data2d/var_info.cc | 4 +-- .../vx_data2d_factory/data2d_factory.cc | 4 +-- .../vx_data2d_factory/data2d_factory_utils.cc | 4 +-- src/libcode/vx_data2d_factory/is_bufr_file.cc | 4 +-- src/libcode/vx_data2d_factory/is_grib_file.cc | 6 ++--- .../vx_data2d_factory/is_netcdf_file.cc | 8 +++--- .../vx_data2d_factory/parse_file_list.cc | 4 +-- .../vx_data2d_factory/var_info_factory.cc | 5 ++-- src/libcode/vx_data2d_grib/data2d_grib.cc | 4 +-- .../vx_data2d_grib/data2d_grib_utils.cc | 4 +-- src/libcode/vx_data2d_grib/grib_classes.cc | 4 +-- src/libcode/vx_data2d_grib/grib_strings.cc | 4 +-- src/libcode/vx_data2d_grib/grib_utils.cc | 4 +-- src/libcode/vx_data2d_grib/var_info_grib.cc | 4 +-- src/libcode/vx_data2d_grib2/data2d_grib2.cc | 2 -- src/libcode/vx_data2d_grib2/var_info_grib2.cc | 4 +-- src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc | 4 +-- src/libcode/vx_data2d_nc_met/data2d_nc_met.cc | 5 ++-- src/libcode/vx_data2d_nc_met/get_met_grid.cc | 6 +++-- src/libcode/vx_data2d_nc_met/met_file.cc | 6 ++--- .../vx_data2d_nc_met/var_info_nc_met.cc | 4 +-- src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc | 5 ++-- src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc | 6 ++--- .../vx_data2d_nc_wrf/var_info_nc_wrf.cc | 4 +-- src/libcode/vx_data2d_nc_wrf/wrf_file.cc | 6 ++--- src/libcode/vx_data2d_python/data2d_python.cc | 4 +-- .../vx_data2d_python/var_info_python.cc | 4 +-- src/libcode/vx_geodesy/spheroid.cc | 6 ++--- src/libcode/vx_gis/dbf_file.cc | 4 +-- src/libcode/vx_gis/shapetype_to_string.cc | 6 ++--- src/libcode/vx_gis/shp_file.cc | 4 +-- src/libcode/vx_gis/shp_point_record.cc | 6 ++--- src/libcode/vx_gis/shp_poly_record.cc | 6 ++--- src/libcode/vx_gis/shx_file.cc | 4 +-- src/libcode/vx_gnomon/gnomon.cc | 26 +++++++++---------- src/libcode/vx_grid/earth_rotation.cc | 6 ++--- src/libcode/vx_grid/find_grid_by_name.cc | 4 +-- src/libcode/vx_grid/gaussian_grid.cc | 6 ++--- src/libcode/vx_grid/goes_grid.cc | 6 ++--- src/libcode/vx_grid/grid_base.cc | 6 ++--- src/libcode/vx_grid/latlon_grid.cc | 6 ++--- src/libcode/vx_grid/latlon_xyz.cc | 6 ++--- src/libcode/vx_grid/lc_grid.cc | 6 ++--- src/libcode/vx_grid/merc_grid.cc | 6 ++--- src/libcode/vx_grid/rot_latlon_grid.cc | 6 ++--- src/libcode/vx_grid/semilatlon_grid.cc | 6 ++--- src/libcode/vx_grid/st_grid.cc | 6 ++--- src/libcode/vx_grid/tcrmw_grid.cc | 4 +-- src/libcode/vx_gsl_prob/gsl_bvn.cc | 4 +-- src/libcode/vx_gsl_prob/gsl_cdf.cc | 4 +-- src/libcode/vx_gsl_prob/gsl_randist.cc | 4 +-- src/libcode/vx_gsl_prob/gsl_statistics.cc | 4 +-- src/libcode/vx_gsl_prob/gsl_wavelet2d.cc | 4 +-- src/libcode/vx_nav/nav.cc | 6 ++--- src/libcode/vx_nc_obs/met_point_data.cc | 6 ++--- src/libcode/vx_nc_obs/nc_obs_util.cc | 6 +++-- src/libcode/vx_nc_obs/nc_point_obs.cc | 7 ++--- src/libcode/vx_nc_obs/nc_point_obs_in.cc | 5 ++-- src/libcode/vx_nc_obs/nc_point_obs_out.cc | 5 ++-- src/libcode/vx_nc_obs/nc_summary.cc | 6 +++-- src/libcode/vx_nc_util/grid_output.cc | 6 ++--- src/libcode/vx_nc_util/load_tc_data.cc | 4 +-- src/libcode/vx_nc_util/nc_var_info.cc | 7 ++--- src/libcode/vx_pb_util/do_blocking.cc | 4 +-- src/libcode/vx_pb_util/do_unblocking.cc | 4 +-- src/libcode/vx_pb_util/pblock.cc | 5 ++-- src/libcode/vx_plot_util/data_plane_plot.cc | 25 +++++++++--------- src/libcode/vx_plot_util/map_region.cc | 4 +-- src/libcode/vx_plot_util/vx_plot_util.cc | 5 ++-- .../vx_pointdata_python/pointdata_python.cc | 4 +-- src/libcode/vx_ps/documentmedia_to_string.cc | 5 ++-- .../vx_ps/documentorientation_to_string.cc | 5 ++-- src/libcode/vx_ps/fontfamily_to_string.cc | 5 ++-- src/libcode/vx_ps/ps_text.cc | 4 +-- src/libcode/vx_ps/table_helper.cc | 4 +-- src/libcode/vx_ps/vx_ps.cc | 5 ++-- 104 files changed, 309 insertions(+), 281 deletions(-) diff --git a/src/libcode/vx_afm/afm.cc b/src/libcode/vx_afm/afm.cc index e40ac65256..c89cc617e4 100644 --- a/src/libcode/vx_afm/afm.cc +++ b/src/libcode/vx_afm/afm.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_afm/afm_keywords.cc b/src/libcode/vx_afm/afm_keywords.cc index 534d8ef6dd..8117af52a2 100644 --- a/src/libcode/vx_afm/afm_keywords.cc +++ b/src/libcode/vx_afm/afm_keywords.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -23,6 +20,9 @@ using namespace std; #include "afm_keywords.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_afm/afm_token.cc b/src/libcode/vx_afm/afm_token.cc index 123e82bdda..bb623f2075 100644 --- a/src/libcode/vx_afm/afm_token.cc +++ b/src/libcode/vx_afm/afm_token.cc @@ -11,9 +11,6 @@ ///////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -27,6 +24,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_afm/afmkeyword_to_string.cc b/src/libcode/vx_afm/afmkeyword_to_string.cc index 2f0bc4ebeb..6030b29fe4 100644 --- a/src/libcode/vx_afm/afmkeyword_to_string.cc +++ b/src/libcode/vx_afm/afmkeyword_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "afmkeyword_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_afm/afmtokentype_to_string.cc b/src/libcode/vx_afm/afmtokentype_to_string.cc index c08fb62f19..eb218009a8 100644 --- a/src/libcode/vx_afm/afmtokentype_to_string.cc +++ b/src/libcode/vx_afm/afmtokentype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "afmtokentype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/analysis_utils.cc b/src/libcode/vx_analysis_util/analysis_utils.cc index c0c079cec3..1786b9b1c6 100644 --- a/src/libcode/vx_analysis_util/analysis_utils.cc +++ b/src/libcode/vx_analysis_util/analysis_utils.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "analysis_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/by_case_info.cc b/src/libcode/vx_analysis_util/by_case_info.cc index 1b8718bf89..493c4d9ab7 100644 --- a/src/libcode/vx_analysis_util/by_case_info.cc +++ b/src/libcode/vx_analysis_util/by_case_info.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/mode_atts.cc b/src/libcode/vx_analysis_util/mode_atts.cc index e63d661549..2774e818a7 100644 --- a/src/libcode/vx_analysis_util/mode_atts.cc +++ b/src/libcode/vx_analysis_util/mode_atts.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/mode_job.cc b/src/libcode/vx_analysis_util/mode_job.cc index b2e0b1339f..8c89cd38c5 100644 --- a/src/libcode/vx_analysis_util/mode_job.cc +++ b/src/libcode/vx_analysis_util/mode_job.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -31,6 +29,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/mode_line.cc b/src/libcode/vx_analysis_util/mode_line.cc index 5a7319565f..b021db9d5b 100644 --- a/src/libcode/vx_analysis_util/mode_line.cc +++ b/src/libcode/vx_analysis_util/mode_line.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 963271d905..470907c1be 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static ConcatString timestring(const unixtime t); diff --git a/src/libcode/vx_analysis_util/stat_line.cc b/src/libcode/vx_analysis_util/stat_line.cc index faf5c409f3..cd119e15ad 100644 --- a/src/libcode/vx_analysis_util/stat_line.cc +++ b/src/libcode/vx_analysis_util/stat_line.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -33,6 +31,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/time_series.cc b/src/libcode/vx_analysis_util/time_series.cc index a07c07debd..9ac89f4d93 100644 --- a/src/libcode/vx_analysis_util/time_series.cc +++ b/src/libcode/vx_analysis_util/time_series.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/bool_calc.cc b/src/libcode/vx_bool_calc/bool_calc.cc index 21ccd83921..47701cbe74 100644 --- a/src/libcode/vx_bool_calc/bool_calc.cc +++ b/src/libcode/vx_bool_calc/bool_calc.cc @@ -1,10 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -15,6 +20,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/make_program.cc b/src/libcode/vx_bool_calc/make_program.cc index 0072a3f658..c18b20835a 100644 --- a/src/libcode/vx_bool_calc/make_program.cc +++ b/src/libcode/vx_bool_calc/make_program.cc @@ -1,10 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +25,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/token.cc b/src/libcode/vx_bool_calc/token.cc index d2bff4c067..e9d6b66df1 100644 --- a/src/libcode/vx_bool_calc/token.cc +++ b/src/libcode/vx_bool_calc/token.cc @@ -1,9 +1,10 @@ - - -//////////////////////////////////////////////////////////////////////// - - -using namespace std; +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// @@ -14,6 +15,8 @@ using namespace std; #include "token.h" #include "tokentype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/token_stack.cc b/src/libcode/vx_bool_calc/token_stack.cc index cdcdb2f039..eeee263c68 100644 --- a/src/libcode/vx_bool_calc/token_stack.cc +++ b/src/libcode/vx_bool_calc/token_stack.cc @@ -1,5 +1,3 @@ - - //////////////////////////////////////////////////////////////////////// @@ -16,9 +14,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -30,6 +25,9 @@ using namespace std; #include "token_stack.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/tokenizer.cc b/src/libcode/vx_bool_calc/tokenizer.cc index 7b676f452e..48ecad1ed4 100644 --- a/src/libcode/vx_bool_calc/tokenizer.cc +++ b/src/libcode/vx_bool_calc/tokenizer.cc @@ -1,10 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -17,6 +22,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_color/color.cc b/src/libcode/vx_color/color.cc index 715968ecab..3edbbd3ebd 100644 --- a/src/libcode/vx_color/color.cc +++ b/src/libcode/vx_color/color.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include @@ -20,6 +18,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_color/color_list.cc b/src/libcode/vx_color/color_list.cc index eb3c8cad18..a82b73a069 100644 --- a/src/libcode/vx_color/color_list.cc +++ b/src/libcode/vx_color/color_list.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_color/color_table.cc b/src/libcode/vx_color/color_table.cc index 341a5f00d2..4af38cee43 100644 --- a/src/libcode/vx_color/color_table.cc +++ b/src/libcode/vx_color/color_table.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "vx_math.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_color/my_color_scanner.cc b/src/libcode/vx_color/my_color_scanner.cc index 96500f4d37..28ddf453ec 100644 --- a/src/libcode/vx_color/my_color_scanner.cc +++ b/src/libcode/vx_color/my_color_scanner.cc @@ -1,12 +1,15 @@ - +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +27,8 @@ using namespace std; #include "color_parser_yacc.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/data2d_utils.cc b/src/libcode/vx_data2d/data2d_utils.cc index 8080480214..e1098d0b0d 100644 --- a/src/libcode/vx_data2d/data2d_utils.cc +++ b/src/libcode/vx_data2d/data2d_utils.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// bool derive_wdir(const DataPlane &u2d, const DataPlane &v2d, diff --git a/src/libcode/vx_data2d/data_class.cc b/src/libcode/vx_data2d/data_class.cc index 1d95284e38..1a2c838ec7 100644 --- a/src/libcode/vx_data2d/data_class.cc +++ b/src/libcode/vx_data2d/data_class.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,9 @@ using namespace std; #include "data2d_utils.h" #include "apply_mask.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/level_info.cc b/src/libcode/vx_data2d/level_info.cc index a02966fb95..58f22f7987 100644 --- a/src/libcode/vx_data2d/level_info.cc +++ b/src/libcode/vx_data2d/level_info.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "is_bad_data.h" @@ -26,6 +24,8 @@ using namespace std; #include "level_info.h" #include "leveltype_to_string.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class LevelInfo diff --git a/src/libcode/vx_data2d/leveltype_to_string.cc b/src/libcode/vx_data2d/leveltype_to_string.cc index 1c7d52b24e..445a18aca7 100644 --- a/src/libcode/vx_data2d/leveltype_to_string.cc +++ b/src/libcode/vx_data2d/leveltype_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "leveltype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/mask_filters.cc b/src/libcode/vx_data2d/mask_filters.cc index b0b6e4e6fa..15e0a4e7b0 100644 --- a/src/libcode/vx_data2d/mask_filters.cc +++ b/src/libcode/vx_data2d/mask_filters.cc @@ -9,10 +9,10 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "mask_filters.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/table_lookup.cc b/src/libcode/vx_data2d/table_lookup.cc index 0fba08a268..2a18417a6e 100644 --- a/src/libcode/vx_data2d/table_lookup.cc +++ b/src/libcode/vx_data2d/table_lookup.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,8 @@ using namespace std; #include #include +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/var_info.cc b/src/libcode/vx_data2d/var_info.cc index 6ee74c08e7..620b7d1fff 100644 --- a/src/libcode/vx_data2d/var_info.cc +++ b/src/libcode/vx_data2d/var_info.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// ConcatString parse_set_attr_string(Dictionary &dict, const char *key, bool check_ws=false); diff --git a/src/libcode/vx_data2d_factory/data2d_factory.cc b/src/libcode/vx_data2d_factory/data2d_factory.cc index 7d188c2080..bcc7a98b76 100644 --- a/src/libcode/vx_data2d_factory/data2d_factory.cc +++ b/src/libcode/vx_data2d_factory/data2d_factory.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -38,6 +36,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class Met2dDataFileFactory diff --git a/src/libcode/vx_data2d_factory/data2d_factory_utils.cc b/src/libcode/vx_data2d_factory/data2d_factory_utils.cc index 83a2ed7ce1..e975c5ddb8 100644 --- a/src/libcode/vx_data2d_factory/data2d_factory_utils.cc +++ b/src/libcode/vx_data2d_factory/data2d_factory_utils.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_factory/is_bufr_file.cc b/src/libcode/vx_data2d_factory/is_bufr_file.cc index 946a5f544d..821cdee32a 100644 --- a/src/libcode/vx_data2d_factory/is_bufr_file.cc +++ b/src/libcode/vx_data2d_factory/is_bufr_file.cc @@ -12,8 +12,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,8 @@ using namespace std; #include "is_bufr_file.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_factory/is_grib_file.cc b/src/libcode/vx_data2d_factory/is_grib_file.cc index ae803eff0b..734d9e49d7 100644 --- a/src/libcode/vx_data2d_factory/is_grib_file.cc +++ b/src/libcode/vx_data2d_factory/is_grib_file.cc @@ -1,5 +1,3 @@ - - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2024 // ** University Corporation for Atmospheric Research (UCAR) @@ -14,8 +12,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +25,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_factory/is_netcdf_file.cc b/src/libcode/vx_data2d_factory/is_netcdf_file.cc index d59b9cb6e3..5155e2e2ff 100644 --- a/src/libcode/vx_data2d_factory/is_netcdf_file.cc +++ b/src/libcode/vx_data2d_factory/is_netcdf_file.cc @@ -1,5 +1,3 @@ - - // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2024 // ** University Corporation for Atmospheric Research (UCAR) @@ -14,8 +12,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,12 +22,14 @@ using namespace std; #include #include -using namespace netCDF; #include "is_netcdf_file.h" #include "vx_nc_util.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_factory/parse_file_list.cc b/src/libcode/vx_data2d_factory/parse_file_list.cc index 5c11d753e7..57d357a314 100644 --- a/src/libcode/vx_data2d_factory/parse_file_list.cc +++ b/src/libcode/vx_data2d_factory/parse_file_list.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -31,6 +29,8 @@ using namespace std; #include "parse_file_list.h" #include "data2d_factory_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_factory/var_info_factory.cc b/src/libcode/vx_data2d_factory/var_info_factory.cc index f270164ad1..252fb5bd3d 100644 --- a/src/libcode/vx_data2d_factory/var_info_factory.cc +++ b/src/libcode/vx_data2d_factory/var_info_factory.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -42,6 +40,9 @@ using namespace std; #include "vx_cal.h" #include "vx_log.h" +using namespace std; + + /////////////////////////////////////////////////////////////////////////////// // // Code for class VarInfoFactory diff --git a/src/libcode/vx_data2d_grib/data2d_grib.cc b/src/libcode/vx_data2d_grib/data2d_grib.cc index 09dc80815a..a3c7bc3001 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc index 2f1f66385b..de590d3274 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/grib_classes.cc b/src/libcode/vx_data2d_grib/grib_classes.cc index 5954a6ed7d..efb1d330fe 100644 --- a/src/libcode/vx_data2d_grib/grib_classes.cc +++ b/src/libcode/vx_data2d_grib/grib_classes.cc @@ -6,8 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; - //////////////////////////////////////////////////////////////////////// @@ -29,6 +27,8 @@ using namespace std; #include "grib_classes.h" #include "grib_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/grib_strings.cc b/src/libcode/vx_data2d_grib/grib_strings.cc index f9b3edcdac..a2de02ee91 100644 --- a/src/libcode/vx_data2d_grib/grib_strings.cc +++ b/src/libcode/vx_data2d_grib/grib_strings.cc @@ -6,8 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; - /////////////////////////////////////////////////////////////////////////////// #include @@ -29,6 +27,8 @@ using namespace std; #include "vx_log.h" #include "vx_data2d.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// ConcatString get_grib_code_list_str(int k, int grib_code, int ptv) diff --git a/src/libcode/vx_data2d_grib/grib_utils.cc b/src/libcode/vx_data2d_grib/grib_utils.cc index 095be46d0a..68a4bc766e 100644 --- a/src/libcode/vx_data2d_grib/grib_utils.cc +++ b/src/libcode/vx_data2d_grib/grib_utils.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "angles.h" #include "is_bad_data.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/var_info_grib.cc b/src/libcode/vx_data2d_grib/var_info_grib.cc index 32f841c32b..0c62fd5502 100644 --- a/src/libcode/vx_data2d_grib/var_info_grib.cc +++ b/src/libcode/vx_data2d_grib/var_info_grib.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -35,6 +33,8 @@ using namespace std; #include "vx_log.h" #include "vx_data2d.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class VarInfoGrib diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.cc b/src/libcode/vx_data2d_grib2/data2d_grib2.cc index 5ea279fb96..006c56d7df 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.cc +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include diff --git a/src/libcode/vx_data2d_grib2/var_info_grib2.cc b/src/libcode/vx_data2d_grib2/var_info_grib2.cc index 9d67ab1929..d49910937d 100644 --- a/src/libcode/vx_data2d_grib2/var_info_grib2.cc +++ b/src/libcode/vx_data2d_grib2/var_info_grib2.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -36,6 +34,8 @@ using namespace std; #include "vx_data2d.h" #include "vx_config.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // diff --git a/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc index 00695d8da5..79594dccd5 100644 --- a/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "vx_log.h" #include "grib_strings.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// static bool is_grib_code_abbr_match(const ConcatString &, int); diff --git a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc index 40caecba95..fc4bf79169 100644 --- a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,9 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class MetNcMetDataFile diff --git a/src/libcode/vx_data2d_nc_met/get_met_grid.cc b/src/libcode/vx_data2d_nc_met/get_met_grid.cc index 7ae924bd34..8b8da3d1a3 100644 --- a/src/libcode/vx_data2d_nc_met/get_met_grid.cc +++ b/src/libcode/vx_data2d_nc_met/get_met_grid.cc @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -17,13 +16,16 @@ using namespace std; #include #include -using namespace netCDF; #include "get_met_grid.h" #include "nc_utils.h" #include "vx_log.h" +using namespace std; +using namespace netCDF; + + /////////////////////////////////////////////////////////////////////////////// static void read_netcdf_grid_v3 (NcFile *, Grid &); diff --git a/src/libcode/vx_data2d_nc_met/met_file.cc b/src/libcode/vx_data2d_nc_met/met_file.cc index 443fe6ff60..afd0db7171 100644 --- a/src/libcode/vx_data2d_nc_met/met_file.cc +++ b/src/libcode/vx_data2d_nc_met/met_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,7 +19,6 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_math.h" #include "vx_cal.h" @@ -31,6 +28,9 @@ using namespace netCDF; #include "get_met_grid.h" #include "nc_utils.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc b/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc index 338d83e8f4..535f69a19c 100644 --- a/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/var_info_nc_met.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "vx_log.h" #include "grib_strings.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// static bool is_grib_code_abbr_match(const ConcatString &, int); diff --git a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc index e249856a7a..b777e04f80 100644 --- a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,9 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class MetNcWrfDataFile diff --git a/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc b/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc index 7f32821921..6519f9583d 100644 --- a/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc +++ b/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -18,7 +16,6 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_log.h" #include "vx_math.h" @@ -26,6 +23,9 @@ using namespace netCDF; #include "get_wrf_grid.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc index 62c1d9c834..9827271d7c 100644 --- a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class VarInfoNcWrf diff --git a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc index 19c99b6de8..324c3be6ac 100644 --- a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc +++ b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,7 +18,6 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_math.h" #include "vx_cal.h" @@ -30,6 +27,9 @@ using namespace netCDF; #include "wrf_file.h" #include "get_wrf_grid.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_python/data2d_python.cc b/src/libcode/vx_data2d_python/data2d_python.cc index 3b146f45f7..42715c9983 100644 --- a/src/libcode/vx_data2d_python/data2d_python.cc +++ b/src/libcode/vx_data2d_python/data2d_python.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_python/var_info_python.cc b/src/libcode/vx_data2d_python/var_info_python.cc index 62bbdcd7aa..6d71569a6a 100644 --- a/src/libcode/vx_data2d_python/var_info_python.cc +++ b/src/libcode/vx_data2d_python/var_info_python.cc @@ -17,8 +17,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -35,6 +33,8 @@ using namespace std; #include "vx_data2d.h" #include "grdfiletype_to_string.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class VarInfoPython diff --git a/src/libcode/vx_geodesy/spheroid.cc b/src/libcode/vx_geodesy/spheroid.cc index 6f71fcfe76..da22aae5fa 100644 --- a/src/libcode/vx_geodesy/spheroid.cc +++ b/src/libcode/vx_geodesy/spheroid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_math.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gis/dbf_file.cc b/src/libcode/vx_gis/dbf_file.cc index 66361dd7e4..e5d3ce5081 100644 --- a/src/libcode/vx_gis/dbf_file.cc +++ b/src/libcode/vx_gis/dbf_file.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "dbf_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gis/shapetype_to_string.cc b/src/libcode/vx_gis/shapetype_to_string.cc index b59df8e274..63a7f2cd47 100644 --- a/src/libcode/vx_gis/shapetype_to_string.cc +++ b/src/libcode/vx_gis/shapetype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "shapetype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gis/shp_file.cc b/src/libcode/vx_gis/shp_file.cc index 76086acf0c..8eded0f2e1 100644 --- a/src/libcode/vx_gis/shp_file.cc +++ b/src/libcode/vx_gis/shp_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,8 @@ using namespace std; #include "shp_file.h" #include "shapetype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gis/shp_point_record.cc b/src/libcode/vx_gis/shp_point_record.cc index c3cc3f126c..9ce7c93ad6 100644 --- a/src/libcode/vx_gis/shp_point_record.cc +++ b/src/libcode/vx_gis/shp_point_record.cc @@ -1,5 +1,3 @@ - - //////////////////////////////////////////////////////////////////////// @@ -15,8 +13,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -31,6 +27,8 @@ using namespace std; #include "shp_point_record.h" #include "shapetype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gis/shp_poly_record.cc b/src/libcode/vx_gis/shp_poly_record.cc index 5a9c46749e..23ca89d738 100644 --- a/src/libcode/vx_gis/shp_poly_record.cc +++ b/src/libcode/vx_gis/shp_poly_record.cc @@ -1,5 +1,3 @@ - - //////////////////////////////////////////////////////////////////////// @@ -15,8 +13,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +28,8 @@ using namespace std; #include "shp_poly_record.h" #include "shapetype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gis/shx_file.cc b/src/libcode/vx_gis/shx_file.cc index 1126168467..1692616415 100644 --- a/src/libcode/vx_gis/shx_file.cc +++ b/src/libcode/vx_gis/shx_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "shx_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gnomon/gnomon.cc b/src/libcode/vx_gnomon/gnomon.cc index 7e60ff86d3..48dd9eb7b7 100644 --- a/src/libcode/vx_gnomon/gnomon.cc +++ b/src/libcode/vx_gnomon/gnomon.cc @@ -7,6 +7,19 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +//////////////////////////////////////////////////////////////////////// + + +#include +#include +#include +#include + +#include "vx_log.h" +#include "trig.h" +#include "gnomon.h" + + using namespace std; @@ -26,19 +39,6 @@ static const double cf = 57.2957795130823208768; //////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include - -#include "vx_log.h" -#include "trig.h" -#include "gnomon.h" - - -//////////////////////////////////////////////////////////////////////// - - static double e1x, e1y, e1z, e2x, e2y, e2z, e3x, e3y, e3z; static int initialized = 0; diff --git a/src/libcode/vx_grid/earth_rotation.cc b/src/libcode/vx_grid/earth_rotation.cc index 09badf97d3..ebef0b5ed9 100644 --- a/src/libcode/vx_grid/earth_rotation.cc +++ b/src/libcode/vx_grid/earth_rotation.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "latlon_xyz.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/find_grid_by_name.cc b/src/libcode/vx_grid/find_grid_by_name.cc index 30fda12c24..7486ac5257 100644 --- a/src/libcode/vx_grid/find_grid_by_name.cc +++ b/src/libcode/vx_grid/find_grid_by_name.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "find_grid_by_name.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/gaussian_grid.cc b/src/libcode/vx_grid/gaussian_grid.cc index eccea8d55b..03ac5bddf7 100644 --- a/src/libcode/vx_grid/gaussian_grid.cc +++ b/src/libcode/vx_grid/gaussian_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "gaussian_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/goes_grid.cc b/src/libcode/vx_grid/goes_grid.cc index 76c8f5e51d..01e172c5de 100644 --- a/src/libcode/vx_grid/goes_grid.cc +++ b/src/libcode/vx_grid/goes_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "goes_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/grid_base.cc b/src/libcode/vx_grid/grid_base.cc index d3b0cfee26..cb9ef2d296 100644 --- a/src/libcode/vx_grid/grid_base.cc +++ b/src/libcode/vx_grid/grid_base.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +22,9 @@ using namespace std; #include "find_grid_by_name.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/latlon_grid.cc b/src/libcode/vx_grid/latlon_grid.cc index 4b9920d5e7..f04c375aa3 100644 --- a/src/libcode/vx_grid/latlon_grid.cc +++ b/src/libcode/vx_grid/latlon_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "latlon_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/latlon_xyz.cc b/src/libcode/vx_grid/latlon_xyz.cc index 768955f24e..5c173db80c 100644 --- a/src/libcode/vx_grid/latlon_xyz.cc +++ b/src/libcode/vx_grid/latlon_xyz.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +22,9 @@ using namespace std; #include "latlon_xyz.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/lc_grid.cc b/src/libcode/vx_grid/lc_grid.cc index 7049f60d94..10fd4502b4 100644 --- a/src/libcode/vx_grid/lc_grid.cc +++ b/src/libcode/vx_grid/lc_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "lc_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/merc_grid.cc b/src/libcode/vx_grid/merc_grid.cc index 015109db2c..b740c124ab 100644 --- a/src/libcode/vx_grid/merc_grid.cc +++ b/src/libcode/vx_grid/merc_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "merc_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/rot_latlon_grid.cc b/src/libcode/vx_grid/rot_latlon_grid.cc index a5df5a3bfc..5756cef893 100644 --- a/src/libcode/vx_grid/rot_latlon_grid.cc +++ b/src/libcode/vx_grid/rot_latlon_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "latlon_xyz.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/semilatlon_grid.cc b/src/libcode/vx_grid/semilatlon_grid.cc index c188025882..86503235f0 100644 --- a/src/libcode/vx_grid/semilatlon_grid.cc +++ b/src/libcode/vx_grid/semilatlon_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "semilatlon_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/st_grid.cc b/src/libcode/vx_grid/st_grid.cc index c1299471e6..533ac1e755 100644 --- a/src/libcode/vx_grid/st_grid.cc +++ b/src/libcode/vx_grid/st_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -26,6 +23,9 @@ using namespace std; #include "st_grid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/tcrmw_grid.cc b/src/libcode/vx_grid/tcrmw_grid.cc index 031c71c65e..e40572bc7d 100644 --- a/src/libcode/vx_grid/tcrmw_grid.cc +++ b/src/libcode/vx_grid/tcrmw_grid.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "trig.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gsl_prob/gsl_bvn.cc b/src/libcode/vx_gsl_prob/gsl_bvn.cc index 1cbb1b950c..988c169b4f 100644 --- a/src/libcode/vx_gsl_prob/gsl_bvn.cc +++ b/src/libcode/vx_gsl_prob/gsl_bvn.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -18,6 +16,8 @@ using namespace std; #include "gsl_bvn.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static const double cf = 45.0/atan(1.0); diff --git a/src/libcode/vx_gsl_prob/gsl_cdf.cc b/src/libcode/vx_gsl_prob/gsl_cdf.cc index efd4a22a1a..79459b5c11 100644 --- a/src/libcode/vx_gsl_prob/gsl_cdf.cc +++ b/src/libcode/vx_gsl_prob/gsl_cdf.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "gsl/gsl_randist.h" #include "is_bad_data.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static double F_newton(double x, double y, double deg_freedom_1, double deg_freedom_2); diff --git a/src/libcode/vx_gsl_prob/gsl_randist.cc b/src/libcode/vx_gsl_prob/gsl_randist.cc index 685fb63973..e8a528a598 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.cc +++ b/src/libcode/vx_gsl_prob/gsl_randist.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "gsl_randist.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static int get_seed(); diff --git a/src/libcode/vx_gsl_prob/gsl_statistics.cc b/src/libcode/vx_gsl_prob/gsl_statistics.cc index 2f1ac4afcc..20d5136cbc 100644 --- a/src/libcode/vx_gsl_prob/gsl_statistics.cc +++ b/src/libcode/vx_gsl_prob/gsl_statistics.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "gsl_statistics.h" #include "gsl/gsl_errno.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// double stats_lag1_autocorrelation(const NumArray &na) { diff --git a/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc b/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc index fe5ad84188..c1b0a1dcc9 100644 --- a/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc +++ b/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "vx_log.h" #include "gsl_wavelet2d.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Allocate a wavelet of the type specified using the wavelet member diff --git a/src/libcode/vx_nav/nav.cc b/src/libcode/vx_nav/nav.cc index 8b81e679e8..9a48b7eae5 100644 --- a/src/libcode/vx_nav/nav.cc +++ b/src/libcode/vx_nav/nav.cc @@ -7,9 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; - - ////////////////////////////////////////////////////////////////// @@ -20,6 +17,9 @@ using namespace std; #include "nav.h" +using namespace std; + + ////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_obs/met_point_data.cc b/src/libcode/vx_nc_obs/met_point_data.cc index 0312f97800..cc4f15fd7e 100644 --- a/src/libcode/vx_nc_obs/met_point_data.cc +++ b/src/libcode/vx_nc_obs/met_point_data.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,7 +22,9 @@ using namespace std; #include "is_bad_data.h" #include "met_point_data.h" -//#include "nc_point_obs.h" + +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_obs/nc_obs_util.cc b/src/libcode/vx_nc_obs/nc_obs_util.cc index 18153beaeb..0b6fa731e3 100644 --- a/src/libcode/vx_nc_obs/nc_obs_util.cc +++ b/src/libcode/vx_nc_obs/nc_obs_util.cc @@ -14,17 +14,19 @@ // Common routines for time summary (into NetCDF). // -using namespace std; #include #include -using namespace netCDF; #include "vx_nc_util.h" #include "nc_obs_util.h" +using namespace std; +using namespace netCDF; + + /////////////////////////////////////////////////////////////////////////////// float hdr_arr_block[NC_BUFFER_SIZE_32K][HDR_ARRAY_LEN]; diff --git a/src/libcode/vx_nc_obs/nc_point_obs.cc b/src/libcode/vx_nc_obs/nc_point_obs.cc index 33e1dfa85b..3584ef88fa 100644 --- a/src/libcode/vx_nc_obs/nc_point_obs.cc +++ b/src/libcode/vx_nc_obs/nc_point_obs.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,13 +19,16 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_log.h" #include "is_bad_data.h" #include "nc_point_obs.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_obs/nc_point_obs_in.cc b/src/libcode/vx_nc_obs/nc_point_obs_in.cc index e669fd6427..57b5d3eea4 100644 --- a/src/libcode/vx_nc_obs/nc_point_obs_in.cc +++ b/src/libcode/vx_nc_obs/nc_point_obs_in.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,9 @@ using namespace std; #include "nc_point_obs_in.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_obs/nc_point_obs_out.cc b/src/libcode/vx_nc_obs/nc_point_obs_out.cc index 5ae87e971b..8835665721 100644 --- a/src/libcode/vx_nc_obs/nc_point_obs_out.cc +++ b/src/libcode/vx_nc_obs/nc_point_obs_out.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,9 @@ using namespace std; #include "nc_summary.h" #include "write_netcdf.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_obs/nc_summary.cc b/src/libcode/vx_nc_obs/nc_summary.cc index b022226958..ced5365427 100644 --- a/src/libcode/vx_nc_obs/nc_summary.cc +++ b/src/libcode/vx_nc_obs/nc_summary.cc @@ -14,18 +14,20 @@ // Common routines for time summary (into NetCDF). // -using namespace std; #include #include -using namespace netCDF; #include "write_netcdf.h" #include "nc_obs_util.h" #include "vx_summary.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// string seconds_to_time_string(const int secs) diff --git a/src/libcode/vx_nc_util/grid_output.cc b/src/libcode/vx_nc_util/grid_output.cc index 079d376844..4a9889f677 100644 --- a/src/libcode/vx_nc_util/grid_output.cc +++ b/src/libcode/vx_nc_util/grid_output.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,12 +18,14 @@ using namespace std; #include #include -using namespace netCDF; #include "grid_output.h" #include "vx_log.h" #include "nc_utils.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_util/load_tc_data.cc b/src/libcode/vx_nc_util/load_tc_data.cc index 91eff09214..572e5e1c4e 100644 --- a/src/libcode/vx_nc_util/load_tc_data.cc +++ b/src/libcode/vx_nc_util/load_tc_data.cc @@ -8,14 +8,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "vx_data2d_nc_met.h" #include "vx_nc_util.h" #include "load_tc_data.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// void load_tc_dland(const ConcatString &dland_file, Grid &grid, diff --git a/src/libcode/vx_nc_util/nc_var_info.cc b/src/libcode/vx_nc_util/nc_var_info.cc index 4d23e8e65b..0c1dfde6ee 100644 --- a/src/libcode/vx_nc_util/nc_var_info.cc +++ b/src/libcode/vx_nc_util/nc_var_info.cc @@ -10,10 +10,7 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include -using namespace netCDF; #include #include @@ -26,6 +23,10 @@ using namespace netCDF; #include "vx_log.h" #include "vx_cal.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// unixtime get_att_value_unixtime(const NcAtt *att) { diff --git a/src/libcode/vx_pb_util/do_blocking.cc b/src/libcode/vx_pb_util/do_blocking.cc index a43b33a768..02c81c5dfe 100644 --- a/src/libcode/vx_pb_util/do_blocking.cc +++ b/src/libcode/vx_pb_util/do_blocking.cc @@ -11,8 +11,6 @@ ////////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,8 @@ using namespace std; #include "copy_bytes.h" #include "do_blocking.h" +using namespace std; + ////////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pb_util/do_unblocking.cc b/src/libcode/vx_pb_util/do_unblocking.cc index 31e07e2631..9822693d73 100644 --- a/src/libcode/vx_pb_util/do_unblocking.cc +++ b/src/libcode/vx_pb_util/do_unblocking.cc @@ -11,8 +11,6 @@ ////////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "copy_bytes.h" #include "do_unblocking.h" +using namespace std; + ////////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pb_util/pblock.cc b/src/libcode/vx_pb_util/pblock.cc index 5ddf837fdd..0626c0ac39 100644 --- a/src/libcode/vx_pb_util/pblock.cc +++ b/src/libcode/vx_pb_util/pblock.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,9 @@ using namespace std; #include "do_blocking.h" #include "do_unblocking.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// void pblock(const char *infile, const char *outfile, Action action) { diff --git a/src/libcode/vx_plot_util/data_plane_plot.cc b/src/libcode/vx_plot_util/data_plane_plot.cc index 7849c93031..4a03211289 100644 --- a/src/libcode/vx_plot_util/data_plane_plot.cc +++ b/src/libcode/vx_plot_util/data_plane_plot.cc @@ -9,19 +9,6 @@ /////////////////////////////////////////////////////////////////////////////// -static const int num_cbar_vals = 300; - -static const double one_inch = 72.0; - -static const int num_ticks = 9; - -static const bool use_flate = true; - - -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; - /////////////////////////////////////////////////////////////////////////////// // // Filename: data_plane_plot.cc @@ -48,8 +35,20 @@ using namespace std; #include "vx_log.h" #include "data_plane_plot.h" +using namespace std; + //////////////////////////////////////////////////////////////////////////////// +static const int num_cbar_vals = 300; + +static const double one_inch = 72.0; + +static const int num_ticks = 9; + +static const bool use_flate = true; + +/////////////////////////////////////////////////////////////////////////////// + void data_plane_plot(const ConcatString & inname, const ConcatString & outname, const Grid & grid, const ConcatString & title, const ColorTable & colortable, MetConfig *conf, diff --git a/src/libcode/vx_plot_util/map_region.cc b/src/libcode/vx_plot_util/map_region.cc index daa54185e6..23fb3758b5 100644 --- a/src/libcode/vx_plot_util/map_region.cc +++ b/src/libcode/vx_plot_util/map_region.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "vx_log.h" #include "map_region.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_plot_util/vx_plot_util.cc b/src/libcode/vx_plot_util/vx_plot_util.cc index abf4e4be7c..e156134a51 100644 --- a/src/libcode/vx_plot_util/vx_plot_util.cc +++ b/src/libcode/vx_plot_util/vx_plot_util.cc @@ -8,8 +8,6 @@ /////////////////////////////////////////////////////////////////////////////// -using namespace std; - // // ach_plotting_pkg.cc // @@ -28,6 +26,9 @@ using namespace std; #include "vx_log.h" #include "vx_plot_util.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////////////// // // Draw a map in a PostScript file. diff --git a/src/libcode/vx_pointdata_python/pointdata_python.cc b/src/libcode/vx_pointdata_python/pointdata_python.cc index fdb1cb34a3..82562d7583 100644 --- a/src/libcode/vx_pointdata_python/pointdata_python.cc +++ b/src/libcode/vx_pointdata_python/pointdata_python.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/documentmedia_to_string.cc b/src/libcode/vx_ps/documentmedia_to_string.cc index d64d6b9123..351376cd72 100644 --- a/src/libcode/vx_ps/documentmedia_to_string.cc +++ b/src/libcode/vx_ps/documentmedia_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "documentmedia_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/documentorientation_to_string.cc b/src/libcode/vx_ps/documentorientation_to_string.cc index e98342f078..dc04b5b7f0 100644 --- a/src/libcode/vx_ps/documentorientation_to_string.cc +++ b/src/libcode/vx_ps/documentorientation_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "documentorientation_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/fontfamily_to_string.cc b/src/libcode/vx_ps/fontfamily_to_string.cc index 4540a5afc9..d38489c800 100644 --- a/src/libcode/vx_ps/fontfamily_to_string.cc +++ b/src/libcode/vx_ps/fontfamily_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "fontfamily_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/ps_text.cc b/src/libcode/vx_ps/ps_text.cc index f4438e208b..5459a41add 100644 --- a/src/libcode/vx_ps/ps_text.cc +++ b/src/libcode/vx_ps/ps_text.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "ps_text.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/table_helper.cc b/src/libcode/vx_ps/table_helper.cc index 9e1eee2f87..4862b9c9dd 100644 --- a/src/libcode/vx_ps/table_helper.cc +++ b/src/libcode/vx_ps/table_helper.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "table_helper.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/vx_ps.cc b/src/libcode/vx_ps/vx_ps.cc index 5462b63737..5e202631df 100644 --- a/src/libcode/vx_ps/vx_ps.cc +++ b/src/libcode/vx_ps/vx_ps.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -36,6 +33,8 @@ using namespace std; #include "ascii85_filter.h" #include "psout_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// From 3f92f6a81ff5a13c456bf817b1d7533b13eaac1d Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 1 Mar 2024 15:45:56 +0000 Subject: [PATCH 020/114] #2673 Moved down 'using namespace' statement. --- src/libcode/vx_pxm/pbm.cc | 5 ++-- src/libcode/vx_pxm/pcm.cc | 4 ++-- src/libcode/vx_pxm/pgm.cc | 4 ++-- src/libcode/vx_pxm/ppm.cc | 4 ++-- src/libcode/vx_pxm/pxm_base.cc | 5 ++-- src/libcode/vx_pxm/pxm_utils.cc | 5 ++-- src/libcode/vx_python3_utils/python3_dict.cc | 8 ++----- src/libcode/vx_python3_utils/python3_list.cc | 8 ++----- src/libcode/vx_python3_utils/python3_numpy.cc | 12 +++++++--- .../vx_python3_utils/python3_script.cc | 12 +++++++--- src/libcode/vx_python3_utils/python3_util.cc | 5 ++-- src/libcode/vx_python3_utils/wchar_argv.cc | 4 ++-- src/libcode/vx_regrid/vx_regrid.cc | 4 ++-- src/libcode/vx_render/ascii85_filter.cc | 4 ++-- src/libcode/vx_render/bit_filter.cc | 4 ++-- src/libcode/vx_render/flate_filter.cc | 4 ++-- src/libcode/vx_render/ps_filter.cc | 4 ++-- src/libcode/vx_render/psout_filter.cc | 4 ++-- src/libcode/vx_render/render_pbm.cc | 4 ++-- src/libcode/vx_render/render_pcm.cc | 4 ++-- src/libcode/vx_render/render_pgm.cc | 4 ++-- src/libcode/vx_render/render_ppm.cc | 4 ++-- src/libcode/vx_render/renderinfo.cc | 4 ++-- src/libcode/vx_render/rle_filter.cc | 4 ++-- src/libcode/vx_render/uc_queue.cc | 4 ++-- src/libcode/vx_seeps/seeps.cc | 14 ++++++++--- src/libcode/vx_series_data/series_data.cc | 4 ++-- src/libcode/vx_series_data/series_pdf.cc | 6 +++-- src/libcode/vx_shapedata/engine.cc | 4 ++-- src/libcode/vx_shapedata/ihull.cc | 11 +++++++-- src/libcode/vx_shapedata/interest.cc | 4 ++-- src/libcode/vx_shapedata/mode_conf_info.cc | 4 ++-- src/libcode/vx_shapedata/moments.cc | 4 ++-- src/libcode/vx_shapedata/set.cc | 4 ++-- src/libcode/vx_shapedata/shapedata.cc | 23 ++++++++++--------- src/libcode/vx_solar/siderial.cc | 5 ++-- src/libcode/vx_solar/solar.cc | 5 ++-- src/libcode/vx_stat_out/stat_columns.cc | 4 ++-- src/libcode/vx_stat_out/stat_hdr_columns.cc | 4 ++-- src/libcode/vx_statistics/apply_mask.cc | 4 ++-- src/libcode/vx_statistics/compute_ci.cc | 4 ++-- src/libcode/vx_statistics/compute_stats.cc | 4 ++-- src/libcode/vx_statistics/contable.cc | 5 ++-- src/libcode/vx_statistics/contable_nx2.cc | 17 +++++++------- src/libcode/vx_statistics/contable_stats.cc | 4 ++-- src/libcode/vx_statistics/ens_stats.cc | 4 ++-- src/libcode/vx_statistics/grid_closed_poly.cc | 4 ++-- src/libcode/vx_statistics/met_stats.cc | 4 ++-- src/libcode/vx_statistics/obs_error.cc | 4 ++-- src/libcode/vx_statistics/pair_base.cc | 4 ++-- .../vx_statistics/pair_data_ensemble.cc | 2 +- src/libcode/vx_statistics/pair_data_point.cc | 4 ++-- src/libcode/vx_statistics/read_climo.cc | 4 ++-- src/libcode/vx_tc_util/atcf_line_base.cc | 4 ++-- src/libcode/vx_tc_util/atcf_prob_line.cc | 4 ++-- src/libcode/vx_tc_util/atcf_track_line.cc | 4 ++-- src/libcode/vx_tc_util/diag_file.cc | 4 ++-- src/libcode/vx_tc_util/gen_shape_info.cc | 4 ++-- src/libcode/vx_tc_util/genesis_info.cc | 4 ++-- src/libcode/vx_tc_util/pair_data_genesis.cc | 4 ++-- src/libcode/vx_tc_util/prob_gen_info.cc | 4 ++-- src/libcode/vx_tc_util/prob_info_array.cc | 4 ++-- src/libcode/vx_tc_util/prob_info_base.cc | 5 ++-- src/libcode/vx_tc_util/prob_rirw_info.cc | 4 ++-- src/libcode/vx_tc_util/prob_rirw_pair_info.cc | 4 ++-- src/libcode/vx_tc_util/tc_columns.cc | 4 ++-- src/libcode/vx_tc_util/tc_hdr_columns.cc | 4 ++-- src/libcode/vx_tc_util/tc_stat_line.cc | 4 ++-- src/libcode/vx_tc_util/track_info.cc | 4 ++-- src/libcode/vx_tc_util/track_pair_info.cc | 4 ++-- src/libcode/vx_tc_util/track_point.cc | 4 ++-- src/libcode/vx_tc_util/vx_tc_nc_util.cc | 5 ++-- .../vx_time_series/compute_swinging_door.cc | 4 ++-- .../vx_time_series/time_series_util.cc | 4 ++-- 74 files changed, 197 insertions(+), 181 deletions(-) diff --git a/src/libcode/vx_pxm/pbm.cc b/src/libcode/vx_pxm/pbm.cc index 8931af17b3..1b81a1203f 100644 --- a/src/libcode/vx_pxm/pbm.cc +++ b/src/libcode/vx_pxm/pbm.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,8 @@ using namespace std; #include "pbm.h" #include "pxm_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/pcm.cc b/src/libcode/vx_pxm/pcm.cc index f1107ccf20..cf3b4b8f3f 100644 --- a/src/libcode/vx_pxm/pcm.cc +++ b/src/libcode/vx_pxm/pcm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/pgm.cc b/src/libcode/vx_pxm/pgm.cc index a38d4fd4e1..d7d67a9095 100644 --- a/src/libcode/vx_pxm/pgm.cc +++ b/src/libcode/vx_pxm/pgm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/ppm.cc b/src/libcode/vx_pxm/ppm.cc index 27cf265eb3..6bc0219e2a 100644 --- a/src/libcode/vx_pxm/ppm.cc +++ b/src/libcode/vx_pxm/ppm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/pxm_base.cc b/src/libcode/vx_pxm/pxm_base.cc index bc52724b35..507dd54806 100644 --- a/src/libcode/vx_pxm/pxm_base.cc +++ b/src/libcode/vx_pxm/pxm_base.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +22,8 @@ using namespace std; #include "vx_log.h" #include "check_endian.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/pxm_utils.cc b/src/libcode/vx_pxm/pxm_utils.cc index 8d496b8082..bcea27eeda 100644 --- a/src/libcode/vx_pxm/pxm_utils.cc +++ b/src/libcode/vx_pxm/pxm_utils.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -23,6 +20,8 @@ using namespace std; #include "pxm_base.h" #include "pxm_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_dict.cc b/src/libcode/vx_python3_utils/python3_dict.cc index f623166a14..dc7a6f4272 100644 --- a/src/libcode/vx_python3_utils/python3_dict.cc +++ b/src/libcode/vx_python3_utils/python3_dict.cc @@ -9,12 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - -//////////////////////////////////////////////////////////////////////// - - #include #include "vx_log.h" @@ -22,6 +16,8 @@ using namespace std; #include "python3_dict.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_list.cc b/src/libcode/vx_python3_utils/python3_list.cc index 51b9c3078a..780ac1f08d 100644 --- a/src/libcode/vx_python3_utils/python3_list.cc +++ b/src/libcode/vx_python3_utils/python3_list.cc @@ -9,12 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - -//////////////////////////////////////////////////////////////////////// - - #include #include "vx_log.h" @@ -22,6 +16,8 @@ using namespace std; #include "python3_list.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_numpy.cc b/src/libcode/vx_python3_utils/python3_numpy.cc index 961bcd0bfb..7a2b27869a 100644 --- a/src/libcode/vx_python3_utils/python3_numpy.cc +++ b/src/libcode/vx_python3_utils/python3_numpy.cc @@ -1,11 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -17,6 +21,8 @@ using namespace std; #include "python3_numpy.h" #include "python3_util.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_script.cc b/src/libcode/vx_python3_utils/python3_script.cc index 34fc038d71..6369354e68 100644 --- a/src/libcode/vx_python3_utils/python3_script.cc +++ b/src/libcode/vx_python3_utils/python3_script.cc @@ -1,11 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -20,6 +24,8 @@ using namespace std; #include "global_python.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_util.cc b/src/libcode/vx_python3_utils/python3_util.cc index 7c648edc88..2227eb8ffc 100644 --- a/src/libcode/vx_python3_utils/python3_util.cc +++ b/src/libcode/vx_python3_utils/python3_util.cc @@ -3,9 +3,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -17,6 +14,8 @@ using namespace std; #include "python3_util.h" #include "global_python.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/wchar_argv.cc b/src/libcode/vx_python3_utils/wchar_argv.cc index 46c5999106..a51eea0675 100644 --- a/src/libcode/vx_python3_utils/wchar_argv.cc +++ b/src/libcode/vx_python3_utils/wchar_argv.cc @@ -13,8 +13,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_regrid/vx_regrid.cc b/src/libcode/vx_regrid/vx_regrid.cc index 95063ac17c..2a22fe38ae 100644 --- a/src/libcode/vx_regrid/vx_regrid.cc +++ b/src/libcode/vx_regrid/vx_regrid.cc @@ -11,14 +11,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "vx_regrid.h" #include "interp_mthd.h" #include "GridTemplate.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/ascii85_filter.cc b/src/libcode/vx_render/ascii85_filter.cc index a0d42aadc6..6947aa92fb 100644 --- a/src/libcode/vx_render/ascii85_filter.cc +++ b/src/libcode/vx_render/ascii85_filter.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "ascii85_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/bit_filter.cc b/src/libcode/vx_render/bit_filter.cc index a9e260ddb4..6436a6d1f7 100644 --- a/src/libcode/vx_render/bit_filter.cc +++ b/src/libcode/vx_render/bit_filter.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "bit_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/flate_filter.cc b/src/libcode/vx_render/flate_filter.cc index b9298bc00a..9bf27bc536 100644 --- a/src/libcode/vx_render/flate_filter.cc +++ b/src/libcode/vx_render/flate_filter.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "vx_log.h" #include "flate_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/ps_filter.cc b/src/libcode/vx_render/ps_filter.cc index bfaade4aa9..ef84f22d3c 100644 --- a/src/libcode/vx_render/ps_filter.cc +++ b/src/libcode/vx_render/ps_filter.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "empty_string.h" #include "ps_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/psout_filter.cc b/src/libcode/vx_render/psout_filter.cc index 02e2693fc6..d9702a133e 100644 --- a/src/libcode/vx_render/psout_filter.cc +++ b/src/libcode/vx_render/psout_filter.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "psout_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/render_pbm.cc b/src/libcode/vx_render/render_pbm.cc index 988fa1d3ce..0321a4a6e2 100644 --- a/src/libcode/vx_render/render_pbm.cc +++ b/src/libcode/vx_render/render_pbm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "vx_render.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/render_pcm.cc b/src/libcode/vx_render/render_pcm.cc index 04e99f0414..1727ea965b 100644 --- a/src/libcode/vx_render/render_pcm.cc +++ b/src/libcode/vx_render/render_pcm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "vx_render.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/render_pgm.cc b/src/libcode/vx_render/render_pgm.cc index 11d0d6801e..b4c4128741 100644 --- a/src/libcode/vx_render/render_pgm.cc +++ b/src/libcode/vx_render/render_pgm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "vx_render.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/render_ppm.cc b/src/libcode/vx_render/render_ppm.cc index 15d4c2200f..17c602b4be 100644 --- a/src/libcode/vx_render/render_ppm.cc +++ b/src/libcode/vx_render/render_ppm.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "vx_render.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/renderinfo.cc b/src/libcode/vx_render/renderinfo.cc index 58912de6f6..5a9dc52963 100644 --- a/src/libcode/vx_render/renderinfo.cc +++ b/src/libcode/vx_render/renderinfo.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "renderinfo.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/rle_filter.cc b/src/libcode/vx_render/rle_filter.cc index 93cd826c4b..bb4cb3f876 100644 --- a/src/libcode/vx_render/rle_filter.cc +++ b/src/libcode/vx_render/rle_filter.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "rle_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/uc_queue.cc b/src/libcode/vx_render/uc_queue.cc index ef6fadfaf5..0eb1aab7a7 100644 --- a/src/libcode/vx_render/uc_queue.cc +++ b/src/libcode/vx_render/uc_queue.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "uc_queue.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_seeps/seeps.cc b/src/libcode/vx_seeps/seeps.cc index 103bb6e172..7df9d82cf9 100644 --- a/src/libcode/vx_seeps/seeps.cc +++ b/src/libcode/vx_seeps/seeps.cc @@ -1,10 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -14,7 +19,6 @@ using namespace std; #include #include -using namespace netCDF; #include "file_exists.h" @@ -23,6 +27,10 @@ using namespace netCDF; #include "nc_utils.h" #include "seeps.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// bool standalone_debug_seeps = false; diff --git a/src/libcode/vx_series_data/series_data.cc b/src/libcode/vx_series_data/series_data.cc index 03b227b0f2..204b10f06e 100644 --- a/src/libcode/vx_series_data/series_data.cc +++ b/src/libcode/vx_series_data/series_data.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "series_data.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static bool read_single_entry(VarInfo*, const ConcatString&, const GrdFileType, diff --git a/src/libcode/vx_series_data/series_pdf.cc b/src/libcode/vx_series_data/series_pdf.cc index 2bce87efdf..f9d9765a35 100644 --- a/src/libcode/vx_series_data/series_pdf.cc +++ b/src/libcode/vx_series_data/series_pdf.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -19,10 +18,13 @@ using namespace std; #include #include -using namespace netCDF; #include "series_pdf.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// void init_pdf( diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index c393610c2f..e5da257536 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -8,8 +8,6 @@ /////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "mode_columns.h" #include "vx_util.h" +using namespace std; + /////////////////////////////////////////////////////////////////////// static const int print_interest_log_level = 5; diff --git a/src/libcode/vx_shapedata/ihull.cc b/src/libcode/vx_shapedata/ihull.cc index 59208964ed..74700ddcc6 100644 --- a/src/libcode/vx_shapedata/ihull.cc +++ b/src/libcode/vx_shapedata/ihull.cc @@ -1,10 +1,15 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -13,6 +18,8 @@ using namespace std; #include "ihull.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_shapedata/interest.cc b/src/libcode/vx_shapedata/interest.cc index d33d32e426..fcb39f2042 100644 --- a/src/libcode/vx_shapedata/interest.cc +++ b/src/libcode/vx_shapedata/interest.cc @@ -21,8 +21,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "interest.h" #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static void get_percentiles(DistributionPercentiles &, diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index 5852d9f51e..6e9ed75e26 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "vx_data2d_factory.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static const char default_multivar_name[] = "Super"; diff --git a/src/libcode/vx_shapedata/moments.cc b/src/libcode/vx_shapedata/moments.cc index d744871929..48ad425c2b 100644 --- a/src/libcode/vx_shapedata/moments.cc +++ b/src/libcode/vx_shapedata/moments.cc @@ -21,8 +21,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -31,6 +29,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // diff --git a/src/libcode/vx_shapedata/set.cc b/src/libcode/vx_shapedata/set.cc index c62637c69e..ed4d7b1604 100644 --- a/src/libcode/vx_shapedata/set.cc +++ b/src/libcode/vx_shapedata/set.cc @@ -19,8 +19,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "set.h" #include "vx_log.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class FcstObsSet diff --git a/src/libcode/vx_shapedata/shapedata.cc b/src/libcode/vx_shapedata/shapedata.cc index bc7332bc94..c968c51f34 100644 --- a/src/libcode/vx_shapedata/shapedata.cc +++ b/src/libcode/vx_shapedata/shapedata.cc @@ -22,17 +22,6 @@ /////////////////////////////////////////////////////////////////////////////// -static const bool use_new = true; - -static const int split_enlarge = 4; // used for ShapeData shrink and expand - -static const bool do_split_fatten = true; - - -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; - #include #include #include @@ -52,6 +41,18 @@ using namespace std; #include "ihull.h" +using namespace std; + + +/////////////////////////////////////////////////////////////////////////////// + + +static const bool use_new = true; + +static const int split_enlarge = 4; // used for ShapeData shrink and expand + +static const bool do_split_fatten = true; + /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_solar/siderial.cc b/src/libcode/vx_solar/siderial.cc index 9424772245..fd2f4fcb95 100644 --- a/src/libcode/vx_solar/siderial.cc +++ b/src/libcode/vx_solar/siderial.cc @@ -9,9 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -20,6 +17,8 @@ using namespace std; #include "siderial.h" #include "astro_constants.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_solar/solar.cc b/src/libcode/vx_solar/solar.cc index 4b8568b4fc..2d6f6a5280 100644 --- a/src/libcode/vx_solar/solar.cc +++ b/src/libcode/vx_solar/solar.cc @@ -9,9 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -21,6 +18,8 @@ using namespace std; #include "solar.h" #include "astro_constants.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 034c3c1961..5df2b6191b 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// const bool use_weighted_seeps = false; diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.cc b/src/libcode/vx_stat_out/stat_hdr_columns.cc index 4304e87e9f..f832b20c02 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.cc +++ b/src/libcode/vx_stat_out/stat_hdr_columns.cc @@ -8,13 +8,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include "stat_hdr_columns.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // diff --git a/src/libcode/vx_statistics/apply_mask.cc b/src/libcode/vx_statistics/apply_mask.cc index 010c091825..a69f3ff2e5 100644 --- a/src/libcode/vx_statistics/apply_mask.cc +++ b/src/libcode/vx_statistics/apply_mask.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static void process_poly_mask(const ConcatString &, const Grid &, diff --git a/src/libcode/vx_statistics/compute_ci.cc b/src/libcode/vx_statistics/compute_ci.cc index e4a9aabae7..a02fcf6e5a 100644 --- a/src/libcode/vx_statistics/compute_ci.cc +++ b/src/libcode/vx_statistics/compute_ci.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static void write_cntinfo(ofstream &, const CNTInfo &); diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index 3c95557c80..e4fe518558 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// const int detailed_debug_level = 5; diff --git a/src/libcode/vx_statistics/contable.cc b/src/libcode/vx_statistics/contable.cc index d01c264fb3..d70405d74a 100644 --- a/src/libcode/vx_statistics/contable.cc +++ b/src/libcode/vx_statistics/contable.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -27,6 +24,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/contable_nx2.cc b/src/libcode/vx_statistics/contable_nx2.cc index 5bb9e1cbae..8611a2d346 100644 --- a/src/libcode/vx_statistics/contable_nx2.cc +++ b/src/libcode/vx_statistics/contable_nx2.cc @@ -11,15 +11,6 @@ //////////////////////////////////////////////////////////////////////// -static const int use_center = 1; - - -//////////////////////////////////////////////////////////////////////// - - -using namespace std; - - #include #include #include @@ -33,6 +24,14 @@ using namespace std; #include "vx_log.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + + +static const int use_center = 1; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/contable_stats.cc b/src/libcode/vx_statistics/contable_stats.cc index f103284ee0..177824c454 100644 --- a/src/libcode/vx_statistics/contable_stats.cc +++ b/src/libcode/vx_statistics/contable_stats.cc @@ -6,8 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "vx_gsl_prob.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for stats for 2x2 contingency tables diff --git a/src/libcode/vx_statistics/ens_stats.cc b/src/libcode/vx_statistics/ens_stats.cc index 4aae9e7471..c3cfe46add 100644 --- a/src/libcode/vx_statistics/ens_stats.cc +++ b/src/libcode/vx_statistics/ens_stats.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class SSVARInfo diff --git a/src/libcode/vx_statistics/grid_closed_poly.cc b/src/libcode/vx_statistics/grid_closed_poly.cc index f26c93820e..043a79df09 100644 --- a/src/libcode/vx_statistics/grid_closed_poly.cc +++ b/src/libcode/vx_statistics/grid_closed_poly.cc @@ -19,8 +19,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -34,6 +32,8 @@ using namespace std; #include "vx_util.h" #include "grid_closed_poly.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class GridClosedPoly diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index a33f1adc73..fb9b280c9b 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class CIInfo diff --git a/src/libcode/vx_statistics/obs_error.cc b/src/libcode/vx_statistics/obs_error.cc index 6ccb4a30f5..662fc8d920 100644 --- a/src/libcode/vx_statistics/obs_error.cc +++ b/src/libcode/vx_statistics/obs_error.cc @@ -7,8 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "obs_error.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // Default observation error table file name diff --git a/src/libcode/vx_statistics/pair_base.cc b/src/libcode/vx_statistics/pair_base.cc index 339861ac9b..63be2df330 100644 --- a/src/libcode/vx_statistics/pair_base.cc +++ b/src/libcode/vx_statistics/pair_base.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static bool sort_obs(ob_val_t a, ob_val_t b) { return a.val #include @@ -33,6 +32,7 @@ using namespace std; using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class PairDataEnsemble diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 15aa9133f0..c4a086d407 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,8 @@ using namespace std; #include "vx_math.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class PairDataPoint diff --git a/src/libcode/vx_statistics/read_climo.cc b/src/libcode/vx_statistics/read_climo.cc index 27fe9e5eae..f5ffb53036 100644 --- a/src/libcode/vx_statistics/read_climo.cc +++ b/src/libcode/vx_statistics/read_climo.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_data2d.h" #include "vx_regrid.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static void read_climo_file( diff --git a/src/libcode/vx_tc_util/atcf_line_base.cc b/src/libcode/vx_tc_util/atcf_line_base.cc index 6db2d00651..9136bc5df1 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.cc +++ b/src/libcode/vx_tc_util/atcf_line_base.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "atcf_line_base.h" #include "atcf_offsets.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // Only print the AVN to GFS conversion message once diff --git a/src/libcode/vx_tc_util/atcf_prob_line.cc b/src/libcode/vx_tc_util/atcf_prob_line.cc index 9cc97c4728..f07c0e57ad 100644 --- a/src/libcode/vx_tc_util/atcf_prob_line.cc +++ b/src/libcode/vx_tc_util/atcf_prob_line.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "atcf_prob_line.h" #include "atcf_offsets.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class ATCFProbLine diff --git a/src/libcode/vx_tc_util/atcf_track_line.cc b/src/libcode/vx_tc_util/atcf_track_line.cc index 106a646f88..bd3ad2a5e2 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.cc +++ b/src/libcode/vx_tc_util/atcf_track_line.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "atcf_track_line.h" #include "atcf_offsets.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class ATCFTrackLine diff --git a/src/libcode/vx_tc_util/diag_file.cc b/src/libcode/vx_tc_util/diag_file.cc index 95336c7765..e75db11773 100644 --- a/src/libcode/vx_tc_util/diag_file.cc +++ b/src/libcode/vx_tc_util/diag_file.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "diag_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static const int ships_wdth[] = { diff --git a/src/libcode/vx_tc_util/gen_shape_info.cc b/src/libcode/vx_tc_util/gen_shape_info.cc index cb8698c20e..60f4ccf561 100644 --- a/src/libcode/vx_tc_util/gen_shape_info.cc +++ b/src/libcode/vx_tc_util/gen_shape_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "gen_shape_info.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class GenShapeInfo diff --git a/src/libcode/vx_tc_util/genesis_info.cc b/src/libcode/vx_tc_util/genesis_info.cc index 1382710dde..85da3d3e34 100644 --- a/src/libcode/vx_tc_util/genesis_info.cc +++ b/src/libcode/vx_tc_util/genesis_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "genesis_info.h" #include "vx_config.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for struct GenesisEventInfo diff --git a/src/libcode/vx_tc_util/pair_data_genesis.cc b/src/libcode/vx_tc_util/pair_data_genesis.cc index c5665e318f..103b84a45e 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.cc +++ b/src/libcode/vx_tc_util/pair_data_genesis.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "pair_data_genesis.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for enum GenesisPairCategory diff --git a/src/libcode/vx_tc_util/prob_gen_info.cc b/src/libcode/vx_tc_util/prob_gen_info.cc index c751e3195f..4dbc55a281 100644 --- a/src/libcode/vx_tc_util/prob_gen_info.cc +++ b/src/libcode/vx_tc_util/prob_gen_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "prob_gen_info.h" #include "atcf_offsets.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class ProbGenInfo diff --git a/src/libcode/vx_tc_util/prob_info_array.cc b/src/libcode/vx_tc_util/prob_info_array.cc index c162876567..51f574e6a3 100644 --- a/src/libcode/vx_tc_util/prob_info_array.cc +++ b/src/libcode/vx_tc_util/prob_info_array.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "prob_rirw_info.h" #include "prob_info_array.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class ProbInfoArray diff --git a/src/libcode/vx_tc_util/prob_info_base.cc b/src/libcode/vx_tc_util/prob_info_base.cc index dc9a6cfc76..e967db4ca5 100644 --- a/src/libcode/vx_tc_util/prob_info_base.cc +++ b/src/libcode/vx_tc_util/prob_info_base.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,9 @@ using namespace std; #include "prob_info_base.h" +using namespace std; + +//////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // // Code for class ProbInfoBase diff --git a/src/libcode/vx_tc_util/prob_rirw_info.cc b/src/libcode/vx_tc_util/prob_rirw_info.cc index 4745f18913..8c117063dc 100644 --- a/src/libcode/vx_tc_util/prob_rirw_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "prob_rirw_info.h" #include "atcf_offsets.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class ProbRIRWInfo diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc index 364e754035..dfb293b535 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "prob_rirw_pair_info.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class ProbRIRWPairInfo diff --git a/src/libcode/vx_tc_util/tc_columns.cc b/src/libcode/vx_tc_util/tc_columns.cc index 3e38075aa7..a50397374c 100644 --- a/src/libcode/vx_tc_util/tc_columns.cc +++ b/src/libcode/vx_tc_util/tc_columns.cc @@ -8,8 +8,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +25,8 @@ using namespace std; #include "vx_util.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// void open_tc_txt_file(ofstream *&out, const char *file_name) { diff --git a/src/libcode/vx_tc_util/tc_hdr_columns.cc b/src/libcode/vx_tc_util/tc_hdr_columns.cc index 1cd1ce26ff..3708417560 100644 --- a/src/libcode/vx_tc_util/tc_hdr_columns.cc +++ b/src/libcode/vx_tc_util/tc_hdr_columns.cc @@ -8,13 +8,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include "tc_hdr_columns.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class TcHdrColumns diff --git a/src/libcode/vx_tc_util/tc_stat_line.cc b/src/libcode/vx_tc_util/tc_stat_line.cc index 78bd215196..1542b0e981 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.cc +++ b/src/libcode/vx_tc_util/tc_stat_line.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +25,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class TCStatLine diff --git a/src/libcode/vx_tc_util/track_info.cc b/src/libcode/vx_tc_util/track_info.cc index 379d60faa1..28e3c7e71d 100644 --- a/src/libcode/vx_tc_util/track_info.cc +++ b/src/libcode/vx_tc_util/track_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "math_constants.h" #include "track_info.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class TrackInfo diff --git a/src/libcode/vx_tc_util/track_pair_info.cc b/src/libcode/vx_tc_util/track_pair_info.cc index dd58b42e5f..4fe226dc1f 100644 --- a/src/libcode/vx_tc_util/track_pair_info.cc +++ b/src/libcode/vx_tc_util/track_pair_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "track_pair_info.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class TrackPairInfo diff --git a/src/libcode/vx_tc_util/track_point.cc b/src/libcode/vx_tc_util/track_point.cc index 1db936322e..6d1232c8c6 100644 --- a/src/libcode/vx_tc_util/track_point.cc +++ b/src/libcode/vx_tc_util/track_point.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "track_point.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class QuadInfo diff --git a/src/libcode/vx_tc_util/vx_tc_nc_util.cc b/src/libcode/vx_tc_util/vx_tc_nc_util.cc index ad4d4403b4..7723787369 100644 --- a/src/libcode/vx_tc_util/vx_tc_nc_util.cc +++ b/src/libcode/vx_tc_util/vx_tc_nc_util.cc @@ -8,13 +8,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include -using namespace netCDF; #include "vx_tc_nc_util.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// void write_tc_track_lines(NcFile* nc_out, diff --git a/src/libcode/vx_time_series/compute_swinging_door.cc b/src/libcode/vx_time_series/compute_swinging_door.cc index 33565dfd01..5e8d04629f 100644 --- a/src/libcode/vx_time_series/compute_swinging_door.cc +++ b/src/libcode/vx_time_series/compute_swinging_door.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "vx_math.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// bool compute_swinging_door_slopes(const TimeArray &valid_times, diff --git a/src/libcode/vx_time_series/time_series_util.cc b/src/libcode/vx_time_series/time_series_util.cc index 184f236d59..57c84436cb 100644 --- a/src/libcode/vx_time_series/time_series_util.cc +++ b/src/libcode/vx_time_series/time_series_util.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "time_series_util.h" #include "compute_swinging_door.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// TimeSeriesType string_to_timeseriestype(const char *s) { From a00c7beaac4e05b5dde3975b10c83d9b1a59761d Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 1 Mar 2024 15:46:25 +0000 Subject: [PATCH 021/114] #2673 Moved down 'using namespace' statement. --- .../ensemble_stat/ensemble_stat_conf_info.cc | 4 ++-- .../core/grid_stat/grid_stat_conf_info.cc | 4 ++-- src/tools/core/mode/cluster_page.cc | 4 ++-- src/tools/core/mode/combine_boolplanes.cc | 4 ++-- src/tools/core/mode/fcst_enlarge_page.cc | 4 ++-- src/tools/core/mode/mode.cc | 4 ++-- src/tools/core/mode/mode_exec.cc | 6 +++--- src/tools/core/mode/mode_frontend.cc | 8 ++++++-- src/tools/core/mode/mode_ps_file.cc | 4 ++-- src/tools/core/mode/mode_superobject.cc | 16 +++++++++++++++- src/tools/core/mode/mode_usage.cc | 4 ++-- src/tools/core/mode/multivar_data.cc | 5 +++-- src/tools/core/mode/multivar_frontend.cc | 5 +++-- src/tools/core/mode/objects_from_netcdf.cc | 8 +------- src/tools/core/mode/obs_enlarge_page.cc | 4 ++-- src/tools/core/mode/overlap_page.cc | 4 ++-- src/tools/core/mode/page_1.cc | 4 ++-- src/tools/core/mode/plot_engine.cc | 4 ++-- src/tools/core/mode_analysis/config_to_att.cc | 6 +++--- src/tools/core/mode_analysis/mode_analysis.cc | 3 ++- .../core/series_analysis/series_analysis.cc | 6 ++++-- .../series_analysis_conf_info.cc | 4 ++-- src/tools/core/stat_analysis/aggr_stat_line.cc | 4 +++- .../core/stat_analysis/parse_stat_line.cc | 4 ++-- .../stat_analysis/skill_score_index_job.cc | 4 ++-- src/tools/core/stat_analysis/stat_analysis.cc | 4 ++-- .../core/stat_analysis/stat_analysis_job.cc | 4 ++-- src/tools/core/wavelet_stat/wavelet_stat.cc | 6 ++++-- .../wavelet_stat/wavelet_stat_conf_info.cc | 4 ++-- src/tools/dev_utils/chk4copyright.cc | 4 ++-- src/tools/dev_utils/gen_climo_bin.cc | 6 ++++-- src/tools/dev_utils/gribtab.dat_to_flat.cc | 4 ++-- src/tools/dev_utils/insitu_nc_file.cc | 6 +++--- src/tools/dev_utils/insitu_nc_to_ascii.cc | 4 ++-- src/tools/dev_utils/met_nc_file.cc | 8 +++----- src/tools/dev_utils/nceptab_to_flat.cc | 18 ++++++++---------- src/tools/dev_utils/pbtime.cc | 4 +++- src/tools/dev_utils/reformat_county_data.cc | 3 ++- src/tools/dev_utils/reformat_map_data.cc | 3 ++- .../dev_utils/shapefiles/make_mapfiles.cc | 4 ++-- src/tools/dev_utils/swinging_door.cc | 4 +++- 41 files changed, 119 insertions(+), 94 deletions(-) diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 8da7df73c6..565653d41c 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +25,8 @@ using namespace std; #include "GridTemplate.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class EnsembleStatConfInfo 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 399913036f..af91816ea4 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_data2d_factory.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class GridStatConfInfo diff --git a/src/tools/core/mode/cluster_page.cc b/src/tools/core/mode/cluster_page.cc index ae25f4ce00..0cc2b31085 100644 --- a/src/tools/core/mode/cluster_page.cc +++ b/src/tools/core/mode/cluster_page.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "mode_ps_table_defs.h" #include "table_helper.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/combine_boolplanes.cc b/src/tools/core/mode/combine_boolplanes.cc index 874d9c4002..111964c94c 100644 --- a/src/tools/core/mode/combine_boolplanes.cc +++ b/src/tools/core/mode/combine_boolplanes.cc @@ -9,12 +9,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "combine_boolplanes.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/fcst_enlarge_page.cc b/src/tools/core/mode/fcst_enlarge_page.cc index 0199e39abf..225ae1fce0 100644 --- a/src/tools/core/mode/fcst_enlarge_page.cc +++ b/src/tools/core/mode/fcst_enlarge_page.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "mode_ps_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/mode.cc b/src/tools/core/mode/mode.cc index 037d2be1a5..dbdcf5a971 100644 --- a/src/tools/core/mode/mode.cc +++ b/src/tools/core/mode/mode.cc @@ -62,8 +62,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -86,6 +84,8 @@ using namespace std; #include "global_python.h" #endif +using namespace std; + /////////////////////////////////////////////////////////////////////// // diff --git a/src/tools/core/mode/mode_exec.cc b/src/tools/core/mode/mode_exec.cc index 9165051a6c..3450bf789f 100644 --- a/src/tools/core/mode/mode_exec.cc +++ b/src/tools/core/mode/mode_exec.cc @@ -10,20 +10,20 @@ /////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include #include #include #include -using namespace netCDF; #include "mode_exec.h" #include "nc_utils.h" #include "vx_regrid.h" +using namespace std; +using namespace netCDF; + /////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/mode_frontend.cc b/src/tools/core/mode/mode_frontend.cc index 43f461e716..9bd8125ead 100644 --- a/src/tools/core/mode/mode_frontend.cc +++ b/src/tools/core/mode/mode_frontend.cc @@ -10,8 +10,6 @@ /////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,12 @@ using namespace std; #include "global_python.h" #endif +using namespace std; + + +/////////////////////////////////////////////////////////////////////// + + extern const char * const program_name; static ModeExecutive *mode_exec = 0; diff --git a/src/tools/core/mode/mode_ps_file.cc b/src/tools/core/mode/mode_ps_file.cc index 2a9c518599..790372f167 100644 --- a/src/tools/core/mode/mode_ps_file.cc +++ b/src/tools/core/mode/mode_ps_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "mode_ps_file.h" #include "vx_plot_util.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/mode_superobject.cc b/src/tools/core/mode/mode_superobject.cc index 27d1c3092f..44c0b4f313 100644 --- a/src/tools/core/mode/mode_superobject.cc +++ b/src/tools/core/mode/mode_superobject.cc @@ -1,7 +1,21 @@ -using namespace std; +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + + +//////////////////////////////////////////////////////////////////////// + + #include "mode_superobject.h" #include "multivar_data.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static void _mask_super(const string &name, int nx, int ny, DataPlane &data) { diff --git a/src/tools/core/mode/mode_usage.cc b/src/tools/core/mode/mode_usage.cc index e6caf8cd3f..fb0b8fdd22 100644 --- a/src/tools/core/mode/mode_usage.cc +++ b/src/tools/core/mode/mode_usage.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "mode_usage.h" @@ -20,6 +18,8 @@ using namespace std; #include "util_constants.h" #include "logger.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/multivar_data.cc b/src/tools/core/mode/multivar_data.cc index 4995983668..3bcfa136f7 100644 --- a/src/tools/core/mode/multivar_data.cc +++ b/src/tools/core/mode/multivar_data.cc @@ -10,8 +10,6 @@ /////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,9 @@ using namespace std; #include "vx_regrid.h" #include "vx_shapedata.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/multivar_frontend.cc b/src/tools/core/mode/multivar_frontend.cc index 7261d04203..b713d12552 100644 --- a/src/tools/core/mode/multivar_frontend.cc +++ b/src/tools/core/mode/multivar_frontend.cc @@ -9,8 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "multivar_frontend.h" #include "mode_usage.h" @@ -19,6 +17,9 @@ using namespace std; #include "global_python.h" #endif +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/objects_from_netcdf.cc b/src/tools/core/mode/objects_from_netcdf.cc index 0821aa3140..9dc6fb4062 100644 --- a/src/tools/core/mode/objects_from_netcdf.cc +++ b/src/tools/core/mode/objects_from_netcdf.cc @@ -10,17 +10,11 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "objects_from_netcdf.h" - -//////////////////////////////////////////////////////////////////////// - - +using namespace std; using namespace netCDF; diff --git a/src/tools/core/mode/obs_enlarge_page.cc b/src/tools/core/mode/obs_enlarge_page.cc index 85a2be7229..fd7fa38db9 100644 --- a/src/tools/core/mode/obs_enlarge_page.cc +++ b/src/tools/core/mode/obs_enlarge_page.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "mode_ps_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/overlap_page.cc b/src/tools/core/mode/overlap_page.cc index 7d1d37fe8c..95578e8eb5 100644 --- a/src/tools/core/mode/overlap_page.cc +++ b/src/tools/core/mode/overlap_page.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "mode_ps_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/page_1.cc b/src/tools/core/mode/page_1.cc index eb6ceb9d0a..5a87e97424 100644 --- a/src/tools/core/mode/page_1.cc +++ b/src/tools/core/mode/page_1.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "mode_ps_table_defs.h" #include "table_helper.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/plot_engine.cc b/src/tools/core/mode/plot_engine.cc index 78ba1954ee..5a92e5643c 100644 --- a/src/tools/core/mode/plot_engine.cc +++ b/src/tools/core/mode/plot_engine.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -19,6 +17,8 @@ using namespace std; #include "mode_ps_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode_analysis/config_to_att.cc b/src/tools/core/mode_analysis/config_to_att.cc index 696e1ae92d..8508d4c43c 100644 --- a/src/tools/core/mode_analysis/config_to_att.cc +++ b/src/tools/core/mode_analysis/config_to_att.cc @@ -25,8 +25,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include @@ -34,10 +32,12 @@ using namespace std; #include #include - #include "config_to_att.h" #include "is_bad_data.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode_analysis/mode_analysis.cc b/src/tools/core/mode_analysis/mode_analysis.cc index 95e1bd43d1..9a4bbf4a28 100644 --- a/src/tools/core/mode_analysis/mode_analysis.cc +++ b/src/tools/core/mode_analysis/mode_analysis.cc @@ -33,7 +33,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -50,6 +49,8 @@ using namespace std; #include "config_to_att.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 223ce9ad65..6282266d78 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -38,7 +38,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -52,7 +51,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "series_analysis.h" @@ -62,6 +60,10 @@ using namespace netCDF; #include "vx_regrid.h" #include "vx_log.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.cc b/src/tools/core/series_analysis/series_analysis_conf_info.cc index 7d22d83643..78eaf2fb19 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.cc +++ b/src/tools/core/series_analysis/series_analysis_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "vx_data2d_factory.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class SeriesAnalysisConfInfo diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 99b5906429..3f402e480d 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -42,7 +42,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -59,6 +58,9 @@ using namespace std; #include "aggr_stat_line.h" #include "parse_stat_line.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static bool is_precip_var_name(const ConcatString &s); diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index 57bc92eb46..eceb835d99 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -36,8 +36,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -50,6 +48,8 @@ using namespace std; #include "parse_stat_line.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// void parse_fho_ctable(STATLine &l, TTContingencyTable &ct) { diff --git a/src/tools/core/stat_analysis/skill_score_index_job.cc b/src/tools/core/stat_analysis/skill_score_index_job.cc index a023cd8dfc..8ae32639e6 100644 --- a/src/tools/core/stat_analysis/skill_score_index_job.cc +++ b/src/tools/core/stat_analysis/skill_score_index_job.cc @@ -18,8 +18,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "skill_score_index_job.h" #include "parse_stat_line.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class SSIndexJobInfo diff --git a/src/tools/core/stat_analysis/stat_analysis.cc b/src/tools/core/stat_analysis/stat_analysis.cc index 912617a213..e5f89feb0f 100644 --- a/src/tools/core/stat_analysis/stat_analysis.cc +++ b/src/tools/core/stat_analysis/stat_analysis.cc @@ -46,8 +46,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -69,6 +67,8 @@ using namespace std; #include "python_line.h" #endif +using namespace std; + //////////////////////////////////////////////////////////////////////// static int using_python = false; diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index dce6d0014f..4df7b60ed7 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -48,8 +48,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -66,6 +64,8 @@ using namespace std; #include "parse_stat_line.h" #include "aggr_stat_line.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// extern bool has_line_type(const vector &, diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index b182a4538d..92de80da60 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -43,7 +43,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -59,7 +58,6 @@ using namespace std; #include #include -using namespace netCDF; #include "wavelet_stat.h" @@ -69,6 +67,10 @@ using namespace netCDF; #include "vx_log.h" #include "vx_plot_util.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index 8a2a896544..f813499b23 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_data2d_factory.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for class WaveletStatConfInfo diff --git a/src/tools/dev_utils/chk4copyright.cc b/src/tools/dev_utils/chk4copyright.cc index e145909d31..b4541b4bf6 100644 --- a/src/tools/dev_utils/chk4copyright.cc +++ b/src/tools/dev_utils/chk4copyright.cc @@ -29,8 +29,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -47,6 +45,8 @@ using namespace std; #include "string_fxns.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/gen_climo_bin.cc b/src/tools/dev_utils/gen_climo_bin.cc index fea08a5d9d..07dbcc3362 100644 --- a/src/tools/dev_utils/gen_climo_bin.cc +++ b/src/tools/dev_utils/gen_climo_bin.cc @@ -19,7 +19,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -33,7 +32,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "vx_util.h" @@ -43,6 +41,10 @@ using namespace netCDF; #include "vx_data2d.h" #include "vx_data2d_factory.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// // // Variables for command line arguments diff --git a/src/tools/dev_utils/gribtab.dat_to_flat.cc b/src/tools/dev_utils/gribtab.dat_to_flat.cc index fbf84434e1..9dc1c766d6 100644 --- a/src/tools/dev_utils/gribtab.dat_to_flat.cc +++ b/src/tools/dev_utils/gribtab.dat_to_flat.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" #include "vx_util.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/insitu_nc_file.cc b/src/tools/dev_utils/insitu_nc_file.cc index 7566eb366f..0da4bd7b73 100644 --- a/src/tools/dev_utils/insitu_nc_file.cc +++ b/src/tools/dev_utils/insitu_nc_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,7 +19,6 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_math.h" #include "vx_cal.h" @@ -30,6 +27,9 @@ using namespace netCDF; #include "insitu_nc_file.h" #include "nc_utils.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/insitu_nc_to_ascii.cc b/src/tools/dev_utils/insitu_nc_to_ascii.cc index d959713037..a7d55d6377 100644 --- a/src/tools/dev_utils/insitu_nc_to_ascii.cc +++ b/src/tools/dev_utils/insitu_nc_to_ascii.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "insitu_nc_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/met_nc_file.cc b/src/tools/dev_utils/met_nc_file.cc index 0389f8e883..deb4ae4ea8 100644 --- a/src/tools/dev_utils/met_nc_file.cc +++ b/src/tools/dev_utils/met_nc_file.cc @@ -7,15 +7,10 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - //////////////////////////////////////////////////////////////////////// -using namespace std; - #include -using namespace netCDF; #include "vx_log.h" #include "vx_math.h" @@ -23,6 +18,9 @@ using namespace netCDF; #include "met_nc_file.h" #include "nc_utils.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/nceptab_to_flat.cc b/src/tools/dev_utils/nceptab_to_flat.cc index ab05cb7698..aeece5178b 100644 --- a/src/tools/dev_utils/nceptab_to_flat.cc +++ b/src/tools/dev_utils/nceptab_to_flat.cc @@ -9,10 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - -//////////////////////////////////////////////////////////////////////// - // // Takes a bunch of C source files from the wgrib code // @@ -25,12 +21,6 @@ using namespace std; //////////////////////////////////////////////////////////////////////// -static const char target_start [] = "const struct"; - - -//////////////////////////////////////////////////////////////////////// - - #include #include #include @@ -41,6 +31,14 @@ static const char target_start [] = "const struct"; #include "vx_log.h" #include "vx_util.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + + +static const char target_start [] = "const struct"; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/pbtime.cc b/src/tools/dev_utils/pbtime.cc index c7d30bc638..98465dffc2 100644 --- a/src/tools/dev_utils/pbtime.cc +++ b/src/tools/dev_utils/pbtime.cc @@ -19,7 +19,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -37,6 +36,9 @@ using namespace std; #include "concat_string.h" #include "temp_file.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // diff --git a/src/tools/dev_utils/reformat_county_data.cc b/src/tools/dev_utils/reformat_county_data.cc index 28ce0be968..65514c3b69 100644 --- a/src/tools/dev_utils/reformat_county_data.cc +++ b/src/tools/dev_utils/reformat_county_data.cc @@ -9,7 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -20,6 +19,8 @@ using namespace std; #include "main.h" #include "vx_util.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/reformat_map_data.cc b/src/tools/dev_utils/reformat_map_data.cc index b1cdcde109..3637c5dcee 100644 --- a/src/tools/dev_utils/reformat_map_data.cc +++ b/src/tools/dev_utils/reformat_map_data.cc @@ -9,7 +9,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -20,6 +19,8 @@ using namespace std; #include "main.h" #include "vx_util.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/shapefiles/make_mapfiles.cc b/src/tools/dev_utils/shapefiles/make_mapfiles.cc index 8a6fa87225..ed83f33a95 100644 --- a/src/tools/dev_utils/shapefiles/make_mapfiles.cc +++ b/src/tools/dev_utils/shapefiles/make_mapfiles.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "shp_poly_record.h" #include "int_array.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/swinging_door.cc b/src/tools/dev_utils/swinging_door.cc index 5feccd043d..844e4fbdf3 100644 --- a/src/tools/dev_utils/swinging_door.cc +++ b/src/tools/dev_utils/swinging_door.cc @@ -23,7 +23,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -47,6 +46,9 @@ using namespace std; #include "met_nc_file.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // Constants From 5706e9733a46870db596456c2b6cf2a033370f77 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 1 Mar 2024 15:47:05 +0000 Subject: [PATCH 022/114] #2673 Moved down 'using namespace' statement. --- src/tools/other/ascii2nc/ascii2nc.cc | 5 ++- .../other/ascii2nc/ascii2nc_conf_info.cc | 4 +- src/tools/other/ascii2nc/ismn_handler.cc | 5 +++ src/tools/other/ascii2nc/little_r_handler.cc | 7 ++-- src/tools/other/ascii2nc/met_handler.cc | 7 ++-- src/tools/other/ascii2nc/ndbc_handler.cc | 8 ++-- src/tools/other/ascii2nc/ndbc_locations.cc | 7 ++-- src/tools/other/ascii2nc/python_handler.cc | 5 +-- src/tools/other/ascii2nc/surfrad_handler.cc | 7 ++-- src/tools/other/ascii2nc/wwsis_handler.cc | 10 ++--- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 6 ++- .../gen_ens_prod/gen_ens_prod_conf_info.cc | 4 +- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 6 ++- src/tools/other/gis_utils/gis_dump_dbf.cc | 3 +- src/tools/other/gis_utils/gis_dump_shp.cc | 4 +- src/tools/other/gis_utils/gis_dump_shx.cc | 3 +- src/tools/other/grid_diag/grid_diag.cc | 6 ++- .../other/grid_diag/grid_diag_conf_info.cc | 4 +- src/tools/other/gsi_tools/conv_record.cc | 4 +- src/tools/other/gsi_tools/gsi_record.cc | 4 +- src/tools/other/gsi_tools/gsi_util.cc | 4 +- src/tools/other/gsi_tools/gsid2mpr.cc | 4 +- src/tools/other/gsi_tools/rad_config.cc | 4 +- src/tools/other/gsi_tools/rad_record.cc | 4 +- src/tools/other/lidar2nc/calipso_5km.cc | 14 +++---- src/tools/other/lidar2nc/hdf_utils.cc | 5 +-- src/tools/other/lidar2nc/lidar2nc.cc | 16 ++++---- src/tools/other/madis2nc/madis2nc.cc | 6 ++- .../other/madis2nc/madis2nc_conf_info.cc | 3 +- src/tools/other/mode_graphics/cgraph_font.cc | 4 +- src/tools/other/mode_graphics/cgraph_main.cc | 4 +- .../cgraphbase_plottype_to_string.cc | 5 +-- src/tools/other/mode_graphics/color_stack.cc | 5 +-- .../mode_graphics/mode_nc_output_file.cc | 6 +-- .../other/mode_graphics/plot_mode_field.cc | 22 +++++------ src/tools/other/mode_time_domain/2d_att.cc | 4 +- .../other/mode_time_domain/2d_att_array.cc | 5 +-- .../other/mode_time_domain/2d_moments.cc | 4 +- src/tools/other/mode_time_domain/3d_att.cc | 4 +- .../mode_time_domain/3d_att_pair_array.cc | 5 +-- .../mode_time_domain/3d_att_single_array.cc | 5 +-- .../other/mode_time_domain/3d_moments.cc | 4 +- src/tools/other/mode_time_domain/fo_graph.cc | 4 +- src/tools/other/mode_time_domain/fo_node.cc | 4 +- .../other/mode_time_domain/fo_node_array.cc | 5 +-- .../other/mode_time_domain/interest_calc.cc | 4 +- src/tools/other/mode_time_domain/mm_engine.cc | 4 +- src/tools/other/mode_time_domain/mtd.cc | 39 ++++++++++--------- .../other/mode_time_domain/mtd_config_info.cc | 4 +- .../other/mode_time_domain/mtd_file_base.cc | 6 +-- .../other/mode_time_domain/mtd_file_float.cc | 6 +-- .../other/mode_time_domain/mtd_file_int.cc | 6 +-- .../other/mode_time_domain/mtd_nc_output.cc | 6 +-- .../other/mode_time_domain/mtd_partition.cc | 4 +- .../other/mode_time_domain/mtd_read_data.cc | 5 ++- .../other/mode_time_domain/mtd_txt_output.cc | 5 +-- .../mode_time_domain/mtdfiletype_to_string.cc | 5 +-- src/tools/other/mode_time_domain/nc_grid.cc | 6 +-- .../other/mode_time_domain/nc_utils_local.cc | 6 +-- .../other/modis_regrid/cloudsat_swath_file.cc | 4 +- src/tools/other/modis_regrid/data_averager.cc | 4 +- .../modis_regrid/data_plane_to_netcdf.cc | 8 ++-- src/tools/other/modis_regrid/modis_file.cc | 4 +- src/tools/other/modis_regrid/modis_regrid.cc | 15 +++---- src/tools/other/modis_regrid/sat_utils.cc | 4 +- src/tools/other/pb2nc/pb2nc_conf_info.cc | 3 +- .../other/plot_data_plane/plot_data_plane.cc | 4 +- .../other/plot_point_obs/plot_point_obs.cc | 4 +- .../plot_point_obs_conf_info.cc | 4 +- .../other/point2grid/point2grid_conf_info.cc | 4 +- .../regrid_data_plane/regrid_data_plane.cc | 6 ++- .../shift_data_plane/shift_data_plane.cc | 6 ++- src/tools/other/wwmca_tool/af_cp_file.cc | 4 +- src/tools/other/wwmca_tool/af_file.cc | 4 +- src/tools/other/wwmca_tool/af_pt_file.cc | 4 +- src/tools/other/wwmca_tool/ave_interp.cc | 4 +- .../wwmca_tool/gridhemisphere_to_string.cc | 5 +-- src/tools/other/wwmca_tool/interp_base.cc | 5 +-- src/tools/other/wwmca_tool/max_interp.cc | 4 +- src/tools/other/wwmca_tool/min_interp.cc | 4 +- src/tools/other/wwmca_tool/nc_output.cc | 6 +-- src/tools/other/wwmca_tool/nearest_interp.cc | 4 +- src/tools/other/wwmca_tool/wwmca_plot.cc | 26 ++++++------- src/tools/other/wwmca_tool/wwmca_ref.cc | 4 +- src/tools/other/wwmca_tool/wwmca_regrid.cc | 4 +- .../tc_utils/rmw_analysis/rmw_analysis.cc | 5 ++- .../rmw_analysis/rmw_analysis_conf_info.cc | 4 +- src/tools/tc_utils/tc_diag/tc_diag.cc | 6 ++- .../tc_utils/tc_diag/tc_diag_conf_info.cc | 4 +- src/tools/tc_utils/tc_dland/tc_dland.cc | 6 ++- src/tools/tc_utils/tc_dland/tc_poly.cc | 4 +- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 4 +- .../tc_utils/tc_pairs/tc_pairs_conf_info.cc | 4 +- src/tools/tc_utils/tc_rmw/tc_rmw.cc | 6 ++- src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc | 4 +- .../tc_utils/tc_rmw/tc_rmw_wind_converter.cc | 4 +- src/tools/tc_utils/tc_stat/tc_stat.cc | 4 +- .../tc_utils/tc_stat/tc_stat_conf_info.cc | 4 +- src/tools/tc_utils/tc_stat/tc_stat_files.cc | 4 +- 99 files changed, 319 insertions(+), 257 deletions(-) diff --git a/src/tools/other/ascii2nc/ascii2nc.cc b/src/tools/other/ascii2nc/ascii2nc.cc index 3eb9135c1d..338cc34098 100644 --- a/src/tools/other/ascii2nc/ascii2nc.cc +++ b/src/tools/other/ascii2nc/ascii2nc.cc @@ -53,8 +53,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -94,6 +92,9 @@ using namespace std; #include "python_handler.h" #endif +using namespace std; + + //////////////////////////////////////////////////////////////////////// // Constants diff --git a/src/tools/other/ascii2nc/ascii2nc_conf_info.cc b/src/tools/other/ascii2nc/ascii2nc_conf_info.cc index 3518b0c68f..fe8c255e83 100644 --- a/src/tools/other/ascii2nc/ascii2nc_conf_info.cc +++ b/src/tools/other/ascii2nc/ascii2nc_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // diff --git a/src/tools/other/ascii2nc/ismn_handler.cc b/src/tools/other/ascii2nc/ismn_handler.cc index e1b2e45759..73faf46c49 100644 --- a/src/tools/other/ascii2nc/ismn_handler.cc +++ b/src/tools/other/ascii2nc/ismn_handler.cc @@ -18,6 +18,11 @@ using namespace std; #include "ismn_handler.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + const int IsmnHandler::MIN_NUM_HDR_COLS = 8; const int IsmnHandler::NUM_OBS_COLS = 5; diff --git a/src/tools/other/ascii2nc/little_r_handler.cc b/src/tools/other/ascii2nc/little_r_handler.cc index a12bcfded4..3de94d81df 100644 --- a/src/tools/other/ascii2nc/little_r_handler.cc +++ b/src/tools/other/ascii2nc/little_r_handler.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include @@ -21,6 +18,10 @@ using namespace std; #include "little_r_handler.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// static const double lr_end_value = -777777.0; static const double lr_missing_value = -888888.0; diff --git a/src/tools/other/ascii2nc/met_handler.cc b/src/tools/other/ascii2nc/met_handler.cc index 5b19b8b0f6..29d37c7d30 100644 --- a/src/tools/other/ascii2nc/met_handler.cc +++ b/src/tools/other/ascii2nc/met_handler.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "vx_log.h" @@ -20,6 +17,10 @@ using namespace std; #include "met_handler.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// static const int n_met_col = 10; static const int n_met_col_qty = 11; diff --git a/src/tools/other/ascii2nc/ndbc_handler.cc b/src/tools/other/ascii2nc/ndbc_handler.cc index 9bd7a78888..1de6c26b9d 100644 --- a/src/tools/other/ascii2nc/ndbc_handler.cc +++ b/src/tools/other/ascii2nc/ndbc_handler.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +22,11 @@ using namespace std; #include "ndbc_handler.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + static const char *stations_env = "MET_NDBC_STATIONS"; const int NdbcHandler::NDBC_FORMAT_VERSION_STANDARD = 1; diff --git a/src/tools/other/ascii2nc/ndbc_locations.cc b/src/tools/other/ascii2nc/ndbc_locations.cc index c4ceb75f60..d766e7e234 100644 --- a/src/tools/other/ascii2nc/ndbc_locations.cc +++ b/src/tools/other/ascii2nc/ndbc_locations.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +22,10 @@ using namespace std; #include "ndbc_locations.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// static bool _parseLine(const string &sline, const string &key, string &value); static bool _parseLineForDouble(const string &sline, const string &key, double &value); diff --git a/src/tools/other/ascii2nc/python_handler.cc b/src/tools/other/ascii2nc/python_handler.cc index 28107fb1c7..eb3111cf53 100644 --- a/src/tools/other/ascii2nc/python_handler.cc +++ b/src/tools/other/ascii2nc/python_handler.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include @@ -23,6 +20,8 @@ using namespace std; #include "vx_python3_utils.h" #include "python_handler.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/ascii2nc/surfrad_handler.cc b/src/tools/other/ascii2nc/surfrad_handler.cc index d2f83572e0..47d45bceec 100644 --- a/src/tools/other/ascii2nc/surfrad_handler.cc +++ b/src/tools/other/ascii2nc/surfrad_handler.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "vx_log.h" @@ -21,6 +18,10 @@ using namespace std; #include "surfrad_handler.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// const int SurfradHandler::NUM_HDR_COLS = 6; const int SurfradHandler::NUM_OBS_COLS = 48; diff --git a/src/tools/other/ascii2nc/wwsis_handler.cc b/src/tools/other/ascii2nc/wwsis_handler.cc index 57b9e23921..a12facb2ce 100644 --- a/src/tools/other/ascii2nc/wwsis_handler.cc +++ b/src/tools/other/ascii2nc/wwsis_handler.cc @@ -7,14 +7,9 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "vx_log.h" @@ -23,6 +18,11 @@ using namespace std; #include "wwsis_handler.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + const string WwsisHandler::HEADER_TYPE = (string)"WWSIS"; diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index dd6d003289..99f585aa14 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -23,7 +23,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -37,7 +36,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "gen_ens_prod.h" @@ -52,6 +50,10 @@ using namespace netCDF; #include "handle_openmp.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc index cce3912742..143fea57c8 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -27,6 +26,9 @@ using namespace std; #include "GridTemplate.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class GenEnsProdConfInfo diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 3a2bf0224f..2aed24a706 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -34,7 +34,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -48,7 +47,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "gen_vx_mask.h" @@ -65,6 +63,10 @@ using namespace netCDF; #include "shp_file.h" #include "grid_closed_poly.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// int met_main(int argc, char *argv[]) { diff --git a/src/tools/other/gis_utils/gis_dump_dbf.cc b/src/tools/other/gis_utils/gis_dump_dbf.cc index c9aab98c9f..e7ed17ceb7 100644 --- a/src/tools/other/gis_utils/gis_dump_dbf.cc +++ b/src/tools/other/gis_utils/gis_dump_dbf.cc @@ -12,7 +12,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -28,6 +27,8 @@ using namespace std; #include "dbf_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gis_utils/gis_dump_shp.cc b/src/tools/other/gis_utils/gis_dump_shp.cc index 5e95bacced..bea6615500 100644 --- a/src/tools/other/gis_utils/gis_dump_shp.cc +++ b/src/tools/other/gis_utils/gis_dump_shp.cc @@ -12,7 +12,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -32,12 +31,13 @@ using namespace std; #include "shapetype_to_string.h" - #include "shp_file.h" #include "shp_poly_record.h" #include "shp_point_record.h" #include "shapetype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gis_utils/gis_dump_shx.cc b/src/tools/other/gis_utils/gis_dump_shx.cc index 7fdda4be1f..77455331ca 100644 --- a/src/tools/other/gis_utils/gis_dump_shx.cc +++ b/src/tools/other/gis_utils/gis_dump_shx.cc @@ -12,7 +12,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -28,6 +27,8 @@ using namespace std; #include "shx_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/grid_diag/grid_diag.cc b/src/tools/other/grid_diag/grid_diag.cc index 4a54b42ee2..b8292e4802 100644 --- a/src/tools/other/grid_diag/grid_diag.cc +++ b/src/tools/other/grid_diag/grid_diag.cc @@ -24,7 +24,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -38,7 +37,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "grid_diag.h" @@ -50,6 +48,10 @@ using namespace netCDF; #include "vx_regrid.h" #include "vx_log.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); diff --git a/src/tools/other/grid_diag/grid_diag_conf_info.cc b/src/tools/other/grid_diag/grid_diag_conf_info.cc index b463db9081..a8f00d634e 100644 --- a/src/tools/other/grid_diag/grid_diag_conf_info.cc +++ b/src/tools/other/grid_diag/grid_diag_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -23,6 +22,9 @@ using namespace std; #include "vx_data2d_factory.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class GridDiagConfInfo diff --git a/src/tools/other/gsi_tools/conv_record.cc b/src/tools/other/gsi_tools/conv_record.cc index 92d5cb8904..5a00487dd8 100644 --- a/src/tools/other/gsi_tools/conv_record.cc +++ b/src/tools/other/gsi_tools/conv_record.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +25,8 @@ using namespace std; #include "conv_offsets.h" #include "ftto.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsi_record.cc b/src/tools/other/gsi_tools/gsi_record.cc index 0f9bf88897..dde50d82e1 100644 --- a/src/tools/other/gsi_tools/gsi_record.cc +++ b/src/tools/other/gsi_tools/gsi_record.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "gsi_record.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsi_util.cc b/src/tools/other/gsi_tools/gsi_util.cc index d56da8a71c..8f88d11c23 100644 --- a/src/tools/other/gsi_tools/gsi_util.cc +++ b/src/tools/other/gsi_tools/gsi_util.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -25,6 +24,9 @@ using namespace std; #include "rad_record.h" #include "gsi_util.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsid2mpr.cc b/src/tools/other/gsi_tools/gsid2mpr.cc index b12c853171..5565452163 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.cc +++ b/src/tools/other/gsi_tools/gsid2mpr.cc @@ -21,7 +21,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -46,6 +45,9 @@ using namespace std; #include "gsi_util.h" #include "gsid2mpr.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static void process_conv(const char *conv_filename, const char *output_filename); diff --git a/src/tools/other/gsi_tools/rad_config.cc b/src/tools/other/gsi_tools/rad_config.cc index 86bb3af627..706b9c7f68 100644 --- a/src/tools/other/gsi_tools/rad_config.cc +++ b/src/tools/other/gsi_tools/rad_config.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "rad_config.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/rad_record.cc b/src/tools/other/gsi_tools/rad_record.cc index eac2a3bd68..04ab4b5052 100644 --- a/src/tools/other/gsi_tools/rad_record.cc +++ b/src/tools/other/gsi_tools/rad_record.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -27,6 +25,8 @@ using namespace std; #include "rad_offsets.h" #include "ftto.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/lidar2nc/calipso_5km.cc b/src/tools/other/lidar2nc/calipso_5km.cc index a169627fa7..d77fdd3ab0 100644 --- a/src/tools/other/lidar2nc/calipso_5km.cc +++ b/src/tools/other/lidar2nc/calipso_5km.cc @@ -11,6 +11,11 @@ //////////////////////////////////////////////////////////////////////// +#include "nint.h" +#include "write_netcdf.h" + +#include "calipso_5km.h" + using namespace std; @@ -27,15 +32,6 @@ static float ff[2]; //////////////////////////////////////////////////////////////////////// -#include "nint.h" -#include "write_netcdf.h" - -#include "calipso_5km.h" - - -//////////////////////////////////////////////////////////////////////// - - inline float km_to_meters(float km) { if ( km == FILL_VALUE ) return ( FILL_VALUE ); diff --git a/src/tools/other/lidar2nc/hdf_utils.cc b/src/tools/other/lidar2nc/hdf_utils.cc index fd5e66530e..bceef11fc5 100644 --- a/src/tools/other/lidar2nc/hdf_utils.cc +++ b/src/tools/other/lidar2nc/hdf_utils.cc @@ -11,13 +11,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; -//////////////////////////////////////////////////////////////////////// +#include "hdf_utils.h" -#include "hdf_utils.h" +using namespace std; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/lidar2nc/lidar2nc.cc b/src/tools/other/lidar2nc/lidar2nc.cc index b2e6573f44..5f51532653 100644 --- a/src/tools/other/lidar2nc/lidar2nc.cc +++ b/src/tools/other/lidar2nc/lidar2nc.cc @@ -23,13 +23,6 @@ //////////////////////////////////////////////////////////////////////// -static const char hdr_typ_string[] = "calipso"; - - -//////////////////////////////////////////////////////////////////////// - -using namespace std; - #include #include #include @@ -43,7 +36,6 @@ using namespace std; #include #include -using namespace netCDF; #include "hdf.h" #include "mfhdf.h" @@ -62,6 +54,14 @@ using namespace netCDF; #include "nc_obs_util.h" #include "nc_point_obs_out.h" +using namespace std; +using namespace netCDF; + + +//////////////////////////////////////////////////////////////////////// + +static const char hdr_typ_string[] = "calipso"; + //////////////////////////////////////////////////////////////////////// static ConcatString program_name; diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index 3a77ce8d72..8aa7bc886e 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -37,7 +37,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -51,7 +50,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "madis2nc.h" @@ -63,6 +61,10 @@ using namespace netCDF; #include "vx_log.h" #include "nc_point_obs_out.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/madis2nc/madis2nc_conf_info.cc b/src/tools/other/madis2nc/madis2nc_conf_info.cc index 6375d0098c..c4b864ab13 100644 --- a/src/tools/other/madis2nc/madis2nc_conf_info.cc +++ b/src/tools/other/madis2nc/madis2nc_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -22,6 +21,8 @@ using namespace std; #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // diff --git a/src/tools/other/mode_graphics/cgraph_font.cc b/src/tools/other/mode_graphics/cgraph_font.cc index 451b6f9c90..2e32369a36 100644 --- a/src/tools/other/mode_graphics/cgraph_font.cc +++ b/src/tools/other/mode_graphics/cgraph_font.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "cgraph_font.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/cgraph_main.cc b/src/tools/other/mode_graphics/cgraph_main.cc index baa2b3be01..abf6384160 100644 --- a/src/tools/other/mode_graphics/cgraph_main.cc +++ b/src/tools/other/mode_graphics/cgraph_main.cc @@ -19,8 +19,6 @@ static const int fl_ligature = 175; //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -35,6 +33,8 @@ using namespace std; #include "gs_ps_map.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc b/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc index 313b169ca4..772e8e840d 100644 --- a/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc +++ b/src/tools/other/mode_graphics/cgraphbase_plottype_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "cgraphbase_plottype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/color_stack.cc b/src/tools/other/mode_graphics/color_stack.cc index fb9d750364..2f14457888 100644 --- a/src/tools/other/mode_graphics/color_stack.cc +++ b/src/tools/other/mode_graphics/color_stack.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -23,6 +20,8 @@ using namespace std; #include "color_stack.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/mode_nc_output_file.cc b/src/tools/other/mode_graphics/mode_nc_output_file.cc index b958f30d6d..cc8b4e0eb0 100644 --- a/src/tools/other/mode_graphics/mode_nc_output_file.cc +++ b/src/tools/other/mode_graphics/mode_nc_output_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,12 +18,14 @@ using namespace std; #include #include -using namespace netCDF; #include "mode_nc_output_file.h" #include "nc_var_info.h" #include "nc_utils.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/plot_mode_field.cc b/src/tools/other/mode_graphics/plot_mode_field.cc index e15bb31c7a..56efe36b26 100644 --- a/src/tools/other/mode_graphics/plot_mode_field.cc +++ b/src/tools/other/mode_graphics/plot_mode_field.cc @@ -22,17 +22,6 @@ //////////////////////////////////////////////////////////////////////// -static const int anno_height = 100; - -static const int ctable_width = 15; - -static const int ctable_text_width = 30; - - -//////////////////////////////////////////////////////////////////////// - -using namespace std; - #include #include #include @@ -48,10 +37,21 @@ using namespace std; #include "vx_config.h" #include "configobjecttype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// +static const int anno_height = 100; + +static const int ctable_width = 15; + +static const int ctable_text_width = 30; + + +//////////////////////////////////////////////////////////////////////// + static ConcatString program_name; static CommandLine cline; diff --git a/src/tools/other/mode_time_domain/2d_att.cc b/src/tools/other/mode_time_domain/2d_att.cc index 09533c9311..7dc5c842f7 100644 --- a/src/tools/other/mode_time_domain/2d_att.cc +++ b/src/tools/other/mode_time_domain/2d_att.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,8 @@ using namespace std; #include "3d_txt_header.h" #include "2d_columns.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/2d_att_array.cc b/src/tools/other/mode_time_domain/2d_att_array.cc index 04b5310414..0a30db3f69 100644 --- a/src/tools/other/mode_time_domain/2d_att_array.cc +++ b/src/tools/other/mode_time_domain/2d_att_array.cc @@ -24,9 +24,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -37,6 +34,8 @@ using namespace std; #include "2d_att_array.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/2d_moments.cc b/src/tools/other/mode_time_domain/2d_moments.cc index 8e4e2a972b..e5eb3313db 100644 --- a/src/tools/other/mode_time_domain/2d_moments.cc +++ b/src/tools/other/mode_time_domain/2d_moments.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "trig.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_att.cc b/src/tools/other/mode_time_domain/3d_att.cc index b35b4d6116..380d49c604 100644 --- a/src/tools/other/mode_time_domain/3d_att.cc +++ b/src/tools/other/mode_time_domain/3d_att.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,8 @@ using namespace std; #include "3d_txt_header.h" #include "3d_single_columns.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_att_pair_array.cc b/src/tools/other/mode_time_domain/3d_att_pair_array.cc index 6e2278889c..57c7a3b2e3 100644 --- a/src/tools/other/mode_time_domain/3d_att_pair_array.cc +++ b/src/tools/other/mode_time_domain/3d_att_pair_array.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,8 @@ using namespace std; #include "3d_att_pair_array.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_att_single_array.cc b/src/tools/other/mode_time_domain/3d_att_single_array.cc index 120747e92f..f77301785a 100644 --- a/src/tools/other/mode_time_domain/3d_att_single_array.cc +++ b/src/tools/other/mode_time_domain/3d_att_single_array.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,8 @@ using namespace std; #include "3d_att_single_array.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_moments.cc b/src/tools/other/mode_time_domain/3d_moments.cc index 2f58298bc0..e7ae40f8c9 100644 --- a/src/tools/other/mode_time_domain/3d_moments.cc +++ b/src/tools/other/mode_time_domain/3d_moments.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "trig.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/fo_graph.cc b/src/tools/other/mode_time_domain/fo_graph.cc index eebc762c26..f088725df2 100644 --- a/src/tools/other/mode_time_domain/fo_graph.cc +++ b/src/tools/other/mode_time_domain/fo_graph.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "fo_graph.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/fo_node.cc b/src/tools/other/mode_time_domain/fo_node.cc index bcad38ee9b..4ea1adf874 100644 --- a/src/tools/other/mode_time_domain/fo_node.cc +++ b/src/tools/other/mode_time_domain/fo_node.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "fo_node.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/fo_node_array.cc b/src/tools/other/mode_time_domain/fo_node_array.cc index 045daaa0ba..4ae86d055a 100644 --- a/src/tools/other/mode_time_domain/fo_node_array.cc +++ b/src/tools/other/mode_time_domain/fo_node_array.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,8 @@ using namespace std; #include "fo_node_array.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/interest_calc.cc b/src/tools/other/mode_time_domain/interest_calc.cc index 9567f78caa..fc55e034b2 100644 --- a/src/tools/other/mode_time_domain/interest_calc.cc +++ b/src/tools/other/mode_time_domain/interest_calc.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "interest_calc.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mm_engine.cc b/src/tools/other/mode_time_domain/mm_engine.cc index 34f7546d48..4351daac7d 100644 --- a/src/tools/other/mode_time_domain/mm_engine.cc +++ b/src/tools/other/mode_time_domain/mm_engine.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "mm_engine.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd.cc b/src/tools/other/mode_time_domain/mtd.cc index 77df84c09f..4ca6ac9f0d 100644 --- a/src/tools/other/mode_time_domain/mtd.cc +++ b/src/tools/other/mode_time_domain/mtd.cc @@ -26,25 +26,6 @@ //////////////////////////////////////////////////////////////////////// -static const char default_config_path [] = "MET_BASE/config/MTDConfig_default"; - -static const char txt_2d_suffix [] = "2d.txt"; - -static const char txt_3d_single_simple_suffix [] = "3d_single_simple.txt"; -static const char txt_3d_pair_simple_suffix [] = "3d_pair_simple.txt"; - -static const char txt_3d_single_cluster_suffix [] = "3d_single_cluster.txt"; -static const char txt_3d_pair_cluster_suffix [] = "3d_pair_cluster.txt"; - -static const char nc_suffix [] = "obj.nc"; - -static const char default_prefix [] = "mtd"; - - -//////////////////////////////////////////////////////////////////////// - -using namespace std; - #include #include #include @@ -61,6 +42,26 @@ using namespace std; #include "mm_engine.h" #include "mtd_nc_output.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + + +static const char default_config_path [] = "MET_BASE/config/MTDConfig_default"; + +static const char txt_2d_suffix [] = "2d.txt"; + +static const char txt_3d_single_simple_suffix [] = "3d_single_simple.txt"; +static const char txt_3d_pair_simple_suffix [] = "3d_pair_simple.txt"; + +static const char txt_3d_single_cluster_suffix [] = "3d_single_cluster.txt"; +static const char txt_3d_pair_cluster_suffix [] = "3d_pair_cluster.txt"; + +static const char nc_suffix [] = "obj.nc"; + +static const char default_prefix [] = "mtd"; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_config_info.cc b/src/tools/other/mode_time_domain/mtd_config_info.cc index ff6c6e0a9e..6842fd5fdd 100644 --- a/src/tools/other/mode_time_domain/mtd_config_info.cc +++ b/src/tools/other/mode_time_domain/mtd_config_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -26,6 +25,9 @@ using namespace std; #include "vx_data2d_factory.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_file_base.cc b/src/tools/other/mode_time_domain/mtd_file_base.cc index fbd98dcf71..3e739ab2bd 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.cc +++ b/src/tools/other/mode_time_domain/mtd_file_base.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,7 +19,6 @@ using namespace std; #include #include -using namespace netCDF; #include "mtd_file.h" #include "mtd_partition.h" @@ -32,6 +29,9 @@ using namespace netCDF; #include "vx_math.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_file_float.cc b/src/tools/other/mode_time_domain/mtd_file_float.cc index 0f0d3d6f7e..b148364db4 100644 --- a/src/tools/other/mode_time_domain/mtd_file_float.cc +++ b/src/tools/other/mode_time_domain/mtd_file_float.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,7 +20,6 @@ using namespace std; #include #include -using namespace netCDF; #include "mtd_file.h" #include "mtd_partition.h" @@ -31,6 +28,9 @@ using namespace netCDF; #include "vx_math.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_file_int.cc b/src/tools/other/mode_time_domain/mtd_file_int.cc index 5964e4c5e2..77f72a3755 100644 --- a/src/tools/other/mode_time_domain/mtd_file_int.cc +++ b/src/tools/other/mode_time_domain/mtd_file_int.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,7 +20,6 @@ using namespace std; #include #include -using namespace netCDF; #include "mtd_file.h" #include "mtd_partition.h" @@ -31,6 +28,9 @@ using namespace netCDF; #include "vx_math.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_nc_output.cc b/src/tools/other/mode_time_domain/mtd_nc_output.cc index cf5ea008b7..497cacdcd1 100644 --- a/src/tools/other/mode_time_domain/mtd_nc_output.cc +++ b/src/tools/other/mode_time_domain/mtd_nc_output.cc @@ -10,20 +10,20 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include #include #include -using namespace netCDF; #include "mtd_nc_output.h" #include "write_netcdf.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_partition.cc b/src/tools/other/mode_time_domain/mtd_partition.cc index 57db83dde7..ff092c1eba 100644 --- a/src/tools/other/mode_time_domain/mtd_partition.cc +++ b/src/tools/other/mode_time_domain/mtd_partition.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "mtd_partition.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_read_data.cc b/src/tools/other/mode_time_domain/mtd_read_data.cc index 20f28a6aeb..74733a8de6 100644 --- a/src/tools/other/mode_time_domain/mtd_read_data.cc +++ b/src/tools/other/mode_time_domain/mtd_read_data.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,9 @@ using namespace std; #include "num_array.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_txt_output.cc b/src/tools/other/mode_time_domain/mtd_txt_output.cc index dea4ac4f0c..f1ee61aa5d 100644 --- a/src/tools/other/mode_time_domain/mtd_txt_output.cc +++ b/src/tools/other/mode_time_domain/mtd_txt_output.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -29,6 +26,8 @@ using namespace std; #include "3d_single_columns.h" #include "2d_columns.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc b/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc index 8587710e51..7857538909 100644 --- a/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc +++ b/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "mtdfiletype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/nc_grid.cc b/src/tools/other/mode_time_domain/nc_grid.cc index 83fb326d07..f8bb76153e 100644 --- a/src/tools/other/mode_time_domain/nc_grid.cc +++ b/src/tools/other/mode_time_domain/nc_grid.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,11 +19,13 @@ using namespace std; #include #include -using namespace netCDF; #include "nc_utils_local.h" #include "nc_grid.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/nc_utils_local.cc b/src/tools/other/mode_time_domain/nc_utils_local.cc index d80d335f1b..b4db4d4e0e 100644 --- a/src/tools/other/mode_time_domain/nc_utils_local.cc +++ b/src/tools/other/mode_time_domain/nc_utils_local.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,12 +19,14 @@ using namespace std; #include #include -using namespace netCDF; #include "nc_utils.h" #include "nc_utils_local.h" #include "vx_log.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/modis_regrid/cloudsat_swath_file.cc b/src/tools/other/modis_regrid/cloudsat_swath_file.cc index 233cdea2b0..6630c2844b 100644 --- a/src/tools/other/modis_regrid/cloudsat_swath_file.cc +++ b/src/tools/other/modis_regrid/cloudsat_swath_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,8 @@ using namespace std; #include "cloudsat_swath_file.h" #include "sat_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/modis_regrid/data_averager.cc b/src/tools/other/modis_regrid/data_averager.cc index e756a4bf7a..a3e9657037 100644 --- a/src/tools/other/modis_regrid/data_averager.cc +++ b/src/tools/other/modis_regrid/data_averager.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "vx_math.h" #include "vx_cal.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/modis_regrid/data_plane_to_netcdf.cc b/src/tools/other/modis_regrid/data_plane_to_netcdf.cc index af9c50c0ff..e43ea1b0df 100644 --- a/src/tools/other/modis_regrid/data_plane_to_netcdf.cc +++ b/src/tools/other/modis_regrid/data_plane_to_netcdf.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,7 +20,6 @@ using namespace std; #include #include -using namespace netCDF; #include "data_plane_to_netcdf.h" #include "vx_log.h" // mlog @@ -32,6 +29,11 @@ using namespace netCDF; #include "write_netcdf.h" // write_netcdf functions #include "var_info_factory.h" // VarInfoFactory +using namespace std; +using namespace netCDF; + + +//////////////////////////////////////////////////////////////////////// extern int get_compress(); diff --git a/src/tools/other/modis_regrid/modis_file.cc b/src/tools/other/modis_regrid/modis_file.cc index c712f2330f..980f52ff5a 100644 --- a/src/tools/other/modis_regrid/modis_file.cc +++ b/src/tools/other/modis_regrid/modis_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "sat_utils.h" #include "cloudsat_swath_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/modis_regrid/modis_regrid.cc b/src/tools/other/modis_regrid/modis_regrid.cc index 788898b60f..f62e654b52 100644 --- a/src/tools/other/modis_regrid/modis_regrid.cc +++ b/src/tools/other/modis_regrid/modis_regrid.cc @@ -10,13 +10,6 @@ //////////////////////////////////////////////////////////////////////// -static const char default_units [] = "none"; - - -//////////////////////////////////////////////////////////////////////// - -using namespace std; - #include #include #include @@ -35,6 +28,14 @@ using namespace std; #include "data_averager.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + + +static const char default_units [] = "none"; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/modis_regrid/sat_utils.cc b/src/tools/other/modis_regrid/sat_utils.cc index 55402459b9..adfbc03f06 100644 --- a/src/tools/other/modis_regrid/sat_utils.cc +++ b/src/tools/other/modis_regrid/sat_utils.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -20,6 +18,8 @@ using namespace std; #include "sat_utils.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/pb2nc/pb2nc_conf_info.cc b/src/tools/other/pb2nc/pb2nc_conf_info.cc index 69af15a22d..7c7db4cee5 100644 --- a/src/tools/other/pb2nc/pb2nc_conf_info.cc +++ b/src/tools/other/pb2nc/pb2nc_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -25,6 +24,8 @@ using namespace std; #include "grib_strings.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/plot_data_plane/plot_data_plane.cc b/src/tools/other/plot_data_plane/plot_data_plane.cc index 89f7c8c8ca..ecab619d02 100644 --- a/src/tools/other/plot_data_plane/plot_data_plane.cc +++ b/src/tools/other/plot_data_plane/plot_data_plane.cc @@ -30,7 +30,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -61,6 +60,9 @@ using namespace std; #include "data2d_python.h" #endif +using namespace std; + + //////////////////////////////////////////////////////////////////////// static ConcatString program_name = (string)"plot_data_plane"; diff --git a/src/tools/other/plot_point_obs/plot_point_obs.cc b/src/tools/other/plot_point_obs/plot_point_obs.cc index 66eb91ee0d..b5f012c575 100644 --- a/src/tools/other/plot_point_obs/plot_point_obs.cc +++ b/src/tools/other/plot_point_obs/plot_point_obs.cc @@ -30,7 +30,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -53,6 +52,9 @@ using namespace std; #include "vx_plot_util.h" #include "nc_point_obs_in.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static void usage(); diff --git a/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc b/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc index 04b798e71a..254cc232c3 100644 --- a/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc +++ b/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include "vx_log.h" #include "vx_util.h" @@ -20,6 +19,9 @@ using namespace std; #include "plot_point_obs_conf_info.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// bool LocationInfo::operator==(const LocationInfo &x) { diff --git a/src/tools/other/point2grid/point2grid_conf_info.cc b/src/tools/other/point2grid/point2grid_conf_info.cc index 84cfec4a12..87d6aa966f 100644 --- a/src/tools/other/point2grid/point2grid_conf_info.cc +++ b/src/tools/other/point2grid/point2grid_conf_info.cc @@ -8,11 +8,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include "point2grid_conf_info.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class PointToGridConfInfo diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index 309aaf3d6a..c348388263 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -28,7 +28,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -44,7 +43,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "vx_log.h" @@ -58,6 +56,10 @@ using namespace netCDF; #include "GridTemplate.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static ConcatString program_name; diff --git a/src/tools/other/shift_data_plane/shift_data_plane.cc b/src/tools/other/shift_data_plane/shift_data_plane.cc index 411f5dd10f..648531df22 100644 --- a/src/tools/other/shift_data_plane/shift_data_plane.cc +++ b/src/tools/other/shift_data_plane/shift_data_plane.cc @@ -27,7 +27,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -41,7 +40,6 @@ using namespace std; #include #include -using namespace netCDF; #include "GridTemplate.h" @@ -58,6 +56,10 @@ using namespace netCDF; #include "data2d_python.h" #endif +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static ConcatString program_name; diff --git a/src/tools/other/wwmca_tool/af_cp_file.cc b/src/tools/other/wwmca_tool/af_cp_file.cc index 70acdb4941..aea2b6907c 100644 --- a/src/tools/other/wwmca_tool/af_cp_file.cc +++ b/src/tools/other/wwmca_tool/af_cp_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "af_file.h" #include "af_cp_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/af_file.cc b/src/tools/other/wwmca_tool/af_file.cc index e0618a2b41..7a252a184e 100644 --- a/src/tools/other/wwmca_tool/af_file.cc +++ b/src/tools/other/wwmca_tool/af_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "af_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/af_pt_file.cc b/src/tools/other/wwmca_tool/af_pt_file.cc index 4b875257d4..c1f55a2f7d 100644 --- a/src/tools/other/wwmca_tool/af_pt_file.cc +++ b/src/tools/other/wwmca_tool/af_pt_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -30,6 +28,8 @@ using namespace std; #include "af_file.h" #include "af_pt_file.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/ave_interp.cc b/src/tools/other/wwmca_tool/ave_interp.cc index a9a2cbcf32..efd3d5e90d 100644 --- a/src/tools/other/wwmca_tool/ave_interp.cc +++ b/src/tools/other/wwmca_tool/ave_interp.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "ave_interp.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/gridhemisphere_to_string.cc b/src/tools/other/wwmca_tool/gridhemisphere_to_string.cc index 884ed06486..4c32d7da8a 100644 --- a/src/tools/other/wwmca_tool/gridhemisphere_to_string.cc +++ b/src/tools/other/wwmca_tool/gridhemisphere_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "gridhemisphere_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/interp_base.cc b/src/tools/other/wwmca_tool/interp_base.cc index 0b7dd9f182..7eedff3fde 100644 --- a/src/tools/other/wwmca_tool/interp_base.cc +++ b/src/tools/other/wwmca_tool/interp_base.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -21,6 +18,8 @@ using namespace std; #include "vx_log.h" #include "interp_base.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/max_interp.cc b/src/tools/other/wwmca_tool/max_interp.cc index 42a1fe322c..bf8a5e7b89 100644 --- a/src/tools/other/wwmca_tool/max_interp.cc +++ b/src/tools/other/wwmca_tool/max_interp.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "max_interp.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/min_interp.cc b/src/tools/other/wwmca_tool/min_interp.cc index 536aa90211..5018b44698 100644 --- a/src/tools/other/wwmca_tool/min_interp.cc +++ b/src/tools/other/wwmca_tool/min_interp.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,8 @@ using namespace std; #include "min_interp.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/nc_output.cc b/src/tools/other/wwmca_tool/nc_output.cc index 7e68c7ab11..54db32f195 100644 --- a/src/tools/other/wwmca_tool/nc_output.cc +++ b/src/tools/other/wwmca_tool/nc_output.cc @@ -10,15 +10,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include #include #include -using namespace netCDF; #include "vx_log.h" #include "vx_cal.h" @@ -29,6 +26,9 @@ using namespace netCDF; #include "nc_utils.h" #include "write_netcdf.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/nearest_interp.cc b/src/tools/other/wwmca_tool/nearest_interp.cc index 2951fdd635..9d7972d8f6 100644 --- a/src/tools/other/wwmca_tool/nearest_interp.cc +++ b/src/tools/other/wwmca_tool/nearest_interp.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "nearest_interp.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/wwmca_plot.cc b/src/tools/other/wwmca_tool/wwmca_plot.cc index b960362156..fafe1adedf 100644 --- a/src/tools/other/wwmca_tool/wwmca_plot.cc +++ b/src/tools/other/wwmca_tool/wwmca_plot.cc @@ -7,19 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -//////////////////////////////////////////////////////////////////////// - -using namespace std; - -static const int gray_min = 130; // these values must be between 0 and 255 inclusive -static const int gray_max = 255; - -static const double h_margin = 40.0; -static const double v_margin = 80.0; - -static const char map_filename [] = "MET_BASE/map/country_major_lakes_data"; - - //////////////////////////////////////////////////////////////////////// @@ -44,6 +31,19 @@ static const char map_filename [] = "MET_BASE/map/country_major_lakes_data"; #include "af_cp_file.h" #include "af_pt_file.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + +static const int gray_min = 130; // these values must be between 0 and 255 inclusive +static const int gray_max = 255; + +static const double h_margin = 40.0; +static const double v_margin = 80.0; + +static const char map_filename [] = "MET_BASE/map/country_major_lakes_data"; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/wwmca_ref.cc b/src/tools/other/wwmca_tool/wwmca_ref.cc index ff66c54268..c154a45430 100644 --- a/src/tools/other/wwmca_tool/wwmca_ref.cc +++ b/src/tools/other/wwmca_tool/wwmca_ref.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -32,6 +30,8 @@ using namespace std; #include "grid_output.h" #include "apply_mask.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/wwmca_regrid.cc b/src/tools/other/wwmca_tool/wwmca_regrid.cc index e25929420b..d0c58ba608 100644 --- a/src/tools/other/wwmca_tool/wwmca_regrid.cc +++ b/src/tools/other/wwmca_tool/wwmca_regrid.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -24,6 +22,8 @@ using namespace std; #include "wwmca_ref.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc b/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc index f2d2b3b5cf..0cc3dfc333 100644 --- a/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc +++ b/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc @@ -6,7 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; #include #include @@ -19,7 +18,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "rmw_analysis.h" @@ -29,6 +27,9 @@ using namespace netCDF; #include "vx_util.h" #include "vx_log.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// static void usage(); diff --git a/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc b/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc index 6862e56cae..cb7642a5fe 100644 --- a/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc +++ b/src/tools/tc_utils/rmw_analysis/rmw_analysis_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -23,6 +22,9 @@ using namespace std; #include "apply_mask.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class RMWAnalysisConfInfo diff --git a/src/tools/tc_utils/tc_diag/tc_diag.cc b/src/tools/tc_utils/tc_diag/tc_diag.cc index 332587b9eb..afdbec9992 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag.cc @@ -20,7 +20,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -33,7 +32,6 @@ using namespace std; #include #include -using namespace netCDF; #ifdef _OPENMP #include "omp.h" @@ -57,6 +55,10 @@ using namespace netCDF; #include "met_file.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static void usage(); diff --git a/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc b/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc index 7684308b81..b4651ca7e6 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -22,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for struct DataOptInfo diff --git a/src/tools/tc_utils/tc_dland/tc_dland.cc b/src/tools/tc_utils/tc_dland/tc_dland.cc index dbdc7d976a..57af2dea1c 100644 --- a/src/tools/tc_utils/tc_dland/tc_dland.cc +++ b/src/tools/tc_utils/tc_dland/tc_dland.cc @@ -23,7 +23,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -36,7 +35,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "grib_classes.h" @@ -51,6 +49,10 @@ using namespace netCDF; #include "write_netcdf.h" #include "tc_poly.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static ConcatString program_name; diff --git a/src/tools/tc_utils/tc_dland/tc_poly.cc b/src/tools/tc_utils/tc_dland/tc_poly.cc index 9f3f892097..b0b0a179c3 100644 --- a/src/tools/tc_utils/tc_dland/tc_poly.cc +++ b/src/tools/tc_utils/tc_dland/tc_poly.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -22,6 +21,9 @@ using namespace std; #include "tc_poly.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class TCPoly diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/src/tools/tc_utils/tc_pairs/tc_pairs.cc index e25c43f64d..9710e45a26 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -49,7 +49,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -73,6 +72,9 @@ using namespace std; #include "met_file.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static const int mxp = 1000; diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc index cfd22631b5..5c53ff22fa 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -23,6 +22,9 @@ using namespace std; #include "apply_mask.h" #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// void parse_conf_diag_info_map(Dictionary *, diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index 4520b1d5ca..e452508e59 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -22,7 +22,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -35,7 +34,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "tc_rmw.h" @@ -55,6 +53,10 @@ using namespace netCDF; #include "met_file.h" +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static void usage(); diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc index 19fa16a3c6..017a446c3c 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -22,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class TCRMWConfInfo diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc b/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc index e5e1a5997e..5f717f3f3c 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc @@ -20,12 +20,14 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include "tc_rmw_wind_converter.h" #include "series_data.h" #include "vx_regrid.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static void wind_ne_to_ra(const TcrmwGrid&, diff --git a/src/tools/tc_utils/tc_stat/tc_stat.cc b/src/tools/tc_utils/tc_stat/tc_stat.cc index d1e85b0855..6519b7befc 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat.cc @@ -25,7 +25,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -48,6 +47,9 @@ using namespace std; #include "met_file.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); diff --git a/src/tools/tc_utils/tc_stat/tc_stat_conf_info.cc b/src/tools/tc_utils/tc_stat/tc_stat_conf_info.cc index 7cc8f5a167..86eb2c43e8 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_conf_info.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_conf_info.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -22,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // Functions for parsing config entries diff --git a/src/tools/tc_utils/tc_stat/tc_stat_files.cc b/src/tools/tc_utils/tc_stat/tc_stat_files.cc index 61a2ed8681..8410a9125f 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_files.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_files.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -27,6 +26,9 @@ using namespace std; #include "vx_util.h" #include "vx_math.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // // Code for class TCStatFiles From 2509f7c1d99d3320930f5d597c6ad0abe80da27d Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 5 Mar 2024 15:40:05 +0000 Subject: [PATCH 023/114] #2673 Added std namespace --- src/tools/core/mode/combine_boolplanes.h | 4 +-- src/tools/core/mode/mode_superobject.h | 6 ++-- src/tools/core/mode/multivar_data.h | 28 +++++++++---------- src/tools/core/mode/multivar_frontend.h | 28 +++++++++---------- .../series_analysis_conf_info.h | 2 +- src/tools/core/stat_analysis/aggr_stat_line.h | 2 +- src/tools/dev_utils/insitu_nc_file.h | 10 +++---- src/tools/other/ascii2nc/ascii2nc_conf_info.h | 8 +++--- src/tools/other/ascii2nc/ismn_handler.h | 10 +++---- src/tools/other/ascii2nc/little_r_handler.h | 4 +-- src/tools/other/ascii2nc/met_handler.h | 4 +-- src/tools/other/ascii2nc/ndbc_handler.h | 22 +++++++-------- src/tools/other/ascii2nc/ndbc_locations.h | 16 +++++------ src/tools/other/ascii2nc/python_handler.h | 6 ++-- src/tools/other/ascii2nc/surfrad_handler.h | 8 +++--- src/tools/other/ascii2nc/wwsis_handler.h | 12 ++++---- src/tools/other/gen_vx_mask/gen_vx_mask.h | 2 +- src/tools/other/grid_diag/grid_diag.h | 26 ++++++++--------- .../other/grid_diag/grid_diag_conf_info.h | 2 +- src/tools/other/gsi_tools/gsid2mpr.h | 2 +- src/tools/other/madis2nc/madis2nc.h | 2 +- .../other/mode_time_domain/mtd_read_data.h | 6 ++-- .../other/point2grid/point2grid_conf_info.h | 4 +-- 23 files changed, 106 insertions(+), 108 deletions(-) diff --git a/src/tools/core/mode/combine_boolplanes.h b/src/tools/core/mode/combine_boolplanes.h index d086eb4f06..2a7c168628 100644 --- a/src/tools/core/mode/combine_boolplanes.h +++ b/src/tools/core/mode/combine_boolplanes.h @@ -34,13 +34,11 @@ //////////////////////////////////////////////////////////////////////// -extern void combine_boolplanes(const string &name, +extern void combine_boolplanes(const std::string &name, const BoolPlane * array, const int n_planes, BoolCalc & calc, BoolPlane & bp_out); - - //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/mode_superobject.h b/src/tools/core/mode/mode_superobject.h index 4450487af4..71d88c430a 100644 --- a/src/tools/core/mode/mode_superobject.h +++ b/src/tools/core/mode/mode_superobject.h @@ -31,12 +31,12 @@ class ModeSuperObject { public: ModeSuperObject(bool isFcst, int n_files, bool do_clusters, - const vector &mvd, + const std::vector &mvd, BoolCalc &calc); inline ~ModeSuperObject() {} - void mask_data_simple(const string &name, MultiVarData &mvd) const; - void mask_data_super(const string &name, const MultiVarData &mvd); + void mask_data_simple(const std::string &name, MultiVarData &mvd) const; + void mask_data_super(const std::string &name, const MultiVarData &mvd); bool _isFcst; bool _hasUnion; diff --git a/src/tools/core/mode/multivar_data.h b/src/tools/core/mode/multivar_data.h index dcd4ef8197..5fbfd0af0b 100644 --- a/src/tools/core/mode/multivar_data.h +++ b/src/tools/core/mode/multivar_data.h @@ -30,11 +30,11 @@ class MultiVarData1 { int *_fill_int_array(ShapeData *sd); float *_fill_float_array(ShapeData *sd); - void _print_summary(const string &name, int *data, const ShapeData &sd) const; + void _print_summary(const std::string &name, int *data, const ShapeData &sd) const; public: - inline MultiVarData1(int nx, int ny, const string &name, + inline MultiVarData1(int nx, int ny, const std::string &name, ModeDataType dataType) : _dataType(dataType), _name(name), @@ -46,13 +46,13 @@ class MultiVarData1 { _convThreshArray(), _mergeThreshArray() {} - + inline ~MultiVarData1() { if (_obj_sd) delete _obj_sd; if (_obj_data) delete [] _obj_data; if (_raw_data) delete [] _raw_data; if (_sd) delete _sd; - } + } void set_obj(ShapeData *sd); void set_raw(ShapeData *sd); @@ -61,10 +61,10 @@ class MultiVarData1 { void set_merge_thresh_array(const ThreshArray &t); void objects_from_arrays(bool do_clusters, BoolPlane & out); - void print(const string &name) const; + void print(const std::string &name) const; ModeDataType _dataType; - string _name; + std::string _name; ShapeData *_obj_sd; int *_obj_data; float *_raw_data; @@ -84,12 +84,12 @@ class MultiVarData { MultiVarData(); ~MultiVarData(); - + void init(ModeDataType dataType, - const string &name, - const Grid &grid, - const string &units, - const string &level, + const std::string &name, + const Grid &grid, + const std::string &units, + const std::string &level, double data_min, double data_max); void set_obj(ShapeData *sd, bool simple); @@ -104,11 +104,11 @@ class MultiVarData { ModeDataType _dataType; MultiVarData1 *_simple; MultiVarData1 *_merge; - string _name; + std::string _name; int _nx, _ny; Grid *_grid; - string _units; - string _level; + std::string _units; + std::string _level; double _data_min, _data_max; }; diff --git a/src/tools/core/mode/multivar_frontend.h b/src/tools/core/mode/multivar_frontend.h index bb21913b9a..f4c78c243d 100644 --- a/src/tools/core/mode/multivar_frontend.h +++ b/src/tools/core/mode/multivar_frontend.h @@ -32,20 +32,20 @@ class MultivarFrontEnd { StringArray fcst_filenames; StringArray obs_filenames; BoolCalc f_calc, o_calc ; - vector fcstInput, obsInput; - vector mvdFcst, mvdObs; - string fcst_fof; - string obs_fof; + std::vector fcstInput, obsInput; + std::vector mvdFcst, mvdObs; + std::string fcst_fof; + std::string obs_fof; void _process_command_line(const StringArray &); - void _read_config(const string & filename); + void _read_config(const std::string & filename); void _setup_inputs(); void _set_output_path(); int _mkdir(const char *dir); void _simple_objects(ModeExecutive::Processing_t p, ModeDataType dtype, - int j, int n_files, const string &filename, + int j, int n_files, const std::string &filename, const ModeInputData &input); - void _init_exec(ModeExecutive::Processing_t p, const string &ffile, const string &ofile); + void _init_exec(ModeExecutive::Processing_t p, const std::string &ffile, const std::string &ofile); void _superobject_mode_algorithm(const ModeSuperObject &fsuper, const ModeSuperObject &osuper); void _intensity_compare_mode_algorithm(const MultiVarData &mvdf, const MultiVarData &mvdo, const ModeSuperObject &fsuper, const ModeSuperObject &osuper); @@ -55,11 +55,11 @@ class MultivarFrontEnd { public: bool do_clusters; - string default_out_dir; + std::string default_out_dir; ModeConfInfo config; ConcatString output_path; - string mode_path; - string config_file; + std::string mode_path; + std::string config_file; Grid verification_grid; MultivarFrontEnd(); @@ -75,22 +75,22 @@ class MultivarFrontEnd { static void set_verbosity (const StringArray &); static void set_compress (const StringArray &); - void read_input(const string &name, int index, ModeDataType type, + void read_input(const std::string &name, int index, ModeDataType type, GrdFileType f_t, GrdFileType other_t, int shift); void create_verif_grid(void); MultiVarData *create_simple_objects(ModeDataType dtype, int j, int n_files, - const string &filename, + const std::string &filename, const ModeInputData &input); void create_intensity_comparisons(int findex, int oindex, const ModeSuperObject &fsuper, const ModeSuperObject &osuper, MultiVarData &mvdf, MultiVarData &mvdo, - const string &fcst_filename, - const string &obs_filename); + const std::string &fcst_filename, + const std::string &obs_filename); void process_superobjects(ModeSuperObject &fsuper, ModeSuperObject &osuper, diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.h b/src/tools/core/series_analysis/series_analysis_conf_info.h index 4bf8527436..76f7041472 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.h +++ b/src/tools/core/series_analysis/series_analysis_conf_info.h @@ -81,7 +81,7 @@ class SeriesAnalysisConfInfo { ConcatString version; // Config file version // Mapping of line type to output statistics - map output_stats; + std::map output_stats; SeriesAnalysisConfInfo(); ~SeriesAnalysisConfInfo(); diff --git a/src/tools/core/stat_analysis/aggr_stat_line.h b/src/tools/core/stat_analysis/aggr_stat_line.h index 42f81d6a25..a934491a1f 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.h +++ b/src/tools/core/stat_analysis/aggr_stat_line.h @@ -178,7 +178,7 @@ struct ssvar_bin_cmp { // Otherwise, parse list of numbers and compare each element StringArray sa1 = cs1.split(":"); StringArray sa2 = cs2.split(":"); - for(int i=0; i getMessageTypeMap() const + std::map getMessageTypeMap() const { return _messageTypeMap; } @@ -56,7 +56,7 @@ class Ascii2NcConfInfo { ConcatString _version; TimeSummaryInfo _timeSummaryInfo; - map _messageTypeMap; + std::map _messageTypeMap; /////////////////////// diff --git a/src/tools/other/ascii2nc/ismn_handler.h b/src/tools/other/ascii2nc/ismn_handler.h index 9f8d26f829..d71cbd4d3e 100644 --- a/src/tools/other/ascii2nc/ismn_handler.h +++ b/src/tools/other/ascii2nc/ismn_handler.h @@ -22,7 +22,7 @@ struct obsVarInfo { int _gribCode; - string _varName; + std::string _varName; }; //////////////////////////////////////////////////////////////////////// @@ -90,12 +90,12 @@ class IsmnHandler : public FileHandler { public: - IsmnHandler(const string &program_name); + IsmnHandler(const std::string &program_name); virtual ~IsmnHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; - static string getFormatString() { return "ismn"; } + static std::string getFormatString() { return "ismn"; } protected: @@ -124,8 +124,8 @@ class IsmnHandler : public FileHandler { StringArray _varNames; // Unchanging header information - string _networkName; - string _stationId; + std::string _networkName; + std::string _stationId; double _stationLat; double _stationLon; double _stationElv; diff --git a/src/tools/other/ascii2nc/little_r_handler.h b/src/tools/other/ascii2nc/little_r_handler.h index 0c72d9cefa..8d41180041 100644 --- a/src/tools/other/ascii2nc/little_r_handler.h +++ b/src/tools/other/ascii2nc/little_r_handler.h @@ -32,12 +32,12 @@ class LittleRHandler : public FileHandler public: - LittleRHandler(const string &program_name); + LittleRHandler(const std::string &program_name); virtual ~LittleRHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; - static string getFormatString() + static std::string getFormatString() { return "little_r"; } diff --git a/src/tools/other/ascii2nc/met_handler.h b/src/tools/other/ascii2nc/met_handler.h index 54dbe39bda..17ef7ea852 100644 --- a/src/tools/other/ascii2nc/met_handler.h +++ b/src/tools/other/ascii2nc/met_handler.h @@ -30,12 +30,12 @@ class MetHandler : public FileHandler public: - MetHandler(const string &program_name); + MetHandler(const std::string &program_name); virtual ~MetHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; - static string getFormatString() + static std::string getFormatString() { return "met_point"; } diff --git a/src/tools/other/ascii2nc/ndbc_handler.h b/src/tools/other/ascii2nc/ndbc_handler.h index 842b29eaac..95d0559e56 100644 --- a/src/tools/other/ascii2nc/ndbc_handler.h +++ b/src/tools/other/ascii2nc/ndbc_handler.h @@ -38,12 +38,12 @@ class NdbcHandler : public FileHandler class Column { public: - string name; // name of the header as found in the file + std::string name; // name of the header as found in the file int ptr; // column index for that data (0,1,..) - inline Column(const string &n) : name(n), ptr(-1) {} + inline Column(const std::string &n) : name(n), ptr(-1) {} inline ~Column() {} inline void clear(void) {ptr = -1;} - inline bool nameEquals(const string &s) const {return name == s;} + inline bool nameEquals(const std::string &s) const {return name == s;} inline void setPtr(int ipt) {ptr = ipt;} inline bool notSet(void) const {return ptr == -1;} }; @@ -51,14 +51,14 @@ class NdbcHandler : public FileHandler public: - NdbcHandler(const string &program_name); + NdbcHandler(const std::string &program_name); virtual ~NdbcHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; void setFormatVersion(int version); - static string getFormatStringStandard() + static std::string getFormatStringStandard() { return "ndbc_standard"; } @@ -92,7 +92,7 @@ class NdbcHandler : public FileHandler // // Unchanging header information for a file (each file is one station) // - string stationId; + std::string stationId; double stationLat; double stationLon; double stationAlt; @@ -107,10 +107,10 @@ class NdbcHandler : public FileHandler int column_pointer_minute; // storage for non time column information (name/pointer) - vector column; + std::vector column; // the lookup file for location information - string locationsFileName; + std::string locationsFileName; // the lookup object NdbcLocations locations; @@ -126,7 +126,7 @@ class NdbcHandler : public FileHandler // parse the file name to identify the station, then lookup and set the // location // - bool _setStationInfo(const string &filename); + bool _setStationInfo(const std::string &filename); // Read and save the header information from the given file, The file pointer // is assumed to be at the beginning of the file. Sets all the pointers based @@ -151,9 +151,9 @@ class NdbcHandler : public FileHandler // parse one line from the ascii file and add to observations bool _parseObservationLineStandard(DataLine &data_line, - const string &filename); + const std::string &filename); - string _extractColumn(const DataLine &data_line, int ptr) const; + std::string _extractColumn(const DataLine &data_line, int ptr) const; double _extractDouble(const DataLine &data_line, int ptr) const; }; diff --git a/src/tools/other/ascii2nc/ndbc_locations.h b/src/tools/other/ascii2nc/ndbc_locations.h index 4b4fc68eb9..9b238c9114 100644 --- a/src/tools/other/ascii2nc/ndbc_locations.h +++ b/src/tools/other/ascii2nc/ndbc_locations.h @@ -28,20 +28,20 @@ class NdbcLocations NdbcLocations(); virtual ~NdbcLocations(); - bool initialize(const string &locationsFile); - bool lookupLatLonElev(const string aqsid, double &lat, double &lon, double &elev) const; + bool initialize(const std::string &locationsFile); + bool lookupLatLonElev(const std::string aqsid, double &lat, double &lon, double &elev) const; void print(void) const; private: - bool _setPtr(DataLine &data_line, const string &headerName, int &ptr) const; + bool _setPtr(DataLine &data_line, const std::string &headerName, int &ptr) const; - string fileName; + std::string fileName; - vector StationId; - vector Lat; - vector Lon; - vector Elev; + std::vector StationId; + std::vector Lat; + std::vector Lon; + std::vector Elev; }; diff --git a/src/tools/other/ascii2nc/python_handler.h b/src/tools/other/ascii2nc/python_handler.h index 85f0a5c418..bd2d794092 100644 --- a/src/tools/other/ascii2nc/python_handler.h +++ b/src/tools/other/ascii2nc/python_handler.h @@ -41,13 +41,13 @@ class PythonHandler : public FileHandler public: - PythonHandler(const string &program_name); + PythonHandler(const std::string &program_name); PythonHandler(const char * program_name, const char * ascii_filename); virtual ~PythonHandler(); bool isFileType(LineDataFile &ascii_file) const; - static string getFormatString() { return "python"; } + static std::string getFormatString() { return "python"; } bool use_tmp_ascii; @@ -66,7 +66,7 @@ class PythonHandler : public FileHandler virtual bool _readObservations(LineDataFile &ascii_file); // this shouldn't be called - virtual bool readAsciiFiles(const vector< ConcatString > &ascii_filename_list); + virtual bool readAsciiFiles(const std::vector< ConcatString > &ascii_filename_list); bool do_straight (); // run compiled python interpreter bool do_tmp_ascii(); // run user-defined MET_PYTHON_EXE diff --git a/src/tools/other/ascii2nc/surfrad_handler.h b/src/tools/other/ascii2nc/surfrad_handler.h index 9f479db7c5..d6d71ffafe 100644 --- a/src/tools/other/ascii2nc/surfrad_handler.h +++ b/src/tools/other/ascii2nc/surfrad_handler.h @@ -31,12 +31,12 @@ class SurfradHandler : public FileHandler public: - SurfradHandler(const string &program_name); + SurfradHandler(const std::string &program_name); virtual ~SurfradHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; - static string getFormatString() + static std::string getFormatString() { return "surfrad"; } @@ -59,7 +59,7 @@ class SurfradHandler : public FileHandler // The header type for these observations - static const string HEADER_TYPE; + static const std::string HEADER_TYPE; // Grib codes for the different fields @@ -91,7 +91,7 @@ class SurfradHandler : public FileHandler // Unchanging header information - string _stationId; + std::string _stationId; double _stationLat; double _stationLon; double _stationAlt; diff --git a/src/tools/other/ascii2nc/wwsis_handler.h b/src/tools/other/ascii2nc/wwsis_handler.h index ebb546a088..a5c913effb 100644 --- a/src/tools/other/ascii2nc/wwsis_handler.h +++ b/src/tools/other/ascii2nc/wwsis_handler.h @@ -33,12 +33,12 @@ class WwsisHandler : public FileHandler public: - WwsisHandler(const string &program_name); + WwsisHandler(const std::string &program_name); virtual ~WwsisHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; - static string getFormatString() + static std::string getFormatString() { return "wwsis"; } @@ -51,7 +51,7 @@ class WwsisHandler : public FileHandler // The header type for these observations - static const string HEADER_TYPE; + static const std::string HEADER_TYPE; // Grib code for the field @@ -70,7 +70,7 @@ class WwsisHandler : public FileHandler int _stepSecs; double _watts; double _derate; - string _tracking; + std::string _tracking; double _tilt; double _azimuth; @@ -101,8 +101,8 @@ class WwsisHandler : public FileHandler // Get the initial valid time from the file name - int _getYearFromFilename(const string &filename) const; - time_t _initValidTime(const string &filename) const; + int _getYearFromFilename(const std::string &filename) const; + time_t _initValidTime(const std::string &filename) const; // Read the observations from the given file and add them to the // _observations vector. diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.h b/src/tools/other/gen_vx_mask/gen_vx_mask.h index 00c6f986cb..8ab03376a7 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.h +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.h @@ -106,7 +106,7 @@ static double mask_val = default_mask_val; static ConcatString mask_name; static unixtime solar_ut = (unixtime) 0; -static std::map shape_str_map; +static std::map shape_str_map; static NumArray shape_numbers; static std::vector shape_recs; diff --git a/src/tools/other/grid_diag/grid_diag.h b/src/tools/other/grid_diag/grid_diag.h index 5f661bdb22..663bb70e7f 100644 --- a/src/tools/other/grid_diag/grid_diag.h +++ b/src/tools/other/grid_diag/grid_diag.h @@ -67,8 +67,8 @@ static const char * default_config_filename = //////////////////////////////////////////////////////////////////////// // Input files -static vector data_files; -static vector file_types; +static std::vector data_files; +static std::vector file_types; static int compress_level = -1; // Output file @@ -86,9 +86,9 @@ static GridDiagConfInfo conf_info; // Output NetCDF file static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; -vector data_var_dims; -vector hist_vars; -vector joint_hist_vars; +std::vector data_var_dims; +std::vector hist_vars; +std::vector joint_hist_vars; static bool multiple_data_sources = false; static bool unique_variable_names = true; @@ -110,16 +110,16 @@ static Met2dDataFileFactory mtddf_factory; static Met2dDataFile *data_mtddf = (Met2dDataFile *) nullptr; // Variable min/max values -vector var_mins; -vector var_maxs; +std::vector var_mins; +std::vector var_maxs; // Variable histogram map -map > histograms; -map > joint_histograms; -map > bin_mins; -map > bin_maxs; -map > bin_mids; -map bin_deltas; +std::map > histograms; +std::map > joint_histograms; +std::map > bin_mins; +std::map > bin_maxs; +std::map > bin_mids; +std::map bin_deltas; // Series length static int n_series = bad_data_int; diff --git a/src/tools/other/grid_diag/grid_diag_conf_info.h b/src/tools/other/grid_diag/grid_diag_conf_info.h index 396c19f300..5a4a2f1a13 100644 --- a/src/tools/other/grid_diag/grid_diag_conf_info.h +++ b/src/tools/other/grid_diag/grid_diag_conf_info.h @@ -58,7 +58,7 @@ class GridDiagConfInfo { void read_config(const char *, const char *); void set_n_data(); - void process_config(vector); + void process_config(std::vector); void process_masks(const Grid &); int get_n_data() const; diff --git a/src/tools/other/gsi_tools/gsid2mpr.h b/src/tools/other/gsi_tools/gsid2mpr.h index 0e5c7f26be..17eb97fa44 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.h +++ b/src/tools/other/gsi_tools/gsid2mpr.h @@ -138,7 +138,7 @@ static StatHdrColumns shc; // Store observation keys to search for duplicates static StringArray obs_key; -static map obs_key_map; +static std::map obs_key_map; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/madis2nc/madis2nc.h b/src/tools/other/madis2nc/madis2nc.h index ab108d497c..aea7ec5b48 100644 --- a/src/tools/other/madis2nc/madis2nc.h +++ b/src/tools/other/madis2nc/madis2nc.h @@ -132,7 +132,7 @@ static int rej_sid = 0; //////////////////////////////////////////////////////////////////////// // Output NetCDF file -NcFile *f_out = (NcFile *) nullptr; +netCDF::NcFile *f_out = (netCDF::NcFile *) nullptr; int processed_count; diff --git a/src/tools/other/mode_time_domain/mtd_read_data.h b/src/tools/other/mode_time_domain/mtd_read_data.h index 16393d6e9f..74d7627da3 100644 --- a/src/tools/other/mode_time_domain/mtd_read_data.h +++ b/src/tools/other/mode_time_domain/mtd_read_data.h @@ -30,9 +30,9 @@ // returns the actual valid times // -extern vector mtd_read_data(MtdConfigInfo &, VarInfo &, - const StringArray & filenames, - MtdFloatFile &); +extern std::vector mtd_read_data(MtdConfigInfo &, VarInfo &, + const StringArray & filenames, + MtdFloatFile &); //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/point2grid/point2grid_conf_info.h b/src/tools/other/point2grid/point2grid_conf_info.h index 2d0bd63da3..f6dff25b55 100644 --- a/src/tools/other/point2grid/point2grid_conf_info.h +++ b/src/tools/other/point2grid/point2grid_conf_info.h @@ -31,8 +31,8 @@ class PointToGridConfInfo { void init_from_scratch(); protected: - map var_name_map; - map def_var_name_map; + std::map var_name_map; + std::map def_var_name_map; public: From ca64f001506784f3b65979d1079cc1064c412bd1 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 5 Mar 2024 19:09:39 +0000 Subject: [PATCH 024/114] #2673 Added std namespace --- src/basic/vx_config/celltype_to_string.cc | 5 ++--- src/libcode/vx_afm/afm_line.cc | 5 ++--- src/libcode/vx_bool_calc/tokentype_to_string.cc | 9 ++++----- src/libcode/vx_regrid/vx_regrid_budget.cc | 3 +-- src/libcode/vx_render/hex_filter.cc | 4 ++-- src/libcode/vx_shapedata/node.cc | 3 ++- src/tools/other/ascii2nc/ismn_handler.cc | 2 -- src/tools/other/gsi_tools/gsidens2orank.cc | 4 ++-- src/tools/other/point2grid/point2grid.cc | 6 ++++-- 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/basic/vx_config/celltype_to_string.cc b/src/basic/vx_config/celltype_to_string.cc index 09c23b0343..8864b0dce5 100644 --- a/src/basic/vx_config/celltype_to_string.cc +++ b/src/basic/vx_config/celltype_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "celltype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_afm/afm_line.cc b/src/libcode/vx_afm/afm_line.cc index d7a4234601..4371e6f00e 100644 --- a/src/libcode/vx_afm/afm_line.cc +++ b/src/libcode/vx_afm/afm_line.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,8 @@ using namespace std; #include "afm_line.h" #include "vx_util.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/tokentype_to_string.cc b/src/libcode/vx_bool_calc/tokentype_to_string.cc index eafea54a4c..571ef9ddea 100644 --- a/src/libcode/vx_bool_calc/tokentype_to_string.cc +++ b/src/libcode/vx_bool_calc/tokentype_to_string.cc @@ -24,13 +24,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "tokentype_to_string.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// @@ -39,7 +38,7 @@ ConcatString tokentype_to_string(const TokenType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { @@ -60,7 +59,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString(s); } diff --git a/src/libcode/vx_regrid/vx_regrid_budget.cc b/src/libcode/vx_regrid/vx_regrid_budget.cc index 9fbedcfc81..d467b5aa0b 100644 --- a/src/libcode/vx_regrid/vx_regrid_budget.cc +++ b/src/libcode/vx_regrid/vx_regrid_budget.cc @@ -11,12 +11,11 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include "vx_regrid.h" #include "interp_mthd.h" +using namespace std; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/hex_filter.cc b/src/libcode/vx_render/hex_filter.cc index deb92552d0..584c8d0f5e 100644 --- a/src/libcode/vx_render/hex_filter.cc +++ b/src/libcode/vx_render/hex_filter.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "hex_filter.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_shapedata/node.cc b/src/libcode/vx_shapedata/node.cc index 38a65049c6..74310ea451 100644 --- a/src/libcode/vx_shapedata/node.cc +++ b/src/libcode/vx_shapedata/node.cc @@ -19,7 +19,6 @@ // /////////////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -30,6 +29,8 @@ using namespace std; #include "vx_log.h" #include "vx_math.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// // // Code for class Node diff --git a/src/tools/other/ascii2nc/ismn_handler.cc b/src/tools/other/ascii2nc/ismn_handler.cc index 507f86d6c1..b46f6971c1 100644 --- a/src/tools/other/ascii2nc/ismn_handler.cc +++ b/src/tools/other/ascii2nc/ismn_handler.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "vx_log.h" diff --git a/src/tools/other/gsi_tools/gsidens2orank.cc b/src/tools/other/gsi_tools/gsidens2orank.cc index c821d03bdc..0c75717fa8 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.cc +++ b/src/tools/other/gsi_tools/gsidens2orank.cc @@ -20,8 +20,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -46,6 +44,8 @@ using namespace std; #include "gsi_util.h" #include "gsidens2orank.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static void process_conv(const char *conv_filename, int i_mem); diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 6708d1cf9e..fe8e7dafe8 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -24,14 +24,12 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include #include #include -using namespace netCDF; #include "main.h" #include "vx_log.h" @@ -52,6 +50,10 @@ using namespace netCDF; #include "pointdata_python.h" #endif +using namespace std; +using namespace netCDF; + + //////////////////////////////////////////////////////////////////////// static ConcatString program_name; From a7f0e0618cf74b2505f27d424286bfed056776cf Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 5 Mar 2024 19:23:18 +0000 Subject: [PATCH 025/114] #2673 Added std namespace --- src/tools/other/gsi_tools/gsidens2orank.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/other/gsi_tools/gsidens2orank.h b/src/tools/other/gsi_tools/gsidens2orank.h index ecd5c31ee7..7dc533f131 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.h +++ b/src/tools/other/gsi_tools/gsidens2orank.h @@ -126,12 +126,12 @@ static ConcatString rng_seed; //////////////////////////////////////////////////////////////////////// // Store conventional and radiance information -static StringArray obs_key; -static map obs_key_map; -static map obs_index_map; -static vector conv_data; -static vector rad_data; -static PairDataEnsemble ens_pd; +static StringArray obs_key; +static std::map obs_key_map; +static std::map obs_index_map; +static std::vector conv_data; +static std::vector rad_data; +static PairDataEnsemble ens_pd; //////////////////////////////////////////////////////////////////////// From 0ab2466d222aade31f504311da622b54c1b067f8 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 6 Mar 2024 20:51:18 +0000 Subject: [PATCH 026/114] #2673 Changed literal 1 to boolean value, true --- src/basic/enum_to_string/my_enum_scanner.cc | 8 ++++---- src/basic/vx_config/config.tab.cc | 2 +- src/basic/vx_config/config_file.cc | 2 +- src/basic/vx_config/my_config_scanner.cc | 10 +++++----- src/basic/vx_util/command_line.cc | 2 +- src/libcode/vx_afm/afm.cc | 4 ++-- src/libcode/vx_afm/afm_line.cc | 2 +- src/libcode/vx_bool_calc/make_program.cc | 2 +- src/libcode/vx_bool_calc/tokenizer.cc | 2 +- src/libcode/vx_color/my_color_scanner.cc | 8 ++++---- src/libcode/vx_pxm/pbm.cc | 2 +- src/libcode/vx_pxm/pcm.cc | 2 +- src/libcode/vx_pxm/pgm.cc | 2 +- src/libcode/vx_pxm/ppm.cc | 2 +- src/libcode/vx_pxm/pxm_utils.cc | 4 ++-- src/tools/dev_utils/nceptab_to_flat.cc | 2 +- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/basic/enum_to_string/my_enum_scanner.cc b/src/basic/enum_to_string/my_enum_scanner.cc index 40e1577c42..375d2344c5 100644 --- a/src/basic/enum_to_string/my_enum_scanner.cc +++ b/src/basic/enum_to_string/my_enum_scanner.cc @@ -130,7 +130,7 @@ if ( first_call ) { init(); first_call = false; } yytext = (char *) lexeme; -while ( 1 ) { +while ( true ) { t = next_token(); @@ -174,7 +174,7 @@ int c, c2; // skip whitespace // -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -600,7 +600,7 @@ c1 = nextchar(); c2 = nextchar(); -while ( 1 ) { +while ( true ) { if ( (c1 == EOF) || (c2 == EOF) ) break; @@ -629,7 +629,7 @@ void do_cpp_comment() int c; -while ( 1 ) { +while ( true ) { c = nextchar(); diff --git a/src/basic/vx_config/config.tab.cc b/src/basic/vx_config/config.tab.cc index 6805b14a43..61513c670b 100644 --- a/src/basic/vx_config/config.tab.cc +++ b/src/basic/vx_config/config.tab.cc @@ -2421,7 +2421,7 @@ DictionaryEntry e; count = 0; -while ( 1 ) { +while ( true ) { v = icvs.pop(); diff --git a/src/basic/vx_config/config_file.cc b/src/basic/vx_config/config_file.cc index c1b363b452..441fa3a9a8 100644 --- a/src/basic/vx_config/config_file.cc +++ b/src/basic/vx_config/config_file.cc @@ -622,7 +622,7 @@ void recursive_envs(string & line) { -while ( 1 ) { +while ( true ) { if ( ! replace_env(line) ) break; diff --git a/src/basic/vx_config/my_config_scanner.cc b/src/basic/vx_config/my_config_scanner.cc index f630924c98..13e41a196c 100644 --- a/src/basic/vx_config/my_config_scanner.cc +++ b/src/basic/vx_config/my_config_scanner.cc @@ -188,7 +188,7 @@ if ( first_call ) { init(); first_call = false; } configtext = (char *) lexeme; -while ( 1 ) { +while ( true ) { t = next_token(); @@ -218,7 +218,7 @@ int c, c2; // skip whitespace // -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -827,7 +827,7 @@ c1 = nextchar(); c2 = nextchar(); -while ( 1 ) { +while ( true ) { if ( (c1 == eof) || (c2 == eof) ) break; @@ -858,7 +858,7 @@ int c = 0; reading_comment = true; -while ( 1 ) { +while ( true ) { if ( configin->eof() ) break; @@ -1034,7 +1034,7 @@ if ( c == '$' ) { env_value = e; - while ( 1 ) { + while ( true ) { if ( ! replace_env(env_value) ) break; diff --git a/src/basic/vx_util/command_line.cc b/src/basic/vx_util/command_line.cc index 0f9e205ebe..de06658b07 100644 --- a/src/basic/vx_util/command_line.cc +++ b/src/basic/vx_util/command_line.cc @@ -1093,7 +1093,7 @@ a.clear(); count = 0; -while ( 1 ) { +while ( true ) { k = pos + count; diff --git a/src/libcode/vx_afm/afm.cc b/src/libcode/vx_afm/afm.cc index 31974f00d0..28b15563d6 100644 --- a/src/libcode/vx_afm/afm.cc +++ b/src/libcode/vx_afm/afm.cc @@ -1903,7 +1903,7 @@ ascii_code = tok.i; c.ascii_code = ascii_code; -while ( 1 ) { +while ( true ) { tok = line.nexttoken(); if ( tok.type == afm_token_endofline ) break; @@ -2024,7 +2024,7 @@ c.pcc = new PCC [c.n_parts]; n_pcc = 0; -while ( 1 ) { +while ( true ) { tok = line.nexttoken(); diff --git a/src/libcode/vx_afm/afm_line.cc b/src/libcode/vx_afm/afm_line.cc index 4371e6f00e..fdf05c6aec 100644 --- a/src/libcode/vx_afm/afm_line.cc +++ b/src/libcode/vx_afm/afm_line.cc @@ -334,7 +334,7 @@ extern istream & operator>>(istream & in, AfmLine & L) L.clear(); -while ( 1 ) { +while ( true ) { L.Line.read_line(in); diff --git a/src/libcode/vx_bool_calc/make_program.cc b/src/libcode/vx_bool_calc/make_program.cc index dabbb8b7ec..8f35e5824a 100644 --- a/src/libcode/vx_bool_calc/make_program.cc +++ b/src/libcode/vx_bool_calc/make_program.cc @@ -65,7 +65,7 @@ tiz.set(input); //////////////// -while ( 1 ) { +while ( true ) { tok = tiz.next_token(); diff --git a/src/libcode/vx_bool_calc/tokenizer.cc b/src/libcode/vx_bool_calc/tokenizer.cc index eed9ada855..7a7d690819 100644 --- a/src/libcode/vx_bool_calc/tokenizer.cc +++ b/src/libcode/vx_bool_calc/tokenizer.cc @@ -167,7 +167,7 @@ char c, c2; // skip whitespace // -while ( 1 ) { +while ( true ) { c = source[pos]; diff --git a/src/libcode/vx_color/my_color_scanner.cc b/src/libcode/vx_color/my_color_scanner.cc index fcd4ef525f..5994787349 100644 --- a/src/libcode/vx_color/my_color_scanner.cc +++ b/src/libcode/vx_color/my_color_scanner.cc @@ -126,7 +126,7 @@ if ( first_call ) { init(); first_call = false; } colortext = (char *) lexeme; -while ( 1 ) { +while ( true ) { t = next_token(); @@ -156,7 +156,7 @@ int c, c2; // skip whitespace // -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -765,7 +765,7 @@ c1 = nextchar(); c2 = nextchar(); -while ( 1 ) { +while ( true ) { if ( (c1 == EOF) || (c2 == EOF) ) break; @@ -794,7 +794,7 @@ void do_cpp_comment() int c; -while ( 1 ) { +while ( true ) { c = nextchar(); diff --git a/src/libcode/vx_pxm/pbm.cc b/src/libcode/vx_pxm/pbm.cc index 9c1e39b7e8..4d4f622327 100644 --- a/src/libcode/vx_pxm/pbm.cc +++ b/src/libcode/vx_pxm/pbm.cc @@ -364,7 +364,7 @@ if ( (c1 != 'P') || (c2 != '4') ) { skip_whitespace(in); -while ( 1 ) { +while ( true ) { j = in.peek(); diff --git a/src/libcode/vx_pxm/pcm.cc b/src/libcode/vx_pxm/pcm.cc index 1fe14b5ee9..c6c41d4878 100644 --- a/src/libcode/vx_pxm/pcm.cc +++ b/src/libcode/vx_pxm/pcm.cc @@ -446,7 +446,7 @@ if ( (c1 != 'P') || (c2 != '9') ) { skip_whitespace(in); -while ( 1 ) { +while ( true ) { j = in.peek(); diff --git a/src/libcode/vx_pxm/pgm.cc b/src/libcode/vx_pxm/pgm.cc index 47d1c7732b..87f6170bc0 100644 --- a/src/libcode/vx_pxm/pgm.cc +++ b/src/libcode/vx_pxm/pgm.cc @@ -326,7 +326,7 @@ if ( (c1 != 'P') || (c2 != '5') ) { skip_whitespace(in); -while ( 1 ) { +while ( true ) { j = in.peek(); diff --git a/src/libcode/vx_pxm/ppm.cc b/src/libcode/vx_pxm/ppm.cc index af49251531..9ce2c79e44 100644 --- a/src/libcode/vx_pxm/ppm.cc +++ b/src/libcode/vx_pxm/ppm.cc @@ -326,7 +326,7 @@ if ( (c1 != 'P') || (c2 != '6') ) { skip_whitespace(in); -while ( 1 ) { +while ( true ) { j = in.peek(); diff --git a/src/libcode/vx_pxm/pxm_utils.cc b/src/libcode/vx_pxm/pxm_utils.cc index 0a1663a6fe..c238c3b94b 100644 --- a/src/libcode/vx_pxm/pxm_utils.cc +++ b/src/libcode/vx_pxm/pxm_utils.cc @@ -53,7 +53,7 @@ void skip_whitespace(istream & in) int c; -while ( 1 ) { +while ( true ) { c = in.peek(); @@ -82,7 +82,7 @@ in.get(c); // toss leading '#' k = 0; -while ( 1 ) { +while ( true ) { in.get(c); diff --git a/src/tools/dev_utils/nceptab_to_flat.cc b/src/tools/dev_utils/nceptab_to_flat.cc index c24585b0ae..4041cab117 100644 --- a/src/tools/dev_utils/nceptab_to_flat.cc +++ b/src/tools/dev_utils/nceptab_to_flat.cc @@ -212,7 +212,7 @@ if ( !found ) { // -while ( 1 ) { +while ( true ) { line.read_line(in); From a6f7646724a03c30ccba79edb9b3ed6946877514 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 14 Mar 2024 08:45:13 -0600 Subject: [PATCH 027/114] Feature #2673 enum_to_string (#2835) --- src/basic/enum_to_string/code.cc | 18 +-- src/basic/enum_to_string/enum_parser.yy | 4 +- src/basic/enum_to_string/enum_scanner.ll | 54 ++++---- src/basic/enum_to_string/info.cc | 2 +- src/basic/enum_to_string/info.h | 12 +- src/basic/enum_to_string/my_enum_scanner.cc | 2 +- src/basic/enum_to_string/scope.h | 6 +- src/basic/vx_config/config.tab.yy | 2 +- src/basic/vx_config/config_scanner.ll | 122 +++++++++--------- .../vx_config/configobjecttype_to_string.cc | 1 - src/libcode/vx_color/color_scanner.ll | 46 +++---- 11 files changed, 132 insertions(+), 137 deletions(-) diff --git a/src/basic/enum_to_string/code.cc b/src/basic/enum_to_string/code.cc index fb62ba003f..9b5c431f35 100644 --- a/src/basic/enum_to_string/code.cc +++ b/src/basic/enum_to_string/code.cc @@ -489,21 +489,19 @@ warning(out); out << "\n\n" << sep << "\n\n" - << "using namespace std;\n" - << "\n\n" << "#include \n" << "\n" << "#include " << L << lower << "_to_string"; if ( header_suffix ) out << header_suffix; -out << R - << "\n" +out << R + << "\n\n" + << "using namespace std;\n" << "\n\n" << sep << "\n\n"; - forward(e, lower, out); out << "\n\n" @@ -607,8 +605,6 @@ warning(out); out << "\n\n" << sep << "\n\n" - << "using namespace std;\n" - << "\n\n" << "#include \n" << "\n" << "#include " << L << lower << "_to_string"; @@ -616,12 +612,12 @@ out << "\n\n" if ( header_suffix ) out << header_suffix; out << R - << "\n" + << "\n\n" + << "using namespace std;\n" << "\n\n" << sep << "\n\n"; - forward_cs(e, lower, out); out << "\n\n" @@ -758,7 +754,7 @@ out << e.name() << " t)\n" << "{\n" << "\n"; -out << "const char * s = (const char *) 0;\n\n"; +out << "const char * s = (const char *) nullptr;\n\n"; out << "switch ( t ) {\n" << "\n"; @@ -802,7 +798,7 @@ out << "\n" << "} // switch\n" << "\n\n"; -out << "return ( ConcatString (s) );\n" +out << "return ConcatString(s);\n" << "\n"; out << "}\n"; diff --git a/src/basic/enum_to_string/enum_parser.yy b/src/basic/enum_to_string/enum_parser.yy index 61718fe01a..989ccd2702 100644 --- a/src/basic/enum_to_string/enum_parser.yy +++ b/src/basic/enum_to_string/enum_parser.yy @@ -46,7 +46,7 @@ extern bool do_concat_string; EnumInfo einfo; -const char * header_filename = (const char *) 0; +const char * header_filename = (const char *) nullptr; ScopeStack ss; @@ -171,7 +171,7 @@ void set_name(const char * text) { int j, n; -const char * c = (const char *) 0; +const char * c = (const char *) nullptr; ostringstream s; diff --git a/src/basic/enum_to_string/enum_scanner.ll b/src/basic/enum_to_string/enum_scanner.ll index f69a8e3e08..a59f4e358a 100644 --- a/src/basic/enum_to_string/enum_scanner.ll +++ b/src/basic/enum_to_string/enum_scanner.ll @@ -89,16 +89,16 @@ WS " "|"\t" %% -enum { do_enum(); return ( token(ENUM) ); } -class { do_class(); return ( token(CLASS) ); } +enum { do_enum(); return token(ENUM); } +class { do_class(); return token(CLASS); } -"{" { if ( do_left_curly() ) return ( token(L_CURLY) ); } -"}" { if ( do_right_curly() ) return ( token(R_CURLY) ); } -"=" { if ( do_equals() ) return ( token (EQ) ); } -";" { if ( do_semi() ) return ( token(';') ); } -"," { if ( do_comma() ) return ( token(',') ); } -("-"?)({DIGIT})+ { if ( do_int() ) return ( token(INTEGER) ); } -({LETTER})({LETTER}|{DIGIT})* { if ( do_id() ) return ( token(ID) ); } +"{" { if ( do_left_curly() ) return token(L_CURLY); } +"}" { if ( do_right_curly() ) return token(R_CURLY); } +"=" { if ( do_equals() ) return token (EQ); } +";" { if ( do_semi() ) return token(';'); } +"," { if ( do_comma() ) return token(','); } +("-"?)({DIGIT})+ { if ( do_int() ) return token(INTEGER); } +({LETTER})({LETTER}|{DIGIT})* { if ( do_id() ) return token(ID); } @@ -160,13 +160,13 @@ if ( enum_mode || last_was_enum || last_was_class ) { strncpy(yylval.name, yytext, sizeof(yylval.name)); - return ( 1 ); + return 1; } -return ( 0 ); +return 0; } @@ -180,13 +180,13 @@ int do_int() column += strlen(yytext); -if ( !enum_mode ) return ( 0 ); +if ( !enum_mode ) return 0; yylval.ival = atoi(yytext); -return ( 1 ); +return 1; } @@ -202,12 +202,12 @@ int do_left_curly() ++column; -if ( !enum_mode ) return ( 0 ); +if ( !enum_mode ) return 0; yylval.ival = bracket_level; -return ( 1 ); +return 1; } @@ -225,12 +225,12 @@ int do_right_curly() ss.clear_to_level(bracket_level); -if ( !enum_mode ) return ( 0 ); +if ( !enum_mode ) return 0; yylval.ival = bracket_level + 1; -return ( 1 ); +return 1; } @@ -244,10 +244,10 @@ int do_semi() ++column; -if ( enum_mode ) return ( 1 ); +if ( enum_mode ) return 1; -return ( 0 ); +return 0; } @@ -261,10 +261,10 @@ int do_equals() ++column; -if ( enum_mode ) return ( 1 ); +if ( enum_mode ) return 1; -return ( 0 ); +return 0; } @@ -278,10 +278,10 @@ int do_comma() ++column; -if ( enum_mode ) return ( 1 ); +if ( enum_mode ) return 1; -return ( 0 ); +return 0; } @@ -300,7 +300,7 @@ c1 = nextchar(); c2 = nextchar(); -while ( 1 ) { +while ( true ) { if ( (c1 == EOF) || (c2 == EOF) ) break; @@ -329,7 +329,7 @@ void do_cpp_comment() int c; -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -366,7 +366,7 @@ if ( c == '\n' ) { } -return ( c ); +return c; } @@ -388,7 +388,7 @@ if ( t == CLASS ) last_was_class = 1; if ( t == ENUM ) last_was_enum = 1; -return ( t ); +return t; } diff --git a/src/basic/enum_to_string/info.cc b/src/basic/enum_to_string/info.cc index c1794c37a4..76927b8979 100644 --- a/src/basic/enum_to_string/info.cc +++ b/src/basic/enum_to_string/info.cc @@ -275,7 +275,7 @@ for (j=0; j 0 ); +return digit_count > 0; } diff --git a/src/basic/enum_to_string/scope.h b/src/basic/enum_to_string/scope.h index ee27397451..93ca9d44ec 100644 --- a/src/basic/enum_to_string/scope.h +++ b/src/basic/enum_to_string/scope.h @@ -57,9 +57,9 @@ class ScopeStackElement { //////////////////////////////////////////////////////////////////////// -inline int ScopeStackElement::level() const { return ( Level ); } +inline int ScopeStackElement::level() const { return Level; } -inline const char * ScopeStackElement::name() const { return ( Name ); } +inline const char * ScopeStackElement::name() const { return Name; } //////////////////////////////////////////////////////////////////////// @@ -113,7 +113,7 @@ class ScopeStack { //////////////////////////////////////////////////////////////////////// -inline int ScopeStack::n_elements() const { return ( N ); } +inline int ScopeStack::n_elements() const { return N; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/config.tab.yy b/src/basic/vx_config/config.tab.yy index 836a874747..dabe56d786 100644 --- a/src/basic/vx_config/config.tab.yy +++ b/src/basic/vx_config/config.tab.yy @@ -815,7 +815,7 @@ DictionaryEntry e; count = 0; -while ( 1 ) { +while ( true ) { v = icvs.pop(); diff --git a/src/basic/vx_config/config_scanner.ll b/src/basic/vx_config/config_scanner.ll index 515b068416..371af9971a 100644 --- a/src/basic/vx_config/config_scanner.ll +++ b/src/basic/vx_config/config_scanner.ll @@ -129,63 +129,63 @@ REAL_NUMBER (("-"?){DIGITS}{EXP})|(("-"?)"."{DIGITS}{OPT_EXP})|(("-"?){DIGITS}" %% -"<" { return ( do_comp() ); } -">" { return ( do_comp() ); } -"<=" { return ( do_comp() ); } -">=" { return ( do_comp() ); } -"==" { return ( do_comp() ); } -"!=" { return ( do_comp() ); } -"NA" { return ( do_comp() ); } +"<" { return do_comp(); } +">" { return do_comp(); } +"<=" { return do_comp(); } +">=" { return do_comp(); } +"==" { return do_comp(); } +"!=" { return do_comp(); } +"NA" { return do_comp(); } -"le"({INT_NUMBER}|{REAL_NUMBER}) { return ( do_fort_thresh() ); } -"lt"({INT_NUMBER}|{REAL_NUMBER}) { return ( do_fort_thresh() ); } -"gt"({INT_NUMBER}|{REAL_NUMBER}) { return ( do_fort_thresh() ); } -"ge"({INT_NUMBER}|{REAL_NUMBER}) { return ( do_fort_thresh() ); } -"eq"({INT_NUMBER}|{REAL_NUMBER}) { return ( do_fort_thresh() ); } -"ne"({INT_NUMBER}|{REAL_NUMBER}) { return ( do_fort_thresh() ); } +"le"({INT_NUMBER}|{REAL_NUMBER}) { return do_fort_thresh(); } +"lt"({INT_NUMBER}|{REAL_NUMBER}) { return do_fort_thresh(); } +"gt"({INT_NUMBER}|{REAL_NUMBER}) { return do_fort_thresh(); } +"ge"({INT_NUMBER}|{REAL_NUMBER}) { return do_fort_thresh(); } +"eq"({INT_NUMBER}|{REAL_NUMBER}) { return do_fort_thresh(); } +"ne"({INT_NUMBER}|{REAL_NUMBER}) { return do_fort_thresh(); } -"&&" { Column+=2; return ( LOGICAL_OP_AND ); } -"||" { Column+=2; return ( LOGICAL_OP_OR ); } +"&&" { Column+=2; return LOGICAL_OP_AND; } +"||" { Column+=2; return LOGICAL_OP_OR; } -"!" { Column+=1; return ( LOGICAL_OP_NOT ); } +"!" { Column+=1; return LOGICAL_OP_NOT; } -"[" { ++Column; is_lhs = false; dict_stack->push_array(); return ( configtext[0] ); } -"{" { ++Column; is_lhs = true; dict_stack->push(); return ( configtext[0] ); } +"[" { ++Column; is_lhs = false; dict_stack->push_array(); return configtext[0]; } +"{" { ++Column; is_lhs = true; dict_stack->push(); return configtext[0]; } -"]" { ++Column; return ( configtext[0] ); } -"}" { ++Column; return ( configtext[0] ); } +"]" { ++Column; return configtext[0]; } +"}" { ++Column; return configtext[0]; } -"(" { ++Column; return ( configtext[0] ); } -")" { ++Column; return ( configtext[0] ); } +"(" { ++Column; return configtext[0]; } +")" { ++Column; return configtext[0]; } -"+" { ++Column; return ( configtext[0] ); } -"-" { ++Column; return ( configtext[0] ); } -"/" { ++Column; return ( configtext[0] ); } -"*" { ++Column; return ( configtext[0] ); } -"^" { ++Column; return ( configtext[0] ); } +"+" { ++Column; return configtext[0]; } +"-" { ++Column; return configtext[0]; } +"/" { ++Column; return configtext[0]; } +"*" { ++Column; return configtext[0]; } +"^" { ++Column; return configtext[0]; } -"=" { ++Column; return ( configtext[0] ); } -";" { ++Column; is_lhs = true; return ( configtext[0] ); } -"," { ++Column; return ( configtext[0] ); } +"=" { ++Column; return configtext[0]; } +";" { ++Column; is_lhs = true; return configtext[0]; } +"," { ++Column; return configtext[0]; } -"\"" { do_quoted_string(); return ( QUOTED_STRING ); } +"\"" { do_quoted_string(); return QUOTED_STRING; } "${"{IDENTIFIER}"}" { do_env(); } -{IDENTIFIER} { return ( do_id() ); } +{IDENTIFIER} { return do_id(); } -{INT_NUMBER} { do_int(); return ( INTEGER ); } +{INT_NUMBER} { do_int(); return INTEGER; } -{REAL_NUMBER} { do_float(); return ( FLOAT ); } +{REAL_NUMBER} { do_float(); return FLOAT; } @@ -199,7 +199,7 @@ REAL_NUMBER (("-"?){DIGITS}{EXP})|(("-"?)"."{DIGITS}{OPT_EXP})|(("-"?){DIGITS}" "\n" { ++LineNumber; Column = 1; } -<> { if ( do_eof() ) return ( 0 ); } +<> { if ( do_eof() ) return 0; } . { ++Column; } @@ -230,7 +230,7 @@ if ( c == '\n' ) { } -return ( c ); +return c; } @@ -245,7 +245,7 @@ void do_cpp_comment() int c; -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -275,7 +275,7 @@ c2 = nextchar(); comment_depth = 1; -while ( 1 ) { +while ( true ) { if ( (c1 == EOF) || (c2 == EOF) ) break; @@ -338,7 +338,7 @@ else { // done // -return ( return_value ); +return return_value; } @@ -389,7 +389,7 @@ char line[max_id_length]; n = 0; -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -476,32 +476,32 @@ Column += strlen(configtext); // print? // -if ( strcmp(configtext, "print" ) == 0 ) { return ( PRINT ); } +if ( strcmp(configtext, "print" ) == 0 ) { return PRINT; } // // boolean? // -if ( strcmp(configtext, "true" ) == 0 ) { configlval.bval = true; return ( BOOLEAN ); } -if ( strcmp(configtext, "false" ) == 0 ) { configlval.bval = false; return ( BOOLEAN ); } +if ( strcmp(configtext, "true" ) == 0 ) { configlval.bval = true; return BOOLEAN; } +if ( strcmp(configtext, "false" ) == 0 ) { configlval.bval = false; return BOOLEAN; } -if ( strcmp(configtext, "TRUE" ) == 0 ) { configlval.bval = true; return ( BOOLEAN ); } -if ( strcmp(configtext, "FALSE" ) == 0 ) { configlval.bval = false; return ( BOOLEAN ); } +if ( strcmp(configtext, "TRUE" ) == 0 ) { configlval.bval = true; return BOOLEAN; } +if ( strcmp(configtext, "FALSE" ) == 0 ) { configlval.bval = false; return BOOLEAN; } // // comparison? // -if ( strcmp(configtext, "lt" ) == 0 ) { configlval.cval = thresh_lt; return ( COMPARISON ); } -if ( strcmp(configtext, "le" ) == 0 ) { configlval.cval = thresh_le; return ( COMPARISON ); } +if ( strcmp(configtext, "lt" ) == 0 ) { configlval.cval = thresh_lt; return COMPARISON; } +if ( strcmp(configtext, "le" ) == 0 ) { configlval.cval = thresh_le; return COMPARISON; } -if ( strcmp(configtext, "gt" ) == 0 ) { configlval.cval = thresh_gt; return ( COMPARISON ); } -if ( strcmp(configtext, "ge" ) == 0 ) { configlval.cval = thresh_ge; return ( COMPARISON ); } +if ( strcmp(configtext, "gt" ) == 0 ) { configlval.cval = thresh_gt; return COMPARISON; } +if ( strcmp(configtext, "ge" ) == 0 ) { configlval.cval = thresh_ge; return COMPARISON; } -if ( strcmp(configtext, "ne" ) == 0 ) { configlval.cval = thresh_ne; return ( COMPARISON ); } -if ( strcmp(configtext, "eq" ) == 0 ) { configlval.cval = thresh_eq; return ( COMPARISON ); } +if ( strcmp(configtext, "ne" ) == 0 ) { configlval.cval = thresh_ne; return COMPARISON; } +if ( strcmp(configtext, "eq" ) == 0 ) { configlval.cval = thresh_eq; return COMPARISON; } -if ( strcmp(configtext, na_str ) == 0 ) { configlval.cval = thresh_na; return ( NA_COMPARISON ); } +if ( strcmp(configtext, na_str ) == 0 ) { configlval.cval = thresh_na; return NA_COMPARISON; } // // builtin ? @@ -509,13 +509,13 @@ if ( strcmp(configtext, na_str ) == 0 ) { configlval.cval = thresh_na; return int index; -if ( (! is_lhs) && is_builtin((string)configtext, index) ) { configlval.index = index; return ( BUILTIN ); } +if ( (! is_lhs) && is_builtin((string)configtext, index) ) { configlval.index = index; return BUILTIN; } // // local variable ? // -if ( is_function_def && ida.has(configtext, index) ) { configlval.index = index; return ( LOCAL_VAR ); } +if ( is_function_def && ida.has(configtext, index) ) { configlval.index = index; return LOCAL_VAR; } // // number? @@ -529,13 +529,13 @@ if ( e && (e->is_number()) && (! is_lhs) ) { set_int(configlval.nval, e->i_value()); - return ( INTEGER ); + return INTEGER; } else { set_double(configlval.nval, e->d_value()); - return ( FLOAT ); + return FLOAT; } @@ -549,7 +549,7 @@ if ( e && (! is_lhs) && (e->type() == UserFunctionType) ) { configlval.entry = e; - return ( USER_FUNCTION ); + return USER_FUNCTION; } @@ -560,7 +560,7 @@ if ( e && (! is_lhs) && (e->type() == UserFunctionType) ) { strncpy(configlval.text, configtext, sizeof(configlval.text) - 1); -return ( IDENTIFIER ); +return IDENTIFIER; } @@ -759,7 +759,7 @@ bool do_eof() { -if ( ! reading_env ) return ( true ); +if ( ! reading_env ) return true; config_delete_buffer(YY_CURRENT_BUFFER); @@ -769,7 +769,7 @@ reading_env = false; Column += 3; -return ( false ); +return false; } @@ -844,7 +844,7 @@ int do_fort_thresh() strncpy(configlval.text, configtext, sizeof(configlval.text)); -return ( FORTRAN_THRESHOLD ); +return FORTRAN_THRESHOLD; } diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index 91d34685bc..d8088d406c 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -28,7 +28,6 @@ #include "configobjecttype_to_string.h" - using namespace std; diff --git a/src/libcode/vx_color/color_scanner.ll b/src/libcode/vx_color/color_scanner.ll index 85242c3f67..3efa922f81 100644 --- a/src/libcode/vx_color/color_scanner.ll +++ b/src/libcode/vx_color/color_scanner.ll @@ -82,38 +82,38 @@ OPT_EXP {EXP}? %% -"," { ++color_file_column; return ( ',' ); } +"," { ++color_file_column; return ','; } -"{" { ++color_file_column; return ( '{' ); } -"}" { ++color_file_column; return ( '}' ); } +"{" { ++color_file_column; return '{'; } +"}" { ++color_file_column; return '}'; } -"(" { ++color_file_column; return ( '(' ); } -")" { ++color_file_column; return ( ')' ); } +"(" { ++color_file_column; return '('; } +")" { ++color_file_column; return ')'; } -"=" { ++color_file_column; return ( '=' ); } +"=" { ++color_file_column; return '='; } -"\"" { do_quoted_string(); return ( QUOTED_STRING ); } +"\"" { do_quoted_string(); return QUOTED_STRING; } -({LETTER})({LETTER}|{DIGIT})* { return ( do_id() ); } +({LETTER})({LETTER}|{DIGIT})* { return do_id(); } -("-"?){DIGITS} { do_int(); return ( INTEGER ); } +("-"?){DIGITS} { do_int(); return INTEGER; } -("-"?){DIGITS}{EXP} { do_float(); return ( FLOAT ); } +("-"?){DIGITS}{EXP} { do_float(); return FLOAT; } -("-"?)"."{DIGITS}{OPT_EXP} { do_float(); return ( FLOAT ); } +("-"?)"."{DIGITS}{OPT_EXP} { do_float(); return FLOAT; } -("-"?){DIGITS}"."{OPT_EXP} { do_float(); return ( FLOAT ); } +("-"?){DIGITS}"."{OPT_EXP} { do_float(); return FLOAT; } -("-"?){DIGITS}"."{DIGITS}{OPT_EXP} { do_float(); return ( FLOAT ); } +("-"?){DIGITS}"."{DIGITS}{OPT_EXP} { do_float(); return FLOAT; } @@ -145,10 +145,10 @@ int do_id() color_file_column += strlen(colortext); -if ( strcmp(colortext, "blend" ) == 0 ) return ( BLEND ); -if ( strcmp(colortext, "hsv" ) == 0 ) return ( HSV ); -if ( strcmp(colortext, "cmyk" ) == 0 ) return ( CMYK ); -if ( strcmp(colortext, "grayvalue") == 0 ) return ( GRAYVALUE ); +if ( strcmp(colortext, "blend" ) == 0 ) return BLEND; +if ( strcmp(colortext, "hsv" ) == 0 ) return HSV; +if ( strcmp(colortext, "cmyk" ) == 0 ) return CMYK; +if ( strcmp(colortext, "grayvalue") == 0 ) return GRAYVALUE; int index; @@ -157,13 +157,13 @@ if ( clist.has_name(colortext, index) ) { colorlval.ival = index; - return ( COLOR_NAME ); + return COLOR_NAME; } strncpy(colorlval.text, colortext, sizeof(colorlval.text) - 1); -return ( ID ); +return ID; } @@ -215,7 +215,7 @@ c2 = nextchar(); comment_depth = 1; -while ( 1 ) { +while ( true ) { if ( (c1 == EOF) || (c2 == EOF) ) break; @@ -252,7 +252,7 @@ void do_cpp_comment() int c; -while ( 1 ) { +while ( true ) { c = nextchar(); @@ -289,7 +289,7 @@ if ( c == '\n' ) { } -return ( c ); +return c; } @@ -308,7 +308,7 @@ char line[128]; n = 0; -while ( 1 ) { +while ( true ) { c = nextchar(); From 108a8958b206d6712197823a083666ab039bf818 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 14 Mar 2024 09:23:53 -0600 Subject: [PATCH 028/114] Feature #2583 ecnt (#2825) * Unrelated to #2583, fix typo in code comments. * Per #2583, add hooks write 3 new ECNT columns for observation error data. * Per #2583, make error messages about mis-matched array lengths more informative. * Per #2583, switch to more concise variable naming conventions of ign_oerr_cnv, ign_oerr_cor, and dawid_seb. * Per #2583, fix typo to enable compilation * Per #2583, define the 5 new ECNT column names. * Per #2583, add 5 new columns to the ECNT table in the Ensemble-Stat chapter * Per #2583, update stat_columns.cc to write these 5 new ECNT columns * Per #2583, update ECNTInfo class to compute the 5 new ECNT statistics. * Per #2583, update stat-analysis to parse the 5 new ECNT columns. * Per #2583, update aggregate_stat logic for 5 new ECNT columns. * Per #2583, update PairDataEnsemble logic for 5 new ECNT columns * Per #2583, update vx_statistics library with obs_error handling logic for the 5 new ECNT columns * Per #2583, changes to make it compile * Per #2583, changes to make it compile * Per #2583, switch to a consistent ECNT column naming convention with OERR at the end. Using IGN_CONV_OERR and IGN_CORR_OERR. * Per #2583, define ObsErrorEntry::variance() with a call to the dist_var() utility function. * Per #2583, update PairDataEnsemble::compute_pair_vals() to compute the 5 new stats with the correct inputs. * Per #2583, add DEBUG(10) log messages about computing these new stats. * Per #2583, update Stat-Analysis to compute these 5 new stats from the ORANK line type. * Per #2583, whitespace and comments. * Per #2583, update the User's Guide. * Per #2583, remove the DS_ADD_OERR and DS_MULT_OERR ECNT columns and rename DS_OERR as DSS, since observation error is not actually involved in its computation. * Per #2583, minor update to Appendix C * Per #2583, rename ECNT line type statistic DSS to IDSS. * Per #2583, fix a couple of typos * Per #2583, more error checking. * Per #2583, remove the ECNT IDSS column since its just 2*pi*IGN, the existing ignorance score, and only provides meaningful information when combined with the other Dawid-Sebastiani statistics that have already been removed. * Per #2583, add Eric's documentation of these new stats to Appendix C. Along the way, update the DOI links in the references based on this APA style guide: https://apastyle.apa.org/style-grammar-guidelines/references/dois-urls#:~:text=Include%20a%20DOI%20for%20all,URL%2C%20include%20only%20the%20DOI. * Per #2583, fix new equations with embedded underscores for PDF by defining both html and pdf formatting options. * Per #2583, update the ign_conv_oerr equation to include a 2 *pi multiplier for consistency with the existing ignorance score. Also, fix the documented equations. * Per #2583, remove log file that was inadvertently added on this branch. * Per #2583, simplify ObsErrorEntry::variance() implementation. For the distribution type of NONE, return a variance of 0.0 rather than bad data, as discussed with @michelleharrold and @JeffBeck-NOAA on 3/8/2024. --------- Co-authored-by: MET Tools Test Account --- data/table_files/met_header_columns_V12.0.txt | 2 +- docs/Users_Guide/appendixC.rst | 53 +++++-- docs/Users_Guide/ensemble-stat.rst | 10 +- docs/Users_Guide/refs.rst | 135 ++++++++++++------ internal/test_unit/hdr/met_12_0.hdr | 2 +- src/basic/vx_util/num_array.cc | 8 +- src/basic/vx_util/stat_column_defs.h | 2 +- src/libcode/vx_gsl_prob/gsl_randist.h | 4 +- src/libcode/vx_stat_out/stat_columns.cc | 8 +- src/libcode/vx_statistics/ens_stats.cc | 18 ++- src/libcode/vx_statistics/ens_stats.h | 4 + src/libcode/vx_statistics/met_stats.cc | 19 +++ src/libcode/vx_statistics/met_stats.h | 2 + src/libcode/vx_statistics/obs_error.cc | 7 + src/libcode/vx_statistics/obs_error.h | 3 + .../vx_statistics/pair_data_ensemble.cc | 117 ++++++++++++--- .../vx_statistics/pair_data_ensemble.h | 90 ++++++------ src/libcode/vx_statistics/pair_data_point.cc | 2 +- .../core/stat_analysis/aggr_stat_line.cc | 27 +++- .../core/stat_analysis/parse_stat_line.cc | 5 + .../core/stat_analysis/parse_stat_line.h | 3 + src/tools/core/wavelet_stat/wavelet_stat.cc | 4 +- 22 files changed, 390 insertions(+), 135 deletions(-) diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index 7ed1e5a187..299e6cb4d6 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -19,7 +19,7 @@ V12.0 : STAT : PJC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : PRC : 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]* PODY_[0-9]* POFD_[0-9]* V12.0 : STAT : PSTD : 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) BASER BASER_NCL BASER_NCU RELIABILITY RESOLUTION UNCERTAINTY ROC_AUC BRIER BRIER_NCL BRIER_NCU BRIERCL BRIERCL_NCL BRIERCL_NCU BSS BSS_SMPL THRESH_[0-9]* V12.0 : STAT : ECLV : 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 VALUE_BASER (N_PTS) CL_[0-9]* VALUE_[0-9]* -V12.0 : STAT : ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS +V12.0 : STAT : ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS IGN_CONV_OERR IGN_CORR_OERR V12.0 : STAT : RPS : 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_PROB RPS_REL RPS_RES RPS_UNC RPS RPSS RPSS_SMPL RPS_COMP V12.0 : STAT : RHIST : 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_RANK) RANK_[0-9]* V12.0 : STAT : PHIST : 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 BIN_SIZE (N_BIN) BIN_[0-9]* diff --git a/docs/Users_Guide/appendixC.rst b/docs/Users_Guide/appendixC.rst index 7c5c618a43..037bd93455 100644 --- a/docs/Users_Guide/appendixC.rst +++ b/docs/Users_Guide/appendixC.rst @@ -401,7 +401,7 @@ SEEPS scores are expected to lie between 0 and 1, with a perfect forecast having MET Verification Measures for Continuous Variables ================================================== -For continuous variables, many verification measures are based on the forecast error (i.e., **f - o**). However, it also is of interest to investigate characteristics of the forecasts, and the observations, as well as their relationship. These concepts are consistent with the general framework for verification outlined by :ref:`Murphy and Winkler, (1987) `. The statistics produced by MET for continuous forecasts represent this philosophy of verification, which focuses on a variety of aspects of performance rather than a single measure. +For continuous variables, many verification measures are based on the forecast error (i.e., **f - o**). However, it also is of interest to investigate characteristics of the forecasts, and the observations, as well as their relationship. These concepts are consistent with the general framework for verification outlined by :ref:`Murphy and Winkler, 1987 `. The statistics produced by MET for continuous forecasts represent this philosophy of verification, which focuses on a variety of aspects of performance rather than a single measure. The verification measures currently evaluated by the Point-Stat tool are defined and described in the subsections below. In these definitions, **f** represents the forecasts, **o** represents the observation, and **n** is the number of forecast-observation pairs. @@ -894,7 +894,7 @@ Calibration Called "CALIBRATION" in PJC output :numref:`table_PS_format_info_PJC` -Calibration is the conditional probability of an event given each probability forecast category (i.e. each row in the **nx2** contingency table). This set of measures is paired with refinement in the calibration-refinement factorization discussed in :ref:`Wilks, (2011) `. A well-calibrated forecast will have calibration values that are near the forecast probability. For example, a 50% probability of precipitation should ideally have a calibration value of 0.5. If the calibration value is higher, then the probability has been underestimated, and vice versa. +Calibration is the conditional probability of an event given each probability forecast category (i.e. each row in the **nx2** contingency table). This set of measures is paired with refinement in the calibration-refinement factorization discussed in :ref:`Wilks, 2011 `. A well-calibrated forecast will have calibration values that are near the forecast probability. For example, a 50% probability of precipitation should ideally have a calibration value of 0.5. If the calibration value is higher, then the probability has been underestimated, and vice versa. .. math:: \text{Calibration}(i) = \frac{n_{i1}}{n_{1.}} = \text{probability}(o_1|p_i) @@ -903,7 +903,7 @@ Refinement Called "REFINEMENT" in PJC output :numref:`table_PS_format_info_PJC` -The relative frequency associated with each forecast probability, sometimes called the marginal distribution or row probability. This measure ignores the event outcome, and simply provides information about the frequency of forecasts for each probability category. This set of measures is paired with the calibration measures in the calibration-refinement factorization discussed by :ref:`Wilks (2011) `. +The relative frequency associated with each forecast probability, sometimes called the marginal distribution or row probability. This measure ignores the event outcome, and simply provides information about the frequency of forecasts for each probability category. This set of measures is paired with the calibration measures in the calibration-refinement factorization discussed by :ref:`Wilks, 2011 `. .. math:: \text{Refinement}(i) = \frac{n_{i.}}{T} = \text{probability}(p_i) @@ -912,7 +912,7 @@ Likelihood Called "LIKELIHOOD" in PJC output :numref:`table_PS_format_info_PJC` -Likelihood is the conditional probability for each forecast category (row) given an event and a component of the likelihood-base rate factorization; see :ref:`Wilks (2011) ` for details. This set of measures considers the distribution of forecasts for only the cases when events occur. Thus, as the forecast probability increases, so should the likelihood. For example, 10% probability of precipitation forecasts should have a much smaller likelihood value than 90% probability of precipitation forecasts. +Likelihood is the conditional probability for each forecast category (row) given an event and a component of the likelihood-base rate factorization; see :ref:`Wilks, 2011 ` for details. This set of measures considers the distribution of forecasts for only the cases when events occur. Thus, as the forecast probability increases, so should the likelihood. For example, 10% probability of precipitation forecasts should have a much smaller likelihood value than 90% probability of precipitation forecasts. .. math:: \text{Likelihood}(i) = \frac{n_{i1}}{n_{.1}} = \text{probability}(p_i|o_1) @@ -923,7 +923,7 @@ Base Rate Called "BASER" in PJC output :numref:`table_PS_format_info_PJC` -This is the probability of an event for each forecast category :math:`p_i` (row), i.e. the conditional base rate. This set of measures is paired with likelihood in the likelihood-base rate factorization, see :ref:`Wilks (2011) ` for further information. This measure is calculated for each row of the contingency table. Ideally, the event should become more frequent as the probability forecast increases. +This is the probability of an event for each forecast category :math:`p_i` (row), i.e. the conditional base rate. This set of measures is paired with likelihood in the likelihood-base rate factorization, see :ref:`Wilks, 2011 ` for further information. This measure is calculated for each row of the contingency table. Ideally, the event should become more frequent as the probability forecast increases. .. math:: \text{Base Rate}(i) = \frac{n_{i1}}{n_{i.}} = \text{probability}(o_{i1}) @@ -976,18 +976,18 @@ RPS Called "RPS" in RPS output :numref:`table_ES_header_info_es_out_ECNT` -While the above probabilistic verification measures utilize dichotomous observations, the Ranked Probability Score (RPS, :ref:`Epstein, 1969 `, :ref:`Murphy, 1969 `) is the only probabilistic verification measure for discrete multiple-category events available in MET. It is assumed that the categories are ordinal as nominal categorical variables can be collapsed into sequences of binary predictands, which can in turn be evaluated with the above measures for dichotomous variables (:ref:`Wilks, 2011 `). The RPS is the multi-category extension of the Brier score (:ref:`Tödter and Ahrens, 2012`), and is a proper score (:ref:`Mason, 2008`). +While the above probabilistic verification measures utilize dichotomous observations, the Ranked Probability Score (RPS, :ref:`Epstein, 1969 `, :ref:`Murphy, 1969 `) is the only probabilistic verification measure for discrete multiple-category events available in MET. It is assumed that the categories are ordinal as nominal categorical variables can be collapsed into sequences of binary predictands, which can in turn be evaluated with the above measures for dichotomous variables (:ref:`Wilks, 2011 `). The RPS is the multi-category extension of the Brier score (:ref:`Tödter and Ahrens, 2012 `), and is a proper score (:ref:`Mason, 2008 `). Let :math:`\text{J}` be the number of categories, then both the forecast, :math:`\text{f} = (f_1,…,f_J)`, and observation, :math:`\text{o} = (o_1,…,o_J)`, are length-:math:`\text{J}` vectors, where the components of :math:`\text{f}` include the probabilities forecast for each category :math:`\text{1,…,J}` and :math:`\text{o}` contains 1 in the category that is realized and zero everywhere else. The cumulative forecasts, :math:`F_m`, and observations, :math:`O_m`, are defined to be: :math:`F_m = \sum_{j=1}^m (f_j)` and :math:`O_m = \sum_{j=1}^m (o_j), m = 1,…,J`. -To clarify, :math:`F_1 = f_1` is the first component of :math:`F_m`, :math:`F_2 = f_1+f_2`, etc., and :math:`F_J = 1`. Similarly, if :math:`o_j = 1` and :math:`i < j`, then :math:`O_i = 0` and when :math:`i >= j`, :math:`O_i = 1`, and of course, :math:`O_J = 1`. Finally, the RPS is defined to be: +To clarify, :math:`F_1 = f_1` is the first component of :math:`F_m`, :math:`F_2 = f_1+f_2`, etc., and :math:`F_J = 1`. Similarly, if :math:`o_j = 1` and :math:`i < j`, then :math:`O_i = 0` and when :math:`i >= j`, :math:`O_i = 1`, and of course, :math:`O_J = 1`. Finally, the RPS is defined to be: .. math:: \text{RPS} = \sum_{m=1}^J (F_m - O_m)^2 = \sum_{m=1}^J BS_m, -where :math:`BS_m` is the Brier score for the m-th category (:ref:`Tödter and Ahrens, 2012`). Subsequently, the RPS lends itself to a decomposition into reliability, resolution and uncertainty components, noting that each component is aggregated over the different categories; these are written to the columns named "RPS_REL", "RPS_RES" and "RPS_UNC" in RPS output :numref:`table_ES_header_info_es_out_ECNT`. +where :math:`BS_m` is the Brier score for the m-th category (:ref:`Tödter and Ahrens, 2012 `). Subsequently, the RPS lends itself to a decomposition into reliability, resolution and uncertainty components, noting that each component is aggregated over the different categories; these are written to the columns named "RPS_REL", "RPS_RES" and "RPS_UNC" in RPS output :numref:`table_ES_header_info_es_out_ECNT`. CRPS ---- @@ -1066,7 +1066,7 @@ The continuous ranked probability skill score (CRPSS) is similar to the MSESS an .. math:: \text{CRPSS} = 1 - \frac{\text{CRPS}_{fcst}}{ \text{CRPS}_{ref}} -For the normal distribution fit (CRPSS), the reference CRPS is computed using the climatological mean and standard deviation. For the empirical distribution (CRPSS_EMP), the reference CRPS is computed by sampling from the assumed normal climatological distribution defined by the mean and standard deviation. +For the normal distribution fit (CRPSS), the reference CRPS is computed using the climatological mean and standard deviation. For the empirical distribution (CRPSS_EMP), the reference CRPS is computed by sampling from the assumed normal climatological distribution defined by the mean and standard deviation. Bias Ratio ---------- @@ -1105,6 +1105,37 @@ Called "PIT" in ORANK output :numref:`table_ES_header_info_es_out_ORANK` The probability integral transform (PIT) is the analog of the rank histogram for a probability distribution forecast (:ref:`Dawid, 1984 `). Its interpretation is the same as that of the verification rank histogram: Calibrated probabilistic forecasts yield PIT histograms that are flat, or uniform. Under-dispersed (not enough spread in the ensemble) forecasts have U-shaped PIT histograms while over-dispersed forecasts have bell-shaped histograms. In MET, the PIT calculation uses a normal distribution fit to the ensemble forecasts. In many cases, use of other distributions would be better. +Observation Error Logarithmic Scoring Rules +------------------------------------------- + +Called "IGN_CONV_OERR" and "IGN_CORR_OERR" in ECNT output :numref:`table_ES_header_info_es_out_ECNT` + +One approach that is used to take observation error into account in a summary measure is to add error to the forecast by a convolution with the observation model (e.g., :ref:`Anderson, 1996 `; :ref:`Hamill, 2001 `; :ref:`Saetra et. al., 2004 `; :ref:`Bröcker and Smith, 2007 `; :ref:`Candille et al., 2007 `; :ref:`Candille and Talagrand, 2008 `; :ref:`Röpnack et al., 2013 `). Specifically, suppose :math:`y=x+w`, where :math:`y` is the observed value, :math:`x` is the true value, and :math:`w` is the error. Then, if :math:`f` is the density forecast for :math:`x` and :math:`\nu` is the observation model, then the implied density forecast for :math:`y` is given by the convolution: + +.. math:: (f*\nu)(y) = \int\nu(y|x)f(x)dx + +:ref:`Ferro, 2017 ` gives the error-convolved version of the ignorance scoring rule (referred to therein as the error-convolved logarithmic scoring rule), which is proper under the model where :math:`w\sim N(0,c^2)`) when the forecast for :math:`x` is :math:`N(\mu,\sigma^2)` with density function :math:`f`, by + +.. only:: latex + + .. math:: \text{IGN\_CONV\_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi (\sigma^2 + c^2)) + \frac{(y - \mu)^2}{2 (\sigma^2 + c^2)} + +.. only:: html + + .. math:: \text{IGN_CONV_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi (\sigma^2 + c^2)) + \frac{(y - \mu)^2}{2 (\sigma^2 + c^2)} + +Another approach to incorporation of observation uncertainty into a measure is the error-correction approach. The approach merely ensures that the scoring rule, :math:`s`, is unbiased for a scoring rule :math:`s_0` if they have the same expected value. :ref:`Ferro, 2017 ` gives the error-corrected ignorance scoring rule (which is also proposer when :math:`w\sim N(0,c^2)`) as + +.. only:: latex + + .. math:: \text{IGN\_CORR\_OERR} = s(f,y) = \log\sigma + \frac{(y - \mu)^2 - c^2}{2\sigma^2} + +.. only:: html + + .. math:: \text{IGN_CORR_OERR} = s(f,y) = \log\sigma + \frac{(y - \mu)^2 - c^2}{2\sigma^2} + +The expected score for the error-convolved ignorance scoring rule typically differs from the expected score that would be achieved if there were no observation error. The error-corrected score, on the other hand, has the same expectation. + RANK ---- @@ -1160,7 +1191,7 @@ The traditional contingency table statistics computed by the Grid-Stat neighborh All of these measures are defined in :numref:`categorical variables`. -In addition to these standard statistics, the neighborhood analysis provides additional continuous measures, the Fractions Brier Score and the Fractions Skill Score. For reference, the Asymptotic Fractions Skill Score and Uniform Fractions Skill Score are also calculated. These measures are defined here, but are explained in much greater detail in :ref:`Ebert (2008) ` and :ref:`Roberts and Lean (2008) `. :ref:`Roberts and Lean (2008) ` also present an application of the methodology. +In addition to these standard statistics, the neighborhood analysis provides additional continuous measures, the Fractions Brier Score and the Fractions Skill Score. For reference, the Asymptotic Fractions Skill Score and Uniform Fractions Skill Score are also calculated. These measures are defined here, but are explained in much greater detail in :ref:`Ebert, 2008 ` and :ref:`Roberts and Lean, 2008 `. :ref:`Roberts and Lean, 2008 ` also present an application of the methodology. Fractions Brier Score --------------------- @@ -1225,7 +1256,7 @@ A mathematical metric, :math:`m(A,B)\geq 0`, must have the following three prope The first establishes that a perfect score is zero and that the only way to obtain a perfect score is if the two sets are identical according to the metric. The second requirement ensures that the order by which the two sets are evaluated will not change the result. The third property ensures that if *C* is closer to *A* than *B* is to *A*, then :math:`m(A,C) < m(A,B)`. -It has been argued in :ref:`Gilleland (2017) ` that the second property of symmetry is not necessarily an important quality to have for a summary measure for verification purposes because lack of symmetry allows for information about false alarms and misses. +It has been argued in :ref:`Gilleland, 2017 ` that the second property of symmetry is not necessarily an important quality to have for a summary measure for verification purposes because lack of symmetry allows for information about false alarms and misses. The results of the distance map verification approaches that are included in the Grid-Stat tool are summarized using a variety of measures. These measures include Baddeley's :math:`\Delta` Metric, the Hausdorff Distance, the Mean-error Distance, Pratt's Figure of Merit, and Zhu's Measure. Their equations are listed below. diff --git a/docs/Users_Guide/ensemble-stat.rst b/docs/Users_Guide/ensemble-stat.rst index 42443aa315..7eba9f1aa9 100644 --- a/docs/Users_Guide/ensemble-stat.rst +++ b/docs/Users_Guide/ensemble-stat.rst @@ -66,7 +66,9 @@ The climatological distribution is also used for the RPSS. The forecast RPS stat Ensemble Observation Error -------------------------- -In an attempt to ameliorate the effect of observation errors on the verification of forecasts, a random perturbation approach has been implemented. A great deal of user flexibility has been built in, but the methods detailed in :ref:`Candille and Talagrand (2008) `. can be replicated using the appropriate options. The user selects a distribution for the observation error, along with parameters for that distribution. Rescaling and bias correction can also be specified prior to the perturbation. Random draws from the distribution can then be added to either, or both, of the forecast and observed fields, including ensemble members. Details about the effects of the choices on verification statistics should be considered, with many details provided in the literature (*e.g.* :ref:`Candille and Talagrand, 2008 `; :ref:`Saetra et al., 2004 `; :ref:`Santos and Ghelli, 2012 `). Generally, perturbation makes verification statistics better when applied to ensemble members, and worse when applied to the observations themselves. +In an attempt to ameliorate the effect of observation errors on the verification of forecasts, a random perturbation approach has been implemented. A great deal of user flexibility has been built in, but the methods detailed in :ref:`Candille and Talagrand (2008) ` can be replicated using the appropriate options. Additional probabilistic measures that include observational uncertainty recommended by :ref:`Ferro, 2017 ` are also provided. + +Observation error information can be defined directly in the Ensemble-Stat configuration file or through a more flexible observation error table lookup. The user selects a distribution for the observation error, along with parameters for that distribution. Rescaling and bias correction can also be specified prior to the perturbation. Random draws from the distribution can then be added to either, or both, of the forecast and observed fields, including ensemble members. Details about the effects of the choices on verification statistics should be considered, with many details provided in the literature (*e.g.* :ref:`Candille and Talagrand, 2008 `; :ref:`Saetra et al., 2004 `; :ref:`Santos and Ghelli, 2012 `). Generally, perturbation makes verification statistics better when applied to ensemble members, and worse when applied to the observations themselves. Normal and uniform are common choices for the observation error distribution. The uniform distribution provides the benefit of being bounded on both sides, thus preventing the perturbation from taking on extreme values. Normal is the most common choice for observation error. However, the user should realize that with the very large samples typical in NWP, some large outliers will almost certainly be introduced with the perturbation. For variables that are bounded below by 0, and that may have inconsistent observation errors (e.g. larger errors with larger measurements), a lognormal distribution may be selected. Wind speeds and precipitation measurements are the most common of this type of NWP variable. The lognormal error perturbation prevents measurements of 0 from being perturbed, and applies larger perturbations when measurements are larger. This is often the desired behavior in these cases, but this distribution can also lead to some outliers being introduced in the perturbation step. @@ -647,6 +649,12 @@ The format of the STAT and ASCII output of the Ensemble-Stat tool are described * - 49 - ME_LT_OBS - The Mean Error of the ensemble values less than or equal to their observations + * - 50 + - IGN_CONV_OERR + - Error-convolved logarithmic scoring rule (i.e. ignornance score) from Equation 5 of :ref:`Ferro, 2017 ` + * - 51 + - IGN_CORR_OERR + - Error-corrected logarithmic scoring rule (i.e. ignornance score) from Equation 7 of :ref:`Ferro, 2017 ` .. _table_ES_header_info_es_out_RPS: diff --git a/docs/Users_Guide/refs.rst b/docs/Users_Guide/refs.rst index b4045f90b6..1c328014cb 100644 --- a/docs/Users_Guide/refs.rst +++ b/docs/Users_Guide/refs.rst @@ -14,11 +14,18 @@ References | Ahijevych, D., E. Gilleland, B.G. Brown, and E.E. Ebert, 2009: Application of | spatial verification methods to idealized and NWP-gridded precipitation forecasts. -| *Weather and Forecasting*, 24 (6), 1485 - 1497, doi: 10.1175/2009WAF2222298.1. +| *Weather and Forecasting*, 24 (6), 1485 - 1497. +| doi: https://doi.org/10.1175/2009WAF2222298.1 | -.. _Barker-1991: +.. _Andersen-1996: + +| Anderson JL., 1996: A method for producing and evaluating probabilistic forecasts +| from ensemble model integrations. *J. Clim.* 9: 1518-1530. +| doi: `https://doi.org/10.1175/1520-0442(1996)009<1518:AMFPAE>2.0.CO;2 2.0.CO;2>`_ +| +.. _Barker-1991: | Barker, T. W., 1991: The relationship between spread and forecast error in | extended-range forecasts. *Journal of Climate*, 4, 733-742. @@ -29,14 +36,14 @@ References | Bradley, A.A., S.S. Schwartz, and T. Hashino, 2008: Sampling Uncertainty | and Confidence Intervals for the Brier Score and Brier Skill Score. | *Weather and Forecasting*, 23, 992-1006. -| +| .. _Brill-2009: | Brill, K. F., and F. Mesinger, 2009: Applying a general analytic method | for assessing bias sensitivity to bias-adjusted threat and equitable | threat scores. *Weather and Forecasting*, 24, 1748-1754. -| +| .. _Brown-2007: @@ -49,32 +56,47 @@ References | http://ams.confex.com/ams/pdfpapers/124856.pdf. | +.. _Bröcker-2007: + +| Bröcker J, Smith LA., 2007: Scoring probabilistic forecasts: The importance +| of being proper. *Weather Forecasting*, 22, 382-388. +| doi: https://doi.org/10.1175/WAF966.1 +| + .. _Buizza-1997: | Buizza, R., 1997: Potential forecast skill of ensemble prediction and spread | and skill distributions of the ECMWF ensemble prediction system. *Monthly* -| *Weather Review*,125, 99-119. -| +| *Weather Review*, 125, 99-119. +| .. _Bullock-2016: | Bullock, R., T. Fowler, and B. Brown, 2016: Method for Object-Based | Diagnostic Evaluation. *NCAR Technical Note* NCAR/TN-532+STR, 66 pp. -| +| + +.. _Candille-2007: + +| Candille G, Côté C, Houtekamer PL, Pellerin G, 2007: Verification of an +| ensemble prediction system against observations. *Mon. Weather Rev.* +| 135: 2688-2699. +| doi: https://doi.org/10.1175/MWR3414.1 +| .. _Candille-2008: | Candille, G., and O. Talagrand, 2008: Impact of observational error on the | validation of ensemble prediction systems. *Quarterly Journal of the Royal* | *Meteorological Society* 134: 959-971. -| +| .. _Casati-2004: | Casati, B., G. Ross, and D. Stephenson, 2004: A new intensity-scale approach | for the verification of spatial precipitation forecasts. *Meteorological* | *Applications* 11, 141-154. -| +| .. _Davis-2006: @@ -86,37 +108,45 @@ References | Davis, C.A., B.G. Brown, and R.G. Bullock, 2006b: Object-based verification | of precipitation forecasts, Part II: Application to convective rain systems. | *Monthly Weather Review*, 134, 1785-1795. -| +| .. _Dawid-1984: | Dawid, A.P., 1984: Statistical theory: The prequential approach. *Journal of* | *the Royal Statistical Society* A147, 278-292. -| +| .. _Ebert-2008: | Ebert, E.E., 2008: Fuzzy verification of high-resolution gridded forecasts: -| a review and proposed framework. *Meteorological Applications,* 15, 51-64. -| +| a review and proposed framework. *Meteorological Applications*, 15, 51-64. +| .. _Eckel-2012: | Eckel, F. A., M.S. Allen, M. C. Sittel, 2012: Estimation of Ambiguity in -| Ensemble Forecasts. *Weather Forecasting,* 27, 50-69. -| doi: http://dx.doi.org/10.1175/WAF-D-11-00015.1 +| Ensemble Forecasts. *Weather Forecasting*, 27, 50-69. +| doi: https://doi.org/10.1175/WAF-D-11-00015.1 | .. _Efron-2007: | Efron, B. 2007: Correlation and large-scale significance testing. *Journal* -| of the American Statistical Association,* 102(477), 93-103. +| of the American Statistical Association*, 102(477), 93-103. | .. _Epstein-1969: | Epstein, E. S., 1969: A scoring system for probability forecasts of ranked categories. -| *J. Appl. Meteor.*, 8, 985-987, 10.1175/1520-0450(1969)008<0985:ASSFPF>2.0.CO;2. +| *J. Appl. Meteor.*, 8, 985-987. +| doi: `https://doi.org/10.1175/1520-0450(1969)008<0985:ASSFPF>2.0.CO;2 2.0.CO;2>`_ +| + +.. _Ferro-2017: + +| Ferro C. A. T., 2017: Measuring forecast performance in the presence of observation error. +| *Q. J. R. Meteorol. Soc.*, 143 (708), 2665-2676. +| doi: https://doi.org/10.1002/qj.3115 | .. _Gilleland-2010: @@ -129,29 +159,32 @@ References | Gilleland, E., 2017: A new characterization in the spatial verification | framework for false alarms, misses, and overall patterns. -| *Weather and Forecasting*, 32 (1), 187 - 198, doi: 10.1175/WAF-D-16-0134.1. +| *Weather and Forecasting*, 32 (1), 187 - 198. +| doi: https://doi.org/10.1175/WAF-D-16-0134.1 | .. _Gilleland_PartI-2020: | Gilleland, E., 2020: Bootstrap methods for statistical inference. | Part I: Comparative forecast verification for continuous variables. -| *Journal of Atmospheric and Oceanic Technology*, 37 (11), 2117 - 2134, -| doi: 10.1175/JTECH-D-20-0069.1. +| *Journal of Atmospheric and Oceanic Technology*, 37 (11), 2117 - 2134. +| doi: https://doi.org/10.1175/JTECH-D-20-0069.1 | .. _Gilleland_PartII-2020: | Gilleland, E., 2020: Bootstrap methods for statistical inference. | Part II: Extreme-value analysis. *Journal of Atmospheric and Oceanic* -| *Technology*, 37 (11), 2135 - 2144, doi: 10.1175/JTECH-D-20-0070.1. +| *Technology*, 37 (11), 2135 - 2144. +| doi: https://doi.org/10.1175/JTECH-D-20-0070.1 | .. _Gilleland-2021: | Gilleland, E., 2021: Novel measures for summarizing high-resolution forecast | performance. *Advances in Statistical Climatology, Meteorology and Oceanography*, -| 7 (1), 13 - 34, doi: 10.5194/ascmo-7-13-2021. +| 7 (1), 13 - 34. +| doi: https://doi.org/10.5194/ascmo-7-13-2021 | .. _Gneiting-2004: @@ -161,7 +194,7 @@ References | *Minimum CRPS Estimation*. Technical Report no. 449, Department of | Statistics, University of Washington. Available at | http://www.stat.washington.edu/www/research/reports/ -| +| .. _Haiden-2012: @@ -175,41 +208,41 @@ References | Hamill, T. M., 2001: Interpretation of rank histograms for verifying ensemble | forecasts. *Monthly Weather Review*, 129, 550-560. -| +| .. _Hersbach-2000: | Hersbach, H., 2000: Decomposition of the Continuous Ranked Probability Score | for Ensemble Prediction Systems. *Weather and Forecasting*, 15, 559-570. -| +| .. _Jolliffe-2012: | Jolliffe, I.T., and D.B. Stephenson, 2012: *Forecast verification. A* | *practitioner's guide in atmospheric science.* Wiley and Sons Ltd, 240 pp. -| +| .. _Knaff-2003: | Knaff, J.A., M. DeMaria, C.R. Sampson, and J.M. Gross, 2003: Statistical, | Five-Day Tropical Cyclone Intensity Forecasts Derived from Climatology -| and Persistence. *Weather and Forecasting,* Vol. 18 Issue 2, p. 80-92. -| +| and Persistence. *Weather and Forecasting*, Vol. 18 Issue 2, p. 80-92. +| .. _Mason-2004: | Mason, S. J., 2004: On Using "Climatology" as a Reference Strategy | in the Brier and Ranked Probability Skill Scores. *Monthly Weather Review*, | 132, 1891-1895. -| +| .. _Mason-2008: | Mason, S. J., 2008: Understanding forecast verification statistics. -| *Meteor. Appl.*, 15, 31-40, doi: 10.1002/met.51. +| *Meteor. Appl.*, 15, 31-40. +| doi: https://doi.org/10.1002/met.51 | - .. _Mittermaier-2014: | Mittermaier, M., 2014: A strategy for verifying near-convection-resolving @@ -220,21 +253,20 @@ References | Mood, A. M., F. A. Graybill and D. C. Boes, 1974: *Introduction to the* | *Theory of Statistics*, McGraw-Hill, 299-338. -| +| .. _Murphy-1969: | Murphy, A.H., 1969: On the ranked probability score. *Journal of Applied* | *Meteorology and Climatology*, 8 (6), 988 - 989, -| doi: 10.1175/1520-0450(1969)008<0988:OTPS>2.0.CO;2. +| doi: `https://doi.org/10.1175/1520-0450(1969)008<0988:OTPS>2.0.CO;2 2.0.CO;2>`_ | .. _Murphy-1987: | Murphy, A.H., and R.L. Winkler, 1987: A general framework for forecast | verification. *Monthly Weather Review*, 115, 1330-1338. -| - +| .. _North-2022: @@ -256,7 +288,7 @@ References | Roberts, N.M., and H.W. Lean, 2008: Scale-selective verification of rainfall | accumulations from high-resolution forecasts of convective events. | *Monthly Weather Review*, 136, 78-97. -| +| .. _Rodwell-2010: @@ -273,11 +305,18 @@ References | https://www.ecmwf.int/node/14595 | +.. _Röpnack-2013: + +| Röpnack A, Hense A, Gebhardt C, Majewski D., 2013: Bayesian model verification +| of NWP ensemble forecasts. *Mon. Weather Rev.* 141: 375–387. +| doi: https://doi.org/10.1175/MWR-D-11-00350.1 +| + .. _Saetra-2004: -| Saetra O., H. Hersbach, J-R Bidlot, D. Richardson, 2004: Effects of +| Saetra Ø., H. Hersbach, J-R Bidlot, D. Richardson, 2004: Effects of | observation errors on the statistics for ensemble spread and -| reliability. *Monthly Weather Review* 132: 1487-1501. +| reliability. *Monthly Weather Review*, 132: 1487-1501. | .. _Santos-2012: @@ -285,7 +324,7 @@ References | Santos C. and A. Ghelli, 2012: Observational probability method to assess | ensemble precipitation forecasts. *Quarterly Journal of the Royal* | *Meteorological Society* 138: 209-221. -| +| .. _Schwartz-2017: @@ -298,20 +337,21 @@ References | Stephenson, D.B., 2000: Use of the "Odds Ratio" for diagnosing | forecast skill. *Weather and Forecasting*, 15, 221-232. -| +| .. _Stephenson-2008: | Stephenson, D.B., B. Casati, C.A.T. Ferro, and C.A. Wilson, 2008: The extreme | dependency score: A non-vanishing measure for forecasts of rare events. | *Meteorological Applications* 15, 41-50. -| +| -.. _Todter-2012: +.. _Tödter-2012: | Tödter, J. and B. Ahrens, 2012: Generalization of the Ignorance Score: | Continuous ranked version and its decomposition. *Monthly Weather Review*, -| 140 (6), 2005 - 2017, doi: 10.1175/MWR-D-11-00266.1. +| 140 (6), 2005 - 2017. +| doi: https://doi.org/10.1175/MWR-D-11-00266.1 | .. _Weniger-2016: @@ -319,17 +359,18 @@ References | Weniger, M., F. Kapp, and P. Friederichs, 2016: Spatial Verification Using | Wavelet Transforms: A Review. *Quarterly Journal of the Royal* | *Meteorological Society*, 143, 120-136. -| +| .. _Wilks-2010: | Wilks, D.S. 2010: Sampling distributions of the Brier score and Brier skill | score under serial dependence. *Quarterly Journal of the Royal* -| *Meteorological Society*, 136, 2109-2118. doi:10.1002/qj.709 -| +| *Meteorological Society*, 136, 2109-2118. +| doi: https://doi.org/10.1002/qj.709 +| .. _Wilks-2011: | Wilks, D., 2011: *Statistical methods in the atmospheric sciences.* | Elsevier, San Diego. -| +| diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index d6bf9fb0b9..a1113d5102 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -19,7 +19,7 @@ PJC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L PRC : 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_ PSTD : 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 BASER BASER_NCL BASER_NCU RELIABILITY RESOLUTION UNCERTAINTY ROC_AUC BRIER BRIER_NCL BRIER_NCU BRIERCL BRIERCL_NCL BRIERCL_NCU BSS BSS_SMPL _VAR_ ECLV : 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 BASE N_PTS _VAR_ -ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS +ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS IGN_CONV_OERR IGN_CORR_OERR RPS : 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_PROB RPS_REL RPS_RES RPS_UNC RPS RPSS RPSS_SMPL RPS_COMP RHIST : 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 CRPS IGN N_RANK CRPSS SPREAD _VAR_ PHIST : 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 BIN_SIZE N_BIN _VAR_ diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index 144736cc88..baaac11c6a 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -1075,7 +1075,9 @@ NumArray NumArray::subset(const NumArray &keep) const // Check bounds if ( keep.n_elements() != n_elements() ) { mlog << Error << "\nNumArray::subset(const NumArray &) -> " - << "the number of elements do not match\n\n"; + << "the number of elements do not match (" + << keep.n_elements() << " keep flags != " + << n_elements() << " array elements)\n\n"; exit ( 1 ); } @@ -1156,7 +1158,9 @@ double NumArray::wmean(const NumArray &wgt) const if ( wgt.n_elements() != n_elements() ) { mlog << Error << "\nNumArray::wmean(const NumArray &) -> " - << "the number of elements do not match\n\n"; + << "the number of elements do not match (" + << wgt.n_elements() << " weights != " + << n_elements() << " array elements)\n\n"; exit ( 1 ); } diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index 909441b5ba..826d5101c9 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -276,7 +276,7 @@ static const char * ecnt_columns [] = { "CRPSS_EMP", "CRPS_EMP_FAIR", "SPREAD_MD", "MAE", "MAE_OERR", "BIAS_RATIO", "N_GE_OBS", "ME_GE_OBS", "N_LT_OBS", - "ME_LT_OBS" + "ME_LT_OBS", "IGN_CONV_OERR", "IGN_CORR_OERR" }; static const char * rps_columns [] = { diff --git a/src/libcode/vx_gsl_prob/gsl_randist.h b/src/libcode/vx_gsl_prob/gsl_randist.h index d562bfe733..e66c312230 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.h +++ b/src/libcode/vx_gsl_prob/gsl_randist.h @@ -58,9 +58,9 @@ extern void ran_sample(const gsl_rng *r, double *, int, double *, int); extern void ran_sample(const gsl_rng *r, NumArray &, NumArray &, int); extern double ran_draw(const gsl_rng *r, DistType, - double p1, double p2 = bad_data_int); + double p1, double p2 = bad_data_double); extern double dist_var(DistType, - double p1, double p2 = bad_data_int); + double p1, double p2 = bad_data_double); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index c4880f83eb..55aded1e28 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -4275,7 +4275,7 @@ void write_ecnt_cols(const ECNTInfo &ecnt_info, // CRPSS_EMP CRPS_EMP_FAIR, SPREAD_MD, // MAE, MAE_OERR, BIAS_RATIO, // N_GE_OBS, ME_GE_OBS, N_LT_OBS, - // ME_LT_OBS + // ME_LT_OBS, IGN_CONV_OERR, IGN_CORR_OERR // at.set_entry(r, c+0, // Total Number of Pairs ecnt_info.n_pair); @@ -4352,6 +4352,12 @@ void write_ecnt_cols(const ECNTInfo &ecnt_info, at.set_entry(r, c+24, // ME of ensemble values < observations ecnt_info.me_lt_obs); + at.set_entry(r, c+25, // Ignorance Score, observation error convolved + ecnt_info.ign_conv_oerr); + + at.set_entry(r, c+26, // Ignorance Score, observation error corrected + ecnt_info.ign_corr_oerr); + return; } diff --git a/src/libcode/vx_statistics/ens_stats.cc b/src/libcode/vx_statistics/ens_stats.cc index 4ed6f821ca..782832b79f 100644 --- a/src/libcode/vx_statistics/ens_stats.cc +++ b/src/libcode/vx_statistics/ens_stats.cc @@ -181,13 +181,15 @@ void ECNTInfo::clear() { crps_emp_fair = spread_md = bad_data_double; crps_gaus = crpscl_gaus = crpss_gaus = bad_data_double; ign = bad_data_double; - me = mae = rmse = spread = bad_data_double; - me_oerr = mae_oerr = rmse_oerr = spread_oerr = bad_data_double; + me = mae = rmse = spread = bad_data_double; + me_oerr = mae_oerr = rmse_oerr = spread_oerr = bad_data_double; spread_plus_oerr = bad_data_double; - n_ge_obs = n_lt_obs = 0; - me_ge_obs = me_lt_obs = bias_ratio = bad_data_double; - + ign_conv_oerr = ign_corr_oerr = bad_data_double; + + n_ge_obs = n_lt_obs = 0; + me_ge_obs = me_lt_obs = bias_ratio = bad_data_double; + return; } @@ -221,6 +223,8 @@ void ECNTInfo::assign(const ECNTInfo &c) { rmse_oerr = c.rmse_oerr; spread_oerr = c.spread_oerr; spread_plus_oerr = c.spread_plus_oerr; + ign_conv_oerr = c.ign_conv_oerr; + ign_corr_oerr = c.ign_corr_oerr; n_ge_obs = c.n_ge_obs; n_lt_obs = c.n_lt_obs; @@ -361,6 +365,10 @@ void ECNTInfo::set(const PairDataEnsemble &pd) { // Compute the square root of the average variance plus oerr spread_plus_oerr = square_root(pd.var_plus_oerr_na.wmean(pd.wgt_na)); + // Compute log scores with observational uncertainty + ign_conv_oerr = pd.ign_conv_oerr_na.wmean(pd.wgt_na); + ign_corr_oerr = pd.ign_corr_oerr_na.wmean(pd.wgt_na); + // Compute bias ratio terms n_ge_obs = nint(pd.n_ge_obs_na.sum()); me_ge_obs = pd.me_ge_obs_na.wmean(pd.n_ge_obs_na); diff --git a/src/libcode/vx_statistics/ens_stats.h b/src/libcode/vx_statistics/ens_stats.h index 17e864fb5e..69eca9f4e1 100644 --- a/src/libcode/vx_statistics/ens_stats.h +++ b/src/libcode/vx_statistics/ens_stats.h @@ -82,6 +82,10 @@ class ECNTInfo { double me_oerr, mae_oerr, rmse_oerr, spread_oerr; double spread_plus_oerr; + // Log scores that incorporate observational uncertainty, + // as advised in Ferro (2017) + double ign_conv_oerr, ign_corr_oerr; + // Bias ratio information int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index a290afcb30..8487d751b5 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3456,6 +3456,25 @@ int min_int(const int *v_int, int n) { return v_min; } +//////////////////////////////////////////////////////////////////////// +// +// Compute mean from a sum +// +//////////////////////////////////////////////////////////////////////// + +double compute_mean(double sum, int n) { + double v; + + if(is_bad_data(sum) || is_bad_data(n) || n == 0) { + v = bad_data_double; + } + else { + v = sum / n; + } + + return(v); +} + //////////////////////////////////////////////////////////////////////// // // Compute variance from sums of squares diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index f0715d45b3..1d5def71a7 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -726,6 +726,8 @@ extern int min_int(const int *, int); // //////////////////////////////////////////////////////////////////////// +extern double compute_mean(double, int); + extern double compute_variance(double, double, int); extern double compute_stdev(double, double, int); diff --git a/src/libcode/vx_statistics/obs_error.cc b/src/libcode/vx_statistics/obs_error.cc index eae4bed423..5b753346a3 100644 --- a/src/libcode/vx_statistics/obs_error.cc +++ b/src/libcode/vx_statistics/obs_error.cc @@ -5,6 +5,7 @@ // ** Research Applications Lab (RAL) // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + //////////////////////////////////////////////////////////////////////// #include @@ -184,6 +185,12 @@ void ObsErrorEntry::dump(ostream & out, int depth) const { //////////////////////////////////////////////////////////////////////// +double ObsErrorEntry::variance() const { + return dist_var(dist_type, dist_parm[0], dist_parm[1]); +} + +//////////////////////////////////////////////////////////////////////// + bool ObsErrorEntry::parse_line(const DataLine &dl) { // Initialize diff --git a/src/libcode/vx_statistics/obs_error.h b/src/libcode/vx_statistics/obs_error.h index 732c4c3ced..11cce141dc 100644 --- a/src/libcode/vx_statistics/obs_error.h +++ b/src/libcode/vx_statistics/obs_error.h @@ -5,6 +5,7 @@ // ** Research Applications Lab (RAL) // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + //////////////////////////////////////////////////////////////////////// #ifndef __OBS_ERROR_H__ @@ -68,6 +69,8 @@ class ObsErrorEntry { // get stuff // + double variance() const; + // // do stuff // diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index cc25f891d3..b9c3868036 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -108,6 +108,9 @@ void PairDataEnsemble::clear() { ign_na.clear(); pit_na.clear(); + ign_conv_oerr_na.clear(); + ign_corr_oerr_na.clear(); + n_ge_obs_na.clear(); me_ge_obs_na.clear(); n_lt_obs_na.clear(); @@ -179,6 +182,8 @@ void PairDataEnsemble::extend(int n) { crpscl_gaus_na.extend (n); ign_na.extend (n); pit_na.extend (n); + ign_conv_oerr_na.extend (n); + ign_corr_oerr_na.extend (n); n_ge_obs_na.extend (n); me_ge_obs_na.extend (n); n_lt_obs_na.extend (n); @@ -235,15 +240,20 @@ void PairDataEnsemble::assign(const PairDataEnsemble &pd) { // PairDataEnsemble v_na = pd.v_na; r_na = pd.r_na; + crps_emp_na = pd.crps_emp_na; crps_emp_fair_na = pd.crps_emp_fair_na; spread_md_na = pd.spread_md_na; crpscl_emp_na = pd.crpscl_emp_na; crps_gaus_na = pd.crps_gaus_na; crpscl_gaus_na = pd.crpscl_gaus_na; + ign_na = pd.ign_na; pit_na = pd.pit_na; + ign_conv_oerr_na = pd.ign_conv_oerr_na; + ign_corr_oerr_na = pd.ign_corr_oerr_na; + n_ge_obs_na = pd.n_ge_obs_na; me_ge_obs_na = pd.me_ge_obs_na; n_lt_obs_na = pd.n_lt_obs_na; @@ -449,6 +459,8 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { crpscl_gaus_na.add(bad_data_double); ign_na.add(bad_data_double); pit_na.add(bad_data_double); + ign_conv_oerr_na.add(bad_data_double); + ign_corr_oerr_na.add(bad_data_double); n_ge_obs_na.add(bad_data_double); me_ge_obs_na.add(bad_data_double); n_lt_obs_na.add(bad_data_double); @@ -461,22 +473,41 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { var_unperturbed = compute_variance(esum_na[i], esumsq_na[i], esumn_na[i]); var_na.add(var_unperturbed); - // Process the observation error information. + // Process the observation error information ObsErrorEntry * e = (has_obs_error() ? obs_error_entry[i] : 0); if(e) { + // Get observation error variance + double oerr_var = e->variance(); + + // Compute the observation error log scores + double v_conv, v_corr; + compute_obs_error_log_scores( + compute_mean(esum_na[i], esumn_na[i]), + compute_stdev(esum_na[i], esumsq_na[i], esumn_na[i]), + o_na[i], oerr_var, + v_conv, v_corr); + ign_conv_oerr_na.add(v_conv); + ign_corr_oerr_na.add(v_corr); + // Compute perturbed ensemble mean and variance // Exclude the control member from the variance mn_oerr_na.add(cur_ens.mean()); var_oerr_na.add(cur_ens.variance(ctrl_index)); - // Compute the variance plus observation error variance. - var_plus_oerr_na.add(var_unperturbed + - dist_var(e->dist_type, - e->dist_parm[0], e->dist_parm[1])); + // Compute the variance plus observation error variance + if(is_bad_data(var_unperturbed) || + is_bad_data(oerr_var)) { + var_plus_oerr_na.add(bad_data_double); + } + else { + var_plus_oerr_na.add(var_unperturbed + oerr_var); + } } - // If no observation error specified, store bad data values. + // If no observation error specified, store bad data values else { + ign_conv_oerr_na.add(bad_data_double); + ign_corr_oerr_na.add(bad_data_double); mn_oerr_na.add(bad_data_double); var_oerr_na.add(bad_data_double); var_plus_oerr_na.add(bad_data_double); @@ -506,8 +537,8 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { derive_climo_vals(cdf_info_ptr, cmn_na[i], csd_na[i], cur_clm); // Store empirical CRPS stats - // - // For crps_emp use temporary, local variable so we can use it for the crps_emp_fair calculation + // For crps_emp use temporary, local variable so we can use it + // for the crps_emp_fair calculation double crps_emp = compute_crps_emp(o_na[i], cur_ens); crps_emp_na.add(crps_emp); crps_emp_fair_na.add(crps_emp - cur_ens.wmean_abs_diff()); @@ -528,9 +559,10 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { // Compute the Bias Ratio terms int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - compute_bias_ratio_terms(o_na[i], cur_ens, - n_ge_obs, me_ge_obs, - n_lt_obs, me_lt_obs); + compute_bias_ratio_terms( + o_na[i], cur_ens, + n_ge_obs, me_ge_obs, + n_lt_obs, me_lt_obs); // Store the Bias Ratio terms n_ge_obs_na.add(n_ge_obs); @@ -864,8 +896,11 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o // // Include in subset: // wgt_na, o_na, cmn_na, csd_na, v_na, r_na, - // crps_emp_na, crps_emp_fair_na, spread_md_na, crpscl_emp_na, crps_gaus_na, crpscl_gaus_na, - // ign_na, pit_na, n_gt_obs_na, me_gt_obs_na, n_lt_obs_na, me_lt_obs_na, + // crps_emp_na, crps_emp_fair_na, spread_md_na, + // crpscl_emp_na, crps_gaus_na, crpscl_gaus_na, + // ign_na, pit_na, + // ign_conv_oerr, ign_corr_oerr, + // n_gt_obs_na, me_gt_obs_na, n_lt_obs_na, me_lt_obs_na, // var_na, var_oerr_na, var_plus_oerr_na, // mn_na, mn_oerr_na, e_na // @@ -888,6 +923,8 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o pd.crpscl_gaus_na.add(crpscl_gaus_na[i]); pd.ign_na.add(ign_na[i]); pd.pit_na.add(pit_na[i]); + pd.ign_conv_oerr_na.add(ign_conv_oerr_na[i]); + pd.ign_corr_oerr_na.add(ign_corr_oerr_na[i]); pd.n_ge_obs_na.add(n_ge_obs_na[i]); pd.me_ge_obs_na.add(me_ge_obs_na[i]); pd.n_lt_obs_na.add(n_lt_obs_na[i]); @@ -1498,7 +1535,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, y < 0 || y >= gr.ny()) return; // For pressure levels, check if the observation pressure level - // falls in the requsted range. + // falls in the requested range. if(obs_info_grib->level().type() == LevelType_Pres) { if(obs_lvl < obs_info_grib->level().lower() || @@ -1593,7 +1630,8 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, } } - // Apply observation error logic bias correction, if requested + // Apply observation error additive and multiplicative + // bias correction, if requested if(obs_error_info->flag) { obs_v = add_obs_error_bc(obs_error_info->rng_ptr, FieldType_Obs, oerr_ptr, obs_v); @@ -2111,5 +2149,52 @@ double compute_bias_ratio(double me_ge_obs, double me_lt_obs) { return v; } - + +//////////////////////////////////////////////////////////////////////// + +void compute_obs_error_log_scores(double emn, double esd, + double obs, double oerr_var, + double &v_conv, double &v_corr) { + + const char *method_name = "compute_obs_error_log_scores() -> "; + + // Check for bad input data + if(is_bad_data(emn) || + is_bad_data(esd) || + is_bad_data(obs) || + is_bad_data(oerr_var)) { + v_conv = v_corr = bad_data_double; + } + else { + double sigma2 = esd * esd; + double ov2 = oerr_var * oerr_var; + + // Error-convolved logarithmic scoring rule in + // Ferro (2017, Eq 5) doi:10.1002/qj.3115 + // Scale by 2.0 * pi for consistency with ignorance score + v_conv = 0.5 * log(2.0 * pi * (sigma2 + ov2)) + + (obs - emn) * (obs - emn) / + (2.0 * (sigma2 + ov2)); + + // Error-corrected logarithmic scoring rule in + // Ferro (2017, Eq 7) doi:10.1002/qj.3115 + // Scale by 2.0 * pi for consistency with ignorance score + v_corr = log(esd) + + ((obs - emn) * (obs - emn) - ov2) / + (2.0 * sigma2); + } + + if(mlog.verbosity_level() >= 10) { + mlog << Debug(10) << method_name + << "inputs (emn = " << emn + << ", esd = " << esd + << ", obs = " << obs + << ", oerr_var = " << oerr_var + << ") and outputs (ign_oerr_conv = " << v_conv + << ", ign_oerr_corr = " << v_corr << ")\n"; + } + + return; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_ensemble.h b/src/libcode/vx_statistics/pair_data_ensemble.h index e6014b59fb..9be2eec3c8 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.h +++ b/src/libcode/vx_statistics/pair_data_ensemble.h @@ -6,6 +6,8 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +//////////////////////////////////////////////////////////////////////// + #ifndef __PAIR_DATA_ENSEMBLE_H__ #define __PAIR_DATA_ENSEMBLE_H__ @@ -74,64 +76,67 @@ class PairDataEnsemble : public PairBase { bool obs_error_flag; // Ensemble, valid count, and rank values - NumArray *e_na; // Ensemble values [n_ens][n_obs] - NumArray v_na; // Number of valid ensemble values [n_obs] - NumArray r_na; // Observation ranks [n_obs] + NumArray *e_na; // Ensemble values [n_ens][n_obs] + NumArray v_na; // Number of valid ensemble values [n_obs] + NumArray r_na; // Observation ranks [n_obs] + + NumArray crps_emp_na; // Empirical Continuous Ranked Probability Score [n_obs] + NumArray crps_emp_fair_na; // Fair Empirical Continuous Ranked Probability Score [n_obs] + NumArray spread_md_na; // Mean absolute difference of ensemble members [n_obs] + NumArray crpscl_emp_na; // Empirical climatological CRPS [n_obs] - NumArray crps_emp_na; // Empirical Continuous Ranked Probability Score [n_obs] - NumArray crps_emp_fair_na; // Fair Empirical Continuous Ranked Probability Score [n_obs] - NumArray spread_md_na; // Mean absolute difference of ensemble members [n_obs] - NumArray crpscl_emp_na; // Empirical climatological CRPS [n_obs] + NumArray crps_gaus_na; // Gaussian CRPS [n_obs] + NumArray crpscl_gaus_na; // Gaussian climatological CRPS [n_obs] - NumArray crps_gaus_na; // Gaussian CRPS [n_obs] - NumArray crpscl_gaus_na; // Gaussian climatological CRPS [n_obs] + NumArray ign_na; // Ignorance Score [n_obs] + NumArray pit_na; // Probability Integral Transform [n_obs] - NumArray ign_na; // Ignorance Score [n_obs] - NumArray pit_na; // Probability Integral Transform [n_obs] + NumArray ign_conv_oerr_na; // Error convolved log score [n_obs] + NumArray ign_corr_oerr_na; // Error corrected log score [n_obs] - NumArray n_ge_obs_na; // Number of ensemble memebers >= obs [n_obs] - NumArray me_ge_obs_na; // Mean error of ensemble members >= obs [n_obs] - NumArray n_lt_obs_na; // Number of ensemble members < obs [n_obs] - NumArray me_lt_obs_na; // Mean error of ensemble members < obs [n_obs] + NumArray n_ge_obs_na; // Number of ensemble memebers >= obs [n_obs] + NumArray me_ge_obs_na; // Mean error of ensemble members >= obs [n_obs] + NumArray n_lt_obs_na; // Number of ensemble members < obs [n_obs] + NumArray me_lt_obs_na; // Mean error of ensemble members < obs [n_obs] - int n_ens; // Number of ensemble members - int n_pair; // Number of valid pairs, n_obs - sum(skip_ba) - int ctrl_index; // Index of the control member - bool skip_const; // Skip cases where the observation and - // all ensemble members are constant - BoolArray skip_ba; // Flag for each observation [n_obs] + int n_ens; // Number of ensemble members + int n_pair; // Number of valid pairs, n_obs - sum(skip_ba) + int ctrl_index; // Index of the control member + bool skip_const; // Skip cases where the observation and + // all ensemble members are constant + BoolArray skip_ba; // Flag for each observation [n_obs] - NumArray rhist_na; // Ranked Histogram [n_ens+1] - NumArray relp_na; // Relative Position Histogram [n_ens] + NumArray rhist_na; // Ranked Histogram [n_ens+1] + NumArray relp_na; // Relative Position Histogram [n_ens] - double phist_bin_size; // Ensemble PIT histogram bin width - NumArray phist_na; // PIT Histogram [n_phist_bin] + double phist_bin_size; // Ensemble PIT histogram bin width + NumArray phist_na; // PIT Histogram [n_phist_bin] NumArray var_na; // Variance of unperturbed members [n_obs] NumArray var_oerr_na; // Variance of perturbed members [n_obs] NumArray var_plus_oerr_na; // Unperturbed variance plus observation error variance [n_obs] - NumArray esum_na; // Sum of unperturbed ensemble values [n_obs] - NumArray esumsq_na; // Sum of unperturbed ensemble squared values [n_obs] - NumArray esumn_na; // Count of ensemble values [n_obs] + NumArray esum_na; // Sum of unperturbed ensemble values [n_obs] + NumArray esumsq_na; // Sum of unperturbed ensemble squared values [n_obs] + NumArray esumn_na; // Count of ensemble values [n_obs] - NumArray mn_na; // Ensemble mean value [n_obs] - NumArray mn_oerr_na; // Mean of perturbed members [n_obs] + NumArray mn_na; // Ensemble mean value [n_obs] + NumArray mn_oerr_na; // Mean of perturbed members [n_obs] - double ssvar_bin_size; // Variance bin size for spread/skill - SSVARInfo *ssvar_bins; // Ensemble spread/skill bin information [n_ssvar_bin] + double ssvar_bin_size; // Variance bin size for spread/skill + SSVARInfo *ssvar_bins; // Ensemble spread/skill bin information [n_ssvar_bin] - double crpss_emp; // Empirical CRPS skill score - double crpss_gaus; // Guassian CRPS skill score + double crpss_emp; // Empirical CRPS skill score + double crpss_gaus; // Guassian CRPS skill score - double me; // ME for ensemble mean - double mae; // MAE for ensemble mean - double rmse; // RMSE for ensemble mean - double me_oerr; // ME for mean of perturbed members - double mae_oerr; // MAE for mean of perturbed members - double rmse_oerr; // RMSE for mean of perturbed members + double me; // ME for ensemble mean + double mae; // MAE for ensemble mean + double rmse; // RMSE for ensemble mean + double me_oerr; // ME for mean of perturbed members + double mae_oerr; // MAE for mean of perturbed members + double rmse_oerr; // RMSE for mean of perturbed members - double bias_ratio; // Bias ratio + double bias_ratio; // Bias ratio ////////////////////////////////////////////////////////////////// @@ -323,6 +328,9 @@ extern double compute_ens_pit(double, double, double); extern void compute_bias_ratio_terms(double, const NumArray &, int &, double &, int &, double &); extern double compute_bias_ratio(double, double); +extern void compute_obs_error_log_scores( + double, double, double, double, + double &, double &); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index cd3b080bc6..2b19b94391 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -1119,7 +1119,7 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, } // For pressure levels, check if the observation pressure level - // falls in the requsted range. + // falls in the requested range. if(obs_info->level().type() == LevelType_Pres) { if(obs_lvl < obs_info->level().lower() || diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 49506e1402..3ca4cfcaff 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -39,6 +39,8 @@ // line types. // 018 02/13/24 Halley Gotway MET #2395 Add wind direction stats // to VL1L2, VAL1L2, and VCNT. +// 019 02/21/24 Halley Gotway MET #2583 Add observation error +// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -2656,6 +2658,8 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, m[key].ens_pd.crps_gaus_na.add(cur.crps_gaus); m[key].ens_pd.crpscl_gaus_na.add(cur.crpscl_gaus); m[key].ens_pd.ign_na.add(cur.ign); + m[key].ens_pd.ign_conv_oerr_na.add(cur.ign_conv_oerr); + m[key].ens_pd.ign_corr_oerr_na.add(cur.ign_corr_oerr); m[key].ens_pd.n_ge_obs_na.add(cur.n_ge_obs); m[key].ens_pd.me_ge_obs_na.add(cur.me_ge_obs); m[key].ens_pd.n_lt_obs_na.add(cur.n_lt_obs); @@ -3229,17 +3233,34 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, m[key].ens_pd.ign_na.add(compute_ens_ign(cur.obs, cur.ens_mean, cur.spread)); m[key].ens_pd.pit_na.add(compute_ens_pit(cur.obs, cur.ens_mean, cur.spread)); + // Back out the observation error variance + double oerr_var = bad_data_double; + if(!is_bad_data(cur.spread_plus_oerr) && + !is_bad_data(cur.spread)) { + oerr_var = square(cur.spread_plus_oerr) - + square(cur.spread); + } + // Store BIAS_RATIO terms int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - compute_bias_ratio_terms(cur.obs, cur.ens_na, - n_ge_obs, me_ge_obs, - n_lt_obs, me_lt_obs); + compute_bias_ratio_terms( + cur.obs, cur.ens_na, + n_ge_obs, me_ge_obs, + n_lt_obs, me_lt_obs); m[key].ens_pd.n_ge_obs_na.add(n_ge_obs); m[key].ens_pd.me_ge_obs_na.add(me_ge_obs); m[key].ens_pd.n_lt_obs_na.add(n_lt_obs); m[key].ens_pd.me_lt_obs_na.add(me_lt_obs); + // Compute observation error log scores + double v_conv, v_corr; + compute_obs_error_log_scores( + cur.ens_mean, cur.spread, cur.obs, oerr_var, + v_conv, v_corr); + m[key].ens_pd.ign_conv_oerr_na.add(v_conv); + m[key].ens_pd.ign_corr_oerr_na.add(v_corr); + // // Increment the RHIST counts // diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index b6ec116759..ebdc9d9a0a 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -33,6 +33,8 @@ // line types. // 013 02/13/24 Halley Gotway MET #2395 Add wind direction stats // to VL1L2, VAL1L2, and VCNT. +// 014 02/21/24 Halley Gotway MET #2583 Add observation error +// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -397,6 +399,9 @@ void parse_ecnt_line(STATLine &l, ECNTData &e_data) { e_data.n_lt_obs = atoi(l.get_item("N_LT_OBS")); e_data.me_lt_obs = atof(l.get_item("ME_LT_OBS")); + e_data.ign_conv_oerr = atof(l.get_item("IGN_CONV_OERR")); + e_data.ign_corr_oerr = atof(l.get_item("IGN_CORR_OERR")); + return; } diff --git a/src/tools/core/stat_analysis/parse_stat_line.h b/src/tools/core/stat_analysis/parse_stat_line.h index 529fdb2df9..c890b45ff7 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.h +++ b/src/tools/core/stat_analysis/parse_stat_line.h @@ -28,6 +28,8 @@ // 011 09/28/22 Prestopnik MET #2227 Remove namespace std // 012 11/10/22 Halley Gotway MET #2339 Add SEEPS and SEEPS_MPR // line types. +// 013 02/21/24 Halley Gotway MET #2583 Add observation error +// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -72,6 +74,7 @@ struct ECNTData { double bias_ratio; int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; + double ign_conv_oerr, ign_corr_oerr; }; // Ranked Histogram (RHIST) data structure diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index 99b0f762ef..827662caf8 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -39,7 +39,7 @@ // 014 07/09/21 Linden MET #1746 Skip thresholding. // 015 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 016 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files -// 017 01/29/24 Halley Gotway MET #2801 Configure time difference warnings +// 017 01/29/24 Halley Gotway MET #2801 Configure time difference warnings // //////////////////////////////////////////////////////////////////////// @@ -425,7 +425,7 @@ void process_scores() { mlog << Debug(2) << "Observation field: "; fill_bad_data(obs_dp_fill, obs_fill); - // Pad the fields out to the nearest power of two if requsted + // Pad the fields out to the nearest power of two if requested if(conf_info.grid_decomp_flag == GridDecompType_Pad) { mlog << Debug(2) << "Padding the fields out to the nearest integer " << "power of two.\n"; From 4c322aa389e3affbe034a14aa6ec581e8fd0814b Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 14 Mar 2024 09:32:18 -0600 Subject: [PATCH 029/114] Revert #2825 since more documentation and testing is needed (#2837) This reverts commit 108a8958b206d6712197823a083666ab039bf818. --- data/table_files/met_header_columns_V12.0.txt | 2 +- docs/Users_Guide/appendixC.rst | 53 ++----- docs/Users_Guide/ensemble-stat.rst | 10 +- docs/Users_Guide/refs.rst | 135 ++++++------------ internal/test_unit/hdr/met_12_0.hdr | 2 +- src/basic/vx_util/num_array.cc | 8 +- src/basic/vx_util/stat_column_defs.h | 2 +- src/libcode/vx_gsl_prob/gsl_randist.h | 4 +- src/libcode/vx_stat_out/stat_columns.cc | 8 +- src/libcode/vx_statistics/ens_stats.cc | 18 +-- src/libcode/vx_statistics/ens_stats.h | 4 - src/libcode/vx_statistics/met_stats.cc | 19 --- src/libcode/vx_statistics/met_stats.h | 2 - src/libcode/vx_statistics/obs_error.cc | 7 - src/libcode/vx_statistics/obs_error.h | 3 - .../vx_statistics/pair_data_ensemble.cc | 117 +++------------ .../vx_statistics/pair_data_ensemble.h | 90 ++++++------ src/libcode/vx_statistics/pair_data_point.cc | 2 +- .../core/stat_analysis/aggr_stat_line.cc | 27 +--- .../core/stat_analysis/parse_stat_line.cc | 5 - .../core/stat_analysis/parse_stat_line.h | 3 - src/tools/core/wavelet_stat/wavelet_stat.cc | 4 +- 22 files changed, 135 insertions(+), 390 deletions(-) diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index 299e6cb4d6..7ed1e5a187 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -19,7 +19,7 @@ V12.0 : STAT : PJC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : PRC : 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]* PODY_[0-9]* POFD_[0-9]* V12.0 : STAT : PSTD : 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) BASER BASER_NCL BASER_NCU RELIABILITY RESOLUTION UNCERTAINTY ROC_AUC BRIER BRIER_NCL BRIER_NCU BRIERCL BRIERCL_NCL BRIERCL_NCU BSS BSS_SMPL THRESH_[0-9]* V12.0 : STAT : ECLV : 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 VALUE_BASER (N_PTS) CL_[0-9]* VALUE_[0-9]* -V12.0 : STAT : ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS IGN_CONV_OERR IGN_CORR_OERR +V12.0 : STAT : ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS V12.0 : STAT : RPS : 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_PROB RPS_REL RPS_RES RPS_UNC RPS RPSS RPSS_SMPL RPS_COMP V12.0 : STAT : RHIST : 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_RANK) RANK_[0-9]* V12.0 : STAT : PHIST : 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 BIN_SIZE (N_BIN) BIN_[0-9]* diff --git a/docs/Users_Guide/appendixC.rst b/docs/Users_Guide/appendixC.rst index 037bd93455..7c5c618a43 100644 --- a/docs/Users_Guide/appendixC.rst +++ b/docs/Users_Guide/appendixC.rst @@ -401,7 +401,7 @@ SEEPS scores are expected to lie between 0 and 1, with a perfect forecast having MET Verification Measures for Continuous Variables ================================================== -For continuous variables, many verification measures are based on the forecast error (i.e., **f - o**). However, it also is of interest to investigate characteristics of the forecasts, and the observations, as well as their relationship. These concepts are consistent with the general framework for verification outlined by :ref:`Murphy and Winkler, 1987 `. The statistics produced by MET for continuous forecasts represent this philosophy of verification, which focuses on a variety of aspects of performance rather than a single measure. +For continuous variables, many verification measures are based on the forecast error (i.e., **f - o**). However, it also is of interest to investigate characteristics of the forecasts, and the observations, as well as their relationship. These concepts are consistent with the general framework for verification outlined by :ref:`Murphy and Winkler, (1987) `. The statistics produced by MET for continuous forecasts represent this philosophy of verification, which focuses on a variety of aspects of performance rather than a single measure. The verification measures currently evaluated by the Point-Stat tool are defined and described in the subsections below. In these definitions, **f** represents the forecasts, **o** represents the observation, and **n** is the number of forecast-observation pairs. @@ -894,7 +894,7 @@ Calibration Called "CALIBRATION" in PJC output :numref:`table_PS_format_info_PJC` -Calibration is the conditional probability of an event given each probability forecast category (i.e. each row in the **nx2** contingency table). This set of measures is paired with refinement in the calibration-refinement factorization discussed in :ref:`Wilks, 2011 `. A well-calibrated forecast will have calibration values that are near the forecast probability. For example, a 50% probability of precipitation should ideally have a calibration value of 0.5. If the calibration value is higher, then the probability has been underestimated, and vice versa. +Calibration is the conditional probability of an event given each probability forecast category (i.e. each row in the **nx2** contingency table). This set of measures is paired with refinement in the calibration-refinement factorization discussed in :ref:`Wilks, (2011) `. A well-calibrated forecast will have calibration values that are near the forecast probability. For example, a 50% probability of precipitation should ideally have a calibration value of 0.5. If the calibration value is higher, then the probability has been underestimated, and vice versa. .. math:: \text{Calibration}(i) = \frac{n_{i1}}{n_{1.}} = \text{probability}(o_1|p_i) @@ -903,7 +903,7 @@ Refinement Called "REFINEMENT" in PJC output :numref:`table_PS_format_info_PJC` -The relative frequency associated with each forecast probability, sometimes called the marginal distribution or row probability. This measure ignores the event outcome, and simply provides information about the frequency of forecasts for each probability category. This set of measures is paired with the calibration measures in the calibration-refinement factorization discussed by :ref:`Wilks, 2011 `. +The relative frequency associated with each forecast probability, sometimes called the marginal distribution or row probability. This measure ignores the event outcome, and simply provides information about the frequency of forecasts for each probability category. This set of measures is paired with the calibration measures in the calibration-refinement factorization discussed by :ref:`Wilks (2011) `. .. math:: \text{Refinement}(i) = \frac{n_{i.}}{T} = \text{probability}(p_i) @@ -912,7 +912,7 @@ Likelihood Called "LIKELIHOOD" in PJC output :numref:`table_PS_format_info_PJC` -Likelihood is the conditional probability for each forecast category (row) given an event and a component of the likelihood-base rate factorization; see :ref:`Wilks, 2011 ` for details. This set of measures considers the distribution of forecasts for only the cases when events occur. Thus, as the forecast probability increases, so should the likelihood. For example, 10% probability of precipitation forecasts should have a much smaller likelihood value than 90% probability of precipitation forecasts. +Likelihood is the conditional probability for each forecast category (row) given an event and a component of the likelihood-base rate factorization; see :ref:`Wilks (2011) ` for details. This set of measures considers the distribution of forecasts for only the cases when events occur. Thus, as the forecast probability increases, so should the likelihood. For example, 10% probability of precipitation forecasts should have a much smaller likelihood value than 90% probability of precipitation forecasts. .. math:: \text{Likelihood}(i) = \frac{n_{i1}}{n_{.1}} = \text{probability}(p_i|o_1) @@ -923,7 +923,7 @@ Base Rate Called "BASER" in PJC output :numref:`table_PS_format_info_PJC` -This is the probability of an event for each forecast category :math:`p_i` (row), i.e. the conditional base rate. This set of measures is paired with likelihood in the likelihood-base rate factorization, see :ref:`Wilks, 2011 ` for further information. This measure is calculated for each row of the contingency table. Ideally, the event should become more frequent as the probability forecast increases. +This is the probability of an event for each forecast category :math:`p_i` (row), i.e. the conditional base rate. This set of measures is paired with likelihood in the likelihood-base rate factorization, see :ref:`Wilks (2011) ` for further information. This measure is calculated for each row of the contingency table. Ideally, the event should become more frequent as the probability forecast increases. .. math:: \text{Base Rate}(i) = \frac{n_{i1}}{n_{i.}} = \text{probability}(o_{i1}) @@ -976,18 +976,18 @@ RPS Called "RPS" in RPS output :numref:`table_ES_header_info_es_out_ECNT` -While the above probabilistic verification measures utilize dichotomous observations, the Ranked Probability Score (RPS, :ref:`Epstein, 1969 `, :ref:`Murphy, 1969 `) is the only probabilistic verification measure for discrete multiple-category events available in MET. It is assumed that the categories are ordinal as nominal categorical variables can be collapsed into sequences of binary predictands, which can in turn be evaluated with the above measures for dichotomous variables (:ref:`Wilks, 2011 `). The RPS is the multi-category extension of the Brier score (:ref:`Tödter and Ahrens, 2012 `), and is a proper score (:ref:`Mason, 2008 `). +While the above probabilistic verification measures utilize dichotomous observations, the Ranked Probability Score (RPS, :ref:`Epstein, 1969 `, :ref:`Murphy, 1969 `) is the only probabilistic verification measure for discrete multiple-category events available in MET. It is assumed that the categories are ordinal as nominal categorical variables can be collapsed into sequences of binary predictands, which can in turn be evaluated with the above measures for dichotomous variables (:ref:`Wilks, 2011 `). The RPS is the multi-category extension of the Brier score (:ref:`Tödter and Ahrens, 2012`), and is a proper score (:ref:`Mason, 2008`). Let :math:`\text{J}` be the number of categories, then both the forecast, :math:`\text{f} = (f_1,…,f_J)`, and observation, :math:`\text{o} = (o_1,…,o_J)`, are length-:math:`\text{J}` vectors, where the components of :math:`\text{f}` include the probabilities forecast for each category :math:`\text{1,…,J}` and :math:`\text{o}` contains 1 in the category that is realized and zero everywhere else. The cumulative forecasts, :math:`F_m`, and observations, :math:`O_m`, are defined to be: :math:`F_m = \sum_{j=1}^m (f_j)` and :math:`O_m = \sum_{j=1}^m (o_j), m = 1,…,J`. -To clarify, :math:`F_1 = f_1` is the first component of :math:`F_m`, :math:`F_2 = f_1+f_2`, etc., and :math:`F_J = 1`. Similarly, if :math:`o_j = 1` and :math:`i < j`, then :math:`O_i = 0` and when :math:`i >= j`, :math:`O_i = 1`, and of course, :math:`O_J = 1`. Finally, the RPS is defined to be: +To clarify, :math:`F_1 = f_1` is the first component of :math:`F_m`, :math:`F_2 = f_1+f_2`, etc., and :math:`F_J = 1`. Similarly, if :math:`o_j = 1` and :math:`i < j`, then :math:`O_i = 0` and when :math:`i >= j`, :math:`O_i = 1`, and of course, :math:`O_J = 1`. Finally, the RPS is defined to be: .. math:: \text{RPS} = \sum_{m=1}^J (F_m - O_m)^2 = \sum_{m=1}^J BS_m, -where :math:`BS_m` is the Brier score for the m-th category (:ref:`Tödter and Ahrens, 2012 `). Subsequently, the RPS lends itself to a decomposition into reliability, resolution and uncertainty components, noting that each component is aggregated over the different categories; these are written to the columns named "RPS_REL", "RPS_RES" and "RPS_UNC" in RPS output :numref:`table_ES_header_info_es_out_ECNT`. +where :math:`BS_m` is the Brier score for the m-th category (:ref:`Tödter and Ahrens, 2012`). Subsequently, the RPS lends itself to a decomposition into reliability, resolution and uncertainty components, noting that each component is aggregated over the different categories; these are written to the columns named "RPS_REL", "RPS_RES" and "RPS_UNC" in RPS output :numref:`table_ES_header_info_es_out_ECNT`. CRPS ---- @@ -1066,7 +1066,7 @@ The continuous ranked probability skill score (CRPSS) is similar to the MSESS an .. math:: \text{CRPSS} = 1 - \frac{\text{CRPS}_{fcst}}{ \text{CRPS}_{ref}} -For the normal distribution fit (CRPSS), the reference CRPS is computed using the climatological mean and standard deviation. For the empirical distribution (CRPSS_EMP), the reference CRPS is computed by sampling from the assumed normal climatological distribution defined by the mean and standard deviation. +For the normal distribution fit (CRPSS), the reference CRPS is computed using the climatological mean and standard deviation. For the empirical distribution (CRPSS_EMP), the reference CRPS is computed by sampling from the assumed normal climatological distribution defined by the mean and standard deviation. Bias Ratio ---------- @@ -1105,37 +1105,6 @@ Called "PIT" in ORANK output :numref:`table_ES_header_info_es_out_ORANK` The probability integral transform (PIT) is the analog of the rank histogram for a probability distribution forecast (:ref:`Dawid, 1984 `). Its interpretation is the same as that of the verification rank histogram: Calibrated probabilistic forecasts yield PIT histograms that are flat, or uniform. Under-dispersed (not enough spread in the ensemble) forecasts have U-shaped PIT histograms while over-dispersed forecasts have bell-shaped histograms. In MET, the PIT calculation uses a normal distribution fit to the ensemble forecasts. In many cases, use of other distributions would be better. -Observation Error Logarithmic Scoring Rules -------------------------------------------- - -Called "IGN_CONV_OERR" and "IGN_CORR_OERR" in ECNT output :numref:`table_ES_header_info_es_out_ECNT` - -One approach that is used to take observation error into account in a summary measure is to add error to the forecast by a convolution with the observation model (e.g., :ref:`Anderson, 1996 `; :ref:`Hamill, 2001 `; :ref:`Saetra et. al., 2004 `; :ref:`Bröcker and Smith, 2007 `; :ref:`Candille et al., 2007 `; :ref:`Candille and Talagrand, 2008 `; :ref:`Röpnack et al., 2013 `). Specifically, suppose :math:`y=x+w`, where :math:`y` is the observed value, :math:`x` is the true value, and :math:`w` is the error. Then, if :math:`f` is the density forecast for :math:`x` and :math:`\nu` is the observation model, then the implied density forecast for :math:`y` is given by the convolution: - -.. math:: (f*\nu)(y) = \int\nu(y|x)f(x)dx - -:ref:`Ferro, 2017 ` gives the error-convolved version of the ignorance scoring rule (referred to therein as the error-convolved logarithmic scoring rule), which is proper under the model where :math:`w\sim N(0,c^2)`) when the forecast for :math:`x` is :math:`N(\mu,\sigma^2)` with density function :math:`f`, by - -.. only:: latex - - .. math:: \text{IGN\_CONV\_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi (\sigma^2 + c^2)) + \frac{(y - \mu)^2}{2 (\sigma^2 + c^2)} - -.. only:: html - - .. math:: \text{IGN_CONV_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi (\sigma^2 + c^2)) + \frac{(y - \mu)^2}{2 (\sigma^2 + c^2)} - -Another approach to incorporation of observation uncertainty into a measure is the error-correction approach. The approach merely ensures that the scoring rule, :math:`s`, is unbiased for a scoring rule :math:`s_0` if they have the same expected value. :ref:`Ferro, 2017 ` gives the error-corrected ignorance scoring rule (which is also proposer when :math:`w\sim N(0,c^2)`) as - -.. only:: latex - - .. math:: \text{IGN\_CORR\_OERR} = s(f,y) = \log\sigma + \frac{(y - \mu)^2 - c^2}{2\sigma^2} - -.. only:: html - - .. math:: \text{IGN_CORR_OERR} = s(f,y) = \log\sigma + \frac{(y - \mu)^2 - c^2}{2\sigma^2} - -The expected score for the error-convolved ignorance scoring rule typically differs from the expected score that would be achieved if there were no observation error. The error-corrected score, on the other hand, has the same expectation. - RANK ---- @@ -1191,7 +1160,7 @@ The traditional contingency table statistics computed by the Grid-Stat neighborh All of these measures are defined in :numref:`categorical variables`. -In addition to these standard statistics, the neighborhood analysis provides additional continuous measures, the Fractions Brier Score and the Fractions Skill Score. For reference, the Asymptotic Fractions Skill Score and Uniform Fractions Skill Score are also calculated. These measures are defined here, but are explained in much greater detail in :ref:`Ebert, 2008 ` and :ref:`Roberts and Lean, 2008 `. :ref:`Roberts and Lean, 2008 ` also present an application of the methodology. +In addition to these standard statistics, the neighborhood analysis provides additional continuous measures, the Fractions Brier Score and the Fractions Skill Score. For reference, the Asymptotic Fractions Skill Score and Uniform Fractions Skill Score are also calculated. These measures are defined here, but are explained in much greater detail in :ref:`Ebert (2008) ` and :ref:`Roberts and Lean (2008) `. :ref:`Roberts and Lean (2008) ` also present an application of the methodology. Fractions Brier Score --------------------- @@ -1256,7 +1225,7 @@ A mathematical metric, :math:`m(A,B)\geq 0`, must have the following three prope The first establishes that a perfect score is zero and that the only way to obtain a perfect score is if the two sets are identical according to the metric. The second requirement ensures that the order by which the two sets are evaluated will not change the result. The third property ensures that if *C* is closer to *A* than *B* is to *A*, then :math:`m(A,C) < m(A,B)`. -It has been argued in :ref:`Gilleland, 2017 ` that the second property of symmetry is not necessarily an important quality to have for a summary measure for verification purposes because lack of symmetry allows for information about false alarms and misses. +It has been argued in :ref:`Gilleland (2017) ` that the second property of symmetry is not necessarily an important quality to have for a summary measure for verification purposes because lack of symmetry allows for information about false alarms and misses. The results of the distance map verification approaches that are included in the Grid-Stat tool are summarized using a variety of measures. These measures include Baddeley's :math:`\Delta` Metric, the Hausdorff Distance, the Mean-error Distance, Pratt's Figure of Merit, and Zhu's Measure. Their equations are listed below. diff --git a/docs/Users_Guide/ensemble-stat.rst b/docs/Users_Guide/ensemble-stat.rst index 7eba9f1aa9..42443aa315 100644 --- a/docs/Users_Guide/ensemble-stat.rst +++ b/docs/Users_Guide/ensemble-stat.rst @@ -66,9 +66,7 @@ The climatological distribution is also used for the RPSS. The forecast RPS stat Ensemble Observation Error -------------------------- -In an attempt to ameliorate the effect of observation errors on the verification of forecasts, a random perturbation approach has been implemented. A great deal of user flexibility has been built in, but the methods detailed in :ref:`Candille and Talagrand (2008) ` can be replicated using the appropriate options. Additional probabilistic measures that include observational uncertainty recommended by :ref:`Ferro, 2017 ` are also provided. - -Observation error information can be defined directly in the Ensemble-Stat configuration file or through a more flexible observation error table lookup. The user selects a distribution for the observation error, along with parameters for that distribution. Rescaling and bias correction can also be specified prior to the perturbation. Random draws from the distribution can then be added to either, or both, of the forecast and observed fields, including ensemble members. Details about the effects of the choices on verification statistics should be considered, with many details provided in the literature (*e.g.* :ref:`Candille and Talagrand, 2008 `; :ref:`Saetra et al., 2004 `; :ref:`Santos and Ghelli, 2012 `). Generally, perturbation makes verification statistics better when applied to ensemble members, and worse when applied to the observations themselves. +In an attempt to ameliorate the effect of observation errors on the verification of forecasts, a random perturbation approach has been implemented. A great deal of user flexibility has been built in, but the methods detailed in :ref:`Candille and Talagrand (2008) `. can be replicated using the appropriate options. The user selects a distribution for the observation error, along with parameters for that distribution. Rescaling and bias correction can also be specified prior to the perturbation. Random draws from the distribution can then be added to either, or both, of the forecast and observed fields, including ensemble members. Details about the effects of the choices on verification statistics should be considered, with many details provided in the literature (*e.g.* :ref:`Candille and Talagrand, 2008 `; :ref:`Saetra et al., 2004 `; :ref:`Santos and Ghelli, 2012 `). Generally, perturbation makes verification statistics better when applied to ensemble members, and worse when applied to the observations themselves. Normal and uniform are common choices for the observation error distribution. The uniform distribution provides the benefit of being bounded on both sides, thus preventing the perturbation from taking on extreme values. Normal is the most common choice for observation error. However, the user should realize that with the very large samples typical in NWP, some large outliers will almost certainly be introduced with the perturbation. For variables that are bounded below by 0, and that may have inconsistent observation errors (e.g. larger errors with larger measurements), a lognormal distribution may be selected. Wind speeds and precipitation measurements are the most common of this type of NWP variable. The lognormal error perturbation prevents measurements of 0 from being perturbed, and applies larger perturbations when measurements are larger. This is often the desired behavior in these cases, but this distribution can also lead to some outliers being introduced in the perturbation step. @@ -649,12 +647,6 @@ The format of the STAT and ASCII output of the Ensemble-Stat tool are described * - 49 - ME_LT_OBS - The Mean Error of the ensemble values less than or equal to their observations - * - 50 - - IGN_CONV_OERR - - Error-convolved logarithmic scoring rule (i.e. ignornance score) from Equation 5 of :ref:`Ferro, 2017 ` - * - 51 - - IGN_CORR_OERR - - Error-corrected logarithmic scoring rule (i.e. ignornance score) from Equation 7 of :ref:`Ferro, 2017 ` .. _table_ES_header_info_es_out_RPS: diff --git a/docs/Users_Guide/refs.rst b/docs/Users_Guide/refs.rst index 1c328014cb..b4045f90b6 100644 --- a/docs/Users_Guide/refs.rst +++ b/docs/Users_Guide/refs.rst @@ -14,19 +14,12 @@ References | Ahijevych, D., E. Gilleland, B.G. Brown, and E.E. Ebert, 2009: Application of | spatial verification methods to idealized and NWP-gridded precipitation forecasts. -| *Weather and Forecasting*, 24 (6), 1485 - 1497. -| doi: https://doi.org/10.1175/2009WAF2222298.1 -| - -.. _Andersen-1996: - -| Anderson JL., 1996: A method for producing and evaluating probabilistic forecasts -| from ensemble model integrations. *J. Clim.* 9: 1518-1530. -| doi: `https://doi.org/10.1175/1520-0442(1996)009<1518:AMFPAE>2.0.CO;2 2.0.CO;2>`_ +| *Weather and Forecasting*, 24 (6), 1485 - 1497, doi: 10.1175/2009WAF2222298.1. | .. _Barker-1991: + | Barker, T. W., 1991: The relationship between spread and forecast error in | extended-range forecasts. *Journal of Climate*, 4, 733-742. | @@ -36,14 +29,14 @@ References | Bradley, A.A., S.S. Schwartz, and T. Hashino, 2008: Sampling Uncertainty | and Confidence Intervals for the Brier Score and Brier Skill Score. | *Weather and Forecasting*, 23, 992-1006. -| +| .. _Brill-2009: | Brill, K. F., and F. Mesinger, 2009: Applying a general analytic method | for assessing bias sensitivity to bias-adjusted threat and equitable | threat scores. *Weather and Forecasting*, 24, 1748-1754. -| +| .. _Brown-2007: @@ -56,47 +49,32 @@ References | http://ams.confex.com/ams/pdfpapers/124856.pdf. | -.. _Bröcker-2007: - -| Bröcker J, Smith LA., 2007: Scoring probabilistic forecasts: The importance -| of being proper. *Weather Forecasting*, 22, 382-388. -| doi: https://doi.org/10.1175/WAF966.1 -| - .. _Buizza-1997: | Buizza, R., 1997: Potential forecast skill of ensemble prediction and spread | and skill distributions of the ECMWF ensemble prediction system. *Monthly* -| *Weather Review*, 125, 99-119. -| +| *Weather Review*,125, 99-119. +| .. _Bullock-2016: | Bullock, R., T. Fowler, and B. Brown, 2016: Method for Object-Based | Diagnostic Evaluation. *NCAR Technical Note* NCAR/TN-532+STR, 66 pp. -| - -.. _Candille-2007: - -| Candille G, Côté C, Houtekamer PL, Pellerin G, 2007: Verification of an -| ensemble prediction system against observations. *Mon. Weather Rev.* -| 135: 2688-2699. -| doi: https://doi.org/10.1175/MWR3414.1 -| +| .. _Candille-2008: | Candille, G., and O. Talagrand, 2008: Impact of observational error on the | validation of ensemble prediction systems. *Quarterly Journal of the Royal* | *Meteorological Society* 134: 959-971. -| +| .. _Casati-2004: | Casati, B., G. Ross, and D. Stephenson, 2004: A new intensity-scale approach | for the verification of spatial precipitation forecasts. *Meteorological* | *Applications* 11, 141-154. -| +| .. _Davis-2006: @@ -108,45 +86,37 @@ References | Davis, C.A., B.G. Brown, and R.G. Bullock, 2006b: Object-based verification | of precipitation forecasts, Part II: Application to convective rain systems. | *Monthly Weather Review*, 134, 1785-1795. -| +| .. _Dawid-1984: | Dawid, A.P., 1984: Statistical theory: The prequential approach. *Journal of* | *the Royal Statistical Society* A147, 278-292. -| +| .. _Ebert-2008: | Ebert, E.E., 2008: Fuzzy verification of high-resolution gridded forecasts: -| a review and proposed framework. *Meteorological Applications*, 15, 51-64. -| +| a review and proposed framework. *Meteorological Applications,* 15, 51-64. +| .. _Eckel-2012: | Eckel, F. A., M.S. Allen, M. C. Sittel, 2012: Estimation of Ambiguity in -| Ensemble Forecasts. *Weather Forecasting*, 27, 50-69. -| doi: https://doi.org/10.1175/WAF-D-11-00015.1 +| Ensemble Forecasts. *Weather Forecasting,* 27, 50-69. +| doi: http://dx.doi.org/10.1175/WAF-D-11-00015.1 | .. _Efron-2007: | Efron, B. 2007: Correlation and large-scale significance testing. *Journal* -| of the American Statistical Association*, 102(477), 93-103. +| of the American Statistical Association,* 102(477), 93-103. | .. _Epstein-1969: | Epstein, E. S., 1969: A scoring system for probability forecasts of ranked categories. -| *J. Appl. Meteor.*, 8, 985-987. -| doi: `https://doi.org/10.1175/1520-0450(1969)008<0985:ASSFPF>2.0.CO;2 2.0.CO;2>`_ -| - -.. _Ferro-2017: - -| Ferro C. A. T., 2017: Measuring forecast performance in the presence of observation error. -| *Q. J. R. Meteorol. Soc.*, 143 (708), 2665-2676. -| doi: https://doi.org/10.1002/qj.3115 +| *J. Appl. Meteor.*, 8, 985-987, 10.1175/1520-0450(1969)008<0985:ASSFPF>2.0.CO;2. | .. _Gilleland-2010: @@ -159,32 +129,29 @@ References | Gilleland, E., 2017: A new characterization in the spatial verification | framework for false alarms, misses, and overall patterns. -| *Weather and Forecasting*, 32 (1), 187 - 198. -| doi: https://doi.org/10.1175/WAF-D-16-0134.1 +| *Weather and Forecasting*, 32 (1), 187 - 198, doi: 10.1175/WAF-D-16-0134.1. | .. _Gilleland_PartI-2020: | Gilleland, E., 2020: Bootstrap methods for statistical inference. | Part I: Comparative forecast verification for continuous variables. -| *Journal of Atmospheric and Oceanic Technology*, 37 (11), 2117 - 2134. -| doi: https://doi.org/10.1175/JTECH-D-20-0069.1 +| *Journal of Atmospheric and Oceanic Technology*, 37 (11), 2117 - 2134, +| doi: 10.1175/JTECH-D-20-0069.1. | .. _Gilleland_PartII-2020: | Gilleland, E., 2020: Bootstrap methods for statistical inference. | Part II: Extreme-value analysis. *Journal of Atmospheric and Oceanic* -| *Technology*, 37 (11), 2135 - 2144. -| doi: https://doi.org/10.1175/JTECH-D-20-0070.1 +| *Technology*, 37 (11), 2135 - 2144, doi: 10.1175/JTECH-D-20-0070.1. | .. _Gilleland-2021: | Gilleland, E., 2021: Novel measures for summarizing high-resolution forecast | performance. *Advances in Statistical Climatology, Meteorology and Oceanography*, -| 7 (1), 13 - 34. -| doi: https://doi.org/10.5194/ascmo-7-13-2021 +| 7 (1), 13 - 34, doi: 10.5194/ascmo-7-13-2021. | .. _Gneiting-2004: @@ -194,7 +161,7 @@ References | *Minimum CRPS Estimation*. Technical Report no. 449, Department of | Statistics, University of Washington. Available at | http://www.stat.washington.edu/www/research/reports/ -| +| .. _Haiden-2012: @@ -208,41 +175,41 @@ References | Hamill, T. M., 2001: Interpretation of rank histograms for verifying ensemble | forecasts. *Monthly Weather Review*, 129, 550-560. -| +| .. _Hersbach-2000: | Hersbach, H., 2000: Decomposition of the Continuous Ranked Probability Score | for Ensemble Prediction Systems. *Weather and Forecasting*, 15, 559-570. -| +| .. _Jolliffe-2012: | Jolliffe, I.T., and D.B. Stephenson, 2012: *Forecast verification. A* | *practitioner's guide in atmospheric science.* Wiley and Sons Ltd, 240 pp. -| +| .. _Knaff-2003: | Knaff, J.A., M. DeMaria, C.R. Sampson, and J.M. Gross, 2003: Statistical, | Five-Day Tropical Cyclone Intensity Forecasts Derived from Climatology -| and Persistence. *Weather and Forecasting*, Vol. 18 Issue 2, p. 80-92. -| +| and Persistence. *Weather and Forecasting,* Vol. 18 Issue 2, p. 80-92. +| .. _Mason-2004: | Mason, S. J., 2004: On Using "Climatology" as a Reference Strategy | in the Brier and Ranked Probability Skill Scores. *Monthly Weather Review*, | 132, 1891-1895. -| +| .. _Mason-2008: | Mason, S. J., 2008: Understanding forecast verification statistics. -| *Meteor. Appl.*, 15, 31-40. -| doi: https://doi.org/10.1002/met.51 +| *Meteor. Appl.*, 15, 31-40, doi: 10.1002/met.51. | + .. _Mittermaier-2014: | Mittermaier, M., 2014: A strategy for verifying near-convection-resolving @@ -253,20 +220,21 @@ References | Mood, A. M., F. A. Graybill and D. C. Boes, 1974: *Introduction to the* | *Theory of Statistics*, McGraw-Hill, 299-338. -| +| .. _Murphy-1969: | Murphy, A.H., 1969: On the ranked probability score. *Journal of Applied* | *Meteorology and Climatology*, 8 (6), 988 - 989, -| doi: `https://doi.org/10.1175/1520-0450(1969)008<0988:OTPS>2.0.CO;2 2.0.CO;2>`_ +| doi: 10.1175/1520-0450(1969)008<0988:OTPS>2.0.CO;2. | .. _Murphy-1987: | Murphy, A.H., and R.L. Winkler, 1987: A general framework for forecast | verification. *Monthly Weather Review*, 115, 1330-1338. -| +| + .. _North-2022: @@ -288,7 +256,7 @@ References | Roberts, N.M., and H.W. Lean, 2008: Scale-selective verification of rainfall | accumulations from high-resolution forecasts of convective events. | *Monthly Weather Review*, 136, 78-97. -| +| .. _Rodwell-2010: @@ -305,18 +273,11 @@ References | https://www.ecmwf.int/node/14595 | -.. _Röpnack-2013: - -| Röpnack A, Hense A, Gebhardt C, Majewski D., 2013: Bayesian model verification -| of NWP ensemble forecasts. *Mon. Weather Rev.* 141: 375–387. -| doi: https://doi.org/10.1175/MWR-D-11-00350.1 -| - .. _Saetra-2004: -| Saetra Ø., H. Hersbach, J-R Bidlot, D. Richardson, 2004: Effects of +| Saetra O., H. Hersbach, J-R Bidlot, D. Richardson, 2004: Effects of | observation errors on the statistics for ensemble spread and -| reliability. *Monthly Weather Review*, 132: 1487-1501. +| reliability. *Monthly Weather Review* 132: 1487-1501. | .. _Santos-2012: @@ -324,7 +285,7 @@ References | Santos C. and A. Ghelli, 2012: Observational probability method to assess | ensemble precipitation forecasts. *Quarterly Journal of the Royal* | *Meteorological Society* 138: 209-221. -| +| .. _Schwartz-2017: @@ -337,21 +298,20 @@ References | Stephenson, D.B., 2000: Use of the "Odds Ratio" for diagnosing | forecast skill. *Weather and Forecasting*, 15, 221-232. -| +| .. _Stephenson-2008: | Stephenson, D.B., B. Casati, C.A.T. Ferro, and C.A. Wilson, 2008: The extreme | dependency score: A non-vanishing measure for forecasts of rare events. | *Meteorological Applications* 15, 41-50. -| +| -.. _Tödter-2012: +.. _Todter-2012: | Tödter, J. and B. Ahrens, 2012: Generalization of the Ignorance Score: | Continuous ranked version and its decomposition. *Monthly Weather Review*, -| 140 (6), 2005 - 2017. -| doi: https://doi.org/10.1175/MWR-D-11-00266.1 +| 140 (6), 2005 - 2017, doi: 10.1175/MWR-D-11-00266.1. | .. _Weniger-2016: @@ -359,18 +319,17 @@ References | Weniger, M., F. Kapp, and P. Friederichs, 2016: Spatial Verification Using | Wavelet Transforms: A Review. *Quarterly Journal of the Royal* | *Meteorological Society*, 143, 120-136. -| +| .. _Wilks-2010: | Wilks, D.S. 2010: Sampling distributions of the Brier score and Brier skill | score under serial dependence. *Quarterly Journal of the Royal* -| *Meteorological Society*, 136, 2109-2118. -| doi: https://doi.org/10.1002/qj.709 -| +| *Meteorological Society*, 136, 2109-2118. doi:10.1002/qj.709 +| .. _Wilks-2011: | Wilks, D., 2011: *Statistical methods in the atmospheric sciences.* | Elsevier, San Diego. -| +| diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index a1113d5102..d6bf9fb0b9 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -19,7 +19,7 @@ PJC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L PRC : 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_ PSTD : 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 BASER BASER_NCL BASER_NCU RELIABILITY RESOLUTION UNCERTAINTY ROC_AUC BRIER BRIER_NCL BRIER_NCU BRIERCL BRIERCL_NCL BRIERCL_NCU BSS BSS_SMPL _VAR_ ECLV : 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 BASE N_PTS _VAR_ -ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS IGN_CONV_OERR IGN_CORR_OERR +ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS RPS : 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_PROB RPS_REL RPS_RES RPS_UNC RPS RPSS RPSS_SMPL RPS_COMP RHIST : 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 CRPS IGN N_RANK CRPSS SPREAD _VAR_ PHIST : 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 BIN_SIZE N_BIN _VAR_ diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index baaac11c6a..144736cc88 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -1075,9 +1075,7 @@ NumArray NumArray::subset(const NumArray &keep) const // Check bounds if ( keep.n_elements() != n_elements() ) { mlog << Error << "\nNumArray::subset(const NumArray &) -> " - << "the number of elements do not match (" - << keep.n_elements() << " keep flags != " - << n_elements() << " array elements)\n\n"; + << "the number of elements do not match\n\n"; exit ( 1 ); } @@ -1158,9 +1156,7 @@ double NumArray::wmean(const NumArray &wgt) const if ( wgt.n_elements() != n_elements() ) { mlog << Error << "\nNumArray::wmean(const NumArray &) -> " - << "the number of elements do not match (" - << wgt.n_elements() << " weights != " - << n_elements() << " array elements)\n\n"; + << "the number of elements do not match\n\n"; exit ( 1 ); } diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index 826d5101c9..909441b5ba 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -276,7 +276,7 @@ static const char * ecnt_columns [] = { "CRPSS_EMP", "CRPS_EMP_FAIR", "SPREAD_MD", "MAE", "MAE_OERR", "BIAS_RATIO", "N_GE_OBS", "ME_GE_OBS", "N_LT_OBS", - "ME_LT_OBS", "IGN_CONV_OERR", "IGN_CORR_OERR" + "ME_LT_OBS" }; static const char * rps_columns [] = { diff --git a/src/libcode/vx_gsl_prob/gsl_randist.h b/src/libcode/vx_gsl_prob/gsl_randist.h index e66c312230..d562bfe733 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.h +++ b/src/libcode/vx_gsl_prob/gsl_randist.h @@ -58,9 +58,9 @@ extern void ran_sample(const gsl_rng *r, double *, int, double *, int); extern void ran_sample(const gsl_rng *r, NumArray &, NumArray &, int); extern double ran_draw(const gsl_rng *r, DistType, - double p1, double p2 = bad_data_double); + double p1, double p2 = bad_data_int); extern double dist_var(DistType, - double p1, double p2 = bad_data_double); + double p1, double p2 = bad_data_int); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 55aded1e28..c4880f83eb 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -4275,7 +4275,7 @@ void write_ecnt_cols(const ECNTInfo &ecnt_info, // CRPSS_EMP CRPS_EMP_FAIR, SPREAD_MD, // MAE, MAE_OERR, BIAS_RATIO, // N_GE_OBS, ME_GE_OBS, N_LT_OBS, - // ME_LT_OBS, IGN_CONV_OERR, IGN_CORR_OERR + // ME_LT_OBS // at.set_entry(r, c+0, // Total Number of Pairs ecnt_info.n_pair); @@ -4352,12 +4352,6 @@ void write_ecnt_cols(const ECNTInfo &ecnt_info, at.set_entry(r, c+24, // ME of ensemble values < observations ecnt_info.me_lt_obs); - at.set_entry(r, c+25, // Ignorance Score, observation error convolved - ecnt_info.ign_conv_oerr); - - at.set_entry(r, c+26, // Ignorance Score, observation error corrected - ecnt_info.ign_corr_oerr); - return; } diff --git a/src/libcode/vx_statistics/ens_stats.cc b/src/libcode/vx_statistics/ens_stats.cc index 782832b79f..4ed6f821ca 100644 --- a/src/libcode/vx_statistics/ens_stats.cc +++ b/src/libcode/vx_statistics/ens_stats.cc @@ -181,15 +181,13 @@ void ECNTInfo::clear() { crps_emp_fair = spread_md = bad_data_double; crps_gaus = crpscl_gaus = crpss_gaus = bad_data_double; ign = bad_data_double; - me = mae = rmse = spread = bad_data_double; - me_oerr = mae_oerr = rmse_oerr = spread_oerr = bad_data_double; + me = mae = rmse = spread = bad_data_double; + me_oerr = mae_oerr = rmse_oerr = spread_oerr = bad_data_double; spread_plus_oerr = bad_data_double; - ign_conv_oerr = ign_corr_oerr = bad_data_double; - - n_ge_obs = n_lt_obs = 0; - me_ge_obs = me_lt_obs = bias_ratio = bad_data_double; - + n_ge_obs = n_lt_obs = 0; + me_ge_obs = me_lt_obs = bias_ratio = bad_data_double; + return; } @@ -223,8 +221,6 @@ void ECNTInfo::assign(const ECNTInfo &c) { rmse_oerr = c.rmse_oerr; spread_oerr = c.spread_oerr; spread_plus_oerr = c.spread_plus_oerr; - ign_conv_oerr = c.ign_conv_oerr; - ign_corr_oerr = c.ign_corr_oerr; n_ge_obs = c.n_ge_obs; n_lt_obs = c.n_lt_obs; @@ -365,10 +361,6 @@ void ECNTInfo::set(const PairDataEnsemble &pd) { // Compute the square root of the average variance plus oerr spread_plus_oerr = square_root(pd.var_plus_oerr_na.wmean(pd.wgt_na)); - // Compute log scores with observational uncertainty - ign_conv_oerr = pd.ign_conv_oerr_na.wmean(pd.wgt_na); - ign_corr_oerr = pd.ign_corr_oerr_na.wmean(pd.wgt_na); - // Compute bias ratio terms n_ge_obs = nint(pd.n_ge_obs_na.sum()); me_ge_obs = pd.me_ge_obs_na.wmean(pd.n_ge_obs_na); diff --git a/src/libcode/vx_statistics/ens_stats.h b/src/libcode/vx_statistics/ens_stats.h index 69eca9f4e1..17e864fb5e 100644 --- a/src/libcode/vx_statistics/ens_stats.h +++ b/src/libcode/vx_statistics/ens_stats.h @@ -82,10 +82,6 @@ class ECNTInfo { double me_oerr, mae_oerr, rmse_oerr, spread_oerr; double spread_plus_oerr; - // Log scores that incorporate observational uncertainty, - // as advised in Ferro (2017) - double ign_conv_oerr, ign_corr_oerr; - // Bias ratio information int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index 8487d751b5..a290afcb30 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3456,25 +3456,6 @@ int min_int(const int *v_int, int n) { return v_min; } -//////////////////////////////////////////////////////////////////////// -// -// Compute mean from a sum -// -//////////////////////////////////////////////////////////////////////// - -double compute_mean(double sum, int n) { - double v; - - if(is_bad_data(sum) || is_bad_data(n) || n == 0) { - v = bad_data_double; - } - else { - v = sum / n; - } - - return(v); -} - //////////////////////////////////////////////////////////////////////// // // Compute variance from sums of squares diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index 1d5def71a7..f0715d45b3 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -726,8 +726,6 @@ extern int min_int(const int *, int); // //////////////////////////////////////////////////////////////////////// -extern double compute_mean(double, int); - extern double compute_variance(double, double, int); extern double compute_stdev(double, double, int); diff --git a/src/libcode/vx_statistics/obs_error.cc b/src/libcode/vx_statistics/obs_error.cc index 5b753346a3..eae4bed423 100644 --- a/src/libcode/vx_statistics/obs_error.cc +++ b/src/libcode/vx_statistics/obs_error.cc @@ -5,7 +5,6 @@ // ** Research Applications Lab (RAL) // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// #include @@ -185,12 +184,6 @@ void ObsErrorEntry::dump(ostream & out, int depth) const { //////////////////////////////////////////////////////////////////////// -double ObsErrorEntry::variance() const { - return dist_var(dist_type, dist_parm[0], dist_parm[1]); -} - -//////////////////////////////////////////////////////////////////////// - bool ObsErrorEntry::parse_line(const DataLine &dl) { // Initialize diff --git a/src/libcode/vx_statistics/obs_error.h b/src/libcode/vx_statistics/obs_error.h index 11cce141dc..732c4c3ced 100644 --- a/src/libcode/vx_statistics/obs_error.h +++ b/src/libcode/vx_statistics/obs_error.h @@ -5,7 +5,6 @@ // ** Research Applications Lab (RAL) // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// #ifndef __OBS_ERROR_H__ @@ -69,8 +68,6 @@ class ObsErrorEntry { // get stuff // - double variance() const; - // // do stuff // diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index b9c3868036..cc25f891d3 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -108,9 +108,6 @@ void PairDataEnsemble::clear() { ign_na.clear(); pit_na.clear(); - ign_conv_oerr_na.clear(); - ign_corr_oerr_na.clear(); - n_ge_obs_na.clear(); me_ge_obs_na.clear(); n_lt_obs_na.clear(); @@ -182,8 +179,6 @@ void PairDataEnsemble::extend(int n) { crpscl_gaus_na.extend (n); ign_na.extend (n); pit_na.extend (n); - ign_conv_oerr_na.extend (n); - ign_corr_oerr_na.extend (n); n_ge_obs_na.extend (n); me_ge_obs_na.extend (n); n_lt_obs_na.extend (n); @@ -240,20 +235,15 @@ void PairDataEnsemble::assign(const PairDataEnsemble &pd) { // PairDataEnsemble v_na = pd.v_na; r_na = pd.r_na; - crps_emp_na = pd.crps_emp_na; crps_emp_fair_na = pd.crps_emp_fair_na; spread_md_na = pd.spread_md_na; crpscl_emp_na = pd.crpscl_emp_na; crps_gaus_na = pd.crps_gaus_na; crpscl_gaus_na = pd.crpscl_gaus_na; - ign_na = pd.ign_na; pit_na = pd.pit_na; - ign_conv_oerr_na = pd.ign_conv_oerr_na; - ign_corr_oerr_na = pd.ign_corr_oerr_na; - n_ge_obs_na = pd.n_ge_obs_na; me_ge_obs_na = pd.me_ge_obs_na; n_lt_obs_na = pd.n_lt_obs_na; @@ -459,8 +449,6 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { crpscl_gaus_na.add(bad_data_double); ign_na.add(bad_data_double); pit_na.add(bad_data_double); - ign_conv_oerr_na.add(bad_data_double); - ign_corr_oerr_na.add(bad_data_double); n_ge_obs_na.add(bad_data_double); me_ge_obs_na.add(bad_data_double); n_lt_obs_na.add(bad_data_double); @@ -473,41 +461,22 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { var_unperturbed = compute_variance(esum_na[i], esumsq_na[i], esumn_na[i]); var_na.add(var_unperturbed); - // Process the observation error information + // Process the observation error information. ObsErrorEntry * e = (has_obs_error() ? obs_error_entry[i] : 0); if(e) { - // Get observation error variance - double oerr_var = e->variance(); - - // Compute the observation error log scores - double v_conv, v_corr; - compute_obs_error_log_scores( - compute_mean(esum_na[i], esumn_na[i]), - compute_stdev(esum_na[i], esumsq_na[i], esumn_na[i]), - o_na[i], oerr_var, - v_conv, v_corr); - ign_conv_oerr_na.add(v_conv); - ign_corr_oerr_na.add(v_corr); - // Compute perturbed ensemble mean and variance // Exclude the control member from the variance mn_oerr_na.add(cur_ens.mean()); var_oerr_na.add(cur_ens.variance(ctrl_index)); - // Compute the variance plus observation error variance - if(is_bad_data(var_unperturbed) || - is_bad_data(oerr_var)) { - var_plus_oerr_na.add(bad_data_double); - } - else { - var_plus_oerr_na.add(var_unperturbed + oerr_var); - } + // Compute the variance plus observation error variance. + var_plus_oerr_na.add(var_unperturbed + + dist_var(e->dist_type, + e->dist_parm[0], e->dist_parm[1])); } - // If no observation error specified, store bad data values + // If no observation error specified, store bad data values. else { - ign_conv_oerr_na.add(bad_data_double); - ign_corr_oerr_na.add(bad_data_double); mn_oerr_na.add(bad_data_double); var_oerr_na.add(bad_data_double); var_plus_oerr_na.add(bad_data_double); @@ -537,8 +506,8 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { derive_climo_vals(cdf_info_ptr, cmn_na[i], csd_na[i], cur_clm); // Store empirical CRPS stats - // For crps_emp use temporary, local variable so we can use it - // for the crps_emp_fair calculation + // + // For crps_emp use temporary, local variable so we can use it for the crps_emp_fair calculation double crps_emp = compute_crps_emp(o_na[i], cur_ens); crps_emp_na.add(crps_emp); crps_emp_fair_na.add(crps_emp - cur_ens.wmean_abs_diff()); @@ -559,10 +528,9 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { // Compute the Bias Ratio terms int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - compute_bias_ratio_terms( - o_na[i], cur_ens, - n_ge_obs, me_ge_obs, - n_lt_obs, me_lt_obs); + compute_bias_ratio_terms(o_na[i], cur_ens, + n_ge_obs, me_ge_obs, + n_lt_obs, me_lt_obs); // Store the Bias Ratio terms n_ge_obs_na.add(n_ge_obs); @@ -896,11 +864,8 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o // // Include in subset: // wgt_na, o_na, cmn_na, csd_na, v_na, r_na, - // crps_emp_na, crps_emp_fair_na, spread_md_na, - // crpscl_emp_na, crps_gaus_na, crpscl_gaus_na, - // ign_na, pit_na, - // ign_conv_oerr, ign_corr_oerr, - // n_gt_obs_na, me_gt_obs_na, n_lt_obs_na, me_lt_obs_na, + // crps_emp_na, crps_emp_fair_na, spread_md_na, crpscl_emp_na, crps_gaus_na, crpscl_gaus_na, + // ign_na, pit_na, n_gt_obs_na, me_gt_obs_na, n_lt_obs_na, me_lt_obs_na, // var_na, var_oerr_na, var_plus_oerr_na, // mn_na, mn_oerr_na, e_na // @@ -923,8 +888,6 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o pd.crpscl_gaus_na.add(crpscl_gaus_na[i]); pd.ign_na.add(ign_na[i]); pd.pit_na.add(pit_na[i]); - pd.ign_conv_oerr_na.add(ign_conv_oerr_na[i]); - pd.ign_corr_oerr_na.add(ign_corr_oerr_na[i]); pd.n_ge_obs_na.add(n_ge_obs_na[i]); pd.me_ge_obs_na.add(me_ge_obs_na[i]); pd.n_lt_obs_na.add(n_lt_obs_na[i]); @@ -1535,7 +1498,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, y < 0 || y >= gr.ny()) return; // For pressure levels, check if the observation pressure level - // falls in the requested range. + // falls in the requsted range. if(obs_info_grib->level().type() == LevelType_Pres) { if(obs_lvl < obs_info_grib->level().lower() || @@ -1630,8 +1593,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, } } - // Apply observation error additive and multiplicative - // bias correction, if requested + // Apply observation error logic bias correction, if requested if(obs_error_info->flag) { obs_v = add_obs_error_bc(obs_error_info->rng_ptr, FieldType_Obs, oerr_ptr, obs_v); @@ -2149,52 +2111,5 @@ double compute_bias_ratio(double me_ge_obs, double me_lt_obs) { return v; } - -//////////////////////////////////////////////////////////////////////// - -void compute_obs_error_log_scores(double emn, double esd, - double obs, double oerr_var, - double &v_conv, double &v_corr) { - - const char *method_name = "compute_obs_error_log_scores() -> "; - - // Check for bad input data - if(is_bad_data(emn) || - is_bad_data(esd) || - is_bad_data(obs) || - is_bad_data(oerr_var)) { - v_conv = v_corr = bad_data_double; - } - else { - double sigma2 = esd * esd; - double ov2 = oerr_var * oerr_var; - - // Error-convolved logarithmic scoring rule in - // Ferro (2017, Eq 5) doi:10.1002/qj.3115 - // Scale by 2.0 * pi for consistency with ignorance score - v_conv = 0.5 * log(2.0 * pi * (sigma2 + ov2)) + - (obs - emn) * (obs - emn) / - (2.0 * (sigma2 + ov2)); - - // Error-corrected logarithmic scoring rule in - // Ferro (2017, Eq 7) doi:10.1002/qj.3115 - // Scale by 2.0 * pi for consistency with ignorance score - v_corr = log(esd) + - ((obs - emn) * (obs - emn) - ov2) / - (2.0 * sigma2); - } - - if(mlog.verbosity_level() >= 10) { - mlog << Debug(10) << method_name - << "inputs (emn = " << emn - << ", esd = " << esd - << ", obs = " << obs - << ", oerr_var = " << oerr_var - << ") and outputs (ign_oerr_conv = " << v_conv - << ", ign_oerr_corr = " << v_corr << ")\n"; - } - - return; -} - + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_ensemble.h b/src/libcode/vx_statistics/pair_data_ensemble.h index 9be2eec3c8..e6014b59fb 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.h +++ b/src/libcode/vx_statistics/pair_data_ensemble.h @@ -6,8 +6,6 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -//////////////////////////////////////////////////////////////////////// - #ifndef __PAIR_DATA_ENSEMBLE_H__ #define __PAIR_DATA_ENSEMBLE_H__ @@ -76,67 +74,64 @@ class PairDataEnsemble : public PairBase { bool obs_error_flag; // Ensemble, valid count, and rank values - NumArray *e_na; // Ensemble values [n_ens][n_obs] - NumArray v_na; // Number of valid ensemble values [n_obs] - NumArray r_na; // Observation ranks [n_obs] - - NumArray crps_emp_na; // Empirical Continuous Ranked Probability Score [n_obs] - NumArray crps_emp_fair_na; // Fair Empirical Continuous Ranked Probability Score [n_obs] - NumArray spread_md_na; // Mean absolute difference of ensemble members [n_obs] - NumArray crpscl_emp_na; // Empirical climatological CRPS [n_obs] + NumArray *e_na; // Ensemble values [n_ens][n_obs] + NumArray v_na; // Number of valid ensemble values [n_obs] + NumArray r_na; // Observation ranks [n_obs] - NumArray crps_gaus_na; // Gaussian CRPS [n_obs] - NumArray crpscl_gaus_na; // Gaussian climatological CRPS [n_obs] + NumArray crps_emp_na; // Empirical Continuous Ranked Probability Score [n_obs] + NumArray crps_emp_fair_na; // Fair Empirical Continuous Ranked Probability Score [n_obs] + NumArray spread_md_na; // Mean absolute difference of ensemble members [n_obs] + NumArray crpscl_emp_na; // Empirical climatological CRPS [n_obs] - NumArray ign_na; // Ignorance Score [n_obs] - NumArray pit_na; // Probability Integral Transform [n_obs] + NumArray crps_gaus_na; // Gaussian CRPS [n_obs] + NumArray crpscl_gaus_na; // Gaussian climatological CRPS [n_obs] - NumArray ign_conv_oerr_na; // Error convolved log score [n_obs] - NumArray ign_corr_oerr_na; // Error corrected log score [n_obs] + NumArray ign_na; // Ignorance Score [n_obs] + NumArray pit_na; // Probability Integral Transform [n_obs] - NumArray n_ge_obs_na; // Number of ensemble memebers >= obs [n_obs] - NumArray me_ge_obs_na; // Mean error of ensemble members >= obs [n_obs] - NumArray n_lt_obs_na; // Number of ensemble members < obs [n_obs] - NumArray me_lt_obs_na; // Mean error of ensemble members < obs [n_obs] + NumArray n_ge_obs_na; // Number of ensemble memebers >= obs [n_obs] + NumArray me_ge_obs_na; // Mean error of ensemble members >= obs [n_obs] + NumArray n_lt_obs_na; // Number of ensemble members < obs [n_obs] + NumArray me_lt_obs_na; // Mean error of ensemble members < obs [n_obs] - int n_ens; // Number of ensemble members - int n_pair; // Number of valid pairs, n_obs - sum(skip_ba) - int ctrl_index; // Index of the control member - bool skip_const; // Skip cases where the observation and - // all ensemble members are constant - BoolArray skip_ba; // Flag for each observation [n_obs] + int n_ens; // Number of ensemble members + int n_pair; // Number of valid pairs, n_obs - sum(skip_ba) + int ctrl_index; // Index of the control member + bool skip_const; // Skip cases where the observation and + // all ensemble members are constant + BoolArray skip_ba; // Flag for each observation [n_obs] - NumArray rhist_na; // Ranked Histogram [n_ens+1] - NumArray relp_na; // Relative Position Histogram [n_ens] + NumArray rhist_na; // Ranked Histogram [n_ens+1] + NumArray relp_na; // Relative Position Histogram [n_ens] - double phist_bin_size; // Ensemble PIT histogram bin width - NumArray phist_na; // PIT Histogram [n_phist_bin] + double phist_bin_size; // Ensemble PIT histogram bin width + NumArray phist_na; // PIT Histogram [n_phist_bin] NumArray var_na; // Variance of unperturbed members [n_obs] NumArray var_oerr_na; // Variance of perturbed members [n_obs] NumArray var_plus_oerr_na; // Unperturbed variance plus observation error variance [n_obs] - NumArray esum_na; // Sum of unperturbed ensemble values [n_obs] - NumArray esumsq_na; // Sum of unperturbed ensemble squared values [n_obs] - NumArray esumn_na; // Count of ensemble values [n_obs] + NumArray esum_na; // Sum of unperturbed ensemble values [n_obs] + NumArray esumsq_na; // Sum of unperturbed ensemble squared values [n_obs] + NumArray esumn_na; // Count of ensemble values [n_obs] - NumArray mn_na; // Ensemble mean value [n_obs] - NumArray mn_oerr_na; // Mean of perturbed members [n_obs] + NumArray mn_na; // Ensemble mean value [n_obs] + NumArray mn_oerr_na; // Mean of perturbed members [n_obs] - double ssvar_bin_size; // Variance bin size for spread/skill - SSVARInfo *ssvar_bins; // Ensemble spread/skill bin information [n_ssvar_bin] + double ssvar_bin_size; // Variance bin size for spread/skill + SSVARInfo *ssvar_bins; // Ensemble spread/skill bin information [n_ssvar_bin] - double crpss_emp; // Empirical CRPS skill score - double crpss_gaus; // Guassian CRPS skill score + double crpss_emp; // Empirical CRPS skill score + double crpss_gaus; // Guassian CRPS skill score - double me; // ME for ensemble mean - double mae; // MAE for ensemble mean - double rmse; // RMSE for ensemble mean - double me_oerr; // ME for mean of perturbed members - double mae_oerr; // MAE for mean of perturbed members - double rmse_oerr; // RMSE for mean of perturbed members + double me; // ME for ensemble mean + double mae; // MAE for ensemble mean + double rmse; // RMSE for ensemble mean + double me_oerr; // ME for mean of perturbed members + double mae_oerr; // MAE for mean of perturbed members + double rmse_oerr; // RMSE for mean of perturbed members - double bias_ratio; // Bias ratio + double bias_ratio; // Bias ratio ////////////////////////////////////////////////////////////////// @@ -328,9 +323,6 @@ extern double compute_ens_pit(double, double, double); extern void compute_bias_ratio_terms(double, const NumArray &, int &, double &, int &, double &); extern double compute_bias_ratio(double, double); -extern void compute_obs_error_log_scores( - double, double, double, double, - double &, double &); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 2b19b94391..cd3b080bc6 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -1119,7 +1119,7 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, } // For pressure levels, check if the observation pressure level - // falls in the requested range. + // falls in the requsted range. if(obs_info->level().type() == LevelType_Pres) { if(obs_lvl < obs_info->level().lower() || diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 3ca4cfcaff..49506e1402 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -39,8 +39,6 @@ // line types. // 018 02/13/24 Halley Gotway MET #2395 Add wind direction stats // to VL1L2, VAL1L2, and VCNT. -// 019 02/21/24 Halley Gotway MET #2583 Add observation error -// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -2658,8 +2656,6 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, m[key].ens_pd.crps_gaus_na.add(cur.crps_gaus); m[key].ens_pd.crpscl_gaus_na.add(cur.crpscl_gaus); m[key].ens_pd.ign_na.add(cur.ign); - m[key].ens_pd.ign_conv_oerr_na.add(cur.ign_conv_oerr); - m[key].ens_pd.ign_corr_oerr_na.add(cur.ign_corr_oerr); m[key].ens_pd.n_ge_obs_na.add(cur.n_ge_obs); m[key].ens_pd.me_ge_obs_na.add(cur.me_ge_obs); m[key].ens_pd.n_lt_obs_na.add(cur.n_lt_obs); @@ -3233,34 +3229,17 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, m[key].ens_pd.ign_na.add(compute_ens_ign(cur.obs, cur.ens_mean, cur.spread)); m[key].ens_pd.pit_na.add(compute_ens_pit(cur.obs, cur.ens_mean, cur.spread)); - // Back out the observation error variance - double oerr_var = bad_data_double; - if(!is_bad_data(cur.spread_plus_oerr) && - !is_bad_data(cur.spread)) { - oerr_var = square(cur.spread_plus_oerr) - - square(cur.spread); - } - // Store BIAS_RATIO terms int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - compute_bias_ratio_terms( - cur.obs, cur.ens_na, - n_ge_obs, me_ge_obs, - n_lt_obs, me_lt_obs); + compute_bias_ratio_terms(cur.obs, cur.ens_na, + n_ge_obs, me_ge_obs, + n_lt_obs, me_lt_obs); m[key].ens_pd.n_ge_obs_na.add(n_ge_obs); m[key].ens_pd.me_ge_obs_na.add(me_ge_obs); m[key].ens_pd.n_lt_obs_na.add(n_lt_obs); m[key].ens_pd.me_lt_obs_na.add(me_lt_obs); - // Compute observation error log scores - double v_conv, v_corr; - compute_obs_error_log_scores( - cur.ens_mean, cur.spread, cur.obs, oerr_var, - v_conv, v_corr); - m[key].ens_pd.ign_conv_oerr_na.add(v_conv); - m[key].ens_pd.ign_corr_oerr_na.add(v_corr); - // // Increment the RHIST counts // diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index ebdc9d9a0a..b6ec116759 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -33,8 +33,6 @@ // line types. // 013 02/13/24 Halley Gotway MET #2395 Add wind direction stats // to VL1L2, VAL1L2, and VCNT. -// 014 02/21/24 Halley Gotway MET #2583 Add observation error -// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -399,9 +397,6 @@ void parse_ecnt_line(STATLine &l, ECNTData &e_data) { e_data.n_lt_obs = atoi(l.get_item("N_LT_OBS")); e_data.me_lt_obs = atof(l.get_item("ME_LT_OBS")); - e_data.ign_conv_oerr = atof(l.get_item("IGN_CONV_OERR")); - e_data.ign_corr_oerr = atof(l.get_item("IGN_CORR_OERR")); - return; } diff --git a/src/tools/core/stat_analysis/parse_stat_line.h b/src/tools/core/stat_analysis/parse_stat_line.h index c890b45ff7..529fdb2df9 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.h +++ b/src/tools/core/stat_analysis/parse_stat_line.h @@ -28,8 +28,6 @@ // 011 09/28/22 Prestopnik MET #2227 Remove namespace std // 012 11/10/22 Halley Gotway MET #2339 Add SEEPS and SEEPS_MPR // line types. -// 013 02/21/24 Halley Gotway MET #2583 Add observation error -// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -74,7 +72,6 @@ struct ECNTData { double bias_ratio; int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - double ign_conv_oerr, ign_corr_oerr; }; // Ranked Histogram (RHIST) data structure diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index 827662caf8..99b0f762ef 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -39,7 +39,7 @@ // 014 07/09/21 Linden MET #1746 Skip thresholding. // 015 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 016 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files -// 017 01/29/24 Halley Gotway MET #2801 Configure time difference warnings +// 017 01/29/24 Halley Gotway MET #2801 Configure time difference warnings // //////////////////////////////////////////////////////////////////////// @@ -425,7 +425,7 @@ void process_scores() { mlog << Debug(2) << "Observation field: "; fill_bad_data(obs_dp_fill, obs_fill); - // Pad the fields out to the nearest power of two if requested + // Pad the fields out to the nearest power of two if requsted if(conf_info.grid_decomp_flag == GridDecompType_Pad) { mlog << Debug(2) << "Padding the fields out to the nearest integer " << "power of two.\n"; From fd1b250593c60cd750a3f703de1fdb8c6480b34b Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 14 Mar 2024 12:17:54 -0600 Subject: [PATCH 030/114] Feature #2583 ecnt fix IGN_OERR_CORR (#2838) * Unrelated to #2583, fix typo in code comments. * Per #2583, add hooks write 3 new ECNT columns for observation error data. * Per #2583, make error messages about mis-matched array lengths more informative. * Per #2583, switch to more concise variable naming conventions of ign_oerr_cnv, ign_oerr_cor, and dawid_seb. * Per #2583, fix typo to enable compilation * Per #2583, define the 5 new ECNT column names. * Per #2583, add 5 new columns to the ECNT table in the Ensemble-Stat chapter * Per #2583, update stat_columns.cc to write these 5 new ECNT columns * Per #2583, update ECNTInfo class to compute the 5 new ECNT statistics. * Per #2583, update stat-analysis to parse the 5 new ECNT columns. * Per #2583, update aggregate_stat logic for 5 new ECNT columns. * Per #2583, update PairDataEnsemble logic for 5 new ECNT columns * Per #2583, update vx_statistics library with obs_error handling logic for the 5 new ECNT columns * Per #2583, changes to make it compile * Per #2583, changes to make it compile * Per #2583, switch to a consistent ECNT column naming convention with OERR at the end. Using IGN_CONV_OERR and IGN_CORR_OERR. * Per #2583, define ObsErrorEntry::variance() with a call to the dist_var() utility function. * Per #2583, update PairDataEnsemble::compute_pair_vals() to compute the 5 new stats with the correct inputs. * Per #2583, add DEBUG(10) log messages about computing these new stats. * Per #2583, update Stat-Analysis to compute these 5 new stats from the ORANK line type. * Per #2583, whitespace and comments. * Per #2583, update the User's Guide. * Per #2583, remove the DS_ADD_OERR and DS_MULT_OERR ECNT columns and rename DS_OERR as DSS, since observation error is not actually involved in its computation. * Per #2583, minor update to Appendix C * Per #2583, rename ECNT line type statistic DSS to IDSS. * Per #2583, fix a couple of typos * Per #2583, more error checking. * Per #2583, remove the ECNT IDSS column since its just 2*pi*IGN, the existing ignorance score, and only provides meaningful information when combined with the other Dawid-Sebastiani statistics that have already been removed. * Per #2583, add Eric's documentation of these new stats to Appendix C. Along the way, update the DOI links in the references based on this APA style guide: https://apastyle.apa.org/style-grammar-guidelines/references/dois-urls#:~:text=Include%20a%20DOI%20for%20all,URL%2C%20include%20only%20the%20DOI. * Per #2583, fix new equations with embedded underscores for PDF by defining both html and pdf formatting options. * Per #2583, update the ign_conv_oerr equation to include a 2 *pi multiplier for consistency with the existing ignorance score. Also, fix the documented equations. * Per #2583, remove log file that was inadvertently added on this branch. * Per #2583, simplify ObsErrorEntry::variance() implementation. For the distribution type of NONE, return a variance of 0.0 rather than bad data, as discussed with @michelleharrold and @JeffBeck-NOAA on 3/8/2024. * Per #2583, updates to ensemble-stat.rst recommended by @michelleharrold and @JeffBeck-NOAA. * Per #2583, implement changes to the IGN_CORR_OERR corrected as directed by @ericgilleland. --------- Co-authored-by: MET Tools Test Account --- data/table_files/met_header_columns_V12.0.txt | 2 +- docs/Users_Guide/appendixC.rst | 53 +++++-- docs/Users_Guide/ensemble-stat.rst | 10 +- docs/Users_Guide/refs.rst | 135 ++++++++++++------ internal/test_unit/hdr/met_12_0.hdr | 2 +- src/basic/vx_util/num_array.cc | 8 +- src/basic/vx_util/stat_column_defs.h | 2 +- src/libcode/vx_gsl_prob/gsl_randist.h | 4 +- src/libcode/vx_stat_out/stat_columns.cc | 8 +- src/libcode/vx_statistics/ens_stats.cc | 18 ++- src/libcode/vx_statistics/ens_stats.h | 4 + src/libcode/vx_statistics/met_stats.cc | 19 +++ src/libcode/vx_statistics/met_stats.h | 2 + src/libcode/vx_statistics/obs_error.cc | 7 + src/libcode/vx_statistics/obs_error.h | 3 + .../vx_statistics/pair_data_ensemble.cc | 117 ++++++++++++--- .../vx_statistics/pair_data_ensemble.h | 90 ++++++------ src/libcode/vx_statistics/pair_data_point.cc | 2 +- .../core/stat_analysis/aggr_stat_line.cc | 27 +++- .../core/stat_analysis/parse_stat_line.cc | 5 + .../core/stat_analysis/parse_stat_line.h | 3 + src/tools/core/wavelet_stat/wavelet_stat.cc | 4 +- 22 files changed, 390 insertions(+), 135 deletions(-) diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index 7ed1e5a187..299e6cb4d6 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -19,7 +19,7 @@ V12.0 : STAT : PJC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : PRC : 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]* PODY_[0-9]* POFD_[0-9]* V12.0 : STAT : PSTD : 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) BASER BASER_NCL BASER_NCU RELIABILITY RESOLUTION UNCERTAINTY ROC_AUC BRIER BRIER_NCL BRIER_NCU BRIERCL BRIERCL_NCL BRIERCL_NCU BSS BSS_SMPL THRESH_[0-9]* V12.0 : STAT : ECLV : 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 VALUE_BASER (N_PTS) CL_[0-9]* VALUE_[0-9]* -V12.0 : STAT : ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS +V12.0 : STAT : ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS IGN_CONV_OERR IGN_CORR_OERR V12.0 : STAT : RPS : 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_PROB RPS_REL RPS_RES RPS_UNC RPS RPSS RPSS_SMPL RPS_COMP V12.0 : STAT : RHIST : 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_RANK) RANK_[0-9]* V12.0 : STAT : PHIST : 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 BIN_SIZE (N_BIN) BIN_[0-9]* diff --git a/docs/Users_Guide/appendixC.rst b/docs/Users_Guide/appendixC.rst index 7c5c618a43..15c3ab5c2d 100644 --- a/docs/Users_Guide/appendixC.rst +++ b/docs/Users_Guide/appendixC.rst @@ -401,7 +401,7 @@ SEEPS scores are expected to lie between 0 and 1, with a perfect forecast having MET Verification Measures for Continuous Variables ================================================== -For continuous variables, many verification measures are based on the forecast error (i.e., **f - o**). However, it also is of interest to investigate characteristics of the forecasts, and the observations, as well as their relationship. These concepts are consistent with the general framework for verification outlined by :ref:`Murphy and Winkler, (1987) `. The statistics produced by MET for continuous forecasts represent this philosophy of verification, which focuses on a variety of aspects of performance rather than a single measure. +For continuous variables, many verification measures are based on the forecast error (i.e., **f - o**). However, it also is of interest to investigate characteristics of the forecasts, and the observations, as well as their relationship. These concepts are consistent with the general framework for verification outlined by :ref:`Murphy and Winkler, 1987 `. The statistics produced by MET for continuous forecasts represent this philosophy of verification, which focuses on a variety of aspects of performance rather than a single measure. The verification measures currently evaluated by the Point-Stat tool are defined and described in the subsections below. In these definitions, **f** represents the forecasts, **o** represents the observation, and **n** is the number of forecast-observation pairs. @@ -894,7 +894,7 @@ Calibration Called "CALIBRATION" in PJC output :numref:`table_PS_format_info_PJC` -Calibration is the conditional probability of an event given each probability forecast category (i.e. each row in the **nx2** contingency table). This set of measures is paired with refinement in the calibration-refinement factorization discussed in :ref:`Wilks, (2011) `. A well-calibrated forecast will have calibration values that are near the forecast probability. For example, a 50% probability of precipitation should ideally have a calibration value of 0.5. If the calibration value is higher, then the probability has been underestimated, and vice versa. +Calibration is the conditional probability of an event given each probability forecast category (i.e. each row in the **nx2** contingency table). This set of measures is paired with refinement in the calibration-refinement factorization discussed in :ref:`Wilks, 2011 `. A well-calibrated forecast will have calibration values that are near the forecast probability. For example, a 50% probability of precipitation should ideally have a calibration value of 0.5. If the calibration value is higher, then the probability has been underestimated, and vice versa. .. math:: \text{Calibration}(i) = \frac{n_{i1}}{n_{1.}} = \text{probability}(o_1|p_i) @@ -903,7 +903,7 @@ Refinement Called "REFINEMENT" in PJC output :numref:`table_PS_format_info_PJC` -The relative frequency associated with each forecast probability, sometimes called the marginal distribution or row probability. This measure ignores the event outcome, and simply provides information about the frequency of forecasts for each probability category. This set of measures is paired with the calibration measures in the calibration-refinement factorization discussed by :ref:`Wilks (2011) `. +The relative frequency associated with each forecast probability, sometimes called the marginal distribution or row probability. This measure ignores the event outcome, and simply provides information about the frequency of forecasts for each probability category. This set of measures is paired with the calibration measures in the calibration-refinement factorization discussed by :ref:`Wilks, 2011 `. .. math:: \text{Refinement}(i) = \frac{n_{i.}}{T} = \text{probability}(p_i) @@ -912,7 +912,7 @@ Likelihood Called "LIKELIHOOD" in PJC output :numref:`table_PS_format_info_PJC` -Likelihood is the conditional probability for each forecast category (row) given an event and a component of the likelihood-base rate factorization; see :ref:`Wilks (2011) ` for details. This set of measures considers the distribution of forecasts for only the cases when events occur. Thus, as the forecast probability increases, so should the likelihood. For example, 10% probability of precipitation forecasts should have a much smaller likelihood value than 90% probability of precipitation forecasts. +Likelihood is the conditional probability for each forecast category (row) given an event and a component of the likelihood-base rate factorization; see :ref:`Wilks, 2011 ` for details. This set of measures considers the distribution of forecasts for only the cases when events occur. Thus, as the forecast probability increases, so should the likelihood. For example, 10% probability of precipitation forecasts should have a much smaller likelihood value than 90% probability of precipitation forecasts. .. math:: \text{Likelihood}(i) = \frac{n_{i1}}{n_{.1}} = \text{probability}(p_i|o_1) @@ -923,7 +923,7 @@ Base Rate Called "BASER" in PJC output :numref:`table_PS_format_info_PJC` -This is the probability of an event for each forecast category :math:`p_i` (row), i.e. the conditional base rate. This set of measures is paired with likelihood in the likelihood-base rate factorization, see :ref:`Wilks (2011) ` for further information. This measure is calculated for each row of the contingency table. Ideally, the event should become more frequent as the probability forecast increases. +This is the probability of an event for each forecast category :math:`p_i` (row), i.e. the conditional base rate. This set of measures is paired with likelihood in the likelihood-base rate factorization, see :ref:`Wilks, 2011 ` for further information. This measure is calculated for each row of the contingency table. Ideally, the event should become more frequent as the probability forecast increases. .. math:: \text{Base Rate}(i) = \frac{n_{i1}}{n_{i.}} = \text{probability}(o_{i1}) @@ -976,18 +976,18 @@ RPS Called "RPS" in RPS output :numref:`table_ES_header_info_es_out_ECNT` -While the above probabilistic verification measures utilize dichotomous observations, the Ranked Probability Score (RPS, :ref:`Epstein, 1969 `, :ref:`Murphy, 1969 `) is the only probabilistic verification measure for discrete multiple-category events available in MET. It is assumed that the categories are ordinal as nominal categorical variables can be collapsed into sequences of binary predictands, which can in turn be evaluated with the above measures for dichotomous variables (:ref:`Wilks, 2011 `). The RPS is the multi-category extension of the Brier score (:ref:`Tödter and Ahrens, 2012`), and is a proper score (:ref:`Mason, 2008`). +While the above probabilistic verification measures utilize dichotomous observations, the Ranked Probability Score (RPS, :ref:`Epstein, 1969 `, :ref:`Murphy, 1969 `) is the only probabilistic verification measure for discrete multiple-category events available in MET. It is assumed that the categories are ordinal as nominal categorical variables can be collapsed into sequences of binary predictands, which can in turn be evaluated with the above measures for dichotomous variables (:ref:`Wilks, 2011 `). The RPS is the multi-category extension of the Brier score (:ref:`Tödter and Ahrens, 2012 `), and is a proper score (:ref:`Mason, 2008 `). Let :math:`\text{J}` be the number of categories, then both the forecast, :math:`\text{f} = (f_1,…,f_J)`, and observation, :math:`\text{o} = (o_1,…,o_J)`, are length-:math:`\text{J}` vectors, where the components of :math:`\text{f}` include the probabilities forecast for each category :math:`\text{1,…,J}` and :math:`\text{o}` contains 1 in the category that is realized and zero everywhere else. The cumulative forecasts, :math:`F_m`, and observations, :math:`O_m`, are defined to be: :math:`F_m = \sum_{j=1}^m (f_j)` and :math:`O_m = \sum_{j=1}^m (o_j), m = 1,…,J`. -To clarify, :math:`F_1 = f_1` is the first component of :math:`F_m`, :math:`F_2 = f_1+f_2`, etc., and :math:`F_J = 1`. Similarly, if :math:`o_j = 1` and :math:`i < j`, then :math:`O_i = 0` and when :math:`i >= j`, :math:`O_i = 1`, and of course, :math:`O_J = 1`. Finally, the RPS is defined to be: +To clarify, :math:`F_1 = f_1` is the first component of :math:`F_m`, :math:`F_2 = f_1+f_2`, etc., and :math:`F_J = 1`. Similarly, if :math:`o_j = 1` and :math:`i < j`, then :math:`O_i = 0` and when :math:`i >= j`, :math:`O_i = 1`, and of course, :math:`O_J = 1`. Finally, the RPS is defined to be: .. math:: \text{RPS} = \sum_{m=1}^J (F_m - O_m)^2 = \sum_{m=1}^J BS_m, -where :math:`BS_m` is the Brier score for the m-th category (:ref:`Tödter and Ahrens, 2012`). Subsequently, the RPS lends itself to a decomposition into reliability, resolution and uncertainty components, noting that each component is aggregated over the different categories; these are written to the columns named "RPS_REL", "RPS_RES" and "RPS_UNC" in RPS output :numref:`table_ES_header_info_es_out_ECNT`. +where :math:`BS_m` is the Brier score for the m-th category (:ref:`Tödter and Ahrens, 2012 `). Subsequently, the RPS lends itself to a decomposition into reliability, resolution and uncertainty components, noting that each component is aggregated over the different categories; these are written to the columns named "RPS_REL", "RPS_RES" and "RPS_UNC" in RPS output :numref:`table_ES_header_info_es_out_ECNT`. CRPS ---- @@ -1066,7 +1066,7 @@ The continuous ranked probability skill score (CRPSS) is similar to the MSESS an .. math:: \text{CRPSS} = 1 - \frac{\text{CRPS}_{fcst}}{ \text{CRPS}_{ref}} -For the normal distribution fit (CRPSS), the reference CRPS is computed using the climatological mean and standard deviation. For the empirical distribution (CRPSS_EMP), the reference CRPS is computed by sampling from the assumed normal climatological distribution defined by the mean and standard deviation. +For the normal distribution fit (CRPSS), the reference CRPS is computed using the climatological mean and standard deviation. For the empirical distribution (CRPSS_EMP), the reference CRPS is computed by sampling from the assumed normal climatological distribution defined by the mean and standard deviation. Bias Ratio ---------- @@ -1105,6 +1105,37 @@ Called "PIT" in ORANK output :numref:`table_ES_header_info_es_out_ORANK` The probability integral transform (PIT) is the analog of the rank histogram for a probability distribution forecast (:ref:`Dawid, 1984 `). Its interpretation is the same as that of the verification rank histogram: Calibrated probabilistic forecasts yield PIT histograms that are flat, or uniform. Under-dispersed (not enough spread in the ensemble) forecasts have U-shaped PIT histograms while over-dispersed forecasts have bell-shaped histograms. In MET, the PIT calculation uses a normal distribution fit to the ensemble forecasts. In many cases, use of other distributions would be better. +Observation Error Logarithmic Scoring Rules +------------------------------------------- + +Called "IGN_CONV_OERR" and "IGN_CORR_OERR" in ECNT output :numref:`table_ES_header_info_es_out_ECNT` + +One approach that is used to take observation error into account in a summary measure is to add error to the forecast by a convolution with the observation model (e.g., :ref:`Anderson, 1996 `; :ref:`Hamill, 2001 `; :ref:`Saetra et. al., 2004 `; :ref:`Bröcker and Smith, 2007 `; :ref:`Candille et al., 2007 `; :ref:`Candille and Talagrand, 2008 `; :ref:`Röpnack et al., 2013 `). Specifically, suppose :math:`y=x+w`, where :math:`y` is the observed value, :math:`x` is the true value, and :math:`w` is the error. Then, if :math:`f` is the density forecast for :math:`x` and :math:`\nu` is the observation model, then the implied density forecast for :math:`y` is given by the convolution: + +.. math:: (f*\nu)(y) = \int\nu(y|x)f(x)dx + +:ref:`Ferro, 2017 ` gives the error-convolved version of the ignorance scoring rule (referred to therein as the error-convolved logarithmic scoring rule), which is proper under the model where :math:`w\sim N(0,c^2)`) when the forecast for :math:`x` is :math:`N(\mu,\sigma^2)` with density function :math:`f`, by + +.. only:: latex + + .. math:: \text{IGN\_CONV\_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi (\sigma^2 + c^2)) + \frac{(y - \mu)^2}{2 (\sigma^2 + c^2)} + +.. only:: html + + .. math:: \text{IGN_CONV_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi (\sigma^2 + c^2)) + \frac{(y - \mu)^2}{2 (\sigma^2 + c^2)} + +Another approach to incorporation of observation uncertainty into a measure is the error-correction approach. The approach merely ensures that the scoring rule, :math:`s`, is unbiased for a scoring rule :math:`s_0` if they have the same expected value. :ref:`Ferro, 2017 ` gives the error-corrected ignorance scoring rule (which is also proposer when :math:`w\sim N(0,c^2)`) as + +.. only:: latex + + .. math:: \text{IGN\_CORR\_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi\sigma^2) + \frac{(y - \mu)^2 - c^2}{2\sigma^2} + +.. only:: html + + .. math:: \text{IGN_CORR_OERR} = s(f,y) = \frac{1}{2}\log(2 \pi\sigma^2) + \frac{(y - \mu)^2 - c^2}{2\sigma^2} + +The expected score for the error-convolved ignorance scoring rule typically differs from the expected score that would be achieved if there were no observation error. The error-corrected score, on the other hand, has the same expectation. + RANK ---- @@ -1160,7 +1191,7 @@ The traditional contingency table statistics computed by the Grid-Stat neighborh All of these measures are defined in :numref:`categorical variables`. -In addition to these standard statistics, the neighborhood analysis provides additional continuous measures, the Fractions Brier Score and the Fractions Skill Score. For reference, the Asymptotic Fractions Skill Score and Uniform Fractions Skill Score are also calculated. These measures are defined here, but are explained in much greater detail in :ref:`Ebert (2008) ` and :ref:`Roberts and Lean (2008) `. :ref:`Roberts and Lean (2008) ` also present an application of the methodology. +In addition to these standard statistics, the neighborhood analysis provides additional continuous measures, the Fractions Brier Score and the Fractions Skill Score. For reference, the Asymptotic Fractions Skill Score and Uniform Fractions Skill Score are also calculated. These measures are defined here, but are explained in much greater detail in :ref:`Ebert, 2008 ` and :ref:`Roberts and Lean, 2008 `. :ref:`Roberts and Lean, 2008 ` also present an application of the methodology. Fractions Brier Score --------------------- @@ -1225,7 +1256,7 @@ A mathematical metric, :math:`m(A,B)\geq 0`, must have the following three prope The first establishes that a perfect score is zero and that the only way to obtain a perfect score is if the two sets are identical according to the metric. The second requirement ensures that the order by which the two sets are evaluated will not change the result. The third property ensures that if *C* is closer to *A* than *B* is to *A*, then :math:`m(A,C) < m(A,B)`. -It has been argued in :ref:`Gilleland (2017) ` that the second property of symmetry is not necessarily an important quality to have for a summary measure for verification purposes because lack of symmetry allows for information about false alarms and misses. +It has been argued in :ref:`Gilleland, 2017 ` that the second property of symmetry is not necessarily an important quality to have for a summary measure for verification purposes because lack of symmetry allows for information about false alarms and misses. The results of the distance map verification approaches that are included in the Grid-Stat tool are summarized using a variety of measures. These measures include Baddeley's :math:`\Delta` Metric, the Hausdorff Distance, the Mean-error Distance, Pratt's Figure of Merit, and Zhu's Measure. Their equations are listed below. diff --git a/docs/Users_Guide/ensemble-stat.rst b/docs/Users_Guide/ensemble-stat.rst index 42443aa315..9a5574a658 100644 --- a/docs/Users_Guide/ensemble-stat.rst +++ b/docs/Users_Guide/ensemble-stat.rst @@ -66,7 +66,9 @@ The climatological distribution is also used for the RPSS. The forecast RPS stat Ensemble Observation Error -------------------------- -In an attempt to ameliorate the effect of observation errors on the verification of forecasts, a random perturbation approach has been implemented. A great deal of user flexibility has been built in, but the methods detailed in :ref:`Candille and Talagrand (2008) `. can be replicated using the appropriate options. The user selects a distribution for the observation error, along with parameters for that distribution. Rescaling and bias correction can also be specified prior to the perturbation. Random draws from the distribution can then be added to either, or both, of the forecast and observed fields, including ensemble members. Details about the effects of the choices on verification statistics should be considered, with many details provided in the literature (*e.g.* :ref:`Candille and Talagrand, 2008 `; :ref:`Saetra et al., 2004 `; :ref:`Santos and Ghelli, 2012 `). Generally, perturbation makes verification statistics better when applied to ensemble members, and worse when applied to the observations themselves. +In an attempt to ameliorate the effect of observation errors on the verification of forecasts, a random perturbation approach has been implemented. A great deal of user flexibility has been built in, but the methods detailed in :ref:`Candille and Talagrand (2008) ` can be replicated using the appropriate options. Additional variations of the ignorance score that include observational uncertainty recommended by :ref:`Ferro, 2017 ` are also provided. + +Observation error information can be defined directly in the Ensemble-Stat configuration file or through a more flexible observation error lookup table. The user selects a distribution for the observation error, along with parameters for that distribution. Rescaling and bias correction can also be specified prior to the perturbation. Random draws from the distribution can then be added to either, or both of the forecast and observed fields, including ensemble members. Details about the effects of the choices on verification statistics should be considered, with many details provided in the literature (*e.g.* :ref:`Candille and Talagrand, 2008 `; :ref:`Saetra et al., 2004 `; :ref:`Santos and Ghelli, 2012 `). Generally, perturbation makes verification statistics better when applied to ensemble members, and worse when applied to the observations themselves. Normal and uniform are common choices for the observation error distribution. The uniform distribution provides the benefit of being bounded on both sides, thus preventing the perturbation from taking on extreme values. Normal is the most common choice for observation error. However, the user should realize that with the very large samples typical in NWP, some large outliers will almost certainly be introduced with the perturbation. For variables that are bounded below by 0, and that may have inconsistent observation errors (e.g. larger errors with larger measurements), a lognormal distribution may be selected. Wind speeds and precipitation measurements are the most common of this type of NWP variable. The lognormal error perturbation prevents measurements of 0 from being perturbed, and applies larger perturbations when measurements are larger. This is often the desired behavior in these cases, but this distribution can also lead to some outliers being introduced in the perturbation step. @@ -647,6 +649,12 @@ The format of the STAT and ASCII output of the Ensemble-Stat tool are described * - 49 - ME_LT_OBS - The Mean Error of the ensemble values less than or equal to their observations + * - 50 + - IGN_CONV_OERR + - Error-convolved logarithmic scoring rule (i.e. ignornance score) from Equation 5 of :ref:`Ferro, 2017 ` + * - 51 + - IGN_CORR_OERR + - Error-corrected logarithmic scoring rule (i.e. ignornance score) from Equation 7 of :ref:`Ferro, 2017 ` .. _table_ES_header_info_es_out_RPS: diff --git a/docs/Users_Guide/refs.rst b/docs/Users_Guide/refs.rst index b4045f90b6..1c328014cb 100644 --- a/docs/Users_Guide/refs.rst +++ b/docs/Users_Guide/refs.rst @@ -14,11 +14,18 @@ References | Ahijevych, D., E. Gilleland, B.G. Brown, and E.E. Ebert, 2009: Application of | spatial verification methods to idealized and NWP-gridded precipitation forecasts. -| *Weather and Forecasting*, 24 (6), 1485 - 1497, doi: 10.1175/2009WAF2222298.1. +| *Weather and Forecasting*, 24 (6), 1485 - 1497. +| doi: https://doi.org/10.1175/2009WAF2222298.1 | -.. _Barker-1991: +.. _Andersen-1996: + +| Anderson JL., 1996: A method for producing and evaluating probabilistic forecasts +| from ensemble model integrations. *J. Clim.* 9: 1518-1530. +| doi: `https://doi.org/10.1175/1520-0442(1996)009<1518:AMFPAE>2.0.CO;2 2.0.CO;2>`_ +| +.. _Barker-1991: | Barker, T. W., 1991: The relationship between spread and forecast error in | extended-range forecasts. *Journal of Climate*, 4, 733-742. @@ -29,14 +36,14 @@ References | Bradley, A.A., S.S. Schwartz, and T. Hashino, 2008: Sampling Uncertainty | and Confidence Intervals for the Brier Score and Brier Skill Score. | *Weather and Forecasting*, 23, 992-1006. -| +| .. _Brill-2009: | Brill, K. F., and F. Mesinger, 2009: Applying a general analytic method | for assessing bias sensitivity to bias-adjusted threat and equitable | threat scores. *Weather and Forecasting*, 24, 1748-1754. -| +| .. _Brown-2007: @@ -49,32 +56,47 @@ References | http://ams.confex.com/ams/pdfpapers/124856.pdf. | +.. _Bröcker-2007: + +| Bröcker J, Smith LA., 2007: Scoring probabilistic forecasts: The importance +| of being proper. *Weather Forecasting*, 22, 382-388. +| doi: https://doi.org/10.1175/WAF966.1 +| + .. _Buizza-1997: | Buizza, R., 1997: Potential forecast skill of ensemble prediction and spread | and skill distributions of the ECMWF ensemble prediction system. *Monthly* -| *Weather Review*,125, 99-119. -| +| *Weather Review*, 125, 99-119. +| .. _Bullock-2016: | Bullock, R., T. Fowler, and B. Brown, 2016: Method for Object-Based | Diagnostic Evaluation. *NCAR Technical Note* NCAR/TN-532+STR, 66 pp. -| +| + +.. _Candille-2007: + +| Candille G, Côté C, Houtekamer PL, Pellerin G, 2007: Verification of an +| ensemble prediction system against observations. *Mon. Weather Rev.* +| 135: 2688-2699. +| doi: https://doi.org/10.1175/MWR3414.1 +| .. _Candille-2008: | Candille, G., and O. Talagrand, 2008: Impact of observational error on the | validation of ensemble prediction systems. *Quarterly Journal of the Royal* | *Meteorological Society* 134: 959-971. -| +| .. _Casati-2004: | Casati, B., G. Ross, and D. Stephenson, 2004: A new intensity-scale approach | for the verification of spatial precipitation forecasts. *Meteorological* | *Applications* 11, 141-154. -| +| .. _Davis-2006: @@ -86,37 +108,45 @@ References | Davis, C.A., B.G. Brown, and R.G. Bullock, 2006b: Object-based verification | of precipitation forecasts, Part II: Application to convective rain systems. | *Monthly Weather Review*, 134, 1785-1795. -| +| .. _Dawid-1984: | Dawid, A.P., 1984: Statistical theory: The prequential approach. *Journal of* | *the Royal Statistical Society* A147, 278-292. -| +| .. _Ebert-2008: | Ebert, E.E., 2008: Fuzzy verification of high-resolution gridded forecasts: -| a review and proposed framework. *Meteorological Applications,* 15, 51-64. -| +| a review and proposed framework. *Meteorological Applications*, 15, 51-64. +| .. _Eckel-2012: | Eckel, F. A., M.S. Allen, M. C. Sittel, 2012: Estimation of Ambiguity in -| Ensemble Forecasts. *Weather Forecasting,* 27, 50-69. -| doi: http://dx.doi.org/10.1175/WAF-D-11-00015.1 +| Ensemble Forecasts. *Weather Forecasting*, 27, 50-69. +| doi: https://doi.org/10.1175/WAF-D-11-00015.1 | .. _Efron-2007: | Efron, B. 2007: Correlation and large-scale significance testing. *Journal* -| of the American Statistical Association,* 102(477), 93-103. +| of the American Statistical Association*, 102(477), 93-103. | .. _Epstein-1969: | Epstein, E. S., 1969: A scoring system for probability forecasts of ranked categories. -| *J. Appl. Meteor.*, 8, 985-987, 10.1175/1520-0450(1969)008<0985:ASSFPF>2.0.CO;2. +| *J. Appl. Meteor.*, 8, 985-987. +| doi: `https://doi.org/10.1175/1520-0450(1969)008<0985:ASSFPF>2.0.CO;2 2.0.CO;2>`_ +| + +.. _Ferro-2017: + +| Ferro C. A. T., 2017: Measuring forecast performance in the presence of observation error. +| *Q. J. R. Meteorol. Soc.*, 143 (708), 2665-2676. +| doi: https://doi.org/10.1002/qj.3115 | .. _Gilleland-2010: @@ -129,29 +159,32 @@ References | Gilleland, E., 2017: A new characterization in the spatial verification | framework for false alarms, misses, and overall patterns. -| *Weather and Forecasting*, 32 (1), 187 - 198, doi: 10.1175/WAF-D-16-0134.1. +| *Weather and Forecasting*, 32 (1), 187 - 198. +| doi: https://doi.org/10.1175/WAF-D-16-0134.1 | .. _Gilleland_PartI-2020: | Gilleland, E., 2020: Bootstrap methods for statistical inference. | Part I: Comparative forecast verification for continuous variables. -| *Journal of Atmospheric and Oceanic Technology*, 37 (11), 2117 - 2134, -| doi: 10.1175/JTECH-D-20-0069.1. +| *Journal of Atmospheric and Oceanic Technology*, 37 (11), 2117 - 2134. +| doi: https://doi.org/10.1175/JTECH-D-20-0069.1 | .. _Gilleland_PartII-2020: | Gilleland, E., 2020: Bootstrap methods for statistical inference. | Part II: Extreme-value analysis. *Journal of Atmospheric and Oceanic* -| *Technology*, 37 (11), 2135 - 2144, doi: 10.1175/JTECH-D-20-0070.1. +| *Technology*, 37 (11), 2135 - 2144. +| doi: https://doi.org/10.1175/JTECH-D-20-0070.1 | .. _Gilleland-2021: | Gilleland, E., 2021: Novel measures for summarizing high-resolution forecast | performance. *Advances in Statistical Climatology, Meteorology and Oceanography*, -| 7 (1), 13 - 34, doi: 10.5194/ascmo-7-13-2021. +| 7 (1), 13 - 34. +| doi: https://doi.org/10.5194/ascmo-7-13-2021 | .. _Gneiting-2004: @@ -161,7 +194,7 @@ References | *Minimum CRPS Estimation*. Technical Report no. 449, Department of | Statistics, University of Washington. Available at | http://www.stat.washington.edu/www/research/reports/ -| +| .. _Haiden-2012: @@ -175,41 +208,41 @@ References | Hamill, T. M., 2001: Interpretation of rank histograms for verifying ensemble | forecasts. *Monthly Weather Review*, 129, 550-560. -| +| .. _Hersbach-2000: | Hersbach, H., 2000: Decomposition of the Continuous Ranked Probability Score | for Ensemble Prediction Systems. *Weather and Forecasting*, 15, 559-570. -| +| .. _Jolliffe-2012: | Jolliffe, I.T., and D.B. Stephenson, 2012: *Forecast verification. A* | *practitioner's guide in atmospheric science.* Wiley and Sons Ltd, 240 pp. -| +| .. _Knaff-2003: | Knaff, J.A., M. DeMaria, C.R. Sampson, and J.M. Gross, 2003: Statistical, | Five-Day Tropical Cyclone Intensity Forecasts Derived from Climatology -| and Persistence. *Weather and Forecasting,* Vol. 18 Issue 2, p. 80-92. -| +| and Persistence. *Weather and Forecasting*, Vol. 18 Issue 2, p. 80-92. +| .. _Mason-2004: | Mason, S. J., 2004: On Using "Climatology" as a Reference Strategy | in the Brier and Ranked Probability Skill Scores. *Monthly Weather Review*, | 132, 1891-1895. -| +| .. _Mason-2008: | Mason, S. J., 2008: Understanding forecast verification statistics. -| *Meteor. Appl.*, 15, 31-40, doi: 10.1002/met.51. +| *Meteor. Appl.*, 15, 31-40. +| doi: https://doi.org/10.1002/met.51 | - .. _Mittermaier-2014: | Mittermaier, M., 2014: A strategy for verifying near-convection-resolving @@ -220,21 +253,20 @@ References | Mood, A. M., F. A. Graybill and D. C. Boes, 1974: *Introduction to the* | *Theory of Statistics*, McGraw-Hill, 299-338. -| +| .. _Murphy-1969: | Murphy, A.H., 1969: On the ranked probability score. *Journal of Applied* | *Meteorology and Climatology*, 8 (6), 988 - 989, -| doi: 10.1175/1520-0450(1969)008<0988:OTPS>2.0.CO;2. +| doi: `https://doi.org/10.1175/1520-0450(1969)008<0988:OTPS>2.0.CO;2 2.0.CO;2>`_ | .. _Murphy-1987: | Murphy, A.H., and R.L. Winkler, 1987: A general framework for forecast | verification. *Monthly Weather Review*, 115, 1330-1338. -| - +| .. _North-2022: @@ -256,7 +288,7 @@ References | Roberts, N.M., and H.W. Lean, 2008: Scale-selective verification of rainfall | accumulations from high-resolution forecasts of convective events. | *Monthly Weather Review*, 136, 78-97. -| +| .. _Rodwell-2010: @@ -273,11 +305,18 @@ References | https://www.ecmwf.int/node/14595 | +.. _Röpnack-2013: + +| Röpnack A, Hense A, Gebhardt C, Majewski D., 2013: Bayesian model verification +| of NWP ensemble forecasts. *Mon. Weather Rev.* 141: 375–387. +| doi: https://doi.org/10.1175/MWR-D-11-00350.1 +| + .. _Saetra-2004: -| Saetra O., H. Hersbach, J-R Bidlot, D. Richardson, 2004: Effects of +| Saetra Ø., H. Hersbach, J-R Bidlot, D. Richardson, 2004: Effects of | observation errors on the statistics for ensemble spread and -| reliability. *Monthly Weather Review* 132: 1487-1501. +| reliability. *Monthly Weather Review*, 132: 1487-1501. | .. _Santos-2012: @@ -285,7 +324,7 @@ References | Santos C. and A. Ghelli, 2012: Observational probability method to assess | ensemble precipitation forecasts. *Quarterly Journal of the Royal* | *Meteorological Society* 138: 209-221. -| +| .. _Schwartz-2017: @@ -298,20 +337,21 @@ References | Stephenson, D.B., 2000: Use of the "Odds Ratio" for diagnosing | forecast skill. *Weather and Forecasting*, 15, 221-232. -| +| .. _Stephenson-2008: | Stephenson, D.B., B. Casati, C.A.T. Ferro, and C.A. Wilson, 2008: The extreme | dependency score: A non-vanishing measure for forecasts of rare events. | *Meteorological Applications* 15, 41-50. -| +| -.. _Todter-2012: +.. _Tödter-2012: | Tödter, J. and B. Ahrens, 2012: Generalization of the Ignorance Score: | Continuous ranked version and its decomposition. *Monthly Weather Review*, -| 140 (6), 2005 - 2017, doi: 10.1175/MWR-D-11-00266.1. +| 140 (6), 2005 - 2017. +| doi: https://doi.org/10.1175/MWR-D-11-00266.1 | .. _Weniger-2016: @@ -319,17 +359,18 @@ References | Weniger, M., F. Kapp, and P. Friederichs, 2016: Spatial Verification Using | Wavelet Transforms: A Review. *Quarterly Journal of the Royal* | *Meteorological Society*, 143, 120-136. -| +| .. _Wilks-2010: | Wilks, D.S. 2010: Sampling distributions of the Brier score and Brier skill | score under serial dependence. *Quarterly Journal of the Royal* -| *Meteorological Society*, 136, 2109-2118. doi:10.1002/qj.709 -| +| *Meteorological Society*, 136, 2109-2118. +| doi: https://doi.org/10.1002/qj.709 +| .. _Wilks-2011: | Wilks, D., 2011: *Statistical methods in the atmospheric sciences.* | Elsevier, San Diego. -| +| diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index d6bf9fb0b9..a1113d5102 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -19,7 +19,7 @@ PJC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L PRC : 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_ PSTD : 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 BASER BASER_NCL BASER_NCU RELIABILITY RESOLUTION UNCERTAINTY ROC_AUC BRIER BRIER_NCL BRIER_NCU BRIERCL BRIERCL_NCL BRIERCL_NCU BSS BSS_SMPL _VAR_ ECLV : 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 BASE N_PTS _VAR_ -ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS +ECNT : 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_ENS CRPS CRPSS IGN ME RMSE SPREAD ME_OERR RMSE_OERR SPREAD_OERR SPREAD_PLUS_OERR CRPSCL CRPS_EMP CRPSCL_EMP CRPSS_EMP CRPS_EMP_FAIR SPREAD_MD MAE MAE_OERR BIAS_RATIO N_GE_OBS ME_GE_OBS N_LT_OBS ME_LT_OBS IGN_CONV_OERR IGN_CORR_OERR RPS : 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_PROB RPS_REL RPS_RES RPS_UNC RPS RPSS RPSS_SMPL RPS_COMP RHIST : 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 CRPS IGN N_RANK CRPSS SPREAD _VAR_ PHIST : 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 BIN_SIZE N_BIN _VAR_ diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index 144736cc88..baaac11c6a 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -1075,7 +1075,9 @@ NumArray NumArray::subset(const NumArray &keep) const // Check bounds if ( keep.n_elements() != n_elements() ) { mlog << Error << "\nNumArray::subset(const NumArray &) -> " - << "the number of elements do not match\n\n"; + << "the number of elements do not match (" + << keep.n_elements() << " keep flags != " + << n_elements() << " array elements)\n\n"; exit ( 1 ); } @@ -1156,7 +1158,9 @@ double NumArray::wmean(const NumArray &wgt) const if ( wgt.n_elements() != n_elements() ) { mlog << Error << "\nNumArray::wmean(const NumArray &) -> " - << "the number of elements do not match\n\n"; + << "the number of elements do not match (" + << wgt.n_elements() << " weights != " + << n_elements() << " array elements)\n\n"; exit ( 1 ); } diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index 909441b5ba..826d5101c9 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -276,7 +276,7 @@ static const char * ecnt_columns [] = { "CRPSS_EMP", "CRPS_EMP_FAIR", "SPREAD_MD", "MAE", "MAE_OERR", "BIAS_RATIO", "N_GE_OBS", "ME_GE_OBS", "N_LT_OBS", - "ME_LT_OBS" + "ME_LT_OBS", "IGN_CONV_OERR", "IGN_CORR_OERR" }; static const char * rps_columns [] = { diff --git a/src/libcode/vx_gsl_prob/gsl_randist.h b/src/libcode/vx_gsl_prob/gsl_randist.h index d562bfe733..e66c312230 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.h +++ b/src/libcode/vx_gsl_prob/gsl_randist.h @@ -58,9 +58,9 @@ extern void ran_sample(const gsl_rng *r, double *, int, double *, int); extern void ran_sample(const gsl_rng *r, NumArray &, NumArray &, int); extern double ran_draw(const gsl_rng *r, DistType, - double p1, double p2 = bad_data_int); + double p1, double p2 = bad_data_double); extern double dist_var(DistType, - double p1, double p2 = bad_data_int); + double p1, double p2 = bad_data_double); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index c4880f83eb..55aded1e28 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -4275,7 +4275,7 @@ void write_ecnt_cols(const ECNTInfo &ecnt_info, // CRPSS_EMP CRPS_EMP_FAIR, SPREAD_MD, // MAE, MAE_OERR, BIAS_RATIO, // N_GE_OBS, ME_GE_OBS, N_LT_OBS, - // ME_LT_OBS + // ME_LT_OBS, IGN_CONV_OERR, IGN_CORR_OERR // at.set_entry(r, c+0, // Total Number of Pairs ecnt_info.n_pair); @@ -4352,6 +4352,12 @@ void write_ecnt_cols(const ECNTInfo &ecnt_info, at.set_entry(r, c+24, // ME of ensemble values < observations ecnt_info.me_lt_obs); + at.set_entry(r, c+25, // Ignorance Score, observation error convolved + ecnt_info.ign_conv_oerr); + + at.set_entry(r, c+26, // Ignorance Score, observation error corrected + ecnt_info.ign_corr_oerr); + return; } diff --git a/src/libcode/vx_statistics/ens_stats.cc b/src/libcode/vx_statistics/ens_stats.cc index 4ed6f821ca..782832b79f 100644 --- a/src/libcode/vx_statistics/ens_stats.cc +++ b/src/libcode/vx_statistics/ens_stats.cc @@ -181,13 +181,15 @@ void ECNTInfo::clear() { crps_emp_fair = spread_md = bad_data_double; crps_gaus = crpscl_gaus = crpss_gaus = bad_data_double; ign = bad_data_double; - me = mae = rmse = spread = bad_data_double; - me_oerr = mae_oerr = rmse_oerr = spread_oerr = bad_data_double; + me = mae = rmse = spread = bad_data_double; + me_oerr = mae_oerr = rmse_oerr = spread_oerr = bad_data_double; spread_plus_oerr = bad_data_double; - n_ge_obs = n_lt_obs = 0; - me_ge_obs = me_lt_obs = bias_ratio = bad_data_double; - + ign_conv_oerr = ign_corr_oerr = bad_data_double; + + n_ge_obs = n_lt_obs = 0; + me_ge_obs = me_lt_obs = bias_ratio = bad_data_double; + return; } @@ -221,6 +223,8 @@ void ECNTInfo::assign(const ECNTInfo &c) { rmse_oerr = c.rmse_oerr; spread_oerr = c.spread_oerr; spread_plus_oerr = c.spread_plus_oerr; + ign_conv_oerr = c.ign_conv_oerr; + ign_corr_oerr = c.ign_corr_oerr; n_ge_obs = c.n_ge_obs; n_lt_obs = c.n_lt_obs; @@ -361,6 +365,10 @@ void ECNTInfo::set(const PairDataEnsemble &pd) { // Compute the square root of the average variance plus oerr spread_plus_oerr = square_root(pd.var_plus_oerr_na.wmean(pd.wgt_na)); + // Compute log scores with observational uncertainty + ign_conv_oerr = pd.ign_conv_oerr_na.wmean(pd.wgt_na); + ign_corr_oerr = pd.ign_corr_oerr_na.wmean(pd.wgt_na); + // Compute bias ratio terms n_ge_obs = nint(pd.n_ge_obs_na.sum()); me_ge_obs = pd.me_ge_obs_na.wmean(pd.n_ge_obs_na); diff --git a/src/libcode/vx_statistics/ens_stats.h b/src/libcode/vx_statistics/ens_stats.h index 17e864fb5e..69eca9f4e1 100644 --- a/src/libcode/vx_statistics/ens_stats.h +++ b/src/libcode/vx_statistics/ens_stats.h @@ -82,6 +82,10 @@ class ECNTInfo { double me_oerr, mae_oerr, rmse_oerr, spread_oerr; double spread_plus_oerr; + // Log scores that incorporate observational uncertainty, + // as advised in Ferro (2017) + double ign_conv_oerr, ign_corr_oerr; + // Bias ratio information int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index a290afcb30..8487d751b5 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3456,6 +3456,25 @@ int min_int(const int *v_int, int n) { return v_min; } +//////////////////////////////////////////////////////////////////////// +// +// Compute mean from a sum +// +//////////////////////////////////////////////////////////////////////// + +double compute_mean(double sum, int n) { + double v; + + if(is_bad_data(sum) || is_bad_data(n) || n == 0) { + v = bad_data_double; + } + else { + v = sum / n; + } + + return(v); +} + //////////////////////////////////////////////////////////////////////// // // Compute variance from sums of squares diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index f0715d45b3..1d5def71a7 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -726,6 +726,8 @@ extern int min_int(const int *, int); // //////////////////////////////////////////////////////////////////////// +extern double compute_mean(double, int); + extern double compute_variance(double, double, int); extern double compute_stdev(double, double, int); diff --git a/src/libcode/vx_statistics/obs_error.cc b/src/libcode/vx_statistics/obs_error.cc index eae4bed423..5b753346a3 100644 --- a/src/libcode/vx_statistics/obs_error.cc +++ b/src/libcode/vx_statistics/obs_error.cc @@ -5,6 +5,7 @@ // ** Research Applications Lab (RAL) // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + //////////////////////////////////////////////////////////////////////// #include @@ -184,6 +185,12 @@ void ObsErrorEntry::dump(ostream & out, int depth) const { //////////////////////////////////////////////////////////////////////// +double ObsErrorEntry::variance() const { + return dist_var(dist_type, dist_parm[0], dist_parm[1]); +} + +//////////////////////////////////////////////////////////////////////// + bool ObsErrorEntry::parse_line(const DataLine &dl) { // Initialize diff --git a/src/libcode/vx_statistics/obs_error.h b/src/libcode/vx_statistics/obs_error.h index 732c4c3ced..11cce141dc 100644 --- a/src/libcode/vx_statistics/obs_error.h +++ b/src/libcode/vx_statistics/obs_error.h @@ -5,6 +5,7 @@ // ** Research Applications Lab (RAL) // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + //////////////////////////////////////////////////////////////////////// #ifndef __OBS_ERROR_H__ @@ -68,6 +69,8 @@ class ObsErrorEntry { // get stuff // + double variance() const; + // // do stuff // diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index cc25f891d3..c2178687ce 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -108,6 +108,9 @@ void PairDataEnsemble::clear() { ign_na.clear(); pit_na.clear(); + ign_conv_oerr_na.clear(); + ign_corr_oerr_na.clear(); + n_ge_obs_na.clear(); me_ge_obs_na.clear(); n_lt_obs_na.clear(); @@ -179,6 +182,8 @@ void PairDataEnsemble::extend(int n) { crpscl_gaus_na.extend (n); ign_na.extend (n); pit_na.extend (n); + ign_conv_oerr_na.extend (n); + ign_corr_oerr_na.extend (n); n_ge_obs_na.extend (n); me_ge_obs_na.extend (n); n_lt_obs_na.extend (n); @@ -235,15 +240,20 @@ void PairDataEnsemble::assign(const PairDataEnsemble &pd) { // PairDataEnsemble v_na = pd.v_na; r_na = pd.r_na; + crps_emp_na = pd.crps_emp_na; crps_emp_fair_na = pd.crps_emp_fair_na; spread_md_na = pd.spread_md_na; crpscl_emp_na = pd.crpscl_emp_na; crps_gaus_na = pd.crps_gaus_na; crpscl_gaus_na = pd.crpscl_gaus_na; + ign_na = pd.ign_na; pit_na = pd.pit_na; + ign_conv_oerr_na = pd.ign_conv_oerr_na; + ign_corr_oerr_na = pd.ign_corr_oerr_na; + n_ge_obs_na = pd.n_ge_obs_na; me_ge_obs_na = pd.me_ge_obs_na; n_lt_obs_na = pd.n_lt_obs_na; @@ -449,6 +459,8 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { crpscl_gaus_na.add(bad_data_double); ign_na.add(bad_data_double); pit_na.add(bad_data_double); + ign_conv_oerr_na.add(bad_data_double); + ign_corr_oerr_na.add(bad_data_double); n_ge_obs_na.add(bad_data_double); me_ge_obs_na.add(bad_data_double); n_lt_obs_na.add(bad_data_double); @@ -461,22 +473,41 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { var_unperturbed = compute_variance(esum_na[i], esumsq_na[i], esumn_na[i]); var_na.add(var_unperturbed); - // Process the observation error information. + // Process the observation error information ObsErrorEntry * e = (has_obs_error() ? obs_error_entry[i] : 0); if(e) { + // Get observation error variance + double oerr_var = e->variance(); + + // Compute the observation error log scores + double v_conv, v_corr; + compute_obs_error_log_scores( + compute_mean(esum_na[i], esumn_na[i]), + compute_stdev(esum_na[i], esumsq_na[i], esumn_na[i]), + o_na[i], oerr_var, + v_conv, v_corr); + ign_conv_oerr_na.add(v_conv); + ign_corr_oerr_na.add(v_corr); + // Compute perturbed ensemble mean and variance // Exclude the control member from the variance mn_oerr_na.add(cur_ens.mean()); var_oerr_na.add(cur_ens.variance(ctrl_index)); - // Compute the variance plus observation error variance. - var_plus_oerr_na.add(var_unperturbed + - dist_var(e->dist_type, - e->dist_parm[0], e->dist_parm[1])); + // Compute the variance plus observation error variance + if(is_bad_data(var_unperturbed) || + is_bad_data(oerr_var)) { + var_plus_oerr_na.add(bad_data_double); + } + else { + var_plus_oerr_na.add(var_unperturbed + oerr_var); + } } - // If no observation error specified, store bad data values. + // If no observation error specified, store bad data values else { + ign_conv_oerr_na.add(bad_data_double); + ign_corr_oerr_na.add(bad_data_double); mn_oerr_na.add(bad_data_double); var_oerr_na.add(bad_data_double); var_plus_oerr_na.add(bad_data_double); @@ -506,8 +537,8 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { derive_climo_vals(cdf_info_ptr, cmn_na[i], csd_na[i], cur_clm); // Store empirical CRPS stats - // - // For crps_emp use temporary, local variable so we can use it for the crps_emp_fair calculation + // For crps_emp use temporary, local variable so we can use it + // for the crps_emp_fair calculation double crps_emp = compute_crps_emp(o_na[i], cur_ens); crps_emp_na.add(crps_emp); crps_emp_fair_na.add(crps_emp - cur_ens.wmean_abs_diff()); @@ -528,9 +559,10 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { // Compute the Bias Ratio terms int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - compute_bias_ratio_terms(o_na[i], cur_ens, - n_ge_obs, me_ge_obs, - n_lt_obs, me_lt_obs); + compute_bias_ratio_terms( + o_na[i], cur_ens, + n_ge_obs, me_ge_obs, + n_lt_obs, me_lt_obs); // Store the Bias Ratio terms n_ge_obs_na.add(n_ge_obs); @@ -864,8 +896,11 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o // // Include in subset: // wgt_na, o_na, cmn_na, csd_na, v_na, r_na, - // crps_emp_na, crps_emp_fair_na, spread_md_na, crpscl_emp_na, crps_gaus_na, crpscl_gaus_na, - // ign_na, pit_na, n_gt_obs_na, me_gt_obs_na, n_lt_obs_na, me_lt_obs_na, + // crps_emp_na, crps_emp_fair_na, spread_md_na, + // crpscl_emp_na, crps_gaus_na, crpscl_gaus_na, + // ign_na, pit_na, + // ign_conv_oerr, ign_corr_oerr, + // n_gt_obs_na, me_gt_obs_na, n_lt_obs_na, me_lt_obs_na, // var_na, var_oerr_na, var_plus_oerr_na, // mn_na, mn_oerr_na, e_na // @@ -888,6 +923,8 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o pd.crpscl_gaus_na.add(crpscl_gaus_na[i]); pd.ign_na.add(ign_na[i]); pd.pit_na.add(pit_na[i]); + pd.ign_conv_oerr_na.add(ign_conv_oerr_na[i]); + pd.ign_corr_oerr_na.add(ign_corr_oerr_na[i]); pd.n_ge_obs_na.add(n_ge_obs_na[i]); pd.me_ge_obs_na.add(me_ge_obs_na[i]); pd.n_lt_obs_na.add(n_lt_obs_na[i]); @@ -1498,7 +1535,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, y < 0 || y >= gr.ny()) return; // For pressure levels, check if the observation pressure level - // falls in the requsted range. + // falls in the requested range. if(obs_info_grib->level().type() == LevelType_Pres) { if(obs_lvl < obs_info_grib->level().lower() || @@ -1593,7 +1630,8 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, } } - // Apply observation error logic bias correction, if requested + // Apply observation error additive and multiplicative + // bias correction, if requested if(obs_error_info->flag) { obs_v = add_obs_error_bc(obs_error_info->rng_ptr, FieldType_Obs, oerr_ptr, obs_v); @@ -2111,5 +2149,52 @@ double compute_bias_ratio(double me_ge_obs, double me_lt_obs) { return v; } - + +//////////////////////////////////////////////////////////////////////// + +void compute_obs_error_log_scores(double emn, double esd, + double obs, double oerr_var, + double &v_conv, double &v_corr) { + + const char *method_name = "compute_obs_error_log_scores() -> "; + + // Check for bad input data + if(is_bad_data(emn) || + is_bad_data(esd) || + is_bad_data(obs) || + is_bad_data(oerr_var)) { + v_conv = v_corr = bad_data_double; + } + else { + double sigma2 = esd * esd; + double ov2 = oerr_var * oerr_var; + + // Error-convolved logarithmic scoring rule in + // Ferro (2017, Eq 5) doi:10.1002/qj.3115 + // Scale by 2.0 * pi for consistency with ignorance score + v_conv = 0.5 * log(2.0 * pi * (sigma2 + ov2)) + + ((obs - emn) * (obs - emn)) / + (2.0 * (sigma2 + ov2)); + + // Error-corrected logarithmic scoring rule in + // Ferro (2017, Eq 7) doi:10.1002/qj.3115 + // Scale by 2.0 * pi for consistency with ignorance score + v_corr = 0.5 * log(2.0 * pi * sigma2) + + ((obs - emn) * (obs - emn) - ov2) / + (2.0 * sigma2); + } + + if(mlog.verbosity_level() >= 10) { + mlog << Debug(10) << method_name + << "inputs (emn = " << emn + << ", esd = " << esd + << ", obs = " << obs + << ", oerr_var = " << oerr_var + << ") and outputs (ign_oerr_conv = " << v_conv + << ", ign_oerr_corr = " << v_corr << ")\n"; + } + + return; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_ensemble.h b/src/libcode/vx_statistics/pair_data_ensemble.h index e6014b59fb..9be2eec3c8 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.h +++ b/src/libcode/vx_statistics/pair_data_ensemble.h @@ -6,6 +6,8 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +//////////////////////////////////////////////////////////////////////// + #ifndef __PAIR_DATA_ENSEMBLE_H__ #define __PAIR_DATA_ENSEMBLE_H__ @@ -74,64 +76,67 @@ class PairDataEnsemble : public PairBase { bool obs_error_flag; // Ensemble, valid count, and rank values - NumArray *e_na; // Ensemble values [n_ens][n_obs] - NumArray v_na; // Number of valid ensemble values [n_obs] - NumArray r_na; // Observation ranks [n_obs] + NumArray *e_na; // Ensemble values [n_ens][n_obs] + NumArray v_na; // Number of valid ensemble values [n_obs] + NumArray r_na; // Observation ranks [n_obs] + + NumArray crps_emp_na; // Empirical Continuous Ranked Probability Score [n_obs] + NumArray crps_emp_fair_na; // Fair Empirical Continuous Ranked Probability Score [n_obs] + NumArray spread_md_na; // Mean absolute difference of ensemble members [n_obs] + NumArray crpscl_emp_na; // Empirical climatological CRPS [n_obs] - NumArray crps_emp_na; // Empirical Continuous Ranked Probability Score [n_obs] - NumArray crps_emp_fair_na; // Fair Empirical Continuous Ranked Probability Score [n_obs] - NumArray spread_md_na; // Mean absolute difference of ensemble members [n_obs] - NumArray crpscl_emp_na; // Empirical climatological CRPS [n_obs] + NumArray crps_gaus_na; // Gaussian CRPS [n_obs] + NumArray crpscl_gaus_na; // Gaussian climatological CRPS [n_obs] - NumArray crps_gaus_na; // Gaussian CRPS [n_obs] - NumArray crpscl_gaus_na; // Gaussian climatological CRPS [n_obs] + NumArray ign_na; // Ignorance Score [n_obs] + NumArray pit_na; // Probability Integral Transform [n_obs] - NumArray ign_na; // Ignorance Score [n_obs] - NumArray pit_na; // Probability Integral Transform [n_obs] + NumArray ign_conv_oerr_na; // Error convolved log score [n_obs] + NumArray ign_corr_oerr_na; // Error corrected log score [n_obs] - NumArray n_ge_obs_na; // Number of ensemble memebers >= obs [n_obs] - NumArray me_ge_obs_na; // Mean error of ensemble members >= obs [n_obs] - NumArray n_lt_obs_na; // Number of ensemble members < obs [n_obs] - NumArray me_lt_obs_na; // Mean error of ensemble members < obs [n_obs] + NumArray n_ge_obs_na; // Number of ensemble memebers >= obs [n_obs] + NumArray me_ge_obs_na; // Mean error of ensemble members >= obs [n_obs] + NumArray n_lt_obs_na; // Number of ensemble members < obs [n_obs] + NumArray me_lt_obs_na; // Mean error of ensemble members < obs [n_obs] - int n_ens; // Number of ensemble members - int n_pair; // Number of valid pairs, n_obs - sum(skip_ba) - int ctrl_index; // Index of the control member - bool skip_const; // Skip cases where the observation and - // all ensemble members are constant - BoolArray skip_ba; // Flag for each observation [n_obs] + int n_ens; // Number of ensemble members + int n_pair; // Number of valid pairs, n_obs - sum(skip_ba) + int ctrl_index; // Index of the control member + bool skip_const; // Skip cases where the observation and + // all ensemble members are constant + BoolArray skip_ba; // Flag for each observation [n_obs] - NumArray rhist_na; // Ranked Histogram [n_ens+1] - NumArray relp_na; // Relative Position Histogram [n_ens] + NumArray rhist_na; // Ranked Histogram [n_ens+1] + NumArray relp_na; // Relative Position Histogram [n_ens] - double phist_bin_size; // Ensemble PIT histogram bin width - NumArray phist_na; // PIT Histogram [n_phist_bin] + double phist_bin_size; // Ensemble PIT histogram bin width + NumArray phist_na; // PIT Histogram [n_phist_bin] NumArray var_na; // Variance of unperturbed members [n_obs] NumArray var_oerr_na; // Variance of perturbed members [n_obs] NumArray var_plus_oerr_na; // Unperturbed variance plus observation error variance [n_obs] - NumArray esum_na; // Sum of unperturbed ensemble values [n_obs] - NumArray esumsq_na; // Sum of unperturbed ensemble squared values [n_obs] - NumArray esumn_na; // Count of ensemble values [n_obs] + NumArray esum_na; // Sum of unperturbed ensemble values [n_obs] + NumArray esumsq_na; // Sum of unperturbed ensemble squared values [n_obs] + NumArray esumn_na; // Count of ensemble values [n_obs] - NumArray mn_na; // Ensemble mean value [n_obs] - NumArray mn_oerr_na; // Mean of perturbed members [n_obs] + NumArray mn_na; // Ensemble mean value [n_obs] + NumArray mn_oerr_na; // Mean of perturbed members [n_obs] - double ssvar_bin_size; // Variance bin size for spread/skill - SSVARInfo *ssvar_bins; // Ensemble spread/skill bin information [n_ssvar_bin] + double ssvar_bin_size; // Variance bin size for spread/skill + SSVARInfo *ssvar_bins; // Ensemble spread/skill bin information [n_ssvar_bin] - double crpss_emp; // Empirical CRPS skill score - double crpss_gaus; // Guassian CRPS skill score + double crpss_emp; // Empirical CRPS skill score + double crpss_gaus; // Guassian CRPS skill score - double me; // ME for ensemble mean - double mae; // MAE for ensemble mean - double rmse; // RMSE for ensemble mean - double me_oerr; // ME for mean of perturbed members - double mae_oerr; // MAE for mean of perturbed members - double rmse_oerr; // RMSE for mean of perturbed members + double me; // ME for ensemble mean + double mae; // MAE for ensemble mean + double rmse; // RMSE for ensemble mean + double me_oerr; // ME for mean of perturbed members + double mae_oerr; // MAE for mean of perturbed members + double rmse_oerr; // RMSE for mean of perturbed members - double bias_ratio; // Bias ratio + double bias_ratio; // Bias ratio ////////////////////////////////////////////////////////////////// @@ -323,6 +328,9 @@ extern double compute_ens_pit(double, double, double); extern void compute_bias_ratio_terms(double, const NumArray &, int &, double &, int &, double &); extern double compute_bias_ratio(double, double); +extern void compute_obs_error_log_scores( + double, double, double, double, + double &, double &); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index cd3b080bc6..2b19b94391 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -1119,7 +1119,7 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, } // For pressure levels, check if the observation pressure level - // falls in the requsted range. + // falls in the requested range. if(obs_info->level().type() == LevelType_Pres) { if(obs_lvl < obs_info->level().lower() || diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 49506e1402..3ca4cfcaff 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -39,6 +39,8 @@ // line types. // 018 02/13/24 Halley Gotway MET #2395 Add wind direction stats // to VL1L2, VAL1L2, and VCNT. +// 019 02/21/24 Halley Gotway MET #2583 Add observation error +// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -2656,6 +2658,8 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, m[key].ens_pd.crps_gaus_na.add(cur.crps_gaus); m[key].ens_pd.crpscl_gaus_na.add(cur.crpscl_gaus); m[key].ens_pd.ign_na.add(cur.ign); + m[key].ens_pd.ign_conv_oerr_na.add(cur.ign_conv_oerr); + m[key].ens_pd.ign_corr_oerr_na.add(cur.ign_corr_oerr); m[key].ens_pd.n_ge_obs_na.add(cur.n_ge_obs); m[key].ens_pd.me_ge_obs_na.add(cur.me_ge_obs); m[key].ens_pd.n_lt_obs_na.add(cur.n_lt_obs); @@ -3229,17 +3233,34 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, m[key].ens_pd.ign_na.add(compute_ens_ign(cur.obs, cur.ens_mean, cur.spread)); m[key].ens_pd.pit_na.add(compute_ens_pit(cur.obs, cur.ens_mean, cur.spread)); + // Back out the observation error variance + double oerr_var = bad_data_double; + if(!is_bad_data(cur.spread_plus_oerr) && + !is_bad_data(cur.spread)) { + oerr_var = square(cur.spread_plus_oerr) - + square(cur.spread); + } + // Store BIAS_RATIO terms int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; - compute_bias_ratio_terms(cur.obs, cur.ens_na, - n_ge_obs, me_ge_obs, - n_lt_obs, me_lt_obs); + compute_bias_ratio_terms( + cur.obs, cur.ens_na, + n_ge_obs, me_ge_obs, + n_lt_obs, me_lt_obs); m[key].ens_pd.n_ge_obs_na.add(n_ge_obs); m[key].ens_pd.me_ge_obs_na.add(me_ge_obs); m[key].ens_pd.n_lt_obs_na.add(n_lt_obs); m[key].ens_pd.me_lt_obs_na.add(me_lt_obs); + // Compute observation error log scores + double v_conv, v_corr; + compute_obs_error_log_scores( + cur.ens_mean, cur.spread, cur.obs, oerr_var, + v_conv, v_corr); + m[key].ens_pd.ign_conv_oerr_na.add(v_conv); + m[key].ens_pd.ign_corr_oerr_na.add(v_corr); + // // Increment the RHIST counts // diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index b6ec116759..ebdc9d9a0a 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -33,6 +33,8 @@ // line types. // 013 02/13/24 Halley Gotway MET #2395 Add wind direction stats // to VL1L2, VAL1L2, and VCNT. +// 014 02/21/24 Halley Gotway MET #2583 Add observation error +// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -397,6 +399,9 @@ void parse_ecnt_line(STATLine &l, ECNTData &e_data) { e_data.n_lt_obs = atoi(l.get_item("N_LT_OBS")); e_data.me_lt_obs = atof(l.get_item("ME_LT_OBS")); + e_data.ign_conv_oerr = atof(l.get_item("IGN_CONV_OERR")); + e_data.ign_corr_oerr = atof(l.get_item("IGN_CORR_OERR")); + return; } diff --git a/src/tools/core/stat_analysis/parse_stat_line.h b/src/tools/core/stat_analysis/parse_stat_line.h index 529fdb2df9..c890b45ff7 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.h +++ b/src/tools/core/stat_analysis/parse_stat_line.h @@ -28,6 +28,8 @@ // 011 09/28/22 Prestopnik MET #2227 Remove namespace std // 012 11/10/22 Halley Gotway MET #2339 Add SEEPS and SEEPS_MPR // line types. +// 013 02/21/24 Halley Gotway MET #2583 Add observation error +// ECNT statistics. // //////////////////////////////////////////////////////////////////////// @@ -72,6 +74,7 @@ struct ECNTData { double bias_ratio; int n_ge_obs, n_lt_obs; double me_ge_obs, me_lt_obs; + double ign_conv_oerr, ign_corr_oerr; }; // Ranked Histogram (RHIST) data structure diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index 99b0f762ef..827662caf8 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -39,7 +39,7 @@ // 014 07/09/21 Linden MET #1746 Skip thresholding. // 015 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 016 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files -// 017 01/29/24 Halley Gotway MET #2801 Configure time difference warnings +// 017 01/29/24 Halley Gotway MET #2801 Configure time difference warnings // //////////////////////////////////////////////////////////////////////// @@ -425,7 +425,7 @@ void process_scores() { mlog << Debug(2) << "Observation field: "; fill_bad_data(obs_dp_fill, obs_fill); - // Pad the fields out to the nearest power of two if requsted + // Pad the fields out to the nearest power of two if requested if(conf_info.grid_decomp_flag == GridDecompType_Pad) { mlog << Debug(2) << "Padding the fields out to the nearest integer " << "power of two.\n"; From f11318182ab81c3eccc3a781fc6dca6ccccfb100 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 14 Mar 2024 14:11:15 -0600 Subject: [PATCH 031/114] Update the pull request template to include a question about expected impacts to existing METplus Use Cases. --- .github/pull_request_template.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6f7f5e04c4..d3a97c7a05 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -16,9 +16,12 @@ If **yes**, please describe:
- [ ] Do these changes include sufficient testing updates? **[Yes or No]** -- [ ] Will this PR result in changes to the test suite? **[Yes or No]**
+- [ ] Will this PR result in changes to the MET test suite? **[Yes or No]**
If **yes**, describe the new output and/or changes to the existing output:
+- [ ] Will this PR result in changes to existing METplus Use Cases? **[Yes or No]**
+If **yes**, create a new **Update Truth** [METplus issue](https://github.com/dtcenter/METplus/issues/new/choose) to describe them. + - [ ] Please complete this pull request review by **[Fill in date]**.
## Pull Request Checklist ## From be3ce26753de9d6c7aa32b2bed0dc111d9836269 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 19 Mar 2024 18:20:42 +0000 Subject: [PATCH 032/114] #2830 Changed enum Builtin to enum class --- src/basic/vx_config/builtin.cc | 64 ++++++++++++++--------------- src/basic/vx_config/builtin.h | 68 +++++++++++++++---------------- src/basic/vx_config/calculator.cc | 4 +- 3 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/basic/vx_config/builtin.cc b/src/basic/vx_config/builtin.cc index ed54d132b0..966db34858 100644 --- a/src/basic/vx_config/builtin.cc +++ b/src/basic/vx_config/builtin.cc @@ -75,54 +75,54 @@ static double my_C_to_F (double); const BuiltinInfo binfo[] = { - { "sin", 1, builtin_sin, nullptr, nullptr, sin, nullptr }, - { "cos", 1, builtin_cos, nullptr, nullptr, cos, nullptr }, - { "tan", 1, builtin_tan, nullptr, nullptr, tan, nullptr }, + { "sin", 1, Builtin::sin, nullptr, nullptr, sin, nullptr }, + { "cos", 1, Builtin::cos, nullptr, nullptr, cos, nullptr }, + { "tan", 1, Builtin::tan, nullptr, nullptr, tan, nullptr }, - { "sind", 1, builtin_sind, nullptr, nullptr, sin_deg, nullptr }, - { "cosd", 1, builtin_cosd, nullptr, nullptr, cos_deg, nullptr }, - { "tand", 1, builtin_tand, nullptr, nullptr, tan_deg, nullptr }, + { "sind", 1, Builtin::sind, nullptr, nullptr, sin_deg, nullptr }, + { "cosd", 1, Builtin::cosd, nullptr, nullptr, cos_deg, nullptr }, + { "tand", 1, Builtin::tand, nullptr, nullptr, tan_deg, nullptr }, - { "asin", 1, builtin_asin, nullptr, nullptr, asin, nullptr }, - { "acos", 1, builtin_acos, nullptr, nullptr, acos, nullptr }, - { "atan", 1, builtin_atan, nullptr, nullptr, atan, nullptr }, + { "asin", 1, Builtin::asin, nullptr, nullptr, asin, nullptr }, + { "acos", 1, Builtin::acos, nullptr, nullptr, acos, nullptr }, + { "atan", 1, Builtin::atan, nullptr, nullptr, atan, nullptr }, - { "asind", 1, builtin_sind, nullptr, nullptr, arc_sin_deg, nullptr }, - { "acosd", 1, builtin_cosd, nullptr, nullptr, arc_cos_deg, nullptr }, - { "atand", 1, builtin_tand, nullptr, nullptr, arc_tan_deg, nullptr }, + { "asind", 1, Builtin::sind, nullptr, nullptr, arc_sin_deg, nullptr }, + { "acosd", 1, Builtin::cosd, nullptr, nullptr, arc_cos_deg, nullptr }, + { "atand", 1, Builtin::tand, nullptr, nullptr, arc_tan_deg, nullptr }, - { "atan2", 2, builtin_atan2, nullptr, nullptr, nullptr, atan2 }, - { "atan2d", 2, builtin_atan2d, nullptr, nullptr, nullptr, atan2_deg }, + { "atan2", 2, Builtin::atan2, nullptr, nullptr, nullptr, atan2 }, + { "atan2d", 2, Builtin::atan2d, nullptr, nullptr, nullptr, atan2_deg }, - { "arg", 2, builtin_arg, nullptr, nullptr, nullptr, my_arg }, - { "argd", 2, builtin_argd, nullptr, nullptr, nullptr, my_arg_deg }, + { "arg", 2, Builtin::arg, nullptr, nullptr, nullptr, my_arg }, + { "argd", 2, Builtin::argd, nullptr, nullptr, nullptr, my_arg_deg }, - { "log", 1, builtin_log, nullptr, nullptr, log, nullptr }, - { "exp", 1, builtin_exp, nullptr, nullptr, exp, nullptr }, + { "log", 1, Builtin::log, nullptr, nullptr, log, nullptr }, + { "exp", 1, Builtin::exp, nullptr, nullptr, exp, nullptr }, - { "log10", 1, builtin_log10, nullptr, nullptr, log10, nullptr }, - { "exp10", 1, builtin_exp10, nullptr, nullptr, my_exp10, nullptr }, + { "log10", 1, Builtin::log10, nullptr, nullptr, log10, nullptr }, + { "exp10", 1, Builtin::exp10, nullptr, nullptr, my_exp10, nullptr }, - { "sqrt", 1, builtin_sqrt, nullptr, nullptr, sqrt, nullptr }, + { "sqrt", 1, Builtin::sqrt, nullptr, nullptr, sqrt, nullptr }, - { "abs", 1, builtin_abs, abs, nullptr, fabs, nullptr }, + { "abs", 1, Builtin::abs, abs, nullptr, fabs, nullptr }, - { "min", 2, builtin_min, nullptr, my_imin, nullptr, my_dmin }, - { "max", 2, builtin_max, nullptr, my_imax, nullptr, my_dmax }, + { "min", 2, Builtin::min, nullptr, my_imin, nullptr, my_dmin }, + { "max", 2, Builtin::max, nullptr, my_imax, nullptr, my_dmax }, - { "mod", 2, builtin_mod, nullptr, my_imod, nullptr, my_dmod }, + { "mod", 2, Builtin::mod, nullptr, my_imod, nullptr, my_dmod }, - { "floor", 1, builtin_floor, nullptr, nullptr, floor, nullptr }, - { "ceil", 1, builtin_ceil, nullptr, nullptr, ceil, nullptr }, + { "floor", 1, Builtin::floor, nullptr, nullptr, floor, nullptr }, + { "ceil", 1, Builtin::ceil, nullptr, nullptr, ceil, nullptr }, - { "step", 1, builtin_step, my_istep, nullptr, my_dstep, nullptr }, + { "step", 1, Builtin::step, my_istep, nullptr, my_dstep, nullptr }, // Functions defined in ConfigConstants - // { "F_to_C", 1, builtin_F_to_C, nullptr, nullptr, my_F_to_C, nullptr }, - // { "C_to_F", 1, builtin_C_to_F, nullptr, nullptr, my_C_to_F, nullptr }, + // { "F_to_C", 1, Builtin::F_to_C, nullptr, nullptr, my_F_to_C, nullptr }, + // { "C_to_F", 1, Builtin::C_to_F, nullptr, nullptr, my_C_to_F, nullptr }, - { "nint", 1, builtin_nint, nullptr, nullptr, nullptr, nullptr }, - { "sign", 1, builtin_sign, nullptr, nullptr, nullptr, nullptr }, + { "nint", 1, Builtin::nint, nullptr, nullptr, nullptr, nullptr }, + { "sign", 1, Builtin::sign, nullptr, nullptr, nullptr, nullptr }, // diff --git a/src/basic/vx_config/builtin.h b/src/basic/vx_config/builtin.h index d729e8a2a6..369ede5d09 100644 --- a/src/basic/vx_config/builtin.h +++ b/src/basic/vx_config/builtin.h @@ -30,69 +30,69 @@ static const int max_builtin_args = 2; //////////////////////////////////////////////////////////////////////// -enum Builtin { +enum class Builtin { // // built-in functions of one variable // - builtin_sin, - builtin_cos, - builtin_tan, + sin, + cos, + tan, - builtin_sind, - builtin_cosd, - builtin_tand, + sind, + cosd, + tand, - builtin_asin, - builtin_acos, - builtin_atan, + asin, + acos, + atan, - builtin_asind, - builtin_acosd, - builtin_atand, + asind, + acosd, + atand, - builtin_log, - builtin_exp, + log, + exp, - builtin_log10, - builtin_exp10, + log10, + exp10, - builtin_sqrt, - builtin_abs, - builtin_floor, - builtin_ceil, - builtin_nint, - builtin_sign, + sqrt, + abs, + floor, + ceil, + nint, + sign, - builtin_step, + step, // Functions defined in ConfigConstants - // builtin_F_to_C, - // builtin_C_to_F, + // F_to_C, + // C_to_F, // // built-in functions of two variables // - builtin_atan2, - builtin_atan2d, + atan2, + atan2d, - builtin_arg, - builtin_argd, + arg, + argd, - builtin_min, - builtin_max, + min, + max, - builtin_mod, + mod, // // built-in functions of three variables // - // builtin_ifte + // ifte // // flag value diff --git a/src/basic/vx_config/calculator.cc b/src/basic/vx_config/calculator.cc index 9b87fbbb74..1dbc427f4e 100644 --- a/src/basic/vx_config/calculator.cc +++ b/src/basic/vx_config/calculator.cc @@ -391,9 +391,9 @@ const BuiltinInfo & info = binfo[which]; // nint and sign are treated differently // -if ( info.id == builtin_nint ) { do_nint(); return; } +if ( info.id == Builtin::nint ) { do_nint(); return; } -if ( info.id == builtin_sign ) { do_sign(); return; } +if ( info.id == Builtin::sign ) { do_sign(); return; } // // From 0153110cdbd0381e46211343870931b9fa2e0183 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 19 Mar 2024 22:48:20 +0000 Subject: [PATCH 033/114] #2830 Converted enum to enum class at config_constants.h --- src/basic/vx_config/config_constants.h | 136 ++++---- src/basic/vx_config/config_util.cc | 329 +++++++++--------- src/basic/vx_config/config_util.h | 14 + src/libcode/vx_afm/afmtokentype_to_string.cc | 1 - src/libcode/vx_analysis_util/stat_job.cc | 10 +- src/libcode/vx_analysis_util/stat_job.h | 2 +- src/libcode/vx_analysis_util/stat_line.cc | 10 +- src/libcode/vx_nc_util/write_netcdf.cc | 4 +- src/libcode/vx_shapedata/engine.cc | 50 +-- src/libcode/vx_shapedata/mode_conf_info.cc | 18 +- src/libcode/vx_shapedata/mode_field_info.cc | 10 +- src/libcode/vx_stat_out/stat_columns.cc | 118 +++---- src/libcode/vx_stat_out/stat_hdr_columns.cc | 4 +- src/libcode/vx_statistics/apply_mask.cc | 8 +- src/libcode/vx_statistics/met_stats.cc | 6 +- src/libcode/vx_statistics/pair_base.cc | 24 +- src/libcode/vx_statistics/pair_base.h | 2 +- .../vx_statistics/pair_data_ensemble.cc | 6 +- src/libcode/vx_statistics/pair_data_point.cc | 12 +- src/libcode/vx_tc_util/diag_file.cc | 10 +- src/libcode/vx_tc_util/track_info.cc | 2 +- src/libcode/vx_tc_util/track_pair_info.cc | 14 +- src/tools/core/ensemble_stat/ensemble_stat.cc | 66 ++-- .../ensemble_stat/ensemble_stat_conf_info.cc | 24 +- src/tools/core/grid_stat/grid_stat.cc | 242 ++++++------- .../core/grid_stat/grid_stat_conf_info.cc | 34 +- src/tools/core/mode/mode_exec.cc | 64 ++-- src/tools/core/mode/mode_ps_file.cc | 8 +- src/tools/core/mode/multivar_frontend.cc | 8 +- src/tools/core/mode/page_1.cc | 42 +-- src/tools/core/point_stat/point_stat.cc | 144 ++++---- .../core/point_stat/point_stat_conf_info.cc | 42 +-- .../series_analysis_conf_info.cc | 2 +- src/tools/core/wavelet_stat/wavelet_stat.cc | 18 +- .../wavelet_stat/wavelet_stat_conf_info.cc | 56 +-- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 16 +- src/tools/other/gen_vx_mask/gen_vx_mask.h | 2 +- src/tools/other/grid_diag/grid_diag.cc | 4 +- .../other/mode_time_domain/mtd_config_info.cc | 18 +- src/tools/other/point2grid/point2grid.cc | 2 +- .../regrid_data_plane/regrid_data_plane.cc | 2 +- src/tools/tc_utils/tc_gen/tc_gen.cc | 28 +- src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc | 12 +- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 14 +- .../tc_utils/tc_pairs/tc_pairs_conf_info.cc | 4 +- src/tools/tc_utils/tc_stat/tc_stat_job.cc | 6 +- src/tools/tc_utils/tc_stat/tc_stat_job.h | 2 +- 47 files changed, 836 insertions(+), 814 deletions(-) diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index 56908edd31..e7f872f6b5 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -25,10 +25,10 @@ // Enumeration for output_flag configuration parameter // -enum STATOutputType { - STATOutputType_None, // Do not output this line type - STATOutputType_Stat, // Write output to the .stat file - STATOutputType_Both // Write output to .stat and .txt files +enum class STATOutputType { + None, // Do not output this line type + Stat, // Write output to the .stat file + Both // Write output to .stat and .txt files }; //////////////////////////////////////////////////////////////////////// @@ -37,11 +37,11 @@ enum STATOutputType { // Enumeration for field type configuration parameters // -enum FieldType { - FieldType_None, // Default - FieldType_Fcst, // Apply to forecast field - FieldType_Obs, // Apply to observation field - FieldType_Both // Apply to both forecast and observation field +enum class FieldType { + None, // Default + Fcst, // Apply to forecast field + Obs, // Apply to observation field + Both // Apply to both forecast and observation field }; //////////////////////////////////////////////////////////////////////// @@ -50,11 +50,11 @@ enum FieldType { // Enumeration for set logic // -enum SetLogic { - SetLogic_None, // Default - SetLogic_Union, // Union - SetLogic_Intersection, // Intersection - SetLogic_SymDiff // Symmetric Difference +enum class SetLogic { + None, // Default + Union, // Union + Intersection, // Intersection + SymDiff // Symmetric Difference }; //////////////////////////////////////////////////////////////////////// @@ -77,11 +77,11 @@ static const char setlogic_symbol_symdiff[] = "*"; // Enumeration for track type configuration parameters // -enum TrackType { - TrackType_None, // Default - TrackType_ADeck, // Apply to ADeck tracks - TrackType_BDeck, // Apply to BDeck tracks - TrackType_Both // Apply to both ADeck and BDeck tracks +enum class TrackType { + None, // Default + ADeck, // Apply to ADeck tracks + BDeck, // Apply to BDeck tracks + Both // Apply to both ADeck and BDeck tracks }; //////////////////////////////////////////////////////////////////////// @@ -90,12 +90,12 @@ enum TrackType { // Enumeration for tropical cyclone diagnostic types // -enum DiagType { - DiagType_None, // Default - DiagType_CIRA_RT, // Realtime CIRA Tropical Cyclone Diagnostics - DiagType_CIRA_Dev, // Developmental CIRA Tropical Cyclone Diagnostics - DiagType_SHIPS_RT, // Realtime SHIPS Large Scale Diagnostics - DiagType_SHIPS_Dev // Developmental SHIPS Large Scale Diagnostics +enum class DiagType { + None, // Default + CIRA_RT, // Realtime CIRA Tropical Cyclone Diagnostics + CIRA_Dev, // Developmental CIRA Tropical Cyclone Diagnostics + SHIPS_RT, // Realtime SHIPS Large Scale Diagnostics + SHIPS_Dev // Developmental SHIPS Large Scale Diagnostics }; //////////////////////////////////////////////////////////////////////// @@ -117,10 +117,10 @@ static const char ships_diag_dev_str[] = "SHIPS_DIAG_DEV"; // Enumeration for 12-hour interpolation logic // -enum Interp12Type { - Interp12Type_None, // Do not apply 12-hour interpolation logic - Interp12Type_Fill, // Fill in missing 'I' tracks with '2' tracks - Interp12Type_Replace // Replace all 'I' tracks with '2' tracks +enum class Interp12Type { + None, // Do not apply 12-hour interpolation logic + Fill, // Fill in missing 'I' tracks with '2' tracks + Replace // Replace all 'I' tracks with '2' tracks }; //////////////////////////////////////////////////////////////////////// @@ -423,9 +423,9 @@ struct MaskLatLon { // Enumeration for duplicate_flag configuration parameter // -enum DuplicateType { - DuplicateType_None, // Apply no logic for duplicate point obs - DuplicateType_Unique // Filter out duplicate observation values +enum class DuplicateType { + None, // Apply no logic for duplicate point obs + Unique // Filter out duplicate observation values }; //////////////////////////////////////////////////////////////////////// @@ -434,15 +434,15 @@ enum DuplicateType { // Enumeration for obs_summary configuration parameter // -enum ObsSummary { - ObsSummary_None, // Keep all observations, no statistics - ObsSummary_Nearest, // Keep only the observation closest in time - ObsSummary_Min, // Keep only smallest value - ObsSummary_Max, // Keep only largest value - ObsSummary_UW_Mean, // Calculate un-weighted mean - ObsSummary_DW_Mean, // Calculate time weighted mean - ObsSummary_Median, // Calculate median - ObsSummary_Perc // Calculate precentile +enum class ObsSummary { + None, // Keep all observations, no statistics + Nearest, // Keep only the observation closest in time + Min, // Keep only smallest value + Max, // Keep only largest value + UW_Mean, // Calculate un-weighted mean + DW_Mean, // Calculate time weighted mean + Median, // Calculate median + Perc // Calculate precentile }; //////////////////////////////////////////////////////////////////////// @@ -451,10 +451,10 @@ enum ObsSummary { // Enumeration for grid_weight_flag configuration parameter // -enum GridWeightType { - GridWeightType_None, // Apply no grid box weighting - GridWeightType_Cos_Lat, // Apply cosine latitude weighting - GridWeightType_Area // Apply true grid box area weighting +enum class GridWeightType { + None, // Apply no grid box weighting + Cos_Lat, // Apply cosine latitude weighting + Area // Apply true grid box area weighting }; //////////////////////////////////////////////////////////////////////// @@ -463,11 +463,11 @@ enum GridWeightType { // Enumeration for grid_decomp_flag configuration parameter // -enum GridDecompType { - GridDecompType_None, // Default - GridDecompType_Auto, // Automatic tiling - GridDecompType_Tile, // User-specified tile definitions - GridDecompType_Pad // Pad out to next largest tile +enum class GridDecompType { + None, // Default + Auto, // Automatic tiling + Tile, // User-specified tile definitions + Pad // Pad out to next largest tile }; //////////////////////////////////////////////////////////////////////// @@ -476,14 +476,14 @@ enum GridDecompType { // Enumeration for wavelet.type configuration parameter // -enum WaveletType { - WaveletType_None, // Default - WaveletType_Haar, // Haar wavelet - WaveletType_Haar_Cntr, // Centered Haar wavelet - WaveletType_Daub, // Daubechies wavelet - WaveletType_Daub_Cntr, // Centered Daubechies wavelet - WaveletType_BSpline, // BSpline wavelet - WaveletType_BSpline_Cntr // Centered BSpline wavelet +enum class WaveletType { + None, // Default + Haar, // Haar wavelet + Haar_Cntr, // Centered Haar wavelet + Daub, // Daubechies wavelet + Daub_Cntr, // Centered Daubechies wavelet + BSpline, // BSpline wavelet + BSpline_Cntr // Centered BSpline wavelet }; //////////////////////////////////////////////////////////////////////// @@ -492,11 +492,11 @@ enum WaveletType { // Enumeration for MODE merging options // -enum MergeType { - MergeType_None, // No additional merging - MergeType_Both, // Double-threshold and fuzzy engine - MergeType_Thresh, // Double-threshold only - MergeType_Engine // Fuzzy engine only +enum class MergeType { + None, // No additional merging + Both, // Double-threshold and fuzzy engine + Thresh, // Double-threshold only + Engine // Fuzzy engine only }; //////////////////////////////////////////////////////////////////////// @@ -505,11 +505,11 @@ enum MergeType { // Enumeration for MODE matching options // -enum MatchType { - MatchType_None, // No matching - MatchType_MergeBoth, // Match with merging in both fcst and obs - MatchType_MergeFcst, // Match with merging in fcst only - MatchType_NoMerge // Match with no additional merging +enum class MatchType { + None, // No matching + MergeBoth, // Match with merging in both fcst and obs + MergeFcst, // Match with merging in fcst only + NoMerge // Match with no additional merging }; //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index a39bff6c39..1eec001151 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -121,7 +121,7 @@ void GaussianInfo::validate() { void RegridInfo::clear() { enable = false; - field = FieldType_None; + field = FieldType::None; vld_thresh = bad_data_double; name.clear(); method = InterpMthd_None; @@ -266,6 +266,15 @@ RegridInfo &RegridInfo::operator=(const RegridInfo &a) noexcept { /////////////////////////////////////////////////////////////////////////////// +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + +/////////////////////////////////////////////////////////////////////////////// + ConcatString parse_conf_version(Dictionary *dict) { ConcatString s; @@ -375,7 +384,7 @@ GrdFileType parse_conf_file_type(Dictionary *dict) { map parse_conf_output_flag(Dictionary *dict, const STATLineType *line_type, int n_lty) { map output_map; - STATOutputType t = STATOutputType_None; + STATOutputType t = STATOutputType::None; ConcatString cs; int v; @@ -397,9 +406,9 @@ map parse_conf_output_flag(Dictionary *dict, v = dict->lookup_int(cs.c_str()); // Convert integer to enumerated STATOutputType - if(v == conf_const.lookup_int(conf_val_none)) t = STATOutputType_None; - else if(v == conf_const.lookup_int(conf_val_stat)) t = STATOutputType_Stat; - else if(v == conf_const.lookup_int(conf_val_both)) t = STATOutputType_Both; + if(v == conf_const.lookup_int(conf_val_none)) t = STATOutputType::None; + else if(v == conf_const.lookup_int(conf_val_stat)) t = STATOutputType::Stat; + else if(v == conf_const.lookup_int(conf_val_both)) t = STATOutputType::Both; else { mlog << Error << "\nparse_conf_output_flag() -> " << "Unexpected config file value of " << v << " for \"" @@ -1360,8 +1369,8 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { // If integer lookup successful, convert to FieldType. if(regrid_dict->last_lookup_status()) { info.field = int_to_fieldtype(v); - info.enable = (info.field == FieldType_Fcst || - info.field == FieldType_Obs); + info.enable = (info.field == FieldType::Fcst || + info.field == FieldType::Obs); } // If integer lookup unsuccessful, parse vx_grid as a string. // Do not error out since to_grid isn't specified for climo.regrid. @@ -1419,7 +1428,7 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { /////////////////////////////////////////////////////////////////////////////// void InterpInfo::clear() { - field = FieldType_None; + field = FieldType::None; vld_thresh = bad_data_double; n_interp = 0; method.clear(); @@ -1556,7 +1565,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { // If found, interpret value. Otherwise, set to a default value. if(interp_dict->last_lookup_status()) info.field = int_to_fieldtype(v); - else info.field = FieldType_None; + else info.field = FieldType::None; // Conf: vld_thresh double thr = interp_dict->lookup_double(conf_key_vld_thresh, false); @@ -1844,7 +1853,7 @@ ClimoCDFInfo parse_conf_climo_cdf(Dictionary *dict) { void NbrhdInfo::clear() { - field = FieldType_None; + field = FieldType::None; vld_thresh = bad_data_double; width.clear(); cov_ta.clear(); @@ -1885,7 +1894,7 @@ NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { // Conf: field - may be missing // Default info.field to BOTH - info.field = FieldType_Both; + info.field = FieldType::Both; // Skip lookup for conf_key_nbrhd_prob if(strncmp(conf_key, conf_key_nbrhd_prob, strlen(conf_key_nbrhd_prob)) != 0) { @@ -2073,7 +2082,7 @@ HiRAInfo parse_conf_hira(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { - GridWeightType t = GridWeightType_None; + GridWeightType t = GridWeightType::None; int v; if(!dict) { @@ -2086,9 +2095,9 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { v = dict->lookup_int(conf_key_grid_weight_flag); // Convert integer to enumerated GridWeightType - if(v == conf_const.lookup_int(conf_val_none)) t = GridWeightType_None; - else if(v == conf_const.lookup_int(conf_val_cos_lat)) t = GridWeightType_Cos_Lat; - else if(v == conf_const.lookup_int(conf_val_area)) t = GridWeightType_Area; + if(v == conf_const.lookup_int(conf_val_none)) t = GridWeightType::None; + else if(v == conf_const.lookup_int(conf_val_cos_lat)) t = GridWeightType::Cos_Lat; + else if(v == conf_const.lookup_int(conf_val_area)) t = GridWeightType::Area; else { mlog << Error << "\nparse_conf_grid_weight_flag() -> " << "Unexpected config file value of " << v << " for \"" @@ -2102,7 +2111,7 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { - DuplicateType t = DuplicateType_None; + DuplicateType t = DuplicateType::None; int v; if(!dict) { @@ -2115,8 +2124,8 @@ DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { v = dict->lookup_int(conf_key_duplicate_flag); // Convert integer to enumerated DuplicateType - if(v == conf_const.lookup_int(conf_val_none)) t = DuplicateType_None; - else if(v == conf_const.lookup_int(conf_val_unique)) t = DuplicateType_Unique; + if(v == conf_const.lookup_int(conf_val_none)) t = DuplicateType::None; + else if(v == conf_const.lookup_int(conf_val_unique)) t = DuplicateType::Unique; else if(v == conf_const.lookup_int(conf_val_single)) { mlog << Error << "\nparse_conf_duplicate_flag() -> " << "duplicate_flag = SINGLE has been deprecated\n" @@ -2136,7 +2145,7 @@ DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// ObsSummary parse_conf_obs_summary(Dictionary *dict) { - ObsSummary t = ObsSummary_None; + ObsSummary t = ObsSummary::None; int v; if(!dict) { @@ -2149,14 +2158,14 @@ ObsSummary parse_conf_obs_summary(Dictionary *dict) { v = dict->lookup_int(conf_key_obs_summary); // Convert integer to enumerated ObsSummary - if(v == conf_const.lookup_int(conf_val_none)) t = ObsSummary_None; - else if(v == conf_const.lookup_int(conf_val_nearest)) t = ObsSummary_Nearest; - else if(v == conf_const.lookup_int(conf_val_min)) t = ObsSummary_Min; - else if(v == conf_const.lookup_int(conf_val_max)) t = ObsSummary_Max; - else if(v == conf_const.lookup_int(conf_val_uw_mean)) t = ObsSummary_UW_Mean; - else if(v == conf_const.lookup_int(conf_val_dw_mean)) t = ObsSummary_DW_Mean; - else if(v == conf_const.lookup_int(conf_val_median)) t = ObsSummary_Median; - else if(v == conf_const.lookup_int(conf_val_perc)) t = ObsSummary_Perc; + if(v == conf_const.lookup_int(conf_val_none)) t = ObsSummary::None; + else if(v == conf_const.lookup_int(conf_val_nearest)) t = ObsSummary::Nearest; + else if(v == conf_const.lookup_int(conf_val_min)) t = ObsSummary::Min; + else if(v == conf_const.lookup_int(conf_val_max)) t = ObsSummary::Max; + else if(v == conf_const.lookup_int(conf_val_uw_mean)) t = ObsSummary::UW_Mean; + else if(v == conf_const.lookup_int(conf_val_dw_mean)) t = ObsSummary::DW_Mean; + else if(v == conf_const.lookup_int(conf_val_median)) t = ObsSummary::Median; + else if(v == conf_const.lookup_int(conf_val_perc)) t = ObsSummary::Perc; else { mlog << Error << "\nparse_conf_obs_summary() -> " << "Unexpected config file value of " << v << " for \"" @@ -2225,7 +2234,7 @@ ConcatString parse_conf_tmp_dir(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { - GridDecompType t = GridDecompType_None; + GridDecompType t = GridDecompType::None; int v; if(!dict) { @@ -2238,10 +2247,10 @@ GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { v = dict->lookup_int(conf_key_grid_decomp_flag); // Convert integer to enumerated GridDecompType - if(v == conf_const.lookup_int(conf_val_none)) t = GridDecompType_None; - else if(v == conf_const.lookup_int(conf_val_auto)) t = GridDecompType_Auto; - else if(v == conf_const.lookup_int(conf_val_tile)) t = GridDecompType_Tile; - else if(v == conf_const.lookup_int(conf_val_pad)) t = GridDecompType_Pad; + if(v == conf_const.lookup_int(conf_val_none)) t = GridDecompType::None; + else if(v == conf_const.lookup_int(conf_val_auto)) t = GridDecompType::Auto; + else if(v == conf_const.lookup_int(conf_val_tile)) t = GridDecompType::Tile; + else if(v == conf_const.lookup_int(conf_val_pad)) t = GridDecompType::Pad; else { mlog << Error << "\nparse_conf_grid_decomp_flag() -> " << "Unexpected config file value of " << v << " for \"" @@ -2255,7 +2264,7 @@ GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// WaveletType parse_conf_wavelet_type(Dictionary *dict) { - WaveletType t = WaveletType_None; + WaveletType t = WaveletType::None; int v; if(!dict) { @@ -2268,13 +2277,13 @@ WaveletType parse_conf_wavelet_type(Dictionary *dict) { v = dict->lookup_int(conf_key_wavelet_type); // Convert integer to enumerated WaveletType - if(v == conf_const.lookup_int(conf_val_none)) t = WaveletType_None; - else if(v == conf_const.lookup_int(conf_val_haar)) t = WaveletType_Haar; - else if(v == conf_const.lookup_int(conf_val_haar_cntr)) t = WaveletType_Haar_Cntr; - else if(v == conf_const.lookup_int(conf_val_daub)) t = WaveletType_Daub; - else if(v == conf_const.lookup_int(conf_val_daub_cntr)) t = WaveletType_Daub_Cntr; - else if(v == conf_const.lookup_int(conf_val_bspline)) t = WaveletType_BSpline; - else if(v == conf_const.lookup_int(conf_val_bspline_cntr)) t = WaveletType_BSpline_Cntr; + if(v == conf_const.lookup_int(conf_val_none)) t = WaveletType::None; + else if(v == conf_const.lookup_int(conf_val_haar)) t = WaveletType::Haar; + else if(v == conf_const.lookup_int(conf_val_haar_cntr)) t = WaveletType::Haar_Cntr; + else if(v == conf_const.lookup_int(conf_val_daub)) t = WaveletType::Daub; + else if(v == conf_const.lookup_int(conf_val_daub_cntr)) t = WaveletType::Daub_Cntr; + else if(v == conf_const.lookup_int(conf_val_bspline)) t = WaveletType::BSpline; + else if(v == conf_const.lookup_int(conf_val_bspline_cntr)) t = WaveletType::BSpline_Cntr; else { mlog << Error << "\nparse_conf_wavelet_type() -> " << "Unexpected config file value of " << v << " for \"" @@ -2723,13 +2732,13 @@ STATLineType string_to_statlinetype(const char *s) { /////////////////////////////////////////////////////////////////////////////// FieldType int_to_fieldtype(int v) { - FieldType t = FieldType_None; + FieldType t = FieldType::None; // Convert integer to enumerated FieldType - if(v == conf_const.lookup_int(conf_val_none)) t = FieldType_None; - else if(v == conf_const.lookup_int(conf_val_both)) t = FieldType_Both; - else if(v == conf_const.lookup_int(conf_val_fcst)) t = FieldType_Fcst; - else if(v == conf_const.lookup_int(conf_val_obs)) t = FieldType_Obs; + if(v == conf_const.lookup_int(conf_val_none)) t = FieldType::None; + else if(v == conf_const.lookup_int(conf_val_both)) t = FieldType::Both; + else if(v == conf_const.lookup_int(conf_val_fcst)) t = FieldType::Fcst; + else if(v == conf_const.lookup_int(conf_val_obs)) t = FieldType::Obs; else { mlog << Error << "\nint_to_fieldtype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -2767,13 +2776,13 @@ ConcatString fieldtype_to_string(FieldType type) { // Convert enumerated FieldType to string switch(type) { - case(FieldType_None): s = conf_val_none; break; - case(FieldType_Both): s = conf_val_both; break; - case(FieldType_Fcst): s = conf_val_fcst; break; - case(FieldType_Obs): s = conf_val_obs; break; + case(FieldType::None): s = conf_val_none; break; + case(FieldType::Both): s = conf_val_both; break; + case(FieldType::Fcst): s = conf_val_fcst; break; + case(FieldType::Obs): s = conf_val_obs; break; default: mlog << Error << "\nfieldtype_to_string() -> " - << "Unexpected FieldType value of " << type << ".\n\n"; + << "Unexpected FieldType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -2783,13 +2792,13 @@ ConcatString fieldtype_to_string(FieldType type) { /////////////////////////////////////////////////////////////////////////////// SetLogic int_to_setlogic(int v) { - SetLogic t = SetLogic_None; + SetLogic t = SetLogic::None; // Convert integer to enumerated SetLogic - if(v == conf_const.lookup_int(conf_val_none)) t = SetLogic_None; - else if(v == conf_const.lookup_int(conf_val_union)) t = SetLogic_Union; - else if(v == conf_const.lookup_int(conf_val_intersection)) t = SetLogic_Intersection; - else if(v == conf_const.lookup_int(conf_val_symdiff)) t = SetLogic_SymDiff; + if(v == conf_const.lookup_int(conf_val_none)) t = SetLogic::None; + else if(v == conf_const.lookup_int(conf_val_union)) t = SetLogic::Union; + else if(v == conf_const.lookup_int(conf_val_intersection)) t = SetLogic::Intersection; + else if(v == conf_const.lookup_int(conf_val_symdiff)) t = SetLogic::SymDiff; else { mlog << Error << "\nint_to_setlogic() -> " << "Unexpected value of " << v << ".\n\n"; @@ -2802,22 +2811,22 @@ SetLogic int_to_setlogic(int v) { /////////////////////////////////////////////////////////////////////////////// SetLogic string_to_setlogic(const char *s) { - SetLogic t = SetLogic_None; + SetLogic t = SetLogic::None; // Convert string to enumerated SetLogic - if(strcasecmp(s, conf_val_none) == 0) t = SetLogic_None; + if(strcasecmp(s, conf_val_none) == 0) t = SetLogic::None; else if(strcasecmp(s, conf_val_union) == 0 || strcasecmp(s, setlogic_abbr_union) == 0 || - strcasecmp(s, setlogic_symbol_union) == 0) t = SetLogic_Union; + strcasecmp(s, setlogic_symbol_union) == 0) t = SetLogic::Union; else if(strcasecmp(s, conf_val_intersection) == 0 || strcasecmp(s, setlogic_abbr_intersection) == 0 || - strcasecmp(s, setlogic_symbol_intersection) == 0) t = SetLogic_Intersection; + strcasecmp(s, setlogic_symbol_intersection) == 0) t = SetLogic::Intersection; else if(strcasecmp(s, conf_val_symdiff) == 0 || strcasecmp(s, setlogic_abbr_symdiff) == 0 || - strcasecmp(s, setlogic_symbol_symdiff) == 0) t = SetLogic_SymDiff; + strcasecmp(s, setlogic_symbol_symdiff) == 0) t = SetLogic::SymDiff; else { mlog << Error << "\nstring_to_setlogic() -> " @@ -2836,13 +2845,13 @@ ConcatString setlogic_to_string(SetLogic type) { // Convert enumerated SetLogic to string switch(type) { - case(SetLogic_None): s = conf_val_none; break; - case(SetLogic_Union): s = conf_val_union; break; - case(SetLogic_Intersection): s = conf_val_intersection; break; - case(SetLogic_SymDiff): s = conf_val_symdiff; break; + case(SetLogic::None): s = conf_val_none; break; + case(SetLogic::Union): s = conf_val_union; break; + case(SetLogic::Intersection): s = conf_val_intersection; break; + case(SetLogic::SymDiff): s = conf_val_symdiff; break; default: mlog << Error << "\nsetlogic_to_string() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -2856,13 +2865,13 @@ ConcatString setlogic_to_abbr(SetLogic type) { // Convert enumerated SetLogic to an abbreviation switch(type) { - case(SetLogic_None): s = na_str; break; - case(SetLogic_Union): s = setlogic_abbr_union; break; - case(SetLogic_Intersection): s = setlogic_abbr_intersection; break; - case(SetLogic_SymDiff): s = setlogic_abbr_symdiff; break; + case(SetLogic::None): s = na_str; break; + case(SetLogic::Union): s = setlogic_abbr_union; break; + case(SetLogic::Intersection): s = setlogic_abbr_intersection; break; + case(SetLogic::SymDiff): s = setlogic_abbr_symdiff; break; default: mlog << Error << "\nsetlogic_to_abbr() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -2876,13 +2885,13 @@ ConcatString setlogic_to_symbol(SetLogic type) { // Convert enumerated SetLogic to a symbol switch(type) { - case(SetLogic_None): s = na_str; break; - case(SetLogic_Union): s = setlogic_symbol_union; break; - case(SetLogic_Intersection): s = setlogic_symbol_intersection; break; - case(SetLogic_SymDiff): s = setlogic_symbol_symdiff; break; + case(SetLogic::None): s = na_str; break; + case(SetLogic::Union): s = setlogic_symbol_union; break; + case(SetLogic::Intersection): s = setlogic_symbol_intersection; break; + case(SetLogic::SymDiff): s = setlogic_symbol_symdiff; break; default: mlog << Error << "\nsetlogic_to_symbol() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -2892,12 +2901,12 @@ ConcatString setlogic_to_symbol(SetLogic type) { /////////////////////////////////////////////////////////////////////////////// SetLogic check_setlogic(SetLogic t1, SetLogic t2) { - SetLogic t = SetLogic_None; + SetLogic t = SetLogic::None; // If not equal, select the non-default logic type if(t1 == t2) t = t1; - else if(t1 == SetLogic_None) t = t2; - else if(t2 == SetLogic_None) t = t1; + else if(t1 == SetLogic::None) t = t2; + else if(t2 == SetLogic::None) t = t1; // If not equal and both non-default, error out else { mlog << Error << "\ncheck_setlogic() -> " @@ -2913,13 +2922,13 @@ SetLogic check_setlogic(SetLogic t1, SetLogic t2) { /////////////////////////////////////////////////////////////////////////////// TrackType int_to_tracktype(int v) { - TrackType t = TrackType_None; + TrackType t = TrackType::None; // Convert integer to enumerated TrackType - if(v == conf_const.lookup_int(conf_val_none)) t = TrackType_None; - else if(v == conf_const.lookup_int(conf_val_both)) t = TrackType_Both; - else if(v == conf_const.lookup_int(conf_val_adeck)) t = TrackType_ADeck; - else if(v == conf_const.lookup_int(conf_val_bdeck)) t = TrackType_BDeck; + if(v == conf_const.lookup_int(conf_val_none)) t = TrackType::None; + else if(v == conf_const.lookup_int(conf_val_both)) t = TrackType::Both; + else if(v == conf_const.lookup_int(conf_val_adeck)) t = TrackType::ADeck; + else if(v == conf_const.lookup_int(conf_val_bdeck)) t = TrackType::BDeck; else { mlog << Error << "\nint_to_tracktype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -2932,13 +2941,13 @@ TrackType int_to_tracktype(int v) { /////////////////////////////////////////////////////////////////////////////// TrackType string_to_tracktype(const char *s) { - TrackType t = TrackType_None; + TrackType t = TrackType::None; // Convert string to enumerated TrackType - if(strcasecmp(s, conf_val_none) == 0) t = TrackType_None; - else if(strcasecmp(s, conf_val_both) == 0) t = TrackType_Both; - else if(strcasecmp(s, conf_val_adeck) == 0) t = TrackType_ADeck; - else if(strcasecmp(s, conf_val_bdeck) == 0) t = TrackType_BDeck; + if(strcasecmp(s, conf_val_none) == 0) t = TrackType::None; + else if(strcasecmp(s, conf_val_both) == 0) t = TrackType::Both; + else if(strcasecmp(s, conf_val_adeck) == 0) t = TrackType::ADeck; + else if(strcasecmp(s, conf_val_bdeck) == 0) t = TrackType::BDeck; else { mlog << Error << "\nstring_to_tracktype() -> " << "Unexpected TrackType string \"" << s << "\".\n\n"; @@ -2955,13 +2964,13 @@ ConcatString tracktype_to_string(TrackType type) { // Convert enumerated TrackType to string switch(type) { - case(TrackType_None): s = conf_val_none; break; - case(TrackType_Both): s = conf_val_both; break; - case(TrackType_ADeck): s = conf_val_adeck; break; - case(TrackType_BDeck): s = conf_val_bdeck; break; + case(TrackType::None): s = conf_val_none; break; + case(TrackType::Both): s = conf_val_both; break; + case(TrackType::ADeck): s = conf_val_adeck; break; + case(TrackType::BDeck): s = conf_val_bdeck; break; default: mlog << Error << "\ntracktype_to_string() -> " - << "Unexpected TrackType value of " << type << ".\n\n"; + << "Unexpected TrackType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -2971,15 +2980,15 @@ ConcatString tracktype_to_string(TrackType type) { /////////////////////////////////////////////////////////////////////////////// DiagType string_to_diagtype(const char *s) { - DiagType t = DiagType_None; + DiagType t = DiagType::None; // Convert string to enumerated DiagType, storing unknown strings // as the default type - if(strcasecmp(s, cira_diag_rt_str) == 0) t = DiagType_CIRA_RT; - else if(strcasecmp(s, cira_diag_dev_str) == 0) t = DiagType_CIRA_Dev; - else if(strcasecmp(s, ships_diag_rt_str) == 0) t = DiagType_SHIPS_RT; - else if(strcasecmp(s, ships_diag_dev_str) == 0) t = DiagType_SHIPS_Dev; - else t = DiagType_None; + if(strcasecmp(s, cira_diag_rt_str) == 0) t = DiagType::CIRA_RT; + else if(strcasecmp(s, cira_diag_dev_str) == 0) t = DiagType::CIRA_Dev; + else if(strcasecmp(s, ships_diag_rt_str) == 0) t = DiagType::SHIPS_RT; + else if(strcasecmp(s, ships_diag_dev_str) == 0) t = DiagType::SHIPS_Dev; + else t = DiagType::None; return t; } @@ -2991,14 +3000,14 @@ ConcatString diagtype_to_string(DiagType type) { // Convert enumerated DiagType to string switch(type) { - case(DiagType_None): s = conf_val_none; break; - case(DiagType_CIRA_RT): s = cira_diag_rt_str; break; - case(DiagType_CIRA_Dev): s = cira_diag_dev_str; break; - case(DiagType_SHIPS_RT): s = ships_diag_rt_str; break; - case(DiagType_SHIPS_Dev): s = ships_diag_dev_str; break; + case(DiagType::None): s = conf_val_none; break; + case(DiagType::CIRA_RT): s = cira_diag_rt_str; break; + case(DiagType::CIRA_Dev): s = cira_diag_dev_str; break; + case(DiagType::SHIPS_RT): s = ships_diag_rt_str; break; + case(DiagType::SHIPS_Dev): s = ships_diag_dev_str; break; default: mlog << Error << "\ndiagtype_to_string() -> " - << "Unexpected DiagType value of " << type << ".\n\n"; + << "Unexpected DiagType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3008,12 +3017,12 @@ ConcatString diagtype_to_string(DiagType type) { /////////////////////////////////////////////////////////////////////////////// Interp12Type int_to_interp12type(int v) { - Interp12Type t = Interp12Type_None; + Interp12Type t = Interp12Type::None; // Convert integer to enumerated Interp12Type - if(v == conf_const.lookup_int(conf_val_none)) t = Interp12Type_None; - else if(v == conf_const.lookup_int(conf_val_fill)) t = Interp12Type_Fill; - else if(v == conf_const.lookup_int(conf_val_replace)) t = Interp12Type_Replace; + if(v == conf_const.lookup_int(conf_val_none)) t = Interp12Type::None; + else if(v == conf_const.lookup_int(conf_val_fill)) t = Interp12Type::Fill; + else if(v == conf_const.lookup_int(conf_val_replace)) t = Interp12Type::Replace; else { mlog << Error << "\nint_to_interp12type() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3026,12 +3035,12 @@ Interp12Type int_to_interp12type(int v) { /////////////////////////////////////////////////////////////////////////////// Interp12Type string_to_interp12type(const char *s) { - Interp12Type t = Interp12Type_None; + Interp12Type t = Interp12Type::None; // Convert string to enumerated Interp12Type - if(strcasecmp(s, conf_val_none) == 0) t = Interp12Type_None; - else if(strcasecmp(s, conf_val_fill) == 0) t = Interp12Type_Fill; - else if(strcasecmp(s, conf_val_replace) == 0) t = Interp12Type_Replace; + if(strcasecmp(s, conf_val_none) == 0) t = Interp12Type::None; + else if(strcasecmp(s, conf_val_fill) == 0) t = Interp12Type::Fill; + else if(strcasecmp(s, conf_val_replace) == 0) t = Interp12Type::Replace; else { mlog << Error << "\nstring_to_interp12type() -> " << "Unexpected Interp12Type string \"" << s << "\".\n\n"; @@ -3048,12 +3057,12 @@ ConcatString interp12type_to_string(Interp12Type type) { // Convert enumerated Interp12Type to string switch(type) { - case(Interp12Type_None): s = conf_val_none; break; - case(Interp12Type_Fill): s = conf_val_fill; break; - case(Interp12Type_Replace): s = conf_val_replace; break; + case(Interp12Type::None): s = conf_val_none; break; + case(Interp12Type::Fill): s = conf_val_fill; break; + case(Interp12Type::Replace): s = conf_val_replace; break; default: mlog << Error << "\ninterp12type_to_string() -> " - << "Unexpected Interp12Type value of " << type << ".\n\n"; + << "Unexpected Interp12Type value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3063,13 +3072,13 @@ ConcatString interp12type_to_string(Interp12Type type) { /////////////////////////////////////////////////////////////////////////////// MergeType int_to_mergetype(int v) { - MergeType t = MergeType_None; + MergeType t = MergeType::None; // Convert integer to enumerated MergeType - if(v == conf_const.lookup_int(conf_val_none)) t = MergeType_None; - else if(v == conf_const.lookup_int(conf_val_both)) t = MergeType_Both; - else if(v == conf_const.lookup_int(conf_val_thresh)) t = MergeType_Thresh; - else if(v == conf_const.lookup_int(conf_val_engine)) t = MergeType_Engine; + if(v == conf_const.lookup_int(conf_val_none)) t = MergeType::None; + else if(v == conf_const.lookup_int(conf_val_both)) t = MergeType::Both; + else if(v == conf_const.lookup_int(conf_val_thresh)) t = MergeType::Thresh; + else if(v == conf_const.lookup_int(conf_val_engine)) t = MergeType::Engine; else { mlog << Error << "\nint_to_mergetype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3086,13 +3095,13 @@ ConcatString mergetype_to_string(MergeType type) { // Convert enumerated MergeType to string switch(type) { - case(MergeType_None): s = conf_val_none; break; - case(MergeType_Both): s = conf_val_both; break; - case(MergeType_Thresh): s = conf_val_thresh; break; - case(MergeType_Engine): s = conf_val_engine; break; + case(MergeType::None): s = conf_val_none; break; + case(MergeType::Both): s = conf_val_both; break; + case(MergeType::Thresh): s = conf_val_thresh; break; + case(MergeType::Engine): s = conf_val_engine; break; default: mlog << Error << "\nmergetype_to_string() -> " - << "Unexpected MergeType value of " << type << ".\n\n"; + << "Unexpected MergeType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3106,19 +3115,19 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { // Convert enumerated ObsSummary to string switch(type) { - case(ObsSummary_None): s = conf_val_none; break; - case(ObsSummary_Nearest): s = conf_val_nearest; break; - case(ObsSummary_Min): s = conf_val_min; break; - case(ObsSummary_Max): s = conf_val_max; break; - case(ObsSummary_UW_Mean): s = conf_val_uw_mean; break; - case(ObsSummary_DW_Mean): s = conf_val_dw_mean; break; - case(ObsSummary_Median): s = conf_val_median; break; - case(ObsSummary_Perc): + case(ObsSummary::None): s = conf_val_none; break; + case(ObsSummary::Nearest): s = conf_val_nearest; break; + case(ObsSummary::Min): s = conf_val_min; break; + case(ObsSummary::Max): s = conf_val_max; break; + case(ObsSummary::UW_Mean): s = conf_val_uw_mean; break; + case(ObsSummary::DW_Mean): s = conf_val_dw_mean; break; + case(ObsSummary::Median): s = conf_val_median; break; + case(ObsSummary::Perc): s << conf_val_perc << "(" << perc_val << ")"; break; default: mlog << Error << "\nobssummary_to_string() -> " - << "Unexpected ObsSummary value of " << type << ".\n\n"; + << "Unexpected ObsSummary value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3128,13 +3137,13 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { /////////////////////////////////////////////////////////////////////////////// MatchType int_to_matchtype(int v) { - MatchType t = MatchType_None; + MatchType t = MatchType::None; // Convert integer to enumerated MatchType - if(v == conf_const.lookup_int(conf_val_none)) t = MatchType_None; - else if(v == conf_const.lookup_int(conf_val_merge_both)) t = MatchType_MergeBoth; - else if(v == conf_const.lookup_int(conf_val_merge_fcst)) t = MatchType_MergeFcst; - else if(v == conf_const.lookup_int(conf_val_no_merge)) t = MatchType_NoMerge; + if(v == conf_const.lookup_int(conf_val_none)) t = MatchType::None; + else if(v == conf_const.lookup_int(conf_val_merge_both)) t = MatchType::MergeBoth; + else if(v == conf_const.lookup_int(conf_val_merge_fcst)) t = MatchType::MergeFcst; + else if(v == conf_const.lookup_int(conf_val_no_merge)) t = MatchType::NoMerge; else { mlog << Error << "\nint_to_matchtype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3151,13 +3160,13 @@ ConcatString matchtype_to_string(MatchType type) { // Convert enumerated MatchType to string switch(type) { - case(MatchType_None): s = conf_val_none; break; - case(MatchType_MergeBoth): s = conf_val_merge_both; break; - case(MatchType_MergeFcst): s = conf_val_merge_fcst; break; - case(MatchType_NoMerge): s = conf_val_no_merge; break; + case(MatchType::None): s = conf_val_none; break; + case(MatchType::MergeBoth): s = conf_val_merge_both; break; + case(MatchType::MergeFcst): s = conf_val_merge_fcst; break; + case(MatchType::NoMerge): s = conf_val_no_merge; break; default: mlog << Error << "\nmatchtype_to_string() -> " - << "Unexpected MatchType value of " << type << ".\n\n"; + << "Unexpected MatchType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3224,7 +3233,7 @@ ConcatString disttype_to_string(DistType type) { case(DistType_Beta): s = conf_val_beta; break; default: mlog << Error << "\ndisttype_to_string() -> " - << "Unexpected DistType value of " << type << ".\n\n"; + << "Unexpected DistType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3259,13 +3268,13 @@ ConcatString griddecomptype_to_string(GridDecompType type) { // Convert enumerated GridDecompType to string switch(type) { - case(GridDecompType_None): s = conf_val_none; break; - case(GridDecompType_Auto): s = conf_val_auto; break; - case(GridDecompType_Tile): s = conf_val_tile; break; - case(GridDecompType_Pad): s = conf_val_pad; break; + case(GridDecompType::None): s = conf_val_none; break; + case(GridDecompType::Auto): s = conf_val_auto; break; + case(GridDecompType::Tile): s = conf_val_tile; break; + case(GridDecompType::Pad): s = conf_val_pad; break; default: mlog << Error << "\ngriddecomptype_to_string() -> " - << "Unexpected GridDecompType value of " << type << ".\n\n"; + << "Unexpected GridDecompType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -3279,16 +3288,16 @@ ConcatString wavelettype_to_string(WaveletType type) { // Convert enumerated WaveletType to string switch(type) { - case(WaveletType_None): s = conf_val_none; break; - case(WaveletType_Haar): s = conf_val_haar; break; - case(WaveletType_Haar_Cntr): s = conf_val_haar_cntr; break; - case(WaveletType_Daub): s = conf_val_daub; break; - case(WaveletType_Daub_Cntr): s = conf_val_daub_cntr; break; - case(WaveletType_BSpline): s = conf_val_bspline; break; - case(WaveletType_BSpline_Cntr): s = conf_val_bspline_cntr; break; + case(WaveletType::None): s = conf_val_none; break; + case(WaveletType::Haar): s = conf_val_haar; break; + case(WaveletType::Haar_Cntr): s = conf_val_haar_cntr; break; + case(WaveletType::Daub): s = conf_val_daub; break; + case(WaveletType::Daub_Cntr): s = conf_val_daub_cntr; break; + case(WaveletType::BSpline): s = conf_val_bspline; break; + case(WaveletType::BSpline_Cntr): s = conf_val_bspline_cntr; break; default: mlog << Error << "\nwavlettype_to_string() -> " - << "Unexpected WaveletType value of " << type << ".\n\n"; + << "Unexpected WaveletType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index d8137919cb..316c8eb14a 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -150,8 +150,22 @@ extern int parse_conf_percentile(Dictionary *dict); extern void python_compile_error(const char *caller=nullptr); extern void ugrid_compile_error(const char *caller=nullptr); +template +extern auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type; + //////////////////////////////////////////////////////////////////////// +/* +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} +*/ +/////////////////////////////////////////////////////////////////////////////// + #endif /* __CONFIG_UTIL_H__ */ //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_afm/afmtokentype_to_string.cc b/src/libcode/vx_afm/afmtokentype_to_string.cc index 03ee5c72d4..5d04baffd9 100644 --- a/src/libcode/vx_afm/afmtokentype_to_string.cc +++ b/src/libcode/vx_afm/afmtokentype_to_string.cc @@ -28,7 +28,6 @@ #include "afmtokentype_to_string.h" - using namespace std; diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index f5ead39e40..c36758f8db 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -158,7 +158,7 @@ void STATAnalysisJob::clear() { obs_thresh.clear(); cov_thresh.clear(); - thresh_logic = SetLogic_None; + thresh_logic = SetLogic::None; alpha.clear(); @@ -192,11 +192,11 @@ void STATAnalysisJob::clear() { out_fcst_thresh.clear(); out_obs_thresh.clear(); - out_cnt_logic = SetLogic_Union; + out_cnt_logic = SetLogic::Union; out_fcst_wind_thresh.clear(); out_obs_wind_thresh.clear(); - out_wind_logic = SetLogic_Union; + out_wind_logic = SetLogic::Union; out_alpha = bad_data_double; boot_interval = bad_data_int; @@ -942,7 +942,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // thresh_logic // - if(thresh_logic != SetLogic_None && + if(thresh_logic != SetLogic::None && thresh_logic != L.thresh_logic()) return 0; // @@ -2567,7 +2567,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // thresh_logic - if(thresh_logic != SetLogic_None) { + if(thresh_logic != SetLogic::None) { js << "-thresh_logic " << setlogic_to_string(thresh_logic) << " "; } diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 96ee2fc103..e88ba5b1d8 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -305,7 +305,7 @@ class STATAnalysisJob { // // Type of bootstrap confidence interval method: - // 0 = BCa, 1 = Percentile (Default = 1) + // 0 = BCA, 1 = Percentile (Default = 1) // int boot_interval; diff --git a/src/libcode/vx_analysis_util/stat_line.cc b/src/libcode/vx_analysis_util/stat_line.cc index a8f869fa74..9ea8949eda 100644 --- a/src/libcode/vx_analysis_util/stat_line.cc +++ b/src/libcode/vx_analysis_util/stat_line.cc @@ -829,14 +829,14 @@ SetLogic STATLine::thresh_logic() const { -SetLogic t = SetLogic_None; +SetLogic t = SetLogic::None; ConcatString cs = (string)get_item("FCST_THRESH", false); - if(cs.endswith(setlogic_symbol_union)) t = SetLogic_Union; -else if(cs.endswith(setlogic_symbol_intersection)) t = SetLogic_Intersection; -else if(cs.endswith(setlogic_symbol_symdiff)) t = SetLogic_SymDiff; -else t = SetLogic_None; + if(cs.endswith(setlogic_symbol_union)) t = SetLogic::Union; +else if(cs.endswith(setlogic_symbol_intersection)) t = SetLogic::Intersection; +else if(cs.endswith(setlogic_symbol_symdiff)) t = SetLogic::SymDiff; +else t = SetLogic::None; return t; diff --git a/src/libcode/vx_nc_util/write_netcdf.cc b/src/libcode/vx_nc_util/write_netcdf.cc index 0f141ac50e..6a747cf7df 100644 --- a/src/libcode/vx_nc_util/write_netcdf.cc +++ b/src/libcode/vx_nc_util/write_netcdf.cc @@ -228,12 +228,12 @@ void write_netcdf_grid_weight(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, switch(t) { - case GridWeightType_Cos_Lat: + case GridWeightType::Cos_Lat: add_att(&wgt_var, long_name_att_name, "cosine latitude grid weight"); add_att(&wgt_var, units_att_name, "NA"); break; - case GridWeightType_Area: + case GridWeightType::Area: add_att(&wgt_var, long_name_att_name, "true area grid weight"); add_att(&wgt_var, units_att_name, "km^2"); break; diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index e0fc008464..06b767f579 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -916,12 +916,12 @@ void ModeFuzzyEngine::do_fcst_merging(const char *default_config, if(!need_fcst_merge) return; - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Thresh) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Thresh) do_fcst_merge_thresh(); - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Engine) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Engine) do_fcst_merge_engine(default_config, merge_config); // @@ -944,12 +944,12 @@ void ModeFuzzyEngine::do_obs_merging(const char *default_config, if(!need_obs_merge) return; - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Thresh) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Thresh) do_obs_merge_thresh(); - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Engine) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Engine) do_obs_merge_engine(default_config, merge_config); // @@ -978,12 +978,12 @@ void ModeFuzzyEngine::do_fcst_merging(const ShapeData &merge_data) exit(1); } - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Thresh) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Thresh) do_fcst_merge_thresh(merge_data); - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Engine) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Engine) do_fcst_merge_engine("", ""); // @@ -1012,12 +1012,12 @@ void ModeFuzzyEngine::do_obs_merging(const ShapeData &merge_data) exit(1); } - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Thresh) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Thresh) do_obs_merge_thresh(merge_data); - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Engine) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Engine) do_obs_merge_engine("", ""); // @@ -1037,23 +1037,23 @@ void ModeFuzzyEngine::do_matching() { if(!need_match) return; - if(conf_info.match_flag == MatchType_None) { + if(conf_info.match_flag == MatchType::None) { mlog << Warning << "\nModeFuzzyEngine::do_matching() -> " << "no matching requested in configuration file\n\n"; do_no_match(); } - else if(conf_info.match_flag == MatchType_MergeBoth) { + else if(conf_info.match_flag == MatchType::MergeBoth) { do_match_merge(); } - else if(conf_info.match_flag == MatchType_MergeFcst) { + else if(conf_info.match_flag == MatchType::MergeFcst) { do_match_fcst_merge(); } - else if(conf_info.match_flag == MatchType_NoMerge) { + else if(conf_info.match_flag == MatchType::NoMerge) { do_match_only(); } else { mlog << Error << "\nModeFuzzyEngine::do_matching() -> " - << "invalid match_flag value of " << conf_info.match_flag + << "invalid match_flag value of " << enum_class_as_integer(conf_info.match_flag) << " specified.\n\n"; exit(1); } @@ -2928,9 +2928,9 @@ double interest_percentile(ModeFuzzyEngine &eng, const double p, const int flag) double *v = (double *) nullptr; NumArray fcst_na, obs_na; - if(eng.conf_info.match_flag == 0 || - eng.n_fcst == 0 || - eng.n_obs == 0) return 0.0; + if(eng.conf_info.match_flag == MatchType::None || + eng.n_fcst == 0 || + eng.n_obs == 0) return 0.0; // // Initialize the maximum interest value for each object to zero. @@ -3079,7 +3079,7 @@ for (x=0; x<(grid.nx()); ++x) { // // If no matching was requested, don't write any more // - if(eng.conf_info.match_flag == 0) return; + if(eng.conf_info.match_flag == MatchType::None) return; // // Object pairs, increment the counter within the subroutine diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index c037fd4b0e..a46d678289 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -192,7 +192,7 @@ void ModeConfInfo::clear() desc.clear(); obtype.clear(); - mask_missing_flag = FieldType_None; + mask_missing_flag = FieldType::None; grid_res = bad_data_double; @@ -202,15 +202,15 @@ void ModeConfInfo::clear() fcst_multivar_logic.clear(); obs_multivar_logic.clear(); - match_flag = MatchType_None; + match_flag = MatchType::None; max_centroid_dist = bad_data_double; mask_grid_name.clear(); - mask_grid_flag = FieldType_None; + mask_grid_flag = FieldType::None; mask_poly_name.clear(); - mask_poly_flag = FieldType_None; + mask_poly_flag = FieldType::None; centroid_dist_wt = bad_data_double; boundary_dist_wt = bad_data_double; @@ -412,7 +412,7 @@ void ModeConfInfo::process_config_except_fields() // Check that the sum of the weights is non-zero for matching - if(match_flag != MatchType_None && + if(match_flag != MatchType::None && is_eq(centroid_dist_wt + boundary_dist_wt + convex_hull_dist_wt + angle_diff_wt + aspect_diff_wt + area_ratio_wt + @@ -850,7 +850,7 @@ void ModeConfInfo::evaluate_fcst_settings(int j) if ( fcst_array[j].merge_thresh_array.n_elements() == 1 ) fcst_array[j].merge_thresh = fcst_array[j].merge_thresh_array[0]; - if(match_flag == MatchType_None && fcst_array[j].merge_flag != MergeType_None) { + if(match_flag == MatchType::None && fcst_array[j].merge_flag != MergeType::None) { mlog << Warning << "\nModeConfInfo::evaluate_fcst_settings(" << j << ") -> " << "When matching is disabled (match_flag = " << matchtype_to_string(match_flag) @@ -903,7 +903,7 @@ void ModeConfInfo::evaluate_obs_settings(int j) if ( obs_array[j].merge_thresh_array.n_elements() == 1 ) obs_array[j].merge_thresh = obs_array[j].merge_thresh_array[0]; // Check that match_flag is set between 0 and 3 - if(match_flag == MatchType_None && obs_array[j].merge_flag != MergeType_None) { + if(match_flag == MatchType::None && obs_array[j].merge_flag != MergeType::None) { mlog << Warning << "\nModeConfInfo::evaluate_obs_settings(" << j << ") -> " << "When matching is disabled (match_flag = " << matchtype_to_string(match_flag) @@ -1735,7 +1735,7 @@ void ModeConfInfo::check_multivar_not_implemented() for (int i=0; ilookup(conf_key_vld_thresh) ) { if ( _multivar ) { // set defaults to no merging merge_thresh.clear(); - merge_flag = MergeType_None; + merge_flag = MergeType::None; // pull out the name string name = var_info->name(); @@ -286,7 +286,7 @@ if ( _multivar ) { // because that is inconsistent merge_thresh_array = dict->lookup_thresh_array(conf_key_merge_thresh); - if (merge_flag != MergeType_None) { + if (merge_flag != MergeType::None) { mlog << Error << "\nMode_Field_Info::set() -> " << "Field:" << name << ". " << " When 'merge_flag' is explicitly set, 'merge_thresh' must be explicitly set for multivariate mode\n\n"; @@ -310,7 +310,7 @@ if ( _multivar ) { // individual entry doesn't have a merge_thresh, parent has a merge_flag // expect parent to have a merge_thresh merge_thresh_array = dict->lookup_thresh_array(conf_key_merge_thresh); - if (merge_thresh_array.n() == 0 && merge_flag != MergeType_None) { + if (merge_thresh_array.n() == 0 && merge_flag != MergeType::None) { // parent has a merge_flag but no merge_thresh mlog << Error << "\nMode_Field_Info::set() -> " << "Field:" << name << ". using parent merge_flag: " << merge_name @@ -403,7 +403,7 @@ bool Mode_Field_Info::need_merge_thresh () const { -bool status = (merge_flag == MergeType_Both) || (merge_flag == MergeType_Thresh); +bool status = (merge_flag == MergeType::Both) || (merge_flag == MergeType::Thresh); return status; diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 55aded1e28..896d347ad4 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -536,7 +536,7 @@ void write_fho_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -547,7 +547,7 @@ void write_fho_row(StatHdrColumns &shc, const CTSInfo &cts_info, write_fho_cols(cts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -575,7 +575,7 @@ void write_ctc_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -586,7 +586,7 @@ void write_ctc_row(StatHdrColumns &shc, const CTSInfo &cts_info, write_ctc_cols(cts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -615,7 +615,7 @@ void write_cts_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); // Write a line for each alpha value @@ -631,7 +631,7 @@ void write_cts_row(StatHdrColumns &shc, const CTSInfo &cts_info, write_cts_cols(cts_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -660,7 +660,7 @@ void write_mctc_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, shc.set_obs_thresh(mcts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -671,7 +671,7 @@ void write_mctc_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, write_mctc_cols(mcts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -700,7 +700,7 @@ void write_mcts_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, shc.set_obs_thresh(mcts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); // Write a line for each alpha value @@ -716,7 +716,7 @@ void write_mcts_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, write_mcts_cols(mcts_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -767,7 +767,7 @@ void write_cnt_row(StatHdrColumns &shc, const CNTInfo &cnt_info, write_cnt_cols(cnt_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -815,7 +815,7 @@ void write_sl1l2_row(StatHdrColumns &shc, const SL1L2Info &sl1l2_info, write_sl1l2_cols(sl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -862,7 +862,7 @@ void write_sal1l2_row(StatHdrColumns &shc, const SL1L2Info &sl1l2_info, write_sal1l2_cols(sl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -904,7 +904,7 @@ void write_vl1l2_row(StatHdrColumns &shc, const VL1L2Info &vl1l2_info, write_vl1l2_cols(vl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -943,7 +943,7 @@ void write_val1l2_row(StatHdrColumns &shc, const VL1L2Info &vl1l2_info, write_val1l2_cols(vl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -988,7 +988,7 @@ void write_vcnt_row(StatHdrColumns &shc, const VL1L2Info &vcnt_info, write_vcnt_cols(vcnt_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1019,7 +1019,7 @@ void write_pct_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1037,7 +1037,7 @@ void write_pct_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_pct_cols(pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1070,7 +1070,7 @@ void write_pstd_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1091,7 +1091,7 @@ void write_pstd_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_pstd_cols(pct_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1124,7 +1124,7 @@ void write_pjc_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1142,7 +1142,7 @@ void write_pjc_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_pjc_cols(pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1174,7 +1174,7 @@ void write_prc_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1192,7 +1192,7 @@ void write_prc_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_prc_cols(pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1223,7 +1223,7 @@ void write_eclv_row(StatHdrColumns &shc, const PCTInfo &pct_info, // Set the threshold columns, if requested. shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); // Not Applicable @@ -1247,7 +1247,7 @@ void write_eclv_row(StatHdrColumns &shc, const PCTInfo &pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1280,7 +1280,7 @@ void write_eclv_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -1292,7 +1292,7 @@ void write_eclv_row(StatHdrColumns &shc, const CTSInfo &cts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1323,7 +1323,7 @@ void write_nbrctc_row(StatHdrColumns &shc, const NBRCTSInfo &nbrcts_info, shc.set_cov_thresh(nbrcts_info.cthresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); // Write the header columns @@ -1333,7 +1333,7 @@ void write_nbrctc_row(StatHdrColumns &shc, const NBRCTSInfo &nbrcts_info, write_nbrctc_cols(nbrcts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1365,7 +1365,7 @@ void write_nbrcts_row(StatHdrColumns &shc, const NBRCTSInfo &nbrcts_info, shc.set_cov_thresh(nbrcts_info.cthresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); // Write a line for each alpha value for(i=0; i map_val; // Storage for single obs values diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index c2178687ce..173aa68d76 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -1634,7 +1634,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, // bias correction, if requested if(obs_error_info->flag) { obs_v = add_obs_error_bc(obs_error_info->rng_ptr, - FieldType_Obs, oerr_ptr, obs_v); + FieldType::Obs, oerr_ptr, obs_v); } // Look through all of the PairData objects to see if the observation @@ -1844,7 +1844,7 @@ void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { // Apply observation error perturbation, if requested if(obs_error_info->flag) { fcst_v = add_obs_error_inc( - obs_error_info->rng_ptr, FieldType_Fcst, + obs_error_info->rng_ptr, FieldType::Fcst, pd[i][j][k].obs_error_entry[l], pd[i][j][k].o_na[l], fcst_na[m]); } @@ -1891,7 +1891,7 @@ void VxPairDataEnsemble::set_duplicate_flag(DuplicateType duplicate_flag) { for(int i=0; i < n_msg_typ; i++){ for(int j=0; j < n_mask; j++){ for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType_Unique); + pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType::Unique); } } } diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 2b19b94391..0a99b81d0c 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -1429,7 +1429,7 @@ void VxPairDataPoint::set_duplicate_flag(DuplicateType duplicate_flag) { for(int i=0; i < n_msg_typ; i++){ for(int j=0; j < n_mask; j++){ for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType_Unique); + pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType::Unique); } } } @@ -1592,25 +1592,25 @@ bool check_fo_thresh(double f, double o, double cmn, double csd, // If either of the thresholds is NA, reset the logic to intersection // because an NA threshold is always true. if(ft.get_type() == thresh_na || ot.get_type() == thresh_na) { - t = SetLogic_Intersection; + t = SetLogic::Intersection; } switch(t) { - case(SetLogic_Union): + case(SetLogic::Union): if(!fcheck && !ocheck) status = false; break; - case(SetLogic_Intersection): + case(SetLogic::Intersection): if(!fcheck || !ocheck) status = false; break; - case(SetLogic_SymDiff): + case(SetLogic::SymDiff): if(fcheck == ocheck) status = false; break; default: mlog << Error << "\ncheck_fo_thresh() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } diff --git a/src/libcode/vx_tc_util/diag_file.cc b/src/libcode/vx_tc_util/diag_file.cc index 2ea4fdeb3c..71cd94a81b 100644 --- a/src/libcode/vx_tc_util/diag_file.cc +++ b/src/libcode/vx_tc_util/diag_file.cc @@ -163,7 +163,7 @@ void DiagFile::init_from_scratch() { void DiagFile::clear() { // Initialize values - DiagSource = DiagType_None; + DiagSource = DiagType::None; TrackSource.clear(); FieldSource.clear(); StormId.clear(); @@ -215,10 +215,10 @@ void DiagFile::read(const ConcatString &path, const ConcatString &diag_source, DiagType type = string_to_diagtype(diag_source.c_str()); // Read diagnostics based on the source type - if(type == DiagType_CIRA_RT) { + if(type == DiagType::CIRA_RT) { read_cira_rt(path, convert_map); } - else if(type == DiagType_SHIPS_RT) { + else if(type == DiagType::SHIPS_RT) { read_ships_rt(path, convert_map); } else { @@ -249,7 +249,7 @@ void DiagFile::read_cira_rt(const ConcatString &path, clear(); // Store the file type - DiagSource = DiagType_CIRA_RT; + DiagSource = DiagType::CIRA_RT; // Open the file open(path.c_str()); @@ -399,7 +399,7 @@ void DiagFile::read_ships_rt(const ConcatString &path, clear(); // Store the file type - DiagSource = DiagType_SHIPS_RT; + DiagSource = DiagType::SHIPS_RT; // Open the file open(path.c_str()); diff --git a/src/libcode/vx_tc_util/track_info.cc b/src/libcode/vx_tc_util/track_info.cc index a6c411c572..c287d47f9a 100644 --- a/src/libcode/vx_tc_util/track_info.cc +++ b/src/libcode/vx_tc_util/track_info.cc @@ -91,7 +91,7 @@ void TrackInfo::clear() { MaxValidTime = (unixtime) 0; MinWarmCore = (unixtime) 0; MaxWarmCore = (unixtime) 0; - DiagSource = DiagType_None; + DiagSource = DiagType::None; TrackSource.clear(); FieldSource.clear(); DiagName.clear(); diff --git a/src/libcode/vx_tc_util/track_pair_info.cc b/src/libcode/vx_tc_util/track_pair_info.cc index 37e92621e5..8206db0bc7 100644 --- a/src/libcode/vx_tc_util/track_pair_info.cc +++ b/src/libcode/vx_tc_util/track_pair_info.cc @@ -473,7 +473,7 @@ void TrackPairInfo::add_tcdiag_line(const TCStatLine &l) { // Make sure DIAG_SOURCE does not change DiagType diag_source = string_to_diagtype(l.get_item("DIAG_SOURCE")); - if(ADeck.diag_source() != DiagType_None && + if(ADeck.diag_source() != DiagType::None && ADeck.diag_source() != diag_source) { mlog << Error << "\nTrackPairInfo::add_tcdiag_line() -> " << "the diagnostic source type has changed (" @@ -642,7 +642,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, int acur, aprv, bcur, bprv; // Nothing to do. - if(track_type == TrackType_None) return 0; + if(track_type == TrackType::None) return 0; // Check threshold type for non-exact intensity differences. if(!exact_adeck && @@ -751,7 +751,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, // Print debug message when rapid intensification is found if(is_eq(ADeckRIRW[i], 1.0) && - (track_type == TrackType_ADeck || track_type == TrackType_Both)) { + (track_type == TrackType::ADeck || track_type == TrackType::Both)) { mlog << Debug(4) << "Found ADECK RI/RW: " << case_info() << ", VALID = " << unix_to_yyyymmdd_hhmmss(ADeck[i].valid()) << ", " @@ -762,7 +762,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, << acur - aprv << st_adeck.get_str() << "\n"; } if(is_eq(BDeckRIRW[i], 1.0) && - (track_type == TrackType_BDeck || track_type == TrackType_Both)) { + (track_type == TrackType::BDeck || track_type == TrackType::Both)) { mlog << Debug(4) << "Found BDECK RI/RW: " << case_info() << ", VALID = " << unix_to_yyyymmdd_hhmmss(BDeck[i].valid()) << ", " @@ -777,9 +777,9 @@ int TrackPairInfo::check_rirw(const TrackType track_type, if(!Keep[i]) continue; // Update the keep status - if((track_type == TrackType_ADeck && !is_eq(ADeckRIRW[i], 1.0)) || - (track_type == TrackType_BDeck && !is_eq(BDeckRIRW[i], 1.0)) || - (track_type == TrackType_Both && !is_eq(ADeckRIRW[i], 1.0) && !is_eq(BDeckRIRW[i], 1.0))) { + if((track_type == TrackType::ADeck && !is_eq(ADeckRIRW[i], 1.0)) || + (track_type == TrackType::BDeck && !is_eq(BDeckRIRW[i], 1.0)) || + (track_type == TrackType::Both && !is_eq(ADeckRIRW[i], 1.0) && !is_eq(BDeckRIRW[i], 1.0))) { Keep.set(i, 0); n_rej++; } diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 73204c02f9..6a069322d6 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -517,7 +517,7 @@ void process_grid(const Grid &fcst_grid) { ri = conf_info.vx_opt[0].vx_pd.fcst_info->get_var_info()->regrid(); // Read gridded observation data, if necessary - if(ri.field == FieldType_Obs) { + if(ri.field == FieldType::Obs) { if(!grid_obs_flag) { mlog << Error << "\nprocess_grid() -> " @@ -1493,13 +1493,13 @@ void process_grid_vx() { shc.set_interp_wdth(wdth); // Smooth the ensemble mean field, if requested - if(field == FieldType_Fcst || field == FieldType_Both) { + if(field == FieldType::Fcst || field == FieldType::Both) { emn_dp = smooth_field(emn_dp, mthd, wdth, shape, grid.wrap_lon(), vld_thresh, gaussian); } // Smooth the observation field, if requested - if(field == FieldType_Obs || field == FieldType_Both) { + if(field == FieldType::Obs || field == FieldType::Both) { obs_dp = smooth_field(obs_dp, mthd, wdth, shape, grid.wrap_lon(), vld_thresh, gaussian); } @@ -1513,7 +1513,7 @@ void process_grid_vx() { << "Applying observation error bias correction to " << "gridded observation data.\n"; obs_dp = add_obs_error_bc(conf_info.rng_ptr, - FieldType_Obs, oerr_ptr, oraw_dp, oraw_dp, + FieldType::Obs, oerr_ptr, oraw_dp, oraw_dp, conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), conf_info.obtype.c_str()); } @@ -1522,7 +1522,7 @@ void process_grid_vx() { for(k=0; k < conf_info.vx_opt[i].vx_pd.fcst_info->inputs_n(); k++) { // Smooth the forecast field, if requested - if(field == FieldType_Fcst || field == FieldType_Both) { + if(field == FieldType::Fcst || field == FieldType::Both) { fcst_dp[k] = smooth_field(fcst_dp[k], mthd, wdth, shape, grid.wrap_lon(), vld_thresh, gaussian); } @@ -1538,7 +1538,7 @@ void process_grid_vx() { << "Applying observation error perturbation to " << "ensemble member " << k+1 << ".\n"; fcst_dp[k] = add_obs_error_inc(conf_info.rng_ptr, - FieldType_Fcst, oerr_ptr, fraw_dp[k], oraw_dp, + FieldType::Fcst, oerr_ptr, fraw_dp[k], oraw_dp, conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), conf_info.obtype.c_str()); } @@ -1719,7 +1719,7 @@ void do_ecnt(const EnsembleStatVxOpt &vx_opt, ecnt_info.set(*pd_ptr); // Write out ECNT - if(vx_opt.output_flag[i_ecnt] != STATOutputType_None && + if(vx_opt.output_flag[i_ecnt] != STATOutputType::None && ecnt_info.n_pair > 0) { write_ecnt_row(shc, ecnt_info, vx_opt.output_flag[i_ecnt], stat_at, i_stat_row, @@ -1756,7 +1756,7 @@ void do_rps(const EnsembleStatVxOpt &vx_opt, rps_info.set(*pd_ptr); // Write out RPS - if(vx_opt.output_flag[i_rps] != STATOutputType_None && + if(vx_opt.output_flag[i_rps] != STATOutputType::None && rps_info.n_pair > 0) { write_rps_row(shc, rps_info, vx_opt.output_flag[i_rps], stat_at, i_stat_row, @@ -1878,7 +1878,7 @@ void setup_txt_files() { for(i=0; i 1 && (type_cs != "OBS" || - conf_info.vx_opt[i_vx].interp_info.field == FieldType_Obs || - conf_info.vx_opt[i_vx].interp_info.field == FieldType_Both)) { + conf_info.vx_opt[i_vx].interp_info.field == FieldType::Obs || + conf_info.vx_opt[i_vx].interp_info.field == FieldType::Both)) { var_name << "_" << mthd_str << "_" << wdth*wdth; name_str << "_" << mthd_str << "_" << wdth*wdth; } @@ -2739,7 +2739,7 @@ void finish_txt_files() { for(i=0; ifield == FieldType_Fcst || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Fcst || + interp->field == FieldType::Both) { smooth_field(fcst_dp, fcst_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), interp->vld_thresh, interp->gaussian); @@ -855,8 +855,8 @@ void process_scores() { } // If requested in the config file, smooth the observation field - if(interp->field == FieldType_Obs || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Obs || + interp->field == FieldType::Both) { smooth_field(obs_dp, obs_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), interp->vld_thresh, interp->gaussian); @@ -910,10 +910,10 @@ void process_scores() { // Compute CTS scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcat_ta.n() > 0 && - (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { // Initialize for(m=0; m 0) { write_fho_row(shc, cts_info[m], @@ -935,7 +935,7 @@ void process_scores() { } // Write out CTC - if(conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None && cts_info[m].cts.n() > 0) { write_ctc_row(shc, cts_info[m], @@ -945,7 +945,7 @@ void process_scores() { } // Write out CTS - if(conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None && cts_info[m].cts.n() > 0) { write_cts_row(shc, cts_info[m], @@ -955,7 +955,7 @@ void process_scores() { } // Write out ECLV - if(conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None && cts_info[m].cts.n() > 0) { write_eclv_row(shc, cts_info[m], conf_info.vx_opt[i].eclv_points, @@ -969,8 +969,8 @@ void process_scores() { // Compute MCTS scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcat_ta.n() > 1 && - (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None)) { // Initialize mcts_info.clear(); @@ -979,7 +979,7 @@ void process_scores() { do_mcts(mcts_info, i, &pd); // Write out MCTC - if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mctc_row(shc, mcts_info, @@ -989,7 +989,7 @@ void process_scores() { } // Write out MCTS - if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mcts_row(shc, mcts_info, @@ -1001,9 +1001,9 @@ void process_scores() { // Compute CNT, SL1L2, and SAL1L2 scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { do_cnt_sl1l2(conf_info.vx_opt[i], &pd); } @@ -1011,9 +1011,9 @@ void process_scores() { if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcst_info->is_v_wind() && conf_info.vx_opt[i].fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1045,8 +1045,8 @@ void process_scores() { // If requested in the config file, smooth the forecast // and climatology U-wind fields - if(interp->field == FieldType_Fcst || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Fcst || + interp->field == FieldType::Both) { smooth_field(fu_dp, fu_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), interp->vld_thresh, interp->gaussian); @@ -1058,8 +1058,8 @@ void process_scores() { // If requested in the config file, smooth the observation // U-wind field - if(interp->field == FieldType_Obs || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Obs || + interp->field == FieldType::Both) { smooth_field(ou_dp, ou_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), @@ -1082,7 +1082,7 @@ void process_scores() { for(m=0; m 0) { write_vl1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vl1l2], @@ -1091,7 +1091,7 @@ void process_scores() { } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && vl1l2_info[m].vacount > 0) { write_val1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_val1l2], @@ -1100,7 +1100,7 @@ void process_scores() { } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && vl1l2_info[m].vcount > 0) { write_vcnt_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vcnt], @@ -1120,11 +1120,11 @@ void process_scores() { // Compute PCT counts and scores if(conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { do_pct(conf_info.vx_opt[i], &pd); } @@ -1189,7 +1189,7 @@ void process_scores() { } // Write out the fields of requested SEEPS - if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType_None + if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType::None && conf_info.vx_opt[i].fcst_info->is_precipitation() && conf_info.vx_opt[i].obs_info->is_precipitation()) { SeepsAggScore seeps; @@ -1213,7 +1213,7 @@ void process_scores() { // Compute gradient statistics if requested in the config file if(!conf_info.vx_opt[i].fcst_info->is_prob() && - conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType_None) { + conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType::None) { // Allocate memory in one big chunk based on grid size DataPlane fgx_dp, fgy_dp, ogx_dp, ogy_dp; @@ -1268,7 +1268,7 @@ void process_scores() { pd_gx.o_na, pd_gy.o_na, pd_gx.wgt_na); // Write out GRAD - if(conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType::None && grad_info.total > 0) { write_grad_row(shc, grad_info, @@ -1301,7 +1301,7 @@ void process_scores() { // Compute distance map statistics if requested in the config file if(!conf_info.vx_opt[i].fcst_info->is_prob() && - conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType_None) { + conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType::None) { // Allocate memory in one big chunk based on grid size DataPlane fcst_dp_dmap, obs_dp_dmap; @@ -1412,7 +1412,7 @@ void process_scores() { pd.f_na, pd.o_na, pd_thr.f_na, pd_thr.o_na); // Write out DMAP - if(conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType::None && dmap_info.total > 0) { write_dmap_row(shc, dmap_info, @@ -1431,9 +1431,9 @@ void process_scores() { // Loop through and apply the Neighborhood methods for each of the // neighborhood widths if requested in the config file if(!conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType::None)) { // Pointer to current interpolation object NbrhdInfo * nbrhd = &conf_info.vx_opt[i].nbrhd_info; @@ -1479,8 +1479,8 @@ void process_scores() { } // Process the forecast data - if(nbrhd->field == FieldType_Fcst || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Fcst || + nbrhd->field == FieldType::Both) { // Compute fractional coverage field, if necessary. if(fcst_dp_smooth.is_empty() || @@ -1519,8 +1519,8 @@ void process_scores() { } // Process the observation data - if(nbrhd->field == FieldType_Obs || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Obs || + nbrhd->field == FieldType::Both) { // Compute fractional coverage field, if necessary. if(obs_dp_smooth.is_empty() || @@ -1562,13 +1562,13 @@ void process_scores() { mask_bad_data(mask_mp, fcst_dp_smooth); mask_bad_data(mask_mp, obs_dp_smooth); - if(nbrhd->field == FieldType_Fcst || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Fcst || + nbrhd->field == FieldType::Both) { mask_bad_data(mask_mp, fcst_dp_thresh); } - if(nbrhd->field == FieldType_Obs || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Obs || + nbrhd->field == FieldType::Both) { mask_bad_data(mask_mp, obs_dp_thresh); } @@ -1604,8 +1604,8 @@ void process_scores() { if(pd.f_na.n() == 0) continue; // Compute NBRCTS scores - if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType::None) { // Initialize for(n=0; n 0) { // Write out NBRCTC - if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType::None) { write_nbrctc_row(shc, nbrcts_info[n], conf_info.vx_opt[i].output_flag[i_nbrctc], @@ -1630,7 +1630,7 @@ void process_scores() { } // Write out NBRCTS - if(conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType::None) { write_nbrcts_row(shc, nbrcts_info[n], conf_info.vx_opt[i].output_flag[i_nbrcts], @@ -1642,7 +1642,7 @@ void process_scores() { } // end compute NBRCTS // Compute NBRCNT scores - if(conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType::None) { // Initialize nbrcnt_info.clear(); @@ -1651,7 +1651,7 @@ void process_scores() { // Write out NBRCNT if(nbrcnt_info.sl1l2_info.scount > 0 && - conf_info.vx_opt[i].output_flag[i_nbrcnt]) { + (STATOutputType::None!=conf_info.vx_opt[i].output_flag[i_nbrcnt])) { write_nbrcnt_row(shc, nbrcnt_info, conf_info.vx_opt[i].output_flag[i_nbrcnt], @@ -1670,12 +1670,12 @@ void process_scores() { } // end for m // If not computing fractional coverage, all finished with thresholds - if(nbrhd->field == FieldType_None) break; + if(nbrhd->field == FieldType::None) break; } // end for k // If not computing fractional coverage, all finished with neighborhood widths - if(nbrhd->field == FieldType_None) break; + if(nbrhd->field == FieldType::None) break; } // end for j } // end if @@ -1768,9 +1768,9 @@ void process_scores() { // Compute CNT, SL1L2, and SAL1L2 scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { do_cnt_sl1l2(conf_info.vx_opt[i], &pd); } @@ -1778,9 +1778,9 @@ void process_scores() { if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcst_info->is_v_wind() && conf_info.vx_opt[i].fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1850,7 +1850,7 @@ void process_scores() { for(m=0; m 0) { write_vl1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vl1l2], @@ -1859,7 +1859,7 @@ void process_scores() { } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && vl1l2_info[m].vacount > 0) { write_val1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_val1l2], @@ -1868,7 +1868,7 @@ void process_scores() { } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && vl1l2_info[m].vcount > 0) { write_vcnt_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vcnt], @@ -1894,18 +1894,18 @@ void process_scores() { // Write out the data fields if requested in the config file if(conf_info.vx_opt[i].nc_info.do_raw) { write_nc((string)"FCST", fcst_dp_smooth, i, shc.get_interp_mthd(), - bad_data_int, FieldType_Both); + bad_data_int, FieldType::Both); write_nc((string)"OBS", obs_dp_smooth, i, shc.get_interp_mthd(), - bad_data_int, FieldType_Both); + bad_data_int, FieldType::Both); } if(conf_info.vx_opt[i].nc_info.do_diff) { write_nc((string)"DIFF", subtract(fcst_dp_smooth, obs_dp_smooth), i, shc.get_interp_mthd(), bad_data_int, - FieldType_Both); + FieldType::Both); } if(conf_info.vx_opt[i].nc_info.do_climo && !cmn_dp_smooth.is_empty()) { write_nc((string)"CLIMO_MEAN", cmn_dp_smooth, i, shc.get_interp_mthd(), - bad_data_int, FieldType_Both); + bad_data_int, FieldType::Both); } } // end if @@ -1992,7 +1992,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cts, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } else { @@ -2000,7 +2000,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, cts_info, n_cts, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -2041,7 +2041,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } else { @@ -2049,7 +2049,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -2078,9 +2078,9 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Set flags - bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None); - bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType_None); + bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None); + bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType::None); bool precip_flag = (vx_opt.fcst_info->is_precipitation() && vx_opt.obs_info->is_precipitation()); @@ -2127,7 +2127,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_info[j].scount > 0) { write_sl1l2_row(shc, sl1l2_info[j], @@ -2138,7 +2138,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SAL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_info[j].sacount > 0) { write_sal1l2_row(shc, sl1l2_info[j], @@ -2180,7 +2180,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out CNT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_cnt] != STATOutputType_None && + vx_opt.output_flag[i_cnt] != STATOutputType::None && cnt_info[j].n > 0) { write_cnt_row(shc, cnt_info[j], @@ -2194,14 +2194,14 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { if(n_bin > 1) { // Compute SL1L2 climo CDF bin means - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None) { + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None) { SL1L2Info sl1l2_mean; compute_sl1l2_mean(sl1l2_info, n_bin, sl1l2_mean); // Write out SL1L2 - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_mean.scount > 0) { write_sl1l2_row(shc, sl1l2_mean, @@ -2211,7 +2211,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Write out SAL1L2 - if(vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_mean.sacount > 0) { write_sal1l2_row(shc, sl1l2_mean, @@ -2222,7 +2222,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute CNT climo CDF bin means - if(vx_opt.output_flag[i_cnt] != STATOutputType_None) { + if(vx_opt.output_flag[i_cnt] != STATOutputType::None) { CNTInfo cnt_mean; compute_cnt_mean(cnt_info, n_bin, cnt_mean); @@ -2339,14 +2339,14 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(pd, vx_opt.output_flag[i_pstd], pct_info[j]); + compute_pctinfo(pd, ( STATOutputType::None!=vx_opt.output_flag[i_pstd]), pct_info[j]); // Check for no matched pairs to process if(pd.n_obs == 0) continue; // Write out PCT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pct] != STATOutputType_None) { + vx_opt.output_flag[i_pct] != STATOutputType::None) { write_pct_row(shc, pct_info[j], vx_opt.output_flag[i_pct], j, n_bin, stat_at, i_stat_row, @@ -2355,7 +2355,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PSTD if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pstd] != STATOutputType_None) { + vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_info[j], vx_opt.output_flag[i_pstd], j, n_bin, stat_at, i_stat_row, @@ -2364,7 +2364,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PJC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pjc] != STATOutputType_None) { + vx_opt.output_flag[i_pjc] != STATOutputType::None) { write_pjc_row(shc, pct_info[j], vx_opt.output_flag[i_pjc], j, n_bin, stat_at, i_stat_row, @@ -2373,7 +2373,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PRC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_prc] != STATOutputType_None) { + vx_opt.output_flag[i_prc] != STATOutputType::None) { write_prc_row(shc, pct_info[j], vx_opt.output_flag[i_prc], j, n_bin, stat_at, i_stat_row, @@ -2382,7 +2382,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out ECLV if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_eclv] != STATOutputType_None) { + vx_opt.output_flag[i_eclv] != STATOutputType::None) { write_eclv_row(shc, pct_info[j], vx_opt.eclv_points, vx_opt.output_flag[i_eclv], j, n_bin, stat_at, i_stat_row, @@ -2397,7 +2397,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { compute_pct_mean(pct_info, n_bin, pct_mean); // Write out PSTD - if(vx_opt.output_flag[i_pstd] != STATOutputType_None) { + if(vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_mean, vx_opt.output_flag[i_pstd], -1, n_bin, stat_at, i_stat_row, @@ -2427,7 +2427,7 @@ void do_nbrcts(NBRCTSInfo *&nbrcts_info, n_nbrcts = conf_info.vx_opt[i_vx].get_n_cov_thresh(); for(i=0; iis_prob() && - (output_flag[i_mctc] != STATOutputType_None || - output_flag[i_mcts] != STATOutputType_None)) { + (output_flag[i_mctc] != STATOutputType::None || + output_flag[i_mcts] != STATOutputType::None)) { check_mctc_thresh(fcat_ta); check_mctc_thresh(ocat_ta); } @@ -1049,7 +1049,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { } // Check if this output line type is requested - if(output_flag[i_txt_row] == STATOutputType_None) return 0; + if(output_flag[i_txt_row] == STATOutputType::None) return 0; bool prob_flag = fcst_info->is_prob(); bool vect_flag = (fcst_info->is_u_wind() && obs_info->is_u_wind()); diff --git a/src/tools/core/mode/mode_exec.cc b/src/tools/core/mode/mode_exec.cc index cd79fa029e..fde469e92f 100644 --- a/src/tools/core/mode/mode_exec.cc +++ b/src/tools/core/mode/mode_exec.cc @@ -362,14 +362,14 @@ void ModeExecutive::setup_traditional_fcst_obs_data() // Mask out the missing data between fields - if(engine.conf_info.mask_missing_flag == FieldType_Fcst || - engine.conf_info.mask_missing_flag == FieldType_Both) + if(engine.conf_info.mask_missing_flag == FieldType::Fcst || + engine.conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(Fcst_sd.data, Obs_sd.data); // Mask out the missing data between fields - if(engine.conf_info.mask_missing_flag == FieldType_Obs || - engine.conf_info.mask_missing_flag == FieldType_Both) + if(engine.conf_info.mask_missing_flag == FieldType::Obs || + engine.conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(Obs_sd.data, Fcst_sd.data); // Parse the grid and/or polyline masks from the configuration @@ -984,9 +984,9 @@ void ModeExecutive::do_merging_multivar(const ShapeData &f_merge, // set the merge flag and merge_thresh appropriately ModeConfInfo & conf = engine.conf_info; SingleThresh s("ne-9999"); - conf.set_fcst_merge_flag(MergeType_Thresh); + conf.set_fcst_merge_flag(MergeType::Thresh); conf.set_fcst_merge_thresh(s); - conf.set_obs_merge_flag(MergeType_Thresh); + conf.set_obs_merge_flag(MergeType::Thresh); conf.set_obs_merge_thresh(s); } else if (p != MULTIVAR_INTENSITY) { mlog << Error << "\nModeExecutive::do_merging(shapedata, shapedata, p) -> " @@ -1069,7 +1069,7 @@ void ModeExecutive::process_masks(ShapeData & fcst_sd, ShapeData & obs_sd) << "Processing masking regions.\n"; // Parse the grid mask into a ShapeData object - if(engine.conf_info.mask_grid_flag != FieldType_None) { + if(engine.conf_info.mask_grid_flag != FieldType::None) { mlog << Debug(3) << "Processing grid mask: " << engine.conf_info.mask_grid_name << "\n"; @@ -1078,7 +1078,7 @@ void ModeExecutive::process_masks(ShapeData & fcst_sd, ShapeData & obs_sd) } // Parse the poly mask into a ShapeData object - if(engine.conf_info.mask_poly_flag != FieldType_None) { + if(engine.conf_info.mask_poly_flag != FieldType::None) { mlog << Debug(3) << "Processing poly mask: " << engine.conf_info.mask_poly_name << "\n"; @@ -1087,26 +1087,26 @@ void ModeExecutive::process_masks(ShapeData & fcst_sd, ShapeData & obs_sd) } // Apply the grid mask to the forecast field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Fcst || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Fcst || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(fcst_sd, grid_mask_sd); } // Apply the grid mask to the observation field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Obs || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Obs || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(obs_sd, grid_mask_sd); } // Apply the polyline mask to the forecast field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Fcst || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Fcst || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(fcst_sd, poly_mask_sd); } // Apply the polyline mask to the observation field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Obs || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Obs || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(obs_sd, poly_mask_sd); } @@ -1125,7 +1125,7 @@ void ModeExecutive::process_fcst_masks(ShapeData & fcst_sd) mlog << Debug(3) << "Processing masking regions.\n"; // Parse the grid mask into a ShapeData object - if(engine.conf_info.mask_grid_flag != FieldType_None) { + if(engine.conf_info.mask_grid_flag != FieldType::None) { mlog << Debug(3) << "Processing grid mask: " << engine.conf_info.mask_grid_name << "\n"; @@ -1134,7 +1134,7 @@ void ModeExecutive::process_fcst_masks(ShapeData & fcst_sd) } // Parse the poly mask into a ShapeData object - if(engine.conf_info.mask_poly_flag != FieldType_None) { + if(engine.conf_info.mask_poly_flag != FieldType::None) { mlog << Debug(3) << "Processing poly mask: " << engine.conf_info.mask_poly_name << "\n"; @@ -1143,14 +1143,14 @@ void ModeExecutive::process_fcst_masks(ShapeData & fcst_sd) } // Apply the grid mask to the forecast field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Fcst || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Fcst || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(fcst_sd, grid_mask_sd); } // Apply the polyline mask to the forecast field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Fcst || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Fcst || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(fcst_sd, poly_mask_sd); } @@ -1170,7 +1170,7 @@ void ModeExecutive::process_obs_masks(ShapeData & obs_sd) << "Processing masking regions.\n"; // Parse the grid mask into a ShapeData object - if(engine.conf_info.mask_grid_flag != FieldType_None) { + if(engine.conf_info.mask_grid_flag != FieldType::None) { mlog << Debug(3) << "Processing grid mask: " << engine.conf_info.mask_grid_name << "\n"; @@ -1179,7 +1179,7 @@ void ModeExecutive::process_obs_masks(ShapeData & obs_sd) } // Parse the poly mask into a ShapeData object - if(engine.conf_info.mask_poly_flag != FieldType_None) { + if(engine.conf_info.mask_poly_flag != FieldType::None) { mlog << Debug(3) << "Processing poly mask: " << engine.conf_info.mask_poly_name << "\n"; @@ -1188,14 +1188,14 @@ void ModeExecutive::process_obs_masks(ShapeData & obs_sd) } // Apply the grid mask to the observation field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Obs || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Obs || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(obs_sd, grid_mask_sd); } // Apply the polyline mask to the observation field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Obs || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Obs || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(obs_sd, poly_mask_sd); } @@ -1548,8 +1548,8 @@ void ModeExecutive::write_obj_stats() out.close(); - if(engine.conf_info.Fcst->merge_flag == MergeType_Both || - engine.conf_info.Fcst->merge_flag == MergeType_Engine) { + if(engine.conf_info.Fcst->merge_flag == MergeType::Both || + engine.conf_info.Fcst->merge_flag == MergeType::Engine) { // // Create output stats file for forecast merging @@ -1580,8 +1580,8 @@ void ModeExecutive::write_obj_stats() out.close(); } - if(engine.conf_info.Obs->merge_flag == MergeType_Both || - engine.conf_info.Obs->merge_flag == MergeType_Engine) { + if(engine.conf_info.Obs->merge_flag == MergeType::Both || + engine.conf_info.Obs->merge_flag == MergeType::Engine) { // // Create output stats file for observation merging diff --git a/src/tools/core/mode/mode_ps_file.cc b/src/tools/core/mode/mode_ps_file.cc index dd80209b01..605fea24e5 100644 --- a/src/tools/core/mode/mode_ps_file.cc +++ b/src/tools/core/mode/mode_ps_file.cc @@ -554,25 +554,25 @@ void ModePsFile::make_plot(bool isMultivarSuper) plot_engine(*Engine, FOEng, s.c_str()); - if ( (fcst_merge_flag == MergeType_Both) || (fcst_merge_flag == MergeType_Thresh) ) { + if ( (fcst_merge_flag == MergeType::Both) || (fcst_merge_flag == MergeType::Thresh) ) { plot_threshold_merging(*Engine, "Forecast: Threshold Merging", 1); } - if ( (fcst_merge_flag == MergeType_Both) || (fcst_merge_flag == MergeType_Engine) ) { + if ( (fcst_merge_flag == MergeType::Both) || (fcst_merge_flag == MergeType::Engine) ) { plot_engine(*(Engine->fcst_engine), FFEng, "Forecast: ModeFuzzyEngine Merging"); } - if ( (obs_merge_flag == MergeType_Both) || (obs_merge_flag == MergeType_Thresh) ) { + if ( (obs_merge_flag == MergeType::Both) || (obs_merge_flag == MergeType::Thresh) ) { plot_threshold_merging(*Engine, "Observation: Threshold Merging", 0); } - if ( (obs_merge_flag == MergeType_Both) || (obs_merge_flag == MergeType_Engine) ) { + if ( (obs_merge_flag == MergeType::Both) || (obs_merge_flag == MergeType::Engine) ) { plot_engine(*(Engine->obs_engine), OOEng, "Observation: ModeFuzzyEngine Merging"); diff --git a/src/tools/core/mode/multivar_frontend.cc b/src/tools/core/mode/multivar_frontend.cc index efffb4deaa..8941780df3 100644 --- a/src/tools/core/mode/multivar_frontend.cc +++ b/src/tools/core/mode/multivar_frontend.cc @@ -350,14 +350,14 @@ MultivarFrontEnd::create_intensity_comparisons(int findex, int oindex, // from pass1 conf.Fcst->var_info->set_level_name(mvdf._level.c_str()); conf.Fcst->var_info->set_units(mvdf._units.c_str()); - if (fsuper._hasUnion && conf.Fcst->merge_flag == MergeType_Thresh) { + if (fsuper._hasUnion && conf.Fcst->merge_flag == MergeType::Thresh) { mlog << Warning << "\nModeFrontEnd::multivar_intensity_comparisons() -> " << "Logic includes union '||' along with 'merge_flag=THRESH' " << ". This can lead to bad results\n\n"; } conf.Obs->var_info->set_level_name(mvdo._level.c_str()); conf.Obs->var_info->set_units(mvdo._units.c_str()); - if (osuper._hasUnion && conf.Obs->merge_flag == MergeType_Thresh) { + if (osuper._hasUnion && conf.Obs->merge_flag == MergeType::Thresh) { mlog << Warning << "\nModeFrontEnd::multivar_intensity_comparisons() -> " << "Logic includes union '||' along with 'merge_flag=THRESH' " << ". This can lead to bad results\n\n"; @@ -395,8 +395,8 @@ void MultivarFrontEnd::process_superobjects(ModeSuperObject &fsuper, ModeConfInfo & conf = mode_exec->engine.conf_info; if ((fsuper._hasUnion || osuper._hasUnion) && - (conf.Fcst->merge_flag == MergeType_Thresh || - conf.Obs->merge_flag == MergeType_Thresh)) { + (conf.Fcst->merge_flag == MergeType::Thresh || + conf.Obs->merge_flag == MergeType::Thresh)) { mlog << Warning << "\nModeFrontEnd::run_super() -> " << "Logic includes union '||' along with 'merge_flag=THRESH' " << ". This can lead to bad results\n\n"; diff --git a/src/tools/core/mode/page_1.cc b/src/tools/core/mode/page_1.cc index 5a87e97424..74b757f734 100644 --- a/src/tools/core/mode/page_1.cc +++ b/src/tools/core/mode/page_1.cc @@ -690,26 +690,26 @@ void ModePsFile::do_page_1_FOEng(ModeFuzzyEngine & eng, EngineType eng_type, con // Mask missing, grid, and polyline Flags // // write_centered_text(1, 1, Htab_a, text_y, 0.0, 0.5, "Mask M/G/P:"); - if(eng.conf_info.mask_missing_flag == FieldType_Both || - eng.conf_info.mask_missing_flag == FieldType_Fcst) tmp1_str = "on"; + if(eng.conf_info.mask_missing_flag == FieldType::Both || + eng.conf_info.mask_missing_flag == FieldType::Fcst) tmp1_str = "on"; else tmp1_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Fcst) tmp2_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Fcst) tmp2_str = "on"; else tmp2_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Fcst) tmp3_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Fcst) tmp3_str = "on"; else tmp3_str = "off"; label << cs_erase << tmp1_str << '/' << tmp2_str << '/' << tmp3_str; t.write_xy1_to_cell(r, 1, dx, dy, 0.0, 0.0, label.c_str()); - if(eng.conf_info.mask_missing_flag == FieldType_Both || - eng.conf_info.mask_missing_flag == FieldType_Obs) tmp1_str = "on"; + if(eng.conf_info.mask_missing_flag == FieldType::Both || + eng.conf_info.mask_missing_flag == FieldType::Obs) tmp1_str = "on"; else tmp1_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Obs) tmp2_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Obs) tmp2_str = "on"; else tmp2_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Obs) tmp3_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Obs) tmp3_str = "on"; else tmp3_str = "off"; label << cs_erase << tmp1_str << '/' << tmp2_str << '/' << tmp3_str; t.write_xy1_to_cell(r, 2, dx, dy, 0.0, 0.0, label.c_str()); @@ -792,15 +792,15 @@ void ModePsFile::do_page_1_FOEng(ModeFuzzyEngine & eng, EngineType eng_type, con // Merging flag // - if(eng.conf_info.Fcst->merge_flag == MergeType_Thresh) label = "thresh"; - else if(eng.conf_info.Fcst->merge_flag == MergeType_Engine) label = "engine"; - else if(eng.conf_info.Fcst->merge_flag == MergeType_Both) label = "thresh/engine"; + if(eng.conf_info.Fcst->merge_flag == MergeType::Thresh) label = "thresh"; + else if(eng.conf_info.Fcst->merge_flag == MergeType::Engine) label = "engine"; + else if(eng.conf_info.Fcst->merge_flag == MergeType::Both) label = "thresh/engine"; else label = "none"; t.write_xy1_to_cell(r, 1, dx, dy, 0.0, 0.0, label.c_str()); - if(eng.conf_info.Obs->merge_flag == MergeType_Thresh) label = "thresh"; - else if(eng.conf_info.Obs->merge_flag == MergeType_Engine) label = "engine"; - else if(eng.conf_info.Obs->merge_flag == MergeType_Both) label = "thresh/engine"; + if(eng.conf_info.Obs->merge_flag == MergeType::Thresh) label = "thresh"; + else if(eng.conf_info.Obs->merge_flag == MergeType::Engine) label = "engine"; + else if(eng.conf_info.Obs->merge_flag == MergeType::Both) label = "thresh/engine"; else label = "none"; t.write_xy1_to_cell(r, 2, dx, dy, 0.0, 0.0, label.c_str()); @@ -811,9 +811,9 @@ void ModePsFile::do_page_1_FOEng(ModeFuzzyEngine & eng, EngineType eng_type, con // Matching scheme // - if(eng.conf_info.match_flag == MatchType_MergeBoth) label = "match/merge"; - else if(eng.conf_info.match_flag == MatchType_MergeFcst) label = "match/fcst merge"; - else if(eng.conf_info.match_flag == MatchType_NoMerge) label = "match/no merge"; + if(eng.conf_info.match_flag == MatchType::MergeBoth) label = "match/merge"; + else if(eng.conf_info.match_flag == MatchType::MergeFcst) label = "match/fcst merge"; + else if(eng.conf_info.match_flag == MatchType::NoMerge) label = "match/no merge"; else label = "none"; t.write_xy1_to_cell(r, 2, 0.0, dy, 0.5, 0.0, label.c_str()); diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index d950486015..80d16a6145 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -442,7 +442,7 @@ void setup_txt_files() { for(int i=0; iseeps); write_seeps_row(shc, &pd_ptr->seeps, conf_info.vx_opt[i].output_flag[i_seeps], @@ -1096,10 +1096,10 @@ void process_scores() { // Compute CTS scores if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].fcat_ta.n() > 0 && - (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { // Initialize for(m=0; mis_prob() && conf_info.vx_opt[i].fcat_ta.n() > 1 && - (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None)) { // Initialize mcts_info.clear(); @@ -1159,7 +1159,7 @@ void process_scores() { do_mcts(mcts_info, i, pd_ptr); // Write out MCTC - if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mctc_row(shc, mcts_info, @@ -1169,7 +1169,7 @@ void process_scores() { } // Write out MCTS - if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mcts_row(shc, mcts_info, @@ -1181,9 +1181,9 @@ void process_scores() { // Compute CNT, SL1L2, and SAL1L2 scores if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { do_cnt_sl1l2(conf_info.vx_opt[i], pd_ptr); } @@ -1191,9 +1191,9 @@ void process_scores() { if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].vx_pd.fcst_info->is_v_wind() && conf_info.vx_opt[i].vx_pd.fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1233,7 +1233,7 @@ void process_scores() { for(m=0; m 0) { write_vl1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vl1l2], @@ -1242,7 +1242,7 @@ void process_scores() { } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && vl1l2_info[m].vacount > 0) { write_val1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_val1l2], @@ -1251,7 +1251,7 @@ void process_scores() { } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && vl1l2_info[m].vcount > 0) { write_vcnt_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vcnt], @@ -1271,11 +1271,11 @@ void process_scores() { // Compute PCT counts and scores if(conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { do_pct(conf_info.vx_opt[i], pd_ptr); } @@ -1287,8 +1287,8 @@ void process_scores() { // Apply HiRA ensemble verification logic if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].hira_info.flag && - (conf_info.vx_opt[i].output_flag[i_ecnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_rps] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_ecnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_rps] != STATOutputType::None)) { pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][0]; @@ -1303,11 +1303,11 @@ void process_scores() { // Apply HiRA probabilistic verification logic if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].hira_info.flag && - (conf_info.vx_opt[i].output_flag[i_mpr] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_mpr] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None)) { pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][0]; @@ -1365,11 +1365,11 @@ void do_cts(CTSInfo *&cts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == boot_bca_flag) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cat, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1378,7 +1378,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, const PairDataPoint *pd_ptr) { conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, cts_info, n_cat, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1416,11 +1416,11 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == boot_bca_flag) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1429,7 +1429,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, const PairDataPoint *pd_ptr) { conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1458,9 +1458,9 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Set flags - bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None); - bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType_None); + bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None); + bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType::None); bool precip_flag = (vx_opt.vx_pd.fcst_info->is_precipitation() && vx_opt.vx_pd.obs_info->is_precipitation()); @@ -1507,7 +1507,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_info[j].scount > 0) { write_sl1l2_row(shc, sl1l2_info[j], @@ -1518,7 +1518,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SAL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_info[j].sacount > 0) { write_sal1l2_row(shc, sl1l2_info[j], @@ -1560,7 +1560,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out CNT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_cnt] != STATOutputType_None && + vx_opt.output_flag[i_cnt] != STATOutputType::None && cnt_info[j].n > 0) { write_cnt_row(shc, cnt_info[j], @@ -1574,14 +1574,14 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { if(n_bin > 1) { // Compute SL1L2 climo CDF bin means - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None) { + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None) { SL1L2Info sl1l2_mean; compute_sl1l2_mean(sl1l2_info, n_bin, sl1l2_mean); // Write out SL1L2 - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_mean.scount > 0) { write_sl1l2_row(shc, sl1l2_mean, @@ -1591,7 +1591,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Write out SAL1L2 - if(vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_mean.sacount > 0) { write_sal1l2_row(shc, sl1l2_mean, @@ -1602,7 +1602,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute CNT climo CDF bin means - if(vx_opt.output_flag[i_cnt] != STATOutputType_None) { + if(vx_opt.output_flag[i_cnt] != STATOutputType::None) { CNTInfo cnt_mean; compute_cnt_mean(cnt_info, n_bin, cnt_mean); @@ -1720,14 +1720,14 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(pd, vx_opt.output_flag[i_pstd], pct_info[j]); + compute_pctinfo(pd, (STATOutputType::None!=vx_opt.output_flag[i_pstd]), pct_info[j]); // Check for no matched pairs to process if(pd.n_obs == 0) continue; // Write out PCT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pct] != STATOutputType_None) { + vx_opt.output_flag[i_pct] != STATOutputType::None) { write_pct_row(shc, pct_info[j], vx_opt.output_flag[i_pct], j, n_bin, stat_at, i_stat_row, @@ -1736,7 +1736,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PSTD if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pstd] != STATOutputType_None) { + vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_info[j], vx_opt.output_flag[i_pstd], j, n_bin, stat_at, i_stat_row, @@ -1745,7 +1745,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PJC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pjc] != STATOutputType_None) { + vx_opt.output_flag[i_pjc] != STATOutputType::None) { write_pjc_row(shc, pct_info[j], vx_opt.output_flag[i_pjc], j, n_bin, stat_at, i_stat_row, @@ -1754,7 +1754,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PRC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_prc] != STATOutputType_None) { + vx_opt.output_flag[i_prc] != STATOutputType::None) { write_prc_row(shc, pct_info[j], vx_opt.output_flag[i_prc], j, n_bin, stat_at, i_stat_row, @@ -1763,7 +1763,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out ECLV if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_eclv] != STATOutputType_None) { + vx_opt.output_flag[i_eclv] != STATOutputType::None) { write_eclv_row(shc, pct_info[j], vx_opt.eclv_points, vx_opt.output_flag[i_eclv], j, n_bin, stat_at, i_stat_row, @@ -1778,7 +1778,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { compute_pct_mean(pct_info, n_bin, pct_mean); // Write out PSTD - if(vx_opt.output_flag[i_pstd] != STATOutputType_None) { + if(vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_mean, vx_opt.output_flag[i_pstd], -1, n_bin, stat_at, i_stat_row, @@ -1893,7 +1893,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { hira_pd.compute_pair_vals(rng_ptr); // Write out the ECNT line - if(conf_info.vx_opt[i_vx].output_flag[i_ecnt] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_ecnt] != STATOutputType::None) { // Compute ensemble statistics ECNTInfo ecnt_info; @@ -1906,7 +1906,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { } // end if ECNT // Write out the ORANK line - if(conf_info.vx_opt[i_vx].output_flag[i_orank] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_orank] != STATOutputType::None) { write_orank_row(shc, &hira_pd, conf_info.vx_opt[i_vx].output_flag[i_orank], @@ -1919,7 +1919,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { } // end if ORANK // Write out the RPS line - if(conf_info.vx_opt[i_vx].output_flag[i_rps] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_rps] != STATOutputType::None) { // Store ensemble RPS thresholds RPSInfo rps_info; @@ -2085,17 +2085,17 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(hira_pd, conf_info.vx_opt[i_vx].output_flag[i_pstd], + compute_pctinfo(hira_pd, (STATOutputType::None!=conf_info.vx_opt[i_vx].output_flag[i_pstd]), pct_info, &cmn_cov_na); // Set the contents of the output threshold columns shc.set_fcst_thresh (conf_info.vx_opt[i_vx].fcat_ta[i]); shc.set_obs_thresh (conf_info.vx_opt[i_vx].ocat_ta[i]); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh (na_str); // Write out the MPR lines - if(conf_info.vx_opt[i_vx].output_flag[i_mpr] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_mpr] != STATOutputType::None) { write_mpr_row(shc, &hira_pd, conf_info.vx_opt[i_vx].output_flag[i_mpr], stat_at, i_stat_row, @@ -2110,7 +2110,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { shc.set_cov_thresh(conf_info.vx_opt[i_vx].hira_info.cov_ta); // Write out PCT - if(conf_info.vx_opt[i_vx].output_flag[i_pct] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_pct] != STATOutputType::None) { write_pct_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_pct],1, 1, stat_at, i_stat_row, @@ -2118,7 +2118,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Write out PSTD - if(conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_pstd], 1, 1, stat_at, i_stat_row, @@ -2126,7 +2126,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Write out PJC - if(conf_info.vx_opt[i_vx].output_flag[i_pjc] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_pjc] != STATOutputType::None) { write_pjc_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_pjc], 1, 1, stat_at, i_stat_row, @@ -2134,7 +2134,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Write out PRC - if(conf_info.vx_opt[i_vx].output_flag[i_prc] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_prc] != STATOutputType::None) { write_prc_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_prc], 1, 1, stat_at, i_stat_row, @@ -2163,7 +2163,7 @@ void finish_txt_files() { for(i=0; iis_prob() && - (output_flag[i_mctc] != STATOutputType_None || - output_flag[i_mcts] != STATOutputType_None)) { + (output_flag[i_mctc] != STATOutputType::None || + output_flag[i_mcts] != STATOutputType::None)) { check_mctc_thresh(fcat_ta); check_mctc_thresh(ocat_ta); } @@ -1168,8 +1168,8 @@ void PointStatVxOpt::set_vx_pd(PointStatConfInfo *conf_info) { vx_pd.set_duplicate_flag(duplicate_flag); vx_pd.set_obs_summary(obs_summary); vx_pd.set_obs_perc_value(obs_perc); - if (output_flag[i_seeps_mpr] != STATOutputType_None - || output_flag[i_seeps] != STATOutputType_None) { + if (output_flag[i_seeps_mpr] != STATOutputType::None + || output_flag[i_seeps] != STATOutputType::None) { vx_pd.load_seeps_climo(); vx_pd.set_seeps_thresh(seeps_p1_thresh); } @@ -1223,7 +1223,7 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { } // Check if this output line type is requested - if(output_flag[i_txt_row] == STATOutputType_None) return 0; + if(output_flag[i_txt_row] == STATOutputType::None) return 0; bool prob_flag = vx_pd.fcst_info->is_prob(); bool vect_flag = vx_pd.fcst_info->is_v_wind() && diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.cc b/src/tools/core/series_analysis/series_analysis_conf_info.cc index 309f82d4c1..6e79c25863 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.cc +++ b/src/tools/core/series_analysis/series_analysis_conf_info.cc @@ -67,7 +67,7 @@ void SeriesAnalysisConfInfo::clear() { ocat_ta.clear(); fcnt_ta.clear(); ocnt_ta.clear(); - cnt_logic = SetLogic_None; + cnt_logic = SetLogic::None; cdf_info.clear(); ci_alpha.clear(); boot_interval = BootIntervalType_None; diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index 827662caf8..27d868d78b 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -401,13 +401,13 @@ void process_scores() { << " versus " << conf_info.obs_info[i]->magic_str() << ".\n"; // Mask out the missing data between fields - if(conf_info.mask_missing_flag == FieldType_Fcst || - conf_info.mask_missing_flag == FieldType_Both) + if(conf_info.mask_missing_flag == FieldType::Fcst || + conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(fcst_dp, obs_dp); // Mask out the missing data between fields - if(conf_info.mask_missing_flag == FieldType_Obs || - conf_info.mask_missing_flag == FieldType_Both) + if(conf_info.mask_missing_flag == FieldType::Obs || + conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(obs_dp, fcst_dp); // Get the fill data value to be used for each field @@ -426,7 +426,7 @@ void process_scores() { fill_bad_data(obs_dp_fill, obs_fill); // Pad the fields out to the nearest power of two if requested - if(conf_info.grid_decomp_flag == GridDecompType_Pad) { + if(conf_info.grid_decomp_flag == GridDecompType::Pad) { mlog << Debug(2) << "Padding the fields out to the nearest integer " << "power of two.\n"; pad_field(fcst_dp_fill, fcst_fill); @@ -459,7 +459,7 @@ void process_scores() { get_tile(fcst_dp_fill, obs_dp_fill, i, j, f_na, o_na); // Compute Intensity-Scale scores - if(conf_info.output_flag[i_isc] != STATOutputType_None) { + if(conf_info.output_flag[i_isc] != STATOutputType::None) { // Do the intensity-scale decomposition do_intensity_scale(f_na, o_na, isc_info[j], i, j); @@ -599,7 +599,7 @@ void setup_txt_files(unixtime valid_ut, int lead_sec) { // ///////////////////////////////////////////////////////////////////// - if(conf_info.output_flag[i_isc] != STATOutputType_None) { + if(conf_info.output_flag[i_isc] != STATOutputType::None) { // Initialize file stream @@ -1887,7 +1887,7 @@ void close_out_files() { // Write out the contents of the ISC AsciiTable and // close the ISC output files - if(conf_info.output_flag[i_isc] == STATOutputType_Both) { + if(conf_info.output_flag[i_isc] == STATOutputType::Both) { if(isc_out) { *isc_out << isc_at; close_txt_file(isc_out, isc_file.c_str()); @@ -2745,7 +2745,7 @@ void draw_tiles(PSfile *p, Box &dim, for(i=tile_start; i<=tile_end; i++) { // If padding was performed, the tile is the size of the domain - if(conf_info.grid_decomp_flag == GridDecompType_Pad) { + if(conf_info.grid_decomp_flag == GridDecompType::Pad) { tile_bb = dim; } // Find the lower-left and upper-right corners of the tile diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index 4529fe0423..f8ad83eb9a 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -72,13 +72,13 @@ void WaveletStatConfInfo::clear() { model.clear(); desc.clear(); obtype.clear(); - mask_missing_flag = FieldType_None; - grid_decomp_flag = GridDecompType_None; + mask_missing_flag = FieldType::None; + grid_decomp_flag = GridDecompType::None; tile_dim = 0; tile_xll.clear(); tile_yll.clear(); pad_bb.set_llwh(0.0, 0.0, 0.0, 0.0); - wvlt_type = WaveletType_None; + wvlt_type = WaveletType::None; // nc_pairs_flag = false; nc_info.set_all_true(); ps_plot_flag = false; @@ -86,7 +86,7 @@ void WaveletStatConfInfo::clear() { output_prefix.clear(); version.clear(); - for(i=0; i " - << "Unsupported wavelet type value of " << wvlt_type << ".\n\n"; + << "Unsupported wavelet type value of " << enum_class_as_integer(wvlt_type) << ".\n\n"; exit(1); } @@ -349,8 +349,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, // Check for valid member number switch(wvlt_type) { - case(WaveletType_Haar): - case(WaveletType_Haar_Cntr): + case(WaveletType::Haar): + case(WaveletType::Haar_Cntr): if(wvlt_member != 2) { mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "For Haar wavelets, \"" << conf_key_wavelet_member @@ -359,8 +359,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType_Daub): - case(WaveletType_Daub_Cntr): + case(WaveletType::Daub): + case(WaveletType::Daub_Cntr): if(wvlt_member < 4 || wvlt_member > 20 || wvlt_member%2 == 1) { mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "For Daubechies wavelets, \"" << conf_key_wavelet_member @@ -369,8 +369,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType_BSpline): - case(WaveletType_BSpline_Cntr): + case(WaveletType::BSpline): + case(WaveletType::BSpline_Cntr): if(wvlt_member != 103 && wvlt_member != 105 && wvlt_member != 202 && wvlt_member != 204 && wvlt_member != 206 && wvlt_member != 208 && wvlt_member != 301 && wvlt_member != 303 && wvlt_member != 305 && @@ -383,10 +383,10 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType_None): + case(WaveletType::None): default: mlog << Error << "\nWaveletStatConfInfo::process_config() -> " - << "Unsupported wavelet type value of " << wvlt_type << ".\n\n"; + << "Unsupported wavelet type value of " << enum_class_as_integer(wvlt_type) << ".\n\n"; exit(1); } @@ -510,7 +510,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { // Tile the input data using tiles of dimension n by n where n // is the largest integer power of 2 less than the smallest // dimension of the input data and allowing no overlap. - case(GridDecompType_Auto): + case(GridDecompType::Auto): center_tiles(grid.nx(), grid.ny()); @@ -527,7 +527,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { break; // Apply the tiles specified in the configuration file - case(GridDecompType_Tile): + case(GridDecompType::Tile): // Number of tiles based on the user-specified locations n_tile = tile_xll.n(); @@ -546,7 +546,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { // Setup tiles for padding the input fields out to the nearest // integer power of two - case(GridDecompType_Pad): + case(GridDecompType::Pad): pad_tiles(grid.nx(), grid.ny()); @@ -561,11 +561,11 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { break; - case(GridDecompType_None): + case(GridDecompType::None): default: mlog << Error << "\nWaveletStatConfInfo::process_tiles() -> " << "Unsupported grid decomposition type of " - << grid_decomp_flag << ".\n\n"; + << enum_class_as_integer(grid_decomp_flag) << ".\n\n"; exit(1); } // end switch diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 36e54bb45e..4f1fbd4837 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -1347,17 +1347,17 @@ DataPlane combine(const DataPlane &dp_data, const DataPlane &dp_mask, switch(logic) { - case SetLogic_Union: + case SetLogic::Union: if(v_data || v_mask) v = mask_val; else v = 0.0; break; - case SetLogic_Intersection: + case SetLogic::Intersection: if(v_data && v_mask) v = mask_val; else v = 0.0; break; - case SetLogic_SymDiff: + case SetLogic::SymDiff: if((v_data && !v_mask) || (!v_data && v_mask)) v = mask_val; else v = 0.0; break; @@ -1380,10 +1380,10 @@ DataPlane combine(const DataPlane &dp_data, const DataPlane &dp_mask, } // end for x // List the number of points inside the mask - if(logic != SetLogic_None) { + if(logic != SetLogic::None) { mlog << Debug(3) << "Mask " << setlogic_to_string(logic) - << (logic == SetLogic_Intersection ? ":\t" : ":\t\t") + << (logic == SetLogic::Intersection ? ":\t" : ":\t\t") << n_in << " of " << grid.nx() * grid.ny() << " points inside\n"; } @@ -1703,19 +1703,19 @@ void set_complement(const StringArray & a) { //////////////////////////////////////////////////////////////////////// void set_union(const StringArray & a) { - set_logic = SetLogic_Union; + set_logic = SetLogic::Union; } //////////////////////////////////////////////////////////////////////// void set_intersection(const StringArray & a) { - set_logic = SetLogic_Intersection; + set_logic = SetLogic::Intersection; } //////////////////////////////////////////////////////////////////////// void set_symdiff(const StringArray & a) { - set_logic = SetLogic_SymDiff; + set_logic = SetLogic::SymDiff; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.h b/src/tools/other/gen_vx_mask/gen_vx_mask.h index 8ab03376a7..e6f985808c 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.h +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.h @@ -97,7 +97,7 @@ static bool type_is_set = false; // Optional arguments static ConcatString input_field_str, mask_field_str; -static SetLogic set_logic = SetLogic_None; +static SetLogic set_logic = SetLogic::None; static bool complement = false; static SingleThresh thresh; static int height = bad_data_double; diff --git a/src/tools/other/grid_diag/grid_diag.cc b/src/tools/other/grid_diag/grid_diag.cc index f804116648..87f263b68b 100644 --- a/src/tools/other/grid_diag/grid_diag.cc +++ b/src/tools/other/grid_diag/grid_diag.cc @@ -222,8 +222,8 @@ void process_command_line(int argc, char **argv) { &data_grid, &data_grid); // The regrid.to_grid option cannot be set to FCST or OBS - if(conf_info.data_info[0]->regrid().field == FieldType_Fcst || - conf_info.data_info[0]->regrid().field == FieldType_Obs) { + if(conf_info.data_info[0]->regrid().field == FieldType::Fcst || + conf_info.data_info[0]->regrid().field == FieldType::Obs) { mlog << Error << "\nprocess_command_line() -> " << "the \"regrid.to_grid\" configuration option cannot be set to " << "FCST or OBS!\nSpecify a named grid, grid specification string, " diff --git a/src/tools/other/mode_time_domain/mtd_config_info.cc b/src/tools/other/mode_time_domain/mtd_config_info.cc index 5fc84a1eb7..97b9d90e29 100644 --- a/src/tools/other/mode_time_domain/mtd_config_info.cc +++ b/src/tools/other/mode_time_domain/mtd_config_info.cc @@ -91,7 +91,7 @@ void MtdConfigInfo::clear() do_2d_att_ascii = true; do_3d_att_ascii = true; - mask_missing_flag = FieldType_None; + mask_missing_flag = FieldType::None; fcst_conv_radius = bad_data_int; obs_conv_radius = bad_data_int; @@ -111,18 +111,18 @@ void MtdConfigInfo::clear() fcst_merge_thresh.clear(); obs_merge_thresh.clear(); - fcst_merge_flag = MergeType_None; - obs_merge_flag = MergeType_None; + fcst_merge_flag = MergeType::None; + obs_merge_flag = MergeType::None; - match_flag = MatchType_None; + match_flag = MatchType::None; max_centroid_dist = bad_data_double; mask_grid_name.clear(); - mask_grid_flag = FieldType_None; + mask_grid_flag = FieldType::None; mask_poly_name.clear(); - mask_poly_flag = FieldType_None; + mask_poly_flag = FieldType::None; space_centroid_dist_wt = bad_data_double; time_centroid_delta_wt = bad_data_double; @@ -375,8 +375,8 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) // Check that match_flag is set between 0 and 3 /* - if(match_flag == MatchType_None && - (fcst_merge_flag != MergeType_None || obs_merge_flag != MergeType_None) ) { + if(match_flag == MatchType::None && + (fcst_merge_flag != MergeType::None || obs_merge_flag != MergeType::None) ) { mlog << Warning << "\nMtdConfigInfo::process_config() -> " << "When matching is disabled (match_flag = " << matchtype_to_string(match_flag) @@ -458,7 +458,7 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) + start_time_delta_wt + end_time_delta_wt; - if(match_flag != MatchType_None && + if(match_flag != MatchType::None && is_eq( sum, 0.0)) { mlog << Error << "\nMtdConfigInfo::process_config() -> " << "When matching is requested, the sum of the fuzzy engine " diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index fe8e7dafe8..64b6690ecd 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -238,7 +238,7 @@ void process_command_line(int argc, char **argv) { // Set default regridding options RGInfo.enable = true; - RGInfo.field = FieldType_None; + RGInfo.field = FieldType::None; RGInfo.method = DefaultInterpMthd; RGInfo.width = DefaultInterpWdth; RGInfo.vld_thresh = DefaultVldThresh; diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index de5961ae49..396b30633c 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -139,7 +139,7 @@ void process_command_line(int argc, char **argv) { // Set default regridding options RGInfo.enable = true; - RGInfo.field = FieldType_None; + RGInfo.field = FieldType::None; RGInfo.method = DefaultInterpMthd; RGInfo.width = DefaultInterpWdth; RGInfo.gaussian.dx = default_gaussian_dx; diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index 9afc59a3d9..7ad2078807 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -1743,7 +1743,7 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { for(i=0, stat_rows=0, stat_cols=0; iVxMaskName.c_str()); // Write out FHO - if(gci.VxOpt->output_map(stat_fho) != STATOutputType_None) { + if(gci.VxOpt->output_map(stat_fho) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { shc.set_fcst_var(genesis_dev_name); @@ -1992,7 +1992,7 @@ void write_ctc_stats(const PairDataGenesis &gpd, } // Write out CTC - if(gci.VxOpt->output_map(stat_ctc) != STATOutputType_None) { + if(gci.VxOpt->output_map(stat_ctc) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { shc.set_fcst_var(genesis_dev_name); @@ -2014,7 +2014,7 @@ void write_ctc_stats(const PairDataGenesis &gpd, } // Write out CTS - if(gci.VxOpt->output_map(stat_cts) != STATOutputType_None) { + if(gci.VxOpt->output_map(stat_cts) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { gci.CTSDev.compute_stats(); @@ -2042,7 +2042,7 @@ void write_ctc_stats(const PairDataGenesis &gpd, } // Write out GENMPR - if(gci.VxOpt->output_map(stat_genmpr) != STATOutputType_None) { + if(gci.VxOpt->output_map(stat_genmpr) != STATOutputType::None) { shc.set_fcst_var(genesis_name); shc.set_obs_var (genesis_name); write_ctc_genmpr_row(shc, gpd, @@ -2096,7 +2096,7 @@ void write_ctc_genmpr_row(StatHdrColumns &shc, write_ctc_genmpr_cols(gpd, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -2219,7 +2219,7 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { shc.set_obs_valid_end(pgi.BestEnd); // Write PCT output - if(pgi.VxOpt->output_map(stat_pct) != STATOutputType_None) { + if(pgi.VxOpt->output_map(stat_pct) != STATOutputType::None) { write_pct_row(shc, pgi.PCTMap[lead_hr], pgi.VxOpt->output_map(stat_pct), 1, 1, stat_at, i_stat_row, @@ -2227,7 +2227,7 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { } // Write PSTD output - if(pgi.VxOpt->output_map(stat_pstd) != STATOutputType_None) { + if(pgi.VxOpt->output_map(stat_pstd) != STATOutputType::None) { pgi.PCTMap[lead_hr].compute_stats(); pgi.PCTMap[lead_hr].compute_ci(); write_pstd_row(shc, pgi.PCTMap[lead_hr], @@ -2237,7 +2237,7 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { } // Write PJC output - if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType_None) { + if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType::None) { write_pjc_row(shc, pgi.PCTMap[lead_hr], pgi.VxOpt->output_map(stat_pjc), 1, 1, stat_at, i_stat_row, @@ -2245,7 +2245,7 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { } // Write PRC output - if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType_None) { + if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType::None) { write_prc_row(shc, pgi.PCTMap[lead_hr], pgi.VxOpt->output_map(stat_prc), 1, 1, stat_at, i_stat_row, @@ -2253,7 +2253,7 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { } // Write out GENMPR - if(pgi.VxOpt->output_map(stat_genmpr) != STATOutputType_None) { + if(pgi.VxOpt->output_map(stat_genmpr) != STATOutputType::None) { write_pct_genmpr_row(shc, pgi, lead_hr, pgi.VxOpt->output_map(stat_genmpr), stat_at, i_stat_row, @@ -2308,7 +2308,7 @@ void write_pct_genmpr_row(StatHdrColumns &shc, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -2565,7 +2565,7 @@ void finish_txt_files() { for(i=0; i=30.0"); From 0a771d48c2c0e4c0df603f6f072caabee3ace61b Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Fri, 22 Mar 2024 18:23:49 -0600 Subject: [PATCH 034/114] Feature #2830 bootstrap enum (#2843) --- src/basic/vx_config/config_constants.h | 12 ++++--- src/basic/vx_config/config_util.cc | 36 +++++++++++++++++-- src/basic/vx_config/config_util.h | 3 ++ src/basic/vx_util/util_constants.h | 4 --- src/libcode/vx_analysis_util/stat_job.cc | 8 ++--- src/libcode/vx_analysis_util/stat_job.h | 3 +- src/tools/core/grid_stat/grid_stat.cc | 10 +++--- src/tools/core/point_stat/point_stat.cc | 6 ++-- .../core/series_analysis/series_analysis.cc | 6 ++-- .../series_analysis_conf_info.cc | 2 +- .../core/stat_analysis/aggr_stat_line.cc | 8 ++--- .../core/stat_analysis/stat_analysis_job.cc | 2 +- 12 files changed, 64 insertions(+), 36 deletions(-) diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index e7f872f6b5..344e7295dc 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -50,7 +50,7 @@ enum class FieldType { // Enumeration for set logic // -enum class SetLogic { +enum class SetLogic { None, // Default Union, // Union Intersection, // Intersection @@ -256,12 +256,14 @@ struct TimeSummaryInfo { // Enumeration for bootstrapping interval configuration parameter // -enum BootIntervalType { - BootIntervalType_None, // Default - BootIntervalType_BCA, // Bias-Corrected and adjusted method - BootIntervalType_Percentile // Percentile method +enum class BootIntervalType { + None, // Default + BCA, // Bias-Corrected and adjusted method + PCTile // Percentile method }; +//////////////////////////////////////////////////////////////////////// + // // Struct to store bootstrapping information // diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 1eec001151..6f1bf64021 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -1268,7 +1268,7 @@ BootInfo & BootInfo::operator=(const BootInfo &a) noexcept { /////////////////////////////////////////////////////////////////////////////// void BootInfo::clear() { - interval = BootIntervalType_None; + interval = BootIntervalType::None; rep_prop = bad_data_double; n_rep = 0; rng.clear(); @@ -1292,8 +1292,12 @@ BootInfo parse_conf_boot(Dictionary *dict) { v = dict->lookup_int(conf_key_boot_interval); // Convert integer to enumerated BootIntervalType - if(v == conf_const.lookup_int(conf_val_bca)) info.interval = BootIntervalType_BCA; - else if(v == conf_const.lookup_int(conf_val_pctile)) info.interval = BootIntervalType_Percentile; + if(v == conf_const.lookup_int(conf_val_bca)) { + info.interval = BootIntervalType::BCA; + } + else if(v == conf_const.lookup_int(conf_val_pctile)) { + info.interval = BootIntervalType::PCTile; + } else { mlog << Error << "\nparse_conf_boot() -> " << "Unexpected config file value of " << v << " for \"" @@ -2731,6 +2735,32 @@ STATLineType string_to_statlinetype(const char *s) { /////////////////////////////////////////////////////////////////////////////// +const char * bootintervaltype_to_string(const BootIntervalType t) { + const char *s = (const char *) nullptr; + + switch(t) { + case(BootIntervalType::BCA): s = conf_val_bca; break; + case(BootIntervalType::PCTile): s = conf_val_pctile; break; + default: s = conf_val_none; break; + } + + return s; +} + +/////////////////////////////////////////////////////////////////////////////// + +BootIntervalType string_to_bootintervaltype(const char *s) { + BootIntervalType t; + + if(strcasecmp(s, conf_val_bca) == 0) t = BootIntervalType::BCA; + else if(strcasecmp(s, conf_val_pctile) == 0) t = BootIntervalType::PCTile; + else t = BootIntervalType::None; + + return t; +} + +/////////////////////////////////////////////////////////////////////////////// + FieldType int_to_fieldtype(int v) { FieldType t = FieldType::None; diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index 316c8eb14a..4ca142903d 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -105,6 +105,9 @@ extern const char * statlinetype_to_string(const STATLineType); extern void statlinetype_to_string(const STATLineType, char *); extern STATLineType string_to_statlinetype(const char *); +extern const char * bootintervaltype_to_string(const BootIntervalType); +extern BootIntervalType string_to_bootintervaltype(const char *); + extern FieldType int_to_fieldtype(int); extern ConcatString fieldtype_to_string(FieldType); diff --git a/src/basic/vx_util/util_constants.h b/src/basic/vx_util/util_constants.h index f80be6f21c..e2520efd18 100644 --- a/src/basic/vx_util/util_constants.h +++ b/src/basic/vx_util/util_constants.h @@ -95,10 +95,6 @@ static const char ws_reg_exp[] = "[ \t\r\n]"; static const char ws_line_reg_exp[] = "^[ \t\r\n]*$"; static const char sep_str[] = "--------------------------------------------------------------------------------"; -// Bootstrap methods -static const int boot_bca_flag = 0; -static const int boot_perc_flag = 1; - //////////////////////////////////////////////////////////////////////// static const int max_line_len = 2048; diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index c36758f8db..e65db03548 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -199,7 +199,7 @@ void STATAnalysisJob::clear() { out_wind_logic = SetLogic::Union; out_alpha = bad_data_double; - boot_interval = bad_data_int; + boot_interval = BootIntervalType::None; boot_rep_prop = bad_data_double; n_boot_rep = bad_data_int; @@ -621,7 +621,7 @@ void STATAnalysisJob::dump(ostream & out, int depth) const { << swing_width << "\n"; out << prefix << "boot_interval = " - << boot_interval << "\n"; + << bootintervaltype_to_string(boot_interval) << "\n"; out << prefix << "boot_rep_prop = " << boot_rep_prop << "\n"; @@ -1592,7 +1592,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { i++; } else if(jc_array[i] == "-boot_interval") { - boot_interval = atoi(jc_array[i+1].c_str()); + boot_interval = string_to_bootintervaltype(jc_array[i+1].c_str()); i++; } else if(jc_array[i] == "-boot_rep_prop") { @@ -2821,7 +2821,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { out_line_type.has(stat_nbrcnt_str))) { // Bootstrap Information - js << "-boot_interval " << boot_interval << " "; + js << "-boot_interval " << bootintervaltype_to_string(boot_interval) << " "; js << "-boot_rep_prop " << boot_rep_prop << " "; js << "-n_boot_rep " << n_boot_rep << " "; js << "-boot_rng " << boot_rng << " "; diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index e88ba5b1d8..36d00c8dfa 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -305,9 +305,8 @@ class STATAnalysisJob { // // Type of bootstrap confidence interval method: - // 0 = BCA, 1 = Percentile (Default = 1) // - int boot_interval; + BootIntervalType boot_interval; // // When using the percentile method, this is the proportion diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 752a4bcfcb..86c99906a3 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -1988,7 +1988,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cts, @@ -2037,7 +2037,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, @@ -2164,7 +2164,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals - if(vx_opt.boot_info.interval == BootIntervalType_BCA) { + if(vx_opt.boot_info.interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, vx_opt.rank_corr_flag, vx_opt.boot_info.n_rep, @@ -2469,7 +2469,7 @@ void do_nbrcts(NBRCTSInfo *&nbrcts_info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_nbrcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, nbrcts_info, n_nbrcts, @@ -2530,7 +2530,7 @@ void do_nbrcnt(NBRCNTInfo &nbrcnt_info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_nbrcnt_stats_ci_bca(rng_ptr, *pd_ptr, *pd_thr_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, nbrcnt_info, diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 80d16a6145..c911779718 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -1365,7 +1365,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cat, @@ -1416,7 +1416,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, @@ -1544,7 +1544,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals - if(vx_opt.boot_info.interval == BootIntervalType_BCA) { + if(vx_opt.boot_info.interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, vx_opt.rank_corr_flag, vx_opt.boot_info.n_rep, diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index e7a05ad78a..3b1108b709 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -930,7 +930,7 @@ void do_cts(int n, const PairDataPoint *pd_ptr) { // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.n_boot_rep, cts_info, n_cts, true, @@ -994,7 +994,7 @@ void do_mcts(int n, const PairDataPoint *pd_ptr) { // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.n_boot_rep, mcts_info, true, @@ -1060,7 +1060,7 @@ void do_cnt(int n, const PairDataPoint *pd_ptr) { int precip_flag = (conf_info.fcst_info[0]->is_precipitation() && conf_info.obs_info[0]->is_precipitation()); - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, conf_info.rank_corr_flag, conf_info.n_boot_rep, diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.cc b/src/tools/core/series_analysis/series_analysis_conf_info.cc index 6e79c25863..c4a9e2fa50 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.cc +++ b/src/tools/core/series_analysis/series_analysis_conf_info.cc @@ -70,7 +70,7 @@ void SeriesAnalysisConfInfo::clear() { cnt_logic = SetLogic::None; cdf_info.clear(); ci_alpha.clear(); - boot_interval = BootIntervalType_None; + boot_interval = BootIntervalType::None; boot_rep_prop = bad_data_double; n_boot_rep = bad_data_int; boot_rng.clear(); diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 3ca4cfcaff..dd53c0a3e6 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -3927,7 +3927,7 @@ void mpr_to_cts(STATAnalysisJob &job, const AggrMPRInfo &info, // bootstrap confidence intervals // cts_info_ptr = &cts_info; - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, info.pd, job.n_boot_rep, cts_info_ptr, 1, 1, @@ -3997,7 +3997,7 @@ void mpr_to_mcts(STATAnalysisJob &job, const AggrMPRInfo &info, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, info.pd, job.n_boot_rep, mcts_info, 1, @@ -4064,14 +4064,12 @@ void mpr_to_cnt(STATAnalysisJob &job, const AggrMPRInfo &info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(job.boot_interval == boot_bca_flag) { - + if(job.boot_interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd_thr, precip_flag, job.rank_corr_flag, job.n_boot_rep, cnt_info, tmp_dir); } else { - compute_cnt_stats_ci_perc(rng_ptr, pd_thr, precip_flag, job.rank_corr_flag, job.n_boot_rep, job.boot_rep_prop, cnt_info, tmp_dir); diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index da0807f2ec..d47c82c080 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -1130,7 +1130,7 @@ void write_job_summary(STATAnalysisJob &job, // // Compute a bootstrap confidence interval for the mean. // - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_mean_stdev_ci_bca(rng_ptr, val_it->second, job.n_boot_rep, job.out_alpha, mean_ci, stdev_ci); From 98af717b10a4ecbc758c7bb0c31270b55da2d7fa Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 27 Mar 2024 08:31:03 -0600 Subject: [PATCH 035/114] Bugfix #2833 develop azimuth (#2840) * Per #2833, fix n-1 bug when defining the azimuth delta for range/azimuth grids. * Per #2833, when definng TcrmwData:range_max_km, divide by n_range - 1 since the range values start at 0. * Per #2833, remove max_range_km from the TC-RMW config file. Set the default rmw_scale to NA so that its not used by default. And update the documentation. Still actually need to make the logic of the code work as it should. * Per #2833, update tc_rmw to define the range as either a function of rmw or using explicit spacing in km. * Per #2833, update the TCRMW Config files to remove the max_range_km entry, and update the unit test for one call to use RMW ranges and the other to use ranges defined in kilometers. * Per #2833, just correct code comments. * Per #2833, divide by n - 1 when computing the range delta, rather than n. * Per #2833, correct the handling of the maximum range in the tc-rmw tool. For fixed delta km, need to define the max range when setting up the grid at the beginning. --------- Co-authored-by: MET Tools Test Account --- data/config/TCRMWConfig_default | 3 +- docs/Users_Guide/tc-rmw.rst | 14 +---- internal/test_unit/config/TCRMWConfig_gonzalo | 3 +- .../config/TCRMWConfig_pressure_lev_out | 3 +- src/basic/vx_config/config_constants.h | 1 - src/libcode/vx_grid/tcrmw_grid.cc | 5 +- src/libcode/vx_grid/tcrmw_grid.h | 4 +- src/tools/tc_utils/tc_diag/tc_diag.cc | 5 +- src/tools/tc_utils/tc_rmw/tc_rmw.cc | 63 ++++++++++++------- src/tools/tc_utils/tc_rmw/tc_rmw.h | 4 -- src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc | 14 +++-- src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h | 17 +++-- 12 files changed, 72 insertions(+), 64 deletions(-) diff --git a/data/config/TCRMWConfig_default b/data/config/TCRMWConfig_default index dfb18721ac..e27a4b2741 100644 --- a/data/config/TCRMWConfig_default +++ b/data/config/TCRMWConfig_default @@ -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 diff --git a/docs/Users_Guide/tc-rmw.rst b/docs/Users_Guide/tc-rmw.rst index a9e67ffbc1..82628c087c 100644 --- a/docs/Users_Guide/tc-rmw.rst +++ b/docs/Users_Guide/tc-rmw.rst @@ -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. _______________________ diff --git a/internal/test_unit/config/TCRMWConfig_gonzalo b/internal/test_unit/config/TCRMWConfig_gonzalo index 32a6beb118..d2ff3a1c00 100644 --- a/internal/test_unit/config/TCRMWConfig_gonzalo +++ b/internal/test_unit/config/TCRMWConfig_gonzalo @@ -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 diff --git a/internal/test_unit/config/TCRMWConfig_pressure_lev_out b/internal/test_unit/config/TCRMWConfig_pressure_lev_out index 747d9fa9b5..aa8c7a2287 100644 --- a/internal/test_unit/config/TCRMWConfig_pressure_lev_out +++ b/internal/test_unit/config/TCRMWConfig_pressure_lev_out @@ -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; // diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index 56908edd31..065bc27db4 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -1213,7 +1213,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"; diff --git a/src/libcode/vx_grid/tcrmw_grid.cc b/src/libcode/vx_grid/tcrmw_grid.cc index 507c1874b8..a2e1738e1b 100644 --- a/src/libcode/vx_grid/tcrmw_grid.cc +++ b/src/libcode/vx_grid/tcrmw_grid.cc @@ -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; diff --git a/src/libcode/vx_grid/tcrmw_grid.h b/src/libcode/vx_grid/tcrmw_grid.h index 010748bff9..8af34d9261 100644 --- a/src/libcode/vx_grid/tcrmw_grid.h +++ b/src/libcode/vx_grid/tcrmw_grid.h @@ -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 @@ -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 ); } diff --git a/src/tools/tc_utils/tc_diag/tc_diag.cc b/src/tools/tc_utils/tc_diag/tc_diag.cc index 23478fba79..e5815d30cb 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag.cc @@ -17,6 +17,7 @@ // 000 09/27/22 Halley Gotway New // 001 08/17/23 Halley Gotway MET #2609 handle missing data // 002 10/24/23 Halley Gotway MET #2550 enhance diagnostics +// 003 03/11/24 Halley Gotway MET #2833 range/azimuth grid // //////////////////////////////////////////////////////////////////////// @@ -2203,7 +2204,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); diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index c281b758e2..d32bc62d81 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -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 // //////////////////////////////////////////////////////////////////////// @@ -554,7 +555,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); @@ -593,8 +600,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, @@ -606,11 +614,11 @@ void setup_nc_file() { // Get VarInfo data_info = conf_info.data_info[i_var]; mlog << Debug(4) << "Processing field: " << data_info->magic_str() << "\n"; - string fname = data_info->name_attr(); + string fname = data_info->name_attr(); variable_levels[fname].push_back(data_info->level_attr()); variable_long_names[fname] = data_info->long_name_attr(); variable_units[fname] = data_info->units_attr(); - wind_converter.update_input(fname, data_info->units_attr()); + wind_converter.update_input(fname, data_info->units_attr()); } // Define pressure levels @@ -644,7 +652,7 @@ void compute_lat_lon(TcrmwGrid& tcrmw_grid, ia * tcrmw_grid.azimuth_delta_deg(), lat, lon); lat_arr[i] = lat; - lon_arr[i] = - lon; + lon_arr[i] = -lon; } } } @@ -688,9 +696,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(); @@ -713,7 +727,7 @@ void process_fields(const TrackInfoArray& tracks) { for(int i_var = 0; i_var < conf_info.get_n_data(); i_var++) { - // Update the variable info with the valid time of the track point + // Update with the valid time of the track point data_info = conf_info.data_info[i_var]; string sname = data_info->name_attr().string(); @@ -731,24 +745,27 @@ void process_fields(const TrackInfoArray& tracks) { mlog << Debug(4) << "data_max:" << data_max << "\n"; // Regrid data - data_dp = met_regrid(data_dp, latlon_arr, grid, data_info->regrid()); + data_dp = met_regrid(data_dp, latlon_arr, grid, + data_info->regrid()); data_dp.data_range(data_min, data_max); mlog << Debug(4) << "data_min:" << data_min << "\n"; mlog << Debug(4) << "data_max:" << data_max << "\n"; - // if this is "U", setup everything for matching "V" and compute the radial/tangential - if(wind_converter.compute_winds_if_input_is_u(i_point, sname, slevel, valid_time, data_files, ftype, - latlon_arr, lat_arr, lon_arr, grid, data_dp, tcrmw_grid)) { - write_tc_pressure_level_data(nc_out, tcrmw_grid, - pressure_level_indices, data_info->level_attr(), i_point, - data_3d_vars[conf_info.radial_velocity_field_name.string()], - wind_converter.get_wind_r_arr()); - write_tc_pressure_level_data(nc_out, tcrmw_grid, - pressure_level_indices, data_info->level_attr(), i_point, - data_3d_vars[conf_info.tangential_velocity_field_name.string()], - wind_converter.get_wind_t_arr()); + // If this is "U", setup everything for matching "V" + // and compute the radial/tangential winds + if(wind_converter.compute_winds_if_input_is_u( + i_point, sname, slevel, valid_time, data_files, ftype, + latlon_arr, lat_arr, lon_arr, grid, data_dp, tcrmw_grid)) { + write_tc_pressure_level_data(nc_out, tcrmw_grid, + pressure_level_indices, data_info->level_attr(), i_point, + data_3d_vars[conf_info.radial_velocity_field_name.string()], + wind_converter.get_wind_r_arr()); + write_tc_pressure_level_data(nc_out, tcrmw_grid, + pressure_level_indices, data_info->level_attr(), i_point, + data_3d_vars[conf_info.tangential_velocity_field_name.string()], + wind_converter.get_wind_t_arr()); } - + // Write data if(variable_levels[data_info->name_attr()].size() > 1) { write_tc_pressure_level_data(nc_out, tcrmw_grid, diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.h b/src/tools/tc_utils/tc_rmw/tc_rmw.h index b97f136188..7691a2c012 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.h @@ -146,10 +146,6 @@ static Grid grid; static double* lat_arr; static double* lon_arr; -// Wind arrays -/* static double* wind_r_arr; */ -/* static double* wind_t_arr; */ - //////////////////////////////////////////////////////////////////////// #endif // __TC_RMW_H__ diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc index 7f8537ef80..eaaeebafeb 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc @@ -72,7 +72,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; @@ -175,15 +174,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); @@ -192,7 +197,6 @@ void TCRMWConfInfo::process_config(GrdFileType ftype) { tangential_velocity_long_field_name = Conf.lookup_string(conf_key_tangential_velocity_long_field_name); radial_velocity_long_field_name = Conf.lookup_string(conf_key_radial_velocity_long_field_name); - // Conf: data.field fdict = Conf.lookup_array(conf_key_data_field); diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h index f1d8d52ec8..1e3bf5b3b2 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h @@ -50,18 +50,17 @@ class TCRMWConfInfo { // Range/Azimuth information int n_range; int n_azimuth; - double max_range_km; double delta_range_km; double rmw_scale; - // Wind conversion information - bool compute_tangential_and_radial_winds; - ConcatString u_wind_field_name; - ConcatString v_wind_field_name; - ConcatString tangential_velocity_field_name; - ConcatString radial_velocity_field_name; - ConcatString tangential_velocity_long_field_name; - ConcatString radial_velocity_long_field_name; + // Wind conversion information + bool compute_tangential_and_radial_winds; + ConcatString u_wind_field_name; + ConcatString v_wind_field_name; + ConcatString tangential_velocity_field_name; + ConcatString radial_velocity_field_name; + ConcatString tangential_velocity_long_field_name; + ConcatString radial_velocity_long_field_name; // Variable information VarInfo** data_info; From 1c97607a52dea27257aac6032c231c01e90ec5e4 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 27 Mar 2024 18:50:32 +0000 Subject: [PATCH 036/114] #2830 Changed enum PadSize to enum class --- src/libcode/vx_pb_util/do_blocking.cc | 4 ++-- src/libcode/vx_pb_util/do_unblocking.cc | 8 ++++---- src/libcode/vx_pb_util/pblock.cc | 4 ++-- src/libcode/vx_pb_util/pblock.h | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcode/vx_pb_util/do_blocking.cc b/src/libcode/vx_pb_util/do_blocking.cc index 0a62342983..0e6df01b22 100644 --- a/src/libcode/vx_pb_util/do_blocking.cc +++ b/src/libcode/vx_pb_util/do_blocking.cc @@ -115,13 +115,13 @@ unsigned char * b = (unsigned char *) nullptr; switch ( padsize ) { - case padsize_4: + case PadSize::size_4: bytes = 4; b = (unsigned char *) (&I); I = (unsigned int) value; break; - case padsize_8: + case PadSize::size_8: bytes = 8; b = (unsigned char *) (&L); L = (unsigned long long) value; diff --git a/src/libcode/vx_pb_util/do_unblocking.cc b/src/libcode/vx_pb_util/do_unblocking.cc index e0fa2ef90d..0a159c31e6 100644 --- a/src/libcode/vx_pb_util/do_unblocking.cc +++ b/src/libcode/vx_pb_util/do_unblocking.cc @@ -85,12 +85,12 @@ unsigned char * b = (unsigned char *) nullptr; switch ( padsize ) { - case padsize_4: + case PadSize::size_4: bytes = 4; b = (unsigned char *) (&I); break; - case padsize_8: + case PadSize::size_8: bytes = 8; b = (unsigned char *) (&L); break; @@ -119,11 +119,11 @@ if ( (n_read < 0) || ((n_read > 0) && (n_read != bytes)) ) { switch ( padsize ) { - case padsize_4: + case PadSize::size_4: value = I; break; - case padsize_8: + case PadSize::size_8: value = (int) L; break; diff --git a/src/libcode/vx_pb_util/pblock.cc b/src/libcode/vx_pb_util/pblock.cc index 0626c0ac39..057720e528 100644 --- a/src/libcode/vx_pb_util/pblock.cc +++ b/src/libcode/vx_pb_util/pblock.cc @@ -57,9 +57,9 @@ void pblock(const char *infile, const char *outfile, Action action) { // Set the block size for this compiler // #ifdef BLOCK4 - padsize = padsize_4; + padsize = PadSize::size_4; #else - padsize = padsize_8; + padsize = PadSize::size_8; #endif // diff --git a/src/libcode/vx_pb_util/pblock.h b/src/libcode/vx_pb_util/pblock.h index cab711e358..015daaa4c1 100644 --- a/src/libcode/vx_pb_util/pblock.h +++ b/src/libcode/vx_pb_util/pblock.h @@ -18,12 +18,12 @@ //////////////////////////////////////////////////////////////////////// -enum PadSize { +enum class PadSize { - padsize_4, - padsize_8, + size_4, + size_8, - no_padsize + no_pad }; From 40b67d4e22ffb40e2dbaf914d1d3252d8da536b3 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 27 Mar 2024 19:16:43 +0000 Subject: [PATCH 037/114] #2830 Removed redundant parantheses --- src/basic/vx_config/config_util.cc | 218 ++++++++++++++--------------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 6f1bf64021..6c09051747 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -2618,51 +2618,51 @@ const char * statlinetype_to_string(const STATLineType t) { const char *s = (const char *) nullptr; switch(t) { - case(stat_sl1l2): s = stat_sl1l2_str; break; - case(stat_sal1l2): s = stat_sal1l2_str; break; - case(stat_vl1l2): s = stat_vl1l2_str; break; - case(stat_val1l2): s = stat_val1l2_str; break; - case(stat_vcnt): s = stat_vcnt_str; break; - - case(stat_fho): s = stat_fho_str; break; - case(stat_ctc): s = stat_ctc_str; break; - case(stat_cts): s = stat_cts_str; break; - case(stat_mctc): s = stat_mctc_str; break; - case(stat_mcts): s = stat_mcts_str; break; - - case(stat_cnt): s = stat_cnt_str; break; - case(stat_pct): s = stat_pct_str; break; - case(stat_pstd): s = stat_pstd_str; break; - case(stat_pjc): s = stat_pjc_str; break; - case(stat_prc): s = stat_prc_str; break; - - case(stat_eclv): s = stat_eclv_str; break; - case(stat_mpr): s = stat_mpr_str; break; - case(stat_seeps): s = stat_seeps_str; break; - case(stat_seeps_mpr): s = stat_seeps_mpr_str; break; - case(stat_nbrctc): s = stat_nbrctc_str; break; - - case(stat_nbrcts): s = stat_nbrcts_str; break; - case(stat_nbrcnt): s = stat_nbrcnt_str; break; - case(stat_grad): s = stat_grad_str; break; - case(stat_dmap): s = stat_dmap_str; break; - case(stat_isc): s = stat_isc_str; break; - - case(stat_wdir): s = stat_wdir_str; break; - case(stat_ecnt): s = stat_ecnt_str; break; - case(stat_rps): s = stat_rps_str; break; - case(stat_rhist): s = stat_rhist_str; break; - case(stat_phist): s = stat_phist_str; break; - - case(stat_orank): s = stat_orank_str; break; - case(stat_ssvar): s = stat_ssvar_str; break; - case(stat_relp): s = stat_relp_str; break; - case(stat_genmpr): s = stat_genmpr_str; break; - case(stat_ssidx): s = stat_ssidx_str; break; + case stat_sl1l2: s = stat_sl1l2_str; break; + case stat_sal1l2: s = stat_sal1l2_str; break; + case stat_vl1l2: s = stat_vl1l2_str; break; + case stat_val1l2: s = stat_val1l2_str; break; + case stat_vcnt: s = stat_vcnt_str; break; + + case stat_fho: s = stat_fho_str; break; + case stat_ctc: s = stat_ctc_str; break; + case stat_cts: s = stat_cts_str; break; + case stat_mctc: s = stat_mctc_str; break; + case stat_mcts: s = stat_mcts_str; break; + + case stat_cnt: s = stat_cnt_str; break; + case stat_pct: s = stat_pct_str; break; + case stat_pstd: s = stat_pstd_str; break; + case stat_pjc: s = stat_pjc_str; break; + case stat_prc: s = stat_prc_str; break; + + case stat_eclv: s = stat_eclv_str; break; + case stat_mpr: s = stat_mpr_str; break; + case stat_seeps: s = stat_seeps_str; break; + case stat_seeps_mpr: s = stat_seeps_mpr_str; break; + case stat_nbrctc: s = stat_nbrctc_str; break; + + case stat_nbrcts: s = stat_nbrcts_str; break; + case stat_nbrcnt: s = stat_nbrcnt_str; break; + case stat_grad: s = stat_grad_str; break; + case stat_dmap: s = stat_dmap_str; break; + case stat_isc: s = stat_isc_str; break; + + case stat_wdir: s = stat_wdir_str; break; + case stat_ecnt: s = stat_ecnt_str; break; + case stat_rps: s = stat_rps_str; break; + case stat_rhist: s = stat_rhist_str; break; + case stat_phist: s = stat_phist_str; break; + + case stat_orank: s = stat_orank_str; break; + case stat_ssvar: s = stat_ssvar_str; break; + case stat_relp: s = stat_relp_str; break; + case stat_genmpr: s = stat_genmpr_str; break; + case stat_ssidx: s = stat_ssidx_str; break; - case(stat_header): s = stat_header_str; break; + case stat_header: s = stat_header_str; break; - case(no_stat_line_type): + case no_stat_line_type: default: s = stat_na_str; break; } @@ -2736,12 +2736,12 @@ STATLineType string_to_statlinetype(const char *s) { /////////////////////////////////////////////////////////////////////////////// const char * bootintervaltype_to_string(const BootIntervalType t) { - const char *s = (const char *) nullptr; + const auto s = (const char *) nullptr; switch(t) { - case(BootIntervalType::BCA): s = conf_val_bca; break; - case(BootIntervalType::PCTile): s = conf_val_pctile; break; - default: s = conf_val_none; break; + case BootIntervalType::BCA: s = conf_val_bca; break; + case BootIntervalType::PCTile: s = conf_val_pctile; break; + default: s = conf_val_none; break; } return s; @@ -2806,10 +2806,10 @@ ConcatString fieldtype_to_string(FieldType type) { // Convert enumerated FieldType to string switch(type) { - case(FieldType::None): s = conf_val_none; break; - case(FieldType::Both): s = conf_val_both; break; - case(FieldType::Fcst): s = conf_val_fcst; break; - case(FieldType::Obs): s = conf_val_obs; break; + case FieldType::None: s = conf_val_none; break; + case FieldType::Both: s = conf_val_both; break; + case FieldType::Fcst: s = conf_val_fcst; break; + case FieldType::Obs: s = conf_val_obs; break; default: mlog << Error << "\nfieldtype_to_string() -> " << "Unexpected FieldType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -2875,10 +2875,10 @@ ConcatString setlogic_to_string(SetLogic type) { // Convert enumerated SetLogic to string switch(type) { - case(SetLogic::None): s = conf_val_none; break; - case(SetLogic::Union): s = conf_val_union; break; - case(SetLogic::Intersection): s = conf_val_intersection; break; - case(SetLogic::SymDiff): s = conf_val_symdiff; break; + case SetLogic::None: s = conf_val_none; break; + case SetLogic::Union: s = conf_val_union; break; + case SetLogic::Intersection: s = conf_val_intersection; break; + case SetLogic::SymDiff: s = conf_val_symdiff; break; default: mlog << Error << "\nsetlogic_to_string() -> " << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; @@ -2895,10 +2895,10 @@ ConcatString setlogic_to_abbr(SetLogic type) { // Convert enumerated SetLogic to an abbreviation switch(type) { - case(SetLogic::None): s = na_str; break; - case(SetLogic::Union): s = setlogic_abbr_union; break; - case(SetLogic::Intersection): s = setlogic_abbr_intersection; break; - case(SetLogic::SymDiff): s = setlogic_abbr_symdiff; break; + case SetLogic::None: s = na_str; break; + case SetLogic::Union: s = setlogic_abbr_union; break; + case SetLogic::Intersection: s = setlogic_abbr_intersection; break; + case SetLogic::SymDiff: s = setlogic_abbr_symdiff; break; default: mlog << Error << "\nsetlogic_to_abbr() -> " << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; @@ -2915,10 +2915,10 @@ ConcatString setlogic_to_symbol(SetLogic type) { // Convert enumerated SetLogic to a symbol switch(type) { - case(SetLogic::None): s = na_str; break; - case(SetLogic::Union): s = setlogic_symbol_union; break; - case(SetLogic::Intersection): s = setlogic_symbol_intersection; break; - case(SetLogic::SymDiff): s = setlogic_symbol_symdiff; break; + case SetLogic::None: s = na_str; break; + case SetLogic::Union: s = setlogic_symbol_union; break; + case SetLogic::Intersection: s = setlogic_symbol_intersection; break; + case SetLogic::SymDiff: s = setlogic_symbol_symdiff; break; default: mlog << Error << "\nsetlogic_to_symbol() -> " << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; @@ -2994,10 +2994,10 @@ ConcatString tracktype_to_string(TrackType type) { // Convert enumerated TrackType to string switch(type) { - case(TrackType::None): s = conf_val_none; break; - case(TrackType::Both): s = conf_val_both; break; - case(TrackType::ADeck): s = conf_val_adeck; break; - case(TrackType::BDeck): s = conf_val_bdeck; break; + case TrackType::None: s = conf_val_none; break; + case TrackType::Both: s = conf_val_both; break; + case TrackType::ADeck: s = conf_val_adeck; break; + case TrackType::BDeck: s = conf_val_bdeck; break; default: mlog << Error << "\ntracktype_to_string() -> " << "Unexpected TrackType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3030,11 +3030,11 @@ ConcatString diagtype_to_string(DiagType type) { // Convert enumerated DiagType to string switch(type) { - case(DiagType::None): s = conf_val_none; break; - case(DiagType::CIRA_RT): s = cira_diag_rt_str; break; - case(DiagType::CIRA_Dev): s = cira_diag_dev_str; break; - case(DiagType::SHIPS_RT): s = ships_diag_rt_str; break; - case(DiagType::SHIPS_Dev): s = ships_diag_dev_str; break; + case DiagType::None: s = conf_val_none; break; + case DiagType::CIRA_RT: s = cira_diag_rt_str; break; + case DiagType::CIRA_Dev: s = cira_diag_dev_str; break; + case DiagType::SHIPS_RT: s = ships_diag_rt_str; break; + case DiagType::SHIPS_Dev: s = ships_diag_dev_str; break; default: mlog << Error << "\ndiagtype_to_string() -> " << "Unexpected DiagType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3087,9 +3087,9 @@ ConcatString interp12type_to_string(Interp12Type type) { // Convert enumerated Interp12Type to string switch(type) { - case(Interp12Type::None): s = conf_val_none; break; - case(Interp12Type::Fill): s = conf_val_fill; break; - case(Interp12Type::Replace): s = conf_val_replace; break; + case Interp12Type::None: s = conf_val_none; break; + case Interp12Type::Fill: s = conf_val_fill; break; + case Interp12Type::Replace: s = conf_val_replace; break; default: mlog << Error << "\ninterp12type_to_string() -> " << "Unexpected Interp12Type value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3125,10 +3125,10 @@ ConcatString mergetype_to_string(MergeType type) { // Convert enumerated MergeType to string switch(type) { - case(MergeType::None): s = conf_val_none; break; - case(MergeType::Both): s = conf_val_both; break; - case(MergeType::Thresh): s = conf_val_thresh; break; - case(MergeType::Engine): s = conf_val_engine; break; + case MergeType::None: s = conf_val_none; break; + case MergeType::Both: s = conf_val_both; break; + case MergeType::Thresh: s = conf_val_thresh; break; + case MergeType::Engine: s = conf_val_engine; break; default: mlog << Error << "\nmergetype_to_string() -> " << "Unexpected MergeType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3145,14 +3145,14 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { // Convert enumerated ObsSummary to string switch(type) { - case(ObsSummary::None): s = conf_val_none; break; - case(ObsSummary::Nearest): s = conf_val_nearest; break; - case(ObsSummary::Min): s = conf_val_min; break; - case(ObsSummary::Max): s = conf_val_max; break; - case(ObsSummary::UW_Mean): s = conf_val_uw_mean; break; - case(ObsSummary::DW_Mean): s = conf_val_dw_mean; break; - case(ObsSummary::Median): s = conf_val_median; break; - case(ObsSummary::Perc): + case ObsSummary::None: s = conf_val_none; break; + case ObsSummary::Nearest: s = conf_val_nearest; break; + case ObsSummary::Min: s = conf_val_min; break; + case ObsSummary::Max: s = conf_val_max; break; + case ObsSummary::UW_Mean: s = conf_val_uw_mean; break; + case ObsSummary::DW_Mean: s = conf_val_dw_mean; break; + case ObsSummary::Median: s = conf_val_median; break; + case ObsSummary::Perc: s << conf_val_perc << "(" << perc_val << ")"; break; default: @@ -3190,10 +3190,10 @@ ConcatString matchtype_to_string(MatchType type) { // Convert enumerated MatchType to string switch(type) { - case(MatchType::None): s = conf_val_none; break; - case(MatchType::MergeBoth): s = conf_val_merge_both; break; - case(MatchType::MergeFcst): s = conf_val_merge_fcst; break; - case(MatchType::NoMerge): s = conf_val_no_merge; break; + case MatchType::None: s = conf_val_none; break; + case MatchType::MergeBoth: s = conf_val_merge_both; break; + case MatchType::MergeFcst: s = conf_val_merge_fcst; break; + case MatchType::NoMerge: s = conf_val_no_merge; break; default: mlog << Error << "\nmatchtype_to_string() -> " << "Unexpected MatchType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3254,13 +3254,13 @@ ConcatString disttype_to_string(DistType type) { // Convert enumerated DistType to string switch(type) { - case(DistType_None): s = conf_val_none; break; - case(DistType_Normal): s = conf_val_normal; break; - case(DistType_Exponential): s = conf_val_exponential; break; - case(DistType_ChiSquared): s = conf_val_chisquared; break; - case(DistType_Gamma): s = conf_val_gamma; break; - case(DistType_Uniform): s = conf_val_uniform; break; - case(DistType_Beta): s = conf_val_beta; break; + case DistType_None: s = conf_val_none; break; + case DistType_Normal: s = conf_val_normal; break; + case DistType_Exponential: s = conf_val_exponential; break; + case DistType_ChiSquared: s = conf_val_chisquared; break; + case DistType_Gamma: s = conf_val_gamma; break; + case DistType_Uniform: s = conf_val_uniform; break; + case DistType_Beta: s = conf_val_beta; break; default: mlog << Error << "\ndisttype_to_string() -> " << "Unexpected DistType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3298,10 +3298,10 @@ ConcatString griddecomptype_to_string(GridDecompType type) { // Convert enumerated GridDecompType to string switch(type) { - case(GridDecompType::None): s = conf_val_none; break; - case(GridDecompType::Auto): s = conf_val_auto; break; - case(GridDecompType::Tile): s = conf_val_tile; break; - case(GridDecompType::Pad): s = conf_val_pad; break; + case GridDecompType::None: s = conf_val_none; break; + case GridDecompType::Auto: s = conf_val_auto; break; + case GridDecompType::Tile: s = conf_val_tile; break; + case GridDecompType::Pad: s = conf_val_pad; break; default: mlog << Error << "\ngriddecomptype_to_string() -> " << "Unexpected GridDecompType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3318,13 +3318,13 @@ ConcatString wavelettype_to_string(WaveletType type) { // Convert enumerated WaveletType to string switch(type) { - case(WaveletType::None): s = conf_val_none; break; - case(WaveletType::Haar): s = conf_val_haar; break; - case(WaveletType::Haar_Cntr): s = conf_val_haar_cntr; break; - case(WaveletType::Daub): s = conf_val_daub; break; - case(WaveletType::Daub_Cntr): s = conf_val_daub_cntr; break; - case(WaveletType::BSpline): s = conf_val_bspline; break; - case(WaveletType::BSpline_Cntr): s = conf_val_bspline_cntr; break; + case WaveletType::None: s = conf_val_none; break; + case WaveletType::Haar: s = conf_val_haar; break; + case WaveletType::Haar_Cntr: s = conf_val_haar_cntr; break; + case WaveletType::Daub: s = conf_val_daub; break; + case WaveletType::Daub_Cntr: s = conf_val_daub_cntr; break; + case WaveletType::BSpline: s = conf_val_bspline; break; + case WaveletType::BSpline_Cntr: s = conf_val_bspline_cntr; break; default: mlog << Error << "\nwavlettype_to_string() -> " << "Unexpected WaveletType value of " << enum_class_as_integer(type) << ".\n\n"; From 79f81af66deaa97a837bb4408970600f511608c7 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 27 Mar 2024 19:17:10 +0000 Subject: [PATCH 038/114] #2830 Removed commenyted out code --- src/basic/vx_config/config_util.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index 4ca142903d..e5cb69ce6e 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -157,16 +157,6 @@ template extern auto enum_class_as_integer(Enumeration const value) -> typename std::underlying_type::type; -//////////////////////////////////////////////////////////////////////// - -/* -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} -*/ /////////////////////////////////////////////////////////////////////////////// #endif /* __CONFIG_UTIL_H__ */ From 8cc667c80b94cb5ac3590f20e84b233fc715ea7a Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 27 Mar 2024 19:33:36 +0000 Subject: [PATCH 039/114] #2830 Use auto --- src/basic/vx_config/config_util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 6c09051747..aa57950ffd 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -2736,7 +2736,7 @@ STATLineType string_to_statlinetype(const char *s) { /////////////////////////////////////////////////////////////////////////////// const char * bootintervaltype_to_string(const BootIntervalType t) { - const auto s = (const char *) nullptr; + auto s = (const char *) nullptr; switch(t) { case BootIntervalType::BCA: s = conf_val_bca; break; From d6cba7d1c7cc58dcf461a6c18b0932ca4d97a03d Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 28 Mar 2024 01:15:45 +0000 Subject: [PATCH 040/114] #2830 Changed enum to enum class for DistType, InterpMthd, GridTemplates, and NormalizeType --- src/basic/vx_config/config_util.cc | 248 +++++++++--------- .../vx_config/configobjecttype_to_string.cc | 2 +- src/basic/vx_config/grdfiletype_to_string.cc | 1 - src/basic/vx_math/viewgravity_to_string.cc | 1 - src/basic/vx_util/GridTemplate.cc | 27 +- src/basic/vx_util/GridTemplate.h | 10 +- src/basic/vx_util/asciitablejust_to_string.cc | 2 +- src/basic/vx_util/data_plane_util.cc | 30 ++- src/basic/vx_util/interp_mthd.cc | 88 +++---- src/basic/vx_util/interp_mthd.h | 46 ++-- src/basic/vx_util/interp_util.cc | 98 +++---- src/basic/vx_util/normalize.cc | 34 ++- src/basic/vx_util/normalize.h | 12 +- src/libcode/vx_gsl_prob/gsl_randist.cc | 28 +- src/libcode/vx_gsl_prob/gsl_randist.h | 16 +- src/libcode/vx_regrid/vx_regrid.cc | 30 +-- src/libcode/vx_shapedata/shapedata.cc | 2 +- src/libcode/vx_stat_out/stat_columns.cc | 4 +- src/libcode/vx_stat_out/stat_hdr_columns.cc | 2 +- src/libcode/vx_stat_out/stat_hdr_columns.h | 4 +- src/libcode/vx_statistics/obs_error.cc | 16 +- src/libcode/vx_statistics/pair_base.cc | 8 +- .../vx_statistics/pair_data_ensemble.cc | 16 +- src/libcode/vx_statistics/pair_data_point.cc | 21 +- src/tools/core/ensemble_stat/ensemble_stat.cc | 12 +- .../ensemble_stat/ensemble_stat_conf_info.cc | 4 +- src/tools/core/grid_stat/grid_stat.cc | 8 +- .../core/grid_stat/grid_stat_conf_info.cc | 6 +- src/tools/core/point_stat/point_stat.cc | 10 +- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 20 +- .../gen_ens_prod/gen_ens_prod_conf_info.cc | 6 +- src/tools/other/point2grid/point2grid.cc | 24 +- .../regrid_data_plane/regrid_data_plane.cc | 6 +- .../shift_data_plane/shift_data_plane.cc | 4 +- src/tools/other/wwmca_tool/wwmca_ref.cc | 10 +- 35 files changed, 450 insertions(+), 406 deletions(-) diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index aa57950ffd..42e5972444 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -124,10 +124,10 @@ void RegridInfo::clear() { field = FieldType::None; vld_thresh = bad_data_double; name.clear(); - method = InterpMthd_None; + method = InterpMthd::None; width = bad_data_int; gaussian.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; convert_fx.clear(); censor_thresh.clear(); censor_val.clear(); @@ -144,10 +144,10 @@ RegridInfo::RegridInfo() { void RegridInfo::validate() { // Check for unsupported regridding options - if(method == InterpMthd_Best || - method == InterpMthd_Geog_Match || - method == InterpMthd_Gaussian || - method == InterpMthd_HiRA) { + if(method == InterpMthd::Best || + method == InterpMthd::Geog_Match || + method == InterpMthd::Gaussian || + method == InterpMthd::HiRA) { mlog << Error << "\nRegridInfo::validate() -> " << "\"" << interpmthd_to_string(method) << "\" not valid for regridding, only interpolating.\n\n"; @@ -156,31 +156,31 @@ void RegridInfo::validate() { // Check the nearest neighbor special case if(width == 1 && - method != InterpMthd_None && - method != InterpMthd_Nearest && - method != InterpMthd_Force && - method != InterpMthd_Upper_Left && - method != InterpMthd_Upper_Right && - method != InterpMthd_Lower_Right && - method != InterpMthd_Lower_Left && - method != InterpMthd_AW_Mean && - method != InterpMthd_MaxGauss) { + method != InterpMthd::None && + method != InterpMthd::Nearest && + method != InterpMthd::Force && + method != InterpMthd::Upper_Left && + method != InterpMthd::Upper_Right && + method != InterpMthd::Lower_Right && + method != InterpMthd::Lower_Left && + method != InterpMthd::AW_Mean && + method != InterpMthd::MaxGauss) { mlog << Warning << "\nRegridInfo::validate() -> " << "Resetting the regridding method from \"" << interpmthd_to_string(method) << "\" to \"" << interpmthd_nearest_str << "\" since the regridding width is 1.\n\n"; - method = InterpMthd_Nearest; + method = InterpMthd::Nearest; } // Check for some methods, that width is 1 - if((method == InterpMthd_Nearest || - method == InterpMthd_Force || - method == InterpMthd_Upper_Left || - method == InterpMthd_Upper_Right || - method == InterpMthd_Lower_Right || - method == InterpMthd_Lower_Left || - method == InterpMthd_AW_Mean) && + if((method == InterpMthd::Nearest || + method == InterpMthd::Force || + method == InterpMthd::Upper_Left || + method == InterpMthd::Upper_Right || + method == InterpMthd::Lower_Right || + method == InterpMthd::Lower_Left || + method == InterpMthd::AW_Mean) && width != 1) { mlog << Warning << "\nRegridInfo::validate() -> " << "Resetting regridding width from " @@ -190,8 +190,8 @@ void RegridInfo::validate() { } // Check the bilinear and budget special cases - if((method == InterpMthd_Bilin || - method == InterpMthd_Budget) && + if((method == InterpMthd::Bilin || + method == InterpMthd::Budget) && width != 2) { mlog << Warning << "\nRegridInfo::validate() -> " << "Resetting the regridding width from " @@ -201,7 +201,7 @@ void RegridInfo::validate() { } // Check the Gaussian filter - if(method == InterpMthd_MaxGauss && gaussian.radius < gaussian.dx) { + if(method == InterpMthd::MaxGauss && gaussian.radius < gaussian.dx) { mlog << Error << "\nRegridInfo::validate() -> " << "The radius of influence (" << gaussian.radius << ") is less than the delta distance (" << gaussian.dx @@ -226,20 +226,20 @@ void RegridInfo::validate() { void RegridInfo::validate_point() { // Check for unsupported regridding options - if(method != InterpMthd_Max && - method != InterpMthd_Min && - method != InterpMthd_Median && - method != InterpMthd_UW_Mean) { + if(method != InterpMthd::Max && + method != InterpMthd::Min && + method != InterpMthd::Median && + method != InterpMthd::UW_Mean) { mlog << Warning << "\nRegridInfo::validate_point() -> " << "Resetting the regridding method from \"" << interpmthd_to_string(method) << "\" to \"" << interpmthd_uw_mean_str << ".\n" << "\tAvailable methods: " - << interpmthd_to_string(InterpMthd_UW_Mean) << ", " - << interpmthd_to_string(InterpMthd_Max) << ", " - << interpmthd_to_string(InterpMthd_Min) << ", " - << interpmthd_to_string(InterpMthd_Median) << ".\n\n"; - method = InterpMthd_UW_Mean; + << interpmthd_to_string(InterpMthd::UW_Mean) << ", " + << interpmthd_to_string(InterpMthd::Max) << ", " + << interpmthd_to_string(InterpMthd::Min) << ", " + << interpmthd_to_string(InterpMthd::Median) << ".\n\n"; + method = InterpMthd::UW_Mean; } } @@ -1398,7 +1398,7 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: gaussian dx and radius @@ -1408,7 +1408,7 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { info.gaussian.radius = (is_bad_data(conf_value) ? default_gaussian_radius : conf_value); conf_value = regrid_dict->lookup_double(conf_key_trunc_factor, false); info.gaussian.trunc_factor = (is_bad_data(conf_value) ? default_trunc_factor : conf_value); - if (info.method == InterpMthd_Gaussian || info.method == InterpMthd_MaxGauss) info.gaussian.compute(); + if (info.method == InterpMthd::Gaussian || info.method == InterpMthd::MaxGauss) info.gaussian.compute(); // MET#2437 Do not search the higher levels of config file context for convert, // censor_thresh, and censor_val. They must be specified within the @@ -1438,7 +1438,7 @@ void InterpInfo::clear() { method.clear(); width.clear(); gaussian.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; } /////////////////////////////////////////////////////////////////////////////// @@ -1451,15 +1451,15 @@ void InterpInfo::validate() { // Check the nearest neighbor special case if(width[i] == 1 && - methodi != InterpMthd_None && - methodi != InterpMthd_Nearest && - methodi != InterpMthd_Force && - methodi != InterpMthd_Upper_Left && - methodi != InterpMthd_Upper_Right && - methodi != InterpMthd_Lower_Right && - methodi != InterpMthd_Lower_Left && - methodi != InterpMthd_Gaussian && - methodi != InterpMthd_MaxGauss) { + methodi != InterpMthd::None && + methodi != InterpMthd::Nearest && + methodi != InterpMthd::Force && + methodi != InterpMthd::Upper_Left && + methodi != InterpMthd::Upper_Right && + methodi != InterpMthd::Lower_Right && + methodi != InterpMthd::Lower_Left && + methodi != InterpMthd::Gaussian && + methodi != InterpMthd::MaxGauss) { mlog << Warning << "\nInterpInfo::validate() -> " << "Resetting interpolation method " << (int) i << " from \"" << method[i] << "\" to \"" @@ -1469,11 +1469,11 @@ void InterpInfo::validate() { } // Check for some methods, that width is 1 - if((methodi == InterpMthd_Nearest || - methodi == InterpMthd_Upper_Left || - methodi == InterpMthd_Upper_Right || - methodi == InterpMthd_Lower_Right || - methodi == InterpMthd_Lower_Left) && + if((methodi == InterpMthd::Nearest || + methodi == InterpMthd::Upper_Left || + methodi == InterpMthd::Upper_Right || + methodi == InterpMthd::Lower_Right || + methodi == InterpMthd::Lower_Left) && width[i] != 1) { mlog << Warning << "\nInterpInfo::validate() -> " << "Resetting interpolation width " << (int) i << " from " @@ -1483,8 +1483,8 @@ void InterpInfo::validate() { } // Check the bilinear and budget special cases - if((methodi == InterpMthd_Bilin || - methodi == InterpMthd_Budget) && + if((methodi == InterpMthd::Bilin || + methodi == InterpMthd::Budget) && width[i] != 2) { mlog << Warning << "\nInterpInfo::validate() -> " << "Resetting interpolation width " << (int) i << " from " @@ -1494,8 +1494,8 @@ void InterpInfo::validate() { } // Check the Gaussian filter - if(methodi == InterpMthd_Gaussian || - methodi == InterpMthd_MaxGauss) { + if(methodi == InterpMthd::Gaussian || + methodi == InterpMthd::MaxGauss) { if (gaussian.radius < gaussian.dx) { mlog << Error << "\n" << "The radius of influence (" << gaussian.radius @@ -1591,7 +1591,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: gaussian dx and radius @@ -1645,8 +1645,8 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { method = int_to_interpmthd(mthd_na[j]); // Check for unsupported interpolation options - if(method == InterpMthd_Budget || - method == InterpMthd_Force) { + if(method == InterpMthd::Budget || + method == InterpMthd::Force) { mlog << Error << "\nparse_conf_interp() -> " << "\"" << interpmthd_to_string(method) << "\" not valid for interpolating, only regridding.\n\n"; @@ -1666,7 +1666,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { } // end for k - if(method == InterpMthd_Gaussian || method == InterpMthd_MaxGauss) { + if(method == InterpMthd::Gaussian || method == InterpMthd::MaxGauss) { info.gaussian.compute(); } } // end for j @@ -1861,7 +1861,7 @@ void NbrhdInfo::clear() { vld_thresh = bad_data_double; width.clear(); cov_ta.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; } /////////////////////////////////////////////////////////////////////////////// @@ -1949,7 +1949,7 @@ NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: cov_thresh @@ -1979,7 +1979,7 @@ void HiRAInfo::clear() { vld_thresh = bad_data_double; cov_ta.clear(); prob_cat_ta.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; } /////////////////////////////////////////////////////////////////////////////// @@ -2065,7 +2065,7 @@ HiRAInfo parse_conf_hira(Dictionary *dict) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: cov_thresh @@ -2552,30 +2552,30 @@ void check_climo_n_vx(Dictionary *dict, const int n_vx) { /////////////////////////////////////////////////////////////////////////////// InterpMthd int_to_interpmthd(int i) { - InterpMthd m = InterpMthd_None; - - if(i == conf_const.lookup_int(interpmthd_none_str)) m = InterpMthd_None; - else if(i == conf_const.lookup_int(interpmthd_min_str)) m = InterpMthd_Min; - else if(i == conf_const.lookup_int(interpmthd_max_str)) m = InterpMthd_Max; - else if(i == conf_const.lookup_int(interpmthd_median_str)) m = InterpMthd_Median; - else if(i == conf_const.lookup_int(interpmthd_uw_mean_str)) m = InterpMthd_UW_Mean; - else if(i == conf_const.lookup_int(interpmthd_dw_mean_str)) m = InterpMthd_DW_Mean; - else if(i == conf_const.lookup_int(interpmthd_aw_mean_str)) m = InterpMthd_AW_Mean; - else if(i == conf_const.lookup_int(interpmthd_ls_fit_str)) m = InterpMthd_LS_Fit; - else if(i == conf_const.lookup_int(interpmthd_bilin_str)) m = InterpMthd_Bilin; - else if(i == conf_const.lookup_int(interpmthd_nbrhd_str)) m = InterpMthd_Nbrhd; - else if(i == conf_const.lookup_int(interpmthd_nearest_str)) m = InterpMthd_Nearest; - else if(i == conf_const.lookup_int(interpmthd_budget_str)) m = InterpMthd_Budget; - else if(i == conf_const.lookup_int(interpmthd_force_str)) m = InterpMthd_Force; - else if(i == conf_const.lookup_int(interpmthd_best_str)) m = InterpMthd_Best; - else if(i == conf_const.lookup_int(interpmthd_upper_left_str)) m = InterpMthd_Upper_Left; - else if(i == conf_const.lookup_int(interpmthd_upper_right_str)) m = InterpMthd_Upper_Right; - else if(i == conf_const.lookup_int(interpmthd_lower_right_str)) m = InterpMthd_Lower_Right; - else if(i == conf_const.lookup_int(interpmthd_lower_left_str)) m = InterpMthd_Lower_Left; - else if(i == conf_const.lookup_int(interpmthd_gaussian_str)) m = InterpMthd_Gaussian; - else if(i == conf_const.lookup_int(interpmthd_maxgauss_str)) m = InterpMthd_MaxGauss; - else if(i == conf_const.lookup_int(interpmthd_geog_match_str)) m = InterpMthd_Geog_Match; - else if(i == conf_const.lookup_int(interpmthd_hira_str)) m = InterpMthd_HiRA; + InterpMthd m = InterpMthd::None; + + if(i == conf_const.lookup_int(interpmthd_none_str)) m = InterpMthd::None; + else if(i == conf_const.lookup_int(interpmthd_min_str)) m = InterpMthd::Min; + else if(i == conf_const.lookup_int(interpmthd_max_str)) m = InterpMthd::Max; + else if(i == conf_const.lookup_int(interpmthd_median_str)) m = InterpMthd::Median; + else if(i == conf_const.lookup_int(interpmthd_uw_mean_str)) m = InterpMthd::UW_Mean; + else if(i == conf_const.lookup_int(interpmthd_dw_mean_str)) m = InterpMthd::DW_Mean; + else if(i == conf_const.lookup_int(interpmthd_aw_mean_str)) m = InterpMthd::AW_Mean; + else if(i == conf_const.lookup_int(interpmthd_ls_fit_str)) m = InterpMthd::LS_Fit; + else if(i == conf_const.lookup_int(interpmthd_bilin_str)) m = InterpMthd::Bilin; + else if(i == conf_const.lookup_int(interpmthd_nbrhd_str)) m = InterpMthd::Nbrhd; + else if(i == conf_const.lookup_int(interpmthd_nearest_str)) m = InterpMthd::Nearest; + else if(i == conf_const.lookup_int(interpmthd_budget_str)) m = InterpMthd::Budget; + else if(i == conf_const.lookup_int(interpmthd_force_str)) m = InterpMthd::Force; + else if(i == conf_const.lookup_int(interpmthd_best_str)) m = InterpMthd::Best; + else if(i == conf_const.lookup_int(interpmthd_upper_left_str)) m = InterpMthd::Upper_Left; + else if(i == conf_const.lookup_int(interpmthd_upper_right_str)) m = InterpMthd::Upper_Right; + else if(i == conf_const.lookup_int(interpmthd_lower_right_str)) m = InterpMthd::Lower_Right; + else if(i == conf_const.lookup_int(interpmthd_lower_left_str)) m = InterpMthd::Lower_Left; + else if(i == conf_const.lookup_int(interpmthd_gaussian_str)) m = InterpMthd::Gaussian; + else if(i == conf_const.lookup_int(interpmthd_maxgauss_str)) m = InterpMthd::MaxGauss; + else if(i == conf_const.lookup_int(interpmthd_geog_match_str)) m = InterpMthd::Geog_Match; + else if(i == conf_const.lookup_int(interpmthd_hira_str)) m = InterpMthd::HiRA; else { mlog << Error << "\nconf_int_to_interpmthd() -> " << "Unexpected value of " << i @@ -2781,14 +2781,14 @@ FieldType int_to_fieldtype(int v) { /////////////////////////////////////////////////////////////////////////////// GridTemplateFactory::GridTemplates int_to_gridtemplate(int v) { - GridTemplateFactory::GridTemplates t = GridTemplateFactory::GridTemplate_Square; + GridTemplateFactory::GridTemplates t = GridTemplateFactory::GridTemplates::Square; // Convert integer to enumerated FieldType if(v == conf_const.lookup_int(conf_val_square)) { - t = GridTemplateFactory::GridTemplate_Square; + t = GridTemplateFactory::GridTemplates::Square; } else if(v == conf_const.lookup_int(conf_val_circle)) { - t = GridTemplateFactory::GridTemplate_Circle; + t = GridTemplateFactory::GridTemplates::Circle; } else { mlog << Error << "\nint_to_gridtemplate() -> " @@ -3206,16 +3206,16 @@ ConcatString matchtype_to_string(MatchType type) { /////////////////////////////////////////////////////////////////////////////// DistType int_to_disttype(int v) { - DistType t = DistType_None; + DistType t = DistType::None; // Convert integer to enumerated DistType - if(v == conf_const.lookup_int(conf_val_none)) t = DistType_None; - else if(v == conf_const.lookup_int(conf_val_normal)) t = DistType_Normal; - else if(v == conf_const.lookup_int(conf_val_exponential)) t = DistType_Exponential; - else if(v == conf_const.lookup_int(conf_val_chisquared)) t = DistType_ChiSquared; - else if(v == conf_const.lookup_int(conf_val_gamma)) t = DistType_Gamma; - else if(v == conf_const.lookup_int(conf_val_uniform)) t = DistType_Uniform; - else if(v == conf_const.lookup_int(conf_val_beta)) t = DistType_Beta; + if(v == conf_const.lookup_int(conf_val_none)) t = DistType::None; + else if(v == conf_const.lookup_int(conf_val_normal)) t = DistType::Normal; + else if(v == conf_const.lookup_int(conf_val_exponential)) t = DistType::Exponential; + else if(v == conf_const.lookup_int(conf_val_chisquared)) t = DistType::ChiSquared; + else if(v == conf_const.lookup_int(conf_val_gamma)) t = DistType::Gamma; + else if(v == conf_const.lookup_int(conf_val_uniform)) t = DistType::Uniform; + else if(v == conf_const.lookup_int(conf_val_beta)) t = DistType::Beta; else { mlog << Error << "\nint_to_disttype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3228,16 +3228,16 @@ DistType int_to_disttype(int v) { /////////////////////////////////////////////////////////////////////////////// DistType string_to_disttype(const char *s) { - DistType t = DistType_None; + DistType t = DistType::None; // Convert string to enumerated DistType - if(strcasecmp(s, conf_val_none) == 0) t = DistType_None; - else if(strcasecmp(s, conf_val_normal) == 0) t = DistType_Normal; - else if(strcasecmp(s, conf_val_exponential) == 0) t = DistType_Exponential; - else if(strcasecmp(s, conf_val_chisquared) == 0) t = DistType_ChiSquared; - else if(strcasecmp(s, conf_val_gamma) == 0) t = DistType_Gamma; - else if(strcasecmp(s, conf_val_uniform) == 0) t = DistType_Uniform; - else if(strcasecmp(s, conf_val_beta) == 0) t = DistType_Beta; + if(strcasecmp(s, conf_val_none) == 0) t = DistType::None; + else if(strcasecmp(s, conf_val_normal) == 0) t = DistType::Normal; + else if(strcasecmp(s, conf_val_exponential) == 0) t = DistType::Exponential; + else if(strcasecmp(s, conf_val_chisquared) == 0) t = DistType::ChiSquared; + else if(strcasecmp(s, conf_val_gamma) == 0) t = DistType::Gamma; + else if(strcasecmp(s, conf_val_uniform) == 0) t = DistType::Uniform; + else if(strcasecmp(s, conf_val_beta) == 0) t = DistType::Beta; else { mlog << Error << "\nstring_to_disttype() -> " << "Unexpected DistType string \"" << s << "\".\n\n"; @@ -3254,13 +3254,13 @@ ConcatString disttype_to_string(DistType type) { // Convert enumerated DistType to string switch(type) { - case DistType_None: s = conf_val_none; break; - case DistType_Normal: s = conf_val_normal; break; - case DistType_Exponential: s = conf_val_exponential; break; - case DistType_ChiSquared: s = conf_val_chisquared; break; - case DistType_Gamma: s = conf_val_gamma; break; - case DistType_Uniform: s = conf_val_uniform; break; - case DistType_Beta: s = conf_val_beta; break; + case DistType::None: s = conf_val_none; break; + case DistType::Normal: s = conf_val_normal; break; + case DistType::Exponential: s = conf_val_exponential; break; + case DistType::ChiSquared: s = conf_val_chisquared; break; + case DistType::Gamma: s = conf_val_gamma; break; + case DistType::Uniform: s = conf_val_uniform; break; + case DistType::Beta: s = conf_val_beta; break; default: mlog << Error << "\ndisttype_to_string() -> " << "Unexpected DistType value of " << enum_class_as_integer(type) << ".\n\n"; @@ -3278,11 +3278,11 @@ ConcatString dist_to_string(DistType type, const NumArray &parm) { s = disttype_to_string(type); // Append distribution parameters - if(type != DistType_None && parm.n() == 2) { + if(type != DistType::None && parm.n() == 2) { s << "(" << parm[0]; - if(type == DistType_Gamma || - type == DistType_Uniform || - type == DistType_Beta) { + if(type == DistType::Gamma || + type == DistType::Uniform || + type == DistType::Beta) { s << ", " << parm[1]; } s << ")"; @@ -3353,7 +3353,7 @@ StringArray parse_conf_ens_member_ids(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// NormalizeType parse_conf_normalize(Dictionary *dict) { - NormalizeType t = NormalizeType_None; + NormalizeType t = NormalizeType::None; int v; if(!dict) { @@ -3366,11 +3366,11 @@ NormalizeType parse_conf_normalize(Dictionary *dict) { v = dict->lookup_int(conf_key_normalize); // Convert integer to enumerated NormalizeType - if(v == conf_const.lookup_int(normalizetype_none_str)) t = NormalizeType_None; - else if(v == conf_const.lookup_int(normalizetype_climo_anom_str)) t = NormalizeType_ClimoAnom; - else if(v == conf_const.lookup_int(normalizetype_climo_std_anom_str)) t = NormalizeType_ClimoStdAnom; - else if(v == conf_const.lookup_int(normalizetype_fcst_anom_str)) t = NormalizeType_FcstAnom; - else if(v == conf_const.lookup_int(normalizetype_fcst_std_anom_str)) t = NormalizeType_FcstStdAnom; + if(v == conf_const.lookup_int(normalizetype_none_str)) t = NormalizeType::None; + else if(v == conf_const.lookup_int(normalizetype_climo_anom_str)) t = NormalizeType::ClimoAnom; + else if(v == conf_const.lookup_int(normalizetype_climo_std_anom_str)) t = NormalizeType::ClimoStdAnom; + else if(v == conf_const.lookup_int(normalizetype_fcst_anom_str)) t = NormalizeType::FcstAnom; + else if(v == conf_const.lookup_int(normalizetype_fcst_std_anom_str)) t = NormalizeType::FcstStdAnom; else { mlog << Error << "\nparse_conf_normalize() -> " << "Unexpected value of " << v << ".\n\n"; diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index d8088d406c..8bb9f296b8 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -62,7 +62,7 @@ switch ( t ) { } // switch -return ConcatString (s); +return ConcatString(s); } diff --git a/src/basic/vx_config/grdfiletype_to_string.cc b/src/basic/vx_config/grdfiletype_to_string.cc index b5d2d4b6be..c9e89451c3 100644 --- a/src/basic/vx_config/grdfiletype_to_string.cc +++ b/src/basic/vx_config/grdfiletype_to_string.cc @@ -28,7 +28,6 @@ #include "grdfiletype_to_string.h" - using namespace std; diff --git a/src/basic/vx_math/viewgravity_to_string.cc b/src/basic/vx_math/viewgravity_to_string.cc index 63e499533b..78e4e5aad4 100644 --- a/src/basic/vx_math/viewgravity_to_string.cc +++ b/src/basic/vx_math/viewgravity_to_string.cc @@ -28,7 +28,6 @@ #include "viewgravity_to_string.h" - using namespace std; diff --git a/src/basic/vx_util/GridTemplate.cc b/src/basic/vx_util/GridTemplate.cc index 9534c81015..58bc284741 100644 --- a/src/basic/vx_util/GridTemplate.cc +++ b/src/basic/vx_util/GridTemplate.cc @@ -40,6 +40,15 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + +/////////////////////////////////////////////////////////////////////////////// + GridTemplate::GridTemplate(void) : _wrapLon(false) { // Do nothing @@ -591,11 +600,11 @@ void GridTemplate::_setEdgeOffsets() { /////////////////////////////////////////////////////////////////////////////// GridTemplateFactory::GridTemplateFactory() { - enum_to_string.resize(GridTemplate_NUM_TEMPLATES); + enum_to_string.resize(enum_class_as_integer(GridTemplates::NUM_TEMPLATES)); - enum_to_string[GridTemplate_None] = ""; - enum_to_string[GridTemplate_Square] = "SQUARE"; - enum_to_string[GridTemplate_Circle] = "CIRCLE"; + enum_to_string[enum_class_as_integer(GridTemplates::None)] = ""; + enum_to_string[enum_class_as_integer(GridTemplates::Square)] = "SQUARE"; + enum_to_string[enum_class_as_integer(GridTemplates::Circle)] = "CIRCLE"; } /////////////////////////////////////////////////////////////////////////////// @@ -612,7 +621,7 @@ GridTemplateFactory::~GridTemplateFactory() { GridTemplateFactory::GridTemplates GridTemplateFactory::string2Enum(string target) { - for(unsigned int ix = 0; ix < GridTemplate_NUM_TEMPLATES; ix++) { + for(unsigned int ix = 0; ix < enum_class_as_integer(GridTemplates::NUM_TEMPLATES); ix++) { if(enum_to_string[ix] == target) { return static_cast(ix); } @@ -632,7 +641,7 @@ string GridTemplateFactory::enum2String(GridTemplates target) { if(static_cast(target) > enum_to_string.size() - 1) { mlog << Error << "\nGridTemplateFactory::enum2String() -> " - << "target out of range " << target << " > " + << "target out of range " << enum_class_as_integer(target) << " > " << (static_cast(enum_to_string.size()) - 1) << ".\n\n"; exit(1); @@ -659,15 +668,15 @@ GridTemplate* GridTemplateFactory::buildGT(string gt, int width, bool wrap_lon) GridTemplate* GridTemplateFactory::buildGT(GridTemplates gt, int width, bool wrap_lon) { switch (gt) { - case(GridTemplate_Square): + case(GridTemplates::Square): return new RectangularTemplate(width, width, wrap_lon); - case(GridTemplate_Circle): + case(GridTemplates::Circle): return new CircularTemplate(width, wrap_lon); default: mlog << Error << "\nbuildGT() -> " - << "Unexpected GridTemplates value (" << gt << ").\n\n"; + << "Unexpected GridTemplates value (" << enum_class_as_integer(gt) << ").\n\n"; exit(1); } } diff --git a/src/basic/vx_util/GridTemplate.h b/src/basic/vx_util/GridTemplate.h index 6682cc10af..05df9ac644 100644 --- a/src/basic/vx_util/GridTemplate.h +++ b/src/basic/vx_util/GridTemplate.h @@ -159,11 +159,11 @@ class GridTemplateFactory { // do not assign specific values to these enumes. // other code requires them to start at zero and increase by 1 // make sure GridTemplate_NUM_TEMPLATES is always last. - enum GridTemplates { - GridTemplate_None, - GridTemplate_Square, - GridTemplate_Circle, - GridTemplate_NUM_TEMPLATES + enum class GridTemplates { + None, + Square, + Circle, + NUM_TEMPLATES }; // String corresponding to the enumerated values above diff --git a/src/basic/vx_util/asciitablejust_to_string.cc b/src/basic/vx_util/asciitablejust_to_string.cc index fa89d3958e..6bdf630114 100644 --- a/src/basic/vx_util/asciitablejust_to_string.cc +++ b/src/basic/vx_util/asciitablejust_to_string.cc @@ -6,6 +6,7 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + //////////////////////////////////////////////////////////////////////// @@ -27,7 +28,6 @@ #include "asciitablejust_to_string.h" - using namespace std; diff --git a/src/basic/vx_util/data_plane_util.cc b/src/basic/vx_util/data_plane_util.cc index 233b3b6293..16beac9e3c 100644 --- a/src/basic/vx_util/data_plane_util.cc +++ b/src/basic/vx_util/data_plane_util.cc @@ -18,6 +18,7 @@ #include "omp.h" #endif +#include "config_util.h" #include "data_plane_util.h" #include "interp_util.h" #include "two_to_one.h" @@ -36,6 +37,13 @@ using namespace std; // //////////////////////////////////////////////////////////////////////// +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + //////////////////////////////////////////////////////////////////////// // // Check the range of probability values and make sure it's either @@ -106,7 +114,7 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, smooth_dp = dp; // For nearest neighbor, no work to do. - if(width == 1 && mthd == InterpMthd_Nearest) return; + if(width == 1 && mthd == InterpMthd::Nearest) return; // build the grid template GridTemplateFactory gtf; @@ -125,27 +133,27 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, // Compute the smoothed value based on the interpolation method switch(mthd) { - case(InterpMthd_Min): // Minimum + case(InterpMthd::Min): // Minimum v = interp_min(dp, *gt, x, y, t); break; - case(InterpMthd_Max): // Maximum + case(InterpMthd::Max): // Maximum v = interp_max(dp, *gt, x, y, t); break; - case(InterpMthd_Median): // Median + case(InterpMthd::Median): // Median v = interp_median(dp, *gt, x, y, t); break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case(InterpMthd::UW_Mean): // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, t); break; - case(InterpMthd_Gaussian): // For Gaussian, pass the data through + case(InterpMthd::Gaussian): // For Gaussian, pass the data through v = dp.get(x, y); break; - case(InterpMthd_MaxGauss): // For Max Gaussian, compute the max + case(InterpMthd::MaxGauss): // For Max Gaussian, compute the max v = interp_max(dp, *gt, x, y, 0); break; @@ -156,7 +164,7 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, default: mlog << Error << "\nsmooth_field() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd + << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; exit(1); } @@ -168,8 +176,8 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, } // end for x // Apply the Gaussian smoother - if(mthd == InterpMthd_Gaussian || - mthd == InterpMthd_MaxGauss) { + if(mthd == InterpMthd::Gaussian || + mthd == InterpMthd::MaxGauss) { interp_gaussian_dp(smooth_dp, gaussian, t); } @@ -265,7 +273,7 @@ void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, mlog << Debug(3) << "Computing fractional coverage field using the " << t.get_str() << " threshold and the " - << interpmthd_to_string(InterpMthd_Nbrhd) << "(" << gt->size() + << interpmthd_to_string(InterpMthd::Nbrhd) << "(" << gt->size() << ") " << gt->getClassName() << " interpolation method.\n"; // Initialize the fractional coverage field diff --git a/src/basic/vx_util/interp_mthd.cc b/src/basic/vx_util/interp_mthd.cc index ba55b07da3..afb04be803 100644 --- a/src/basic/vx_util/interp_mthd.cc +++ b/src/basic/vx_util/interp_mthd.cc @@ -24,29 +24,29 @@ ConcatString interpmthd_to_string(const InterpMthd m) { ConcatString out; switch(m) { - case(InterpMthd_Min): out = interpmthd_min_str; break; - case(InterpMthd_Max): out = interpmthd_max_str; break; - case(InterpMthd_Median): out = interpmthd_median_str; break; - case(InterpMthd_UW_Mean): out = interpmthd_uw_mean_str; break; - case(InterpMthd_DW_Mean): out = interpmthd_dw_mean_str; break; - case(InterpMthd_AW_Mean): out = interpmthd_aw_mean_str; break; - case(InterpMthd_LS_Fit): out = interpmthd_ls_fit_str; break; - case(InterpMthd_Nbrhd): out = interpmthd_nbrhd_str; break; - case(InterpMthd_Bilin): out = interpmthd_bilin_str; break; - case(InterpMthd_Nearest): out = interpmthd_nearest_str; break; - case(InterpMthd_Budget): out = interpmthd_budget_str; break; - case(InterpMthd_Force): out = interpmthd_force_str; break; - case(InterpMthd_Best): out = interpmthd_best_str; break; - case(InterpMthd_Upper_Left): out = interpmthd_upper_left_str; break; - case(InterpMthd_Upper_Right): out = interpmthd_upper_right_str; break; - case(InterpMthd_Lower_Right): out = interpmthd_lower_right_str; break; - case(InterpMthd_Lower_Left): out = interpmthd_lower_left_str; break; - case(InterpMthd_Gaussian): out = interpmthd_gaussian_str; break; - case(InterpMthd_MaxGauss): out = interpmthd_maxgauss_str; break; - case(InterpMthd_Geog_Match): out = interpmthd_geog_match_str; break; - case(InterpMthd_HiRA): out = interpmthd_hira_str; break; + case InterpMthd::Min: out = interpmthd_min_str; break; + case InterpMthd::Max: out = interpmthd_max_str; break; + case InterpMthd::Median: out = interpmthd_median_str; break; + case InterpMthd::UW_Mean: out = interpmthd_uw_mean_str; break; + case InterpMthd::DW_Mean: out = interpmthd_dw_mean_str; break; + case InterpMthd::AW_Mean: out = interpmthd_aw_mean_str; break; + case InterpMthd::LS_Fit: out = interpmthd_ls_fit_str; break; + case InterpMthd::Nbrhd: out = interpmthd_nbrhd_str; break; + case InterpMthd::Bilin: out = interpmthd_bilin_str; break; + case InterpMthd::Nearest: out = interpmthd_nearest_str; break; + case InterpMthd::Budget: out = interpmthd_budget_str; break; + case InterpMthd::Force: out = interpmthd_force_str; break; + case InterpMthd::Best: out = interpmthd_best_str; break; + case InterpMthd::Upper_Left: out = interpmthd_upper_left_str; break; + case InterpMthd::Upper_Right: out = interpmthd_upper_right_str; break; + case InterpMthd::Lower_Right: out = interpmthd_lower_right_str; break; + case InterpMthd::Lower_Left: out = interpmthd_lower_left_str; break; + case InterpMthd::Gaussian: out = interpmthd_gaussian_str; break; + case InterpMthd::MaxGauss: out = interpmthd_maxgauss_str; break; + case InterpMthd::Geog_Match: out = interpmthd_geog_match_str; break; + case InterpMthd::HiRA: out = interpmthd_hira_str; break; - case(InterpMthd_None): + case InterpMthd::None: default: out = interpmthd_none_str; break; } // switch @@ -58,28 +58,28 @@ ConcatString interpmthd_to_string(const InterpMthd m) { InterpMthd string_to_interpmthd(const char *mthd_str) { InterpMthd m; - if(strcmp(mthd_str, interpmthd_min_str) == 0) m = InterpMthd_Min; - else if(strcmp(mthd_str, interpmthd_max_str) == 0) m = InterpMthd_Max; - else if(strcmp(mthd_str, interpmthd_median_str) == 0) m = InterpMthd_Median; - else if(strcmp(mthd_str, interpmthd_uw_mean_str) == 0) m = InterpMthd_UW_Mean; - else if(strcmp(mthd_str, interpmthd_dw_mean_str) == 0) m = InterpMthd_DW_Mean; - else if(strcmp(mthd_str, interpmthd_aw_mean_str) == 0) m = InterpMthd_AW_Mean; - else if(strcmp(mthd_str, interpmthd_ls_fit_str) == 0) m = InterpMthd_LS_Fit; - else if(strcmp(mthd_str, interpmthd_nbrhd_str) == 0) m = InterpMthd_Nbrhd; - else if(strcmp(mthd_str, interpmthd_bilin_str) == 0) m = InterpMthd_Bilin; - else if(strcmp(mthd_str, interpmthd_nearest_str) == 0) m = InterpMthd_Nearest; - else if(strcmp(mthd_str, interpmthd_budget_str) == 0) m = InterpMthd_Budget; - else if(strcmp(mthd_str, interpmthd_force_str) == 0) m = InterpMthd_Force; - else if(strcmp(mthd_str, interpmthd_best_str) == 0) m = InterpMthd_Best; - else if(strcmp(mthd_str, interpmthd_upper_left_str) == 0) m = InterpMthd_Upper_Left; - else if(strcmp(mthd_str, interpmthd_upper_right_str) == 0) m = InterpMthd_Upper_Right; - else if(strcmp(mthd_str, interpmthd_lower_right_str) == 0) m = InterpMthd_Lower_Right; - else if(strcmp(mthd_str, interpmthd_lower_left_str) == 0) m = InterpMthd_Lower_Left; - else if(strcmp(mthd_str, interpmthd_gaussian_str ) == 0) m = InterpMthd_Gaussian; - else if(strcmp(mthd_str, interpmthd_maxgauss_str ) == 0) m = InterpMthd_MaxGauss; - else if(strcmp(mthd_str, interpmthd_geog_match_str) == 0) m = InterpMthd_Geog_Match; - else if(strcmp(mthd_str, interpmthd_hira_str) == 0) m = InterpMthd_HiRA; - else m = InterpMthd_None; + if(strcmp(mthd_str, interpmthd_min_str) == 0) m = InterpMthd::Min; + else if(strcmp(mthd_str, interpmthd_max_str) == 0) m = InterpMthd::Max; + else if(strcmp(mthd_str, interpmthd_median_str) == 0) m = InterpMthd::Median; + else if(strcmp(mthd_str, interpmthd_uw_mean_str) == 0) m = InterpMthd::UW_Mean; + else if(strcmp(mthd_str, interpmthd_dw_mean_str) == 0) m = InterpMthd::DW_Mean; + else if(strcmp(mthd_str, interpmthd_aw_mean_str) == 0) m = InterpMthd::AW_Mean; + else if(strcmp(mthd_str, interpmthd_ls_fit_str) == 0) m = InterpMthd::LS_Fit; + else if(strcmp(mthd_str, interpmthd_nbrhd_str) == 0) m = InterpMthd::Nbrhd; + else if(strcmp(mthd_str, interpmthd_bilin_str) == 0) m = InterpMthd::Bilin; + else if(strcmp(mthd_str, interpmthd_nearest_str) == 0) m = InterpMthd::Nearest; + else if(strcmp(mthd_str, interpmthd_budget_str) == 0) m = InterpMthd::Budget; + else if(strcmp(mthd_str, interpmthd_force_str) == 0) m = InterpMthd::Force; + else if(strcmp(mthd_str, interpmthd_best_str) == 0) m = InterpMthd::Best; + else if(strcmp(mthd_str, interpmthd_upper_left_str) == 0) m = InterpMthd::Upper_Left; + else if(strcmp(mthd_str, interpmthd_upper_right_str) == 0) m = InterpMthd::Upper_Right; + else if(strcmp(mthd_str, interpmthd_lower_right_str) == 0) m = InterpMthd::Lower_Right; + else if(strcmp(mthd_str, interpmthd_lower_left_str) == 0) m = InterpMthd::Lower_Left; + else if(strcmp(mthd_str, interpmthd_gaussian_str ) == 0) m = InterpMthd::Gaussian; + else if(strcmp(mthd_str, interpmthd_maxgauss_str ) == 0) m = InterpMthd::MaxGauss; + else if(strcmp(mthd_str, interpmthd_geog_match_str) == 0) m = InterpMthd::Geog_Match; + else if(strcmp(mthd_str, interpmthd_hira_str) == 0) m = InterpMthd::HiRA; + else m = InterpMthd::None; return m; } diff --git a/src/basic/vx_util/interp_mthd.h b/src/basic/vx_util/interp_mthd.h index 0f061241e1..b5468168ed 100644 --- a/src/basic/vx_util/interp_mthd.h +++ b/src/basic/vx_util/interp_mthd.h @@ -21,29 +21,29 @@ // // Enumeration for interpolation methods // -enum InterpMthd { - InterpMthd_None, - InterpMthd_Min, - InterpMthd_Max, - InterpMthd_Median, - InterpMthd_UW_Mean, - InterpMthd_DW_Mean, - InterpMthd_AW_Mean, - InterpMthd_LS_Fit, - InterpMthd_Nbrhd, - InterpMthd_Bilin, - InterpMthd_Nearest, - InterpMthd_Budget, - InterpMthd_Force, - InterpMthd_Best, - InterpMthd_Upper_Left, - InterpMthd_Upper_Right, - InterpMthd_Lower_Right, - InterpMthd_Lower_Left, - InterpMthd_Gaussian, - InterpMthd_MaxGauss, - InterpMthd_Geog_Match, - InterpMthd_HiRA +enum class InterpMthd { + None, + Min, + Max, + Median, + UW_Mean, + DW_Mean, + AW_Mean, + LS_Fit, + Nbrhd, + Bilin, + Nearest, + Budget, + Force, + Best, + Upper_Left, + Upper_Right, + Lower_Right, + Lower_Left, + Gaussian, + MaxGauss, + Geog_Match, + HiRA }; // diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index 826c396e1e..db776d737e 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -16,6 +16,7 @@ #include #include +#include "config_util.h" #include "interp_util.h" #include "GridTemplate.h" #include "RectangularTemplate.h" @@ -26,6 +27,15 @@ using namespace std; +//////////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + //////////////////////////////////////////////////////////////////////// // // Code for struct SurfaceInfo @@ -958,68 +968,68 @@ double compute_sfc_interp(const DataPlane &dp, // Compute the interpolated value for the fields above and below switch(mthd) { - case(InterpMthd_Min): // Minimum + case(InterpMthd::Min): // Minimum v = interp_min(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_Max): // Maximum + case(InterpMthd::Max): // Maximum v = interp_max(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_Median): // Median + case(InterpMthd::Median): // Median v = interp_median(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case(InterpMthd::UW_Mean): // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_DW_Mean): // Distance-Weighted Mean + case(InterpMthd::DW_Mean): // Distance-Weighted Mean v = interp_dw_mean(dp, *gt, obs_x, obs_y, dw_mean_pow, interp_thresh, &sfc_mask); break; - case(InterpMthd_LS_Fit): // Least-squares fit + case(InterpMthd::LS_Fit): // Least-squares fit v = interp_ls_fit(dp, *gt, obs_x, obs_y, interp_thresh, &sfc_mask); break; - case(InterpMthd_Bilin): // Bilinear interpolation + case(InterpMthd::Bilin): // Bilinear interpolation v = interp_bilin(dp, wrap_lon, obs_x, obs_y, &sfc_mask); break; - case(InterpMthd_Nearest): // Nearest Neighbor + case(InterpMthd::Nearest): // Nearest Neighbor v = interp_xy(dp, wrap_lon, x, y, &sfc_mask); break; - case(InterpMthd_Best): // Best Match + case(InterpMthd::Best): // Best Match v = interp_best(dp, *gt, x, y, obs_v, interp_thresh, &sfc_mask); break; - case(InterpMthd_Upper_Left): // Upper Left corner of the grid box + case(InterpMthd::Upper_Left): // Upper Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), ceil(obs_y), &sfc_mask); break; - case(InterpMthd_Upper_Right): // Upper Right corner of the grid box + case(InterpMthd::Upper_Right): // Upper Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), ceil(obs_y), &sfc_mask); break; - case(InterpMthd_Lower_Right): // Lower Right corner of the grid box + case(InterpMthd::Lower_Right): // Lower Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), floor(obs_y), &sfc_mask); break; - case(InterpMthd_Lower_Left): // Lower Left corner of the grid box + case(InterpMthd::Lower_Left): // Lower Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), floor(obs_y), &sfc_mask); break; - case(InterpMthd_Geog_Match): // Geography Match for surface point verification + case(InterpMthd::Geog_Match): // Geography Match for surface point verification v = interp_geog_match(dp, *gt, obs_x, obs_y, obs_v, &sfc_mask); break; default: mlog << Error << "\ncompute_sfc_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; exit(1); } @@ -1127,73 +1137,73 @@ double compute_horz_interp(const DataPlane &dp, // Compute the interpolated value for the fields above and below switch(mthd) { - case(InterpMthd_Min): // Minimum + case(InterpMthd::Min): // Minimum v = interp_min(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_Max): // Maximum + case(InterpMthd::Max): // Maximum v = interp_max(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_Median): // Median + case(InterpMthd::Median): // Median v = interp_median(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case(InterpMthd::UW_Mean): // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_DW_Mean): // Distance-Weighted Mean + case(InterpMthd::DW_Mean): // Distance-Weighted Mean v = interp_dw_mean(dp, *gt, obs_x, obs_y, dw_mean_pow, interp_thresh); break; - case(InterpMthd_LS_Fit): // Least-squares fit + case(InterpMthd::LS_Fit): // Least-squares fit v = interp_ls_fit(dp, *gt, obs_x, obs_y, interp_thresh); break; - case(InterpMthd_Nbrhd): // Neighborhood fractional coverage + case(InterpMthd::Nbrhd): // Neighborhood fractional coverage v = interp_nbrhd(dp, *gt, x, y, interp_thresh, cat_thresh, cmn, csd); break; - case(InterpMthd_Bilin): // Bilinear interpolation + case(InterpMthd::Bilin): // Bilinear interpolation v = interp_bilin(dp, wrap_lon, obs_x, obs_y); break; - case(InterpMthd_Nearest): // Nearest Neighbor + case(InterpMthd::Nearest): // Nearest Neighbor v = interp_xy(dp, wrap_lon, x, y); break; - case(InterpMthd_Best): // Best Match + case(InterpMthd::Best): // Best Match v = interp_best(dp, *gt, x, y, obs_v, interp_thresh); break; - case(InterpMthd_Upper_Left): // Upper Left corner of the grid box + case(InterpMthd::Upper_Left): // Upper Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), ceil(obs_y)); break; - case(InterpMthd_Upper_Right): // Upper Right corner of the grid box + case(InterpMthd::Upper_Right): // Upper Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), ceil(obs_y)); break; - case(InterpMthd_Lower_Right): // Lower Right corner of the grid box + case(InterpMthd::Lower_Right): // Lower Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), floor(obs_y)); break; - case(InterpMthd_Lower_Left): // Lower Left corner of the grid box + case(InterpMthd::Lower_Left): // Lower Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), floor(obs_y)); break; - case(InterpMthd_Geog_Match): // Geography Match for surface point verification + case(InterpMthd::Geog_Match): // Geography Match for surface point verification v = interp_geog_match(dp, *gt, obs_x, obs_y, obs_v); break; default: mlog << Error << "\ncompute_horz_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; exit(1); } @@ -1308,37 +1318,37 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, // Compute interpolation weights switch(mthd) { - case(InterpMthd_Min): // Minimum - case(InterpMthd_Max): // Maximum + case(InterpMthd::Min): // Minimum + case(InterpMthd::Max): // Maximum w1 = w2 = bad_data_double; break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case(InterpMthd::UW_Mean): // Unweighted Mean w1 = w2 = 0.5; break; - case(InterpMthd_DW_Mean): // Distance-Weighted Mean + case(InterpMthd::DW_Mean): // Distance-Weighted Mean w1 = (double) (dp2.valid() - to_ut) / (dp2.valid() - dp1.valid()); w2 = (double) (to_ut - dp1.valid()) / (dp2.valid() - dp1.valid()); break; - case(InterpMthd_Nearest): // Nearest Neighbor + case(InterpMthd::Nearest): // Nearest Neighbor use_min = ((to_ut - dp1.valid()) <= (dp2.valid() - to_ut)); w1 = (use_min ? 1.0 : 0.0); w2 = (use_min ? 0.0 : 1.0); break; - case(InterpMthd_AW_Mean): // Area-Weighted Mean - case(InterpMthd_Median): // Median - case(InterpMthd_LS_Fit): // Least-squares fit - case(InterpMthd_Bilin): // Bilinear interpolation + case(InterpMthd::AW_Mean): // Area-Weighted Mean + case(InterpMthd::Median): // Median + case(InterpMthd::LS_Fit): // Least-squares fit + case(InterpMthd::Bilin): // Bilinear interpolation default: mlog << Error << "\nvalid_time_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; exit(1); } @@ -1360,11 +1370,11 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, if(!is_bad_data(v1) && !is_bad_data(v2)) { // Minimum - if(mthd == InterpMthd_Min) v = min(v1, v2); + if(mthd == InterpMthd::Min) v = min(v1, v2); // Maximum - else if(mthd == InterpMthd_Max) v = max(v1, v2); + else if(mthd == InterpMthd::Max) v = max(v1, v2); // Apply weights - else v = w1*v1 + w2*v2; + else v = w1*v1 + w2*v2; } // Store interpolated value diff --git a/src/basic/vx_util/normalize.cc b/src/basic/vx_util/normalize.cc index 11e8e9a7d2..5ad26ddfa3 100644 --- a/src/basic/vx_util/normalize.cc +++ b/src/basic/vx_util/normalize.cc @@ -14,10 +14,20 @@ #include #include +#include "config_util.h" #include "normalize.h" using namespace std; +//////////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + /////////////////////////////////////////////////////////////////////////////// ConcatString normalizetype_to_string(const NormalizeType type) { @@ -26,29 +36,29 @@ ConcatString normalizetype_to_string(const NormalizeType type) { // Convert enumerated NormalizeType to string switch(type) { - case NormalizeType_None: + case NormalizeType::None: s = normalizetype_none_str; break; - case NormalizeType_ClimoAnom: + case NormalizeType::ClimoAnom: s = normalizetype_climo_anom_str; break; - case NormalizeType_ClimoStdAnom: + case NormalizeType::ClimoStdAnom: s = normalizetype_climo_std_anom_str; break; - case NormalizeType_FcstAnom: + case NormalizeType::FcstAnom: s = normalizetype_fcst_anom_str; break; - case NormalizeType_FcstStdAnom: + case NormalizeType::FcstStdAnom: s = normalizetype_fcst_std_anom_str; break; default: mlog << Error << "\nnormalizetype_to_string() -> " - << "Unexpected NormalizeType value of " << type << ".\n\n"; + << "Unexpected NormalizeType value of " << enum_class_as_integer(type) << ".\n\n"; exit(1); } @@ -67,10 +77,10 @@ void normalize_data(DataPlane &dp, const NormalizeType type, // Supported types switch(type) { - case NormalizeType_None: + case NormalizeType::None: break; - case NormalizeType_ClimoAnom: + case NormalizeType::ClimoAnom: if(!cmn_ptr || dp.nxy() != cmn_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " << "the climatology mean is required for " @@ -80,7 +90,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, dp.anomaly(*cmn_ptr); break; - case NormalizeType_ClimoStdAnom: + case NormalizeType::ClimoStdAnom: if(!cmn_ptr || dp.nxy() != cmn_ptr->nxy() || !csd_ptr || dp.nxy() != csd_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " @@ -91,7 +101,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, dp.standard_anomaly(*cmn_ptr, *csd_ptr); break; - case NormalizeType_FcstAnom: + case NormalizeType::FcstAnom: if(!fmn_ptr || dp.nxy() != fmn_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " << "the forecast mean is required for " @@ -101,7 +111,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, dp.anomaly(*fmn_ptr); break; - case NormalizeType_FcstStdAnom: + case NormalizeType::FcstStdAnom: if(!fmn_ptr || dp.nxy() != fmn_ptr->nxy() || !fsd_ptr || dp.nxy() != fsd_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " @@ -115,7 +125,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, default: mlog << Error << "\nnormalize_data() -> " << "unexpected NormalizeType value (" - << type << ")\n\n"; + << enum_class_as_integer(type) << ")\n\n"; exit(1); } // end switch diff --git a/src/basic/vx_util/normalize.h b/src/basic/vx_util/normalize.h index b91fa45476..96fc32bc03 100644 --- a/src/basic/vx_util/normalize.h +++ b/src/basic/vx_util/normalize.h @@ -22,12 +22,12 @@ // Enumeration for normalization types // -enum NormalizeType { - NormalizeType_None, // No normalization - NormalizeType_ClimoAnom, // Subtract climo mean - NormalizeType_ClimoStdAnom, // Subtract climo mean and divide stdev - NormalizeType_FcstAnom, // Subtract fcst mean - NormalizeType_FcstStdAnom // Subtract fcst mean and divide stdev +enum class NormalizeType { + None, // No normalization + ClimoAnom, // Subtract climo mean + ClimoStdAnom, // Subtract climo mean and divide stdev + FcstAnom, // Subtract fcst mean + FcstStdAnom // Subtract fcst mean and divide stdev }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gsl_prob/gsl_randist.cc b/src/libcode/vx_gsl_prob/gsl_randist.cc index 3a9d87442d..956e912727 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.cc +++ b/src/libcode/vx_gsl_prob/gsl_randist.cc @@ -219,31 +219,31 @@ double ran_draw(const gsl_rng *r, DistType t, double p1, double p2) { // Switch on the distribution type switch(t) { - case(DistType_Normal): + case(DistType::Normal): v = gsl_ran_gaussian(r, p1); break; - case(DistType_Exponential): + case(DistType::Exponential): v = gsl_ran_exponential(r, p1); break; - case(DistType_ChiSquared): + case(DistType::ChiSquared): v = gsl_ran_chisq(r, p1); break; - case(DistType_Gamma): + case(DistType::Gamma): v = gsl_ran_gamma(r, p1, p2); break; - case(DistType_Uniform): + case(DistType::Uniform): v = gsl_ran_flat(r, p1, p2); break; - case(DistType_Beta): + case(DistType::Beta): v = gsl_ran_beta(r, p1, p2); break; - case(DistType_None): + case(DistType::None): default: v = 0.0; break; @@ -269,31 +269,31 @@ double dist_var(DistType t, double p1, double p2) { // Switch on the distribution type switch(t) { - case(DistType_Normal): + case(DistType::Normal): v = p1*p1; break; - case(DistType_Exponential): + case(DistType::Exponential): v = 1.0 / (p1*p1); break; - case(DistType_ChiSquared): + case(DistType::ChiSquared): v = 2*p1; break; - case(DistType_Gamma): + case(DistType::Gamma): v = p1 / (p2*p2); break; - case(DistType_Uniform): + case(DistType::Uniform): v = ((p2-p1)*(p2-p1)) / 12.0; break; - case(DistType_Beta): + case(DistType::Beta): v = (p1*p2) / ((p1+p2)*(p1+p2)*(p1+p2+1.0)); break; - case(DistType_None): + case(DistType::None): default: v = 0.0; break; diff --git a/src/libcode/vx_gsl_prob/gsl_randist.h b/src/libcode/vx_gsl_prob/gsl_randist.h index e66c312230..1e8555e0d4 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.h +++ b/src/libcode/vx_gsl_prob/gsl_randist.h @@ -23,14 +23,14 @@ // Enumeration for distribution types // -enum DistType { - DistType_None, // No distribution - DistType_Normal, // Normal distribution - DistType_Exponential, // Exponential distribution - DistType_ChiSquared, // Chi-Squared distribution - DistType_Gamma, // Gamma distribution - DistType_Uniform, // Uniform distribution - DistType_Beta // Beta distribution +enum class DistType { + None, // No distribution + Normal, // Normal distribution + Exponential, // Exponential distribution + ChiSquared, // Chi-Squared distribution + Gamma, // Gamma distribution + Uniform, // Uniform distribution + Beta // Beta distribution }; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_regrid/vx_regrid.cc b/src/libcode/vx_regrid/vx_regrid.cc index 418cceb5c3..7abfee78b4 100644 --- a/src/libcode/vx_regrid/vx_regrid.cc +++ b/src/libcode/vx_regrid/vx_regrid.cc @@ -32,30 +32,30 @@ DataPlane out; switch ( info.method ) { - case InterpMthd_Min: - case InterpMthd_Max: - case InterpMthd_Median: - case InterpMthd_UW_Mean: - case InterpMthd_DW_Mean: - case InterpMthd_LS_Fit: - case InterpMthd_Bilin: - case InterpMthd_Nearest: + case InterpMthd::Min: + case InterpMthd::Max: + case InterpMthd::Median: + case InterpMthd::UW_Mean: + case InterpMthd::DW_Mean: + case InterpMthd::LS_Fit: + case InterpMthd::Bilin: + case InterpMthd::Nearest: out = met_regrid_generic (in, from_grid, to_grid, info); break; - case InterpMthd_Budget: + case InterpMthd::Budget: out = met_regrid_budget (in, from_grid, to_grid, info); break; - case InterpMthd_AW_Mean: + case InterpMthd::AW_Mean: out = met_regrid_area_weighted (in, from_grid, to_grid, info); break; - case InterpMthd_Force: + case InterpMthd::Force: out = met_regrid_force (in, from_grid, to_grid, info); break; - case InterpMthd_MaxGauss: + case InterpMthd::MaxGauss: out = met_regrid_maxgauss (in, from_grid, to_grid, info); break; @@ -97,9 +97,9 @@ DataPlane met_regrid_nearest (const DataPlane & from_data, const Grid & from_gri RegridInfo ri; ri.enable = true; -ri.method = InterpMthd_Nearest; +ri.method = InterpMthd::Nearest; ri.width = 1; -ri.shape = GridTemplateFactory::GridTemplate_Square; +ri.shape = GridTemplateFactory::GridTemplates::Square; return met_regrid_generic(from_data, from_grid, to_grid, ri); @@ -346,7 +346,7 @@ for (xt=0; xt<(to_grid.nx()); ++xt) { } else { value = compute_horz_interp(from_data, x_from, y_from, - bad_data_double, InterpMthd_Max, info.width, + bad_data_double, InterpMthd::Max, info.width, info.shape, from_grid.wrap_lon(), info.vld_thresh); } diff --git a/src/libcode/vx_shapedata/shapedata.cc b/src/libcode/vx_shapedata/shapedata.cc index ca2c6ead1c..94fed61cba 100644 --- a/src/libcode/vx_shapedata/shapedata.cc +++ b/src/libcode/vx_shapedata/shapedata.cc @@ -532,7 +532,7 @@ void ShapeData::conv_filter_circ(int diameter, double vld_thresh) { // Build the grid template with shape circle and wrap_lon false GridTemplateFactory gtf; - GridTemplate* gt = gtf.buildGT(GridTemplateFactory::GridTemplate_Circle, + GridTemplate* gt = gtf.buildGT(GridTemplateFactory::GridTemplates::Circle, diameter, false); #pragma omp single diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 896d347ad4..07c4df90d6 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -1682,8 +1682,8 @@ void write_isc_row(StatHdrColumns &shc, const ISCInfo &isc_info, shc.set_line_type(stat_isc_str); // Not Applicable - shc.set_interp_mthd(InterpMthd_None, - GridTemplateFactory::GridTemplate_None); + shc.set_interp_mthd(InterpMthd::None, + GridTemplateFactory::GridTemplates::None); shc.set_interp_wdth(bad_data_int); shc.set_cov_thresh(na_str); shc.set_alpha(bad_data_double); diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.cc b/src/libcode/vx_stat_out/stat_hdr_columns.cc index dab211c348..005499d8ed 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.cc +++ b/src/libcode/vx_stat_out/stat_hdr_columns.cc @@ -221,7 +221,7 @@ void StatHdrColumns::set_interp_mthd(ConcatString s, ConcatString mthd = s; // Only append the interpolation shape when applicable - if(shape != GridTemplateFactory::GridTemplate_None && + if(shape != GridTemplateFactory::GridTemplates::None && mthd != interpmthd_none_str && mthd != interpmthd_bilin_str && mthd != interpmthd_nearest_str && diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.h b/src/libcode/vx_stat_out/stat_hdr_columns.h index 7b40ff54ee..6a1c5da0fb 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.h +++ b/src/libcode/vx_stat_out/stat_hdr_columns.h @@ -133,9 +133,9 @@ class StatHdrColumns { void set_mask (const char *); void set_interp_mthd (ConcatString s, - GridTemplateFactory::GridTemplates shape = GridTemplateFactory::GridTemplate_None); + GridTemplateFactory::GridTemplates shape = GridTemplateFactory::GridTemplates::None); void set_interp_mthd (const InterpMthd m, - GridTemplateFactory::GridTemplates shape = GridTemplateFactory::GridTemplate_None); + GridTemplateFactory::GridTemplates shape = GridTemplateFactory::GridTemplates::None); void set_interp_pnts (const int); void set_interp_wdth (const int); diff --git a/src/libcode/vx_statistics/obs_error.cc b/src/libcode/vx_statistics/obs_error.cc index 5b753346a3..6b2c95a906 100644 --- a/src/libcode/vx_statistics/obs_error.cc +++ b/src/libcode/vx_statistics/obs_error.cc @@ -108,7 +108,7 @@ void ObsErrorEntry::clear() { bias_scale = bias_offset = bad_data_double; - dist_type = DistType_None; + dist_type = DistType::None; dist_parm.clear(); v_min = bad_data_double; @@ -240,7 +240,7 @@ bool ObsErrorEntry::parse_line(const DataLine &dl) { bias_offset = (strcmp(dl[10], na_str) == 0 ? bad_data_double : atof(dl[10])); dist_type = string_to_disttype(dl[11]); - if(dist_type != DistType_None) dist_parm.add_css(dl[12]); + if(dist_type != DistType::None) dist_parm.add_css(dl[12]); // Range check if((hgt_range.n() != 0 && hgt_range.n() != 2) || @@ -320,13 +320,13 @@ void ObsErrorEntry::validate() { int n_req; // Number of distribution parameters - if(dist_type == DistType_Gamma || - dist_type == DistType_Uniform || - dist_type == DistType_Beta) n_req = 2; + if(dist_type == DistType::Gamma || + dist_type == DistType::Uniform || + dist_type == DistType::Beta) n_req = 2; else n_req = 1; // Make sure we have the expected number of parameters - if(dist_type != DistType_None && + if(dist_type != DistType::None && dist_parm.n() != n_req) { mlog << Error << "\nObsErrorEntry::validate() -> " << "expected " << n_req << " parameter(s) but got " @@ -714,7 +714,7 @@ double add_obs_error_inc(const gsl_rng *r, FieldType t, if(!e || is_bad_data(v)) return v; // Apply the specified random perturbation - if(e->dist_type != DistType_None) { + if(e->dist_type != DistType::None) { v_new += ran_draw(r, e->dist_type, e->dist_parm[0], e->dist_parm[1]); } @@ -727,7 +727,7 @@ double add_obs_error_inc(const gsl_rng *r, FieldType t, if(mlog.verbosity_level() >= 4) { // Check for no updates - if(e->dist_type == DistType_None) { + if(e->dist_type == DistType::None) { mlog << Debug(4) << "Applying no observation error update for " << fieldtype_to_string(t) << " value " << v diff --git a/src/libcode/vx_statistics/pair_base.cc b/src/libcode/vx_statistics/pair_base.cc index 99a14e97e3..f3ffaed3fb 100644 --- a/src/libcode/vx_statistics/pair_base.cc +++ b/src/libcode/vx_statistics/pair_base.cc @@ -74,8 +74,8 @@ void PairBase::clear() { msg_typ_vals.clear(); interp_wdth = 0; - interp_mthd = InterpMthd_None; - interp_shape = GridTemplateFactory::GridTemplate_None; + interp_mthd = InterpMthd::None; + interp_shape = GridTemplateFactory::GridTemplates::None; o_na.clear(); x_na.clear(); @@ -123,8 +123,8 @@ void PairBase::erase() { msg_typ.clear(); msg_typ_vals.clear(); - interp_mthd = InterpMthd_None; - interp_shape = GridTemplateFactory::GridTemplate_None; + interp_mthd = InterpMthd::None; + interp_shape = GridTemplateFactory::GridTemplates::None; o_na.erase(); x_na.erase(); diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index 173aa68d76..2cf41de138 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -1399,7 +1399,7 @@ void VxPairDataEnsemble::set_ens_size(int n) { for(int k=0; kflag) { // Use config file setting, if specified - if(obs_error_info->entry.dist_type != DistType_None) { + if(obs_error_info->entry.dist_type != DistType::None) { oerr_ptr = &(obs_error_info->entry); } // Otherwise, do a table lookup @@ -1692,10 +1692,10 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, // Check for valid interpolation options if(climo_sd_dpa.n_planes() > 0 && - (pd[0][0][k].interp_mthd == InterpMthd_Min || - pd[0][0][k].interp_mthd == InterpMthd_Max || - pd[0][0][k].interp_mthd == InterpMthd_Median || - pd[0][0][k].interp_mthd == InterpMthd_Best)) { + (pd[0][0][k].interp_mthd == InterpMthd::Min || + pd[0][0][k].interp_mthd == InterpMthd::Max || + pd[0][0][k].interp_mthd == InterpMthd::Median || + pd[0][0][k].interp_mthd == InterpMthd::Best)) { mlog << Warning << "\nVxPairDataEnsemble::add_point_obs() -> " << "applying the " << interpmthd_to_string(pd[0][0][k].interp_mthd) @@ -1752,7 +1752,7 @@ void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { for(k=0; k " @@ -1785,7 +1785,7 @@ void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { } // Extract the HiRA neighborhood of values - if(pd[0][0][k].interp_mthd == InterpMthd_HiRA) { + if(pd[0][0][k].interp_mthd == InterpMthd::HiRA) { // For HiRA, set the ensemble mean to bad data if(mn) { diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 0a99b81d0c..dd84a4e440 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -28,6 +28,15 @@ using namespace std; +//////////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + //////////////////////////////////////////////////////////////////////// // // Code for class PairDataPoint @@ -1081,8 +1090,8 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Interpolate model topography to observation location double topo = compute_horz_interp( *sfc_info.topo_ptr, obs_x, obs_y, hdr_elv, - InterpMthd_Bilin, 2, - GridTemplateFactory::GridTemplate_Square, + InterpMthd::Bilin, 2, + GridTemplateFactory::GridTemplates::Square, gr.wrap_lon(), 1.0); // Skip bad topography values @@ -1277,10 +1286,10 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check for valid interpolation options if(climo_sd_dpa.n_planes() > 0 && - (pd[0][0][k].interp_mthd == InterpMthd_Min || - pd[0][0][k].interp_mthd == InterpMthd_Max || - pd[0][0][k].interp_mthd == InterpMthd_Median || - pd[0][0][k].interp_mthd == InterpMthd_Best)) { + (pd[0][0][k].interp_mthd == InterpMthd::Min || + pd[0][0][k].interp_mthd == InterpMthd::Max || + pd[0][0][k].interp_mthd == InterpMthd::Median || + pd[0][0][k].interp_mthd == InterpMthd::Best)) { mlog << Warning << "\nVxPairDataPoint::add_point_obs() -> " << "applying the " << interpmthd_to_string(pd[0][0][k].interp_mthd) diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 6a069322d6..f00ca74bfd 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -1285,7 +1285,7 @@ void process_grid_vx() { if(conf_info.vx_opt[i].obs_error.flag) { // Use config file setting, if specified - if(conf_info.vx_opt[i].obs_error.entry.dist_type != DistType_None) { + if(conf_info.vx_opt[i].obs_error.entry.dist_type != DistType::None) { mlog << Debug(3) << "Observation error for gridded verification is " << "defined in the configuration file.\n"; @@ -1476,11 +1476,11 @@ void process_grid_vx() { FieldType field = conf_info.vx_opt[i].interp_info.field; // Check for allowable smoothing operation - if(mthd == InterpMthd_DW_Mean || - mthd == InterpMthd_LS_Fit || - mthd == InterpMthd_Bilin || - mthd == InterpMthd_Nbrhd || - mthd == InterpMthd_HiRA) { + if(mthd == InterpMthd::DW_Mean || + mthd == InterpMthd::LS_Fit || + mthd == InterpMthd::Bilin || + mthd == InterpMthd::Nbrhd || + mthd == InterpMthd::HiRA) { mlog << Warning << "\nprocess_grid_vx() -> " << mthd_str << " option not supported for " diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 479b1406dd..003057617f 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -284,7 +284,7 @@ void EnsembleStatConfInfo::process_config(GrdFileType etype, // Track the maximum HiRA size for(j=0; jwidth.n(); j++) { - shc.set_interp_mthd(InterpMthd_Nbrhd, nbrhd->shape); + shc.set_interp_mthd(InterpMthd::Nbrhd, nbrhd->shape); shc.set_interp_wdth(nbrhd->width[j]); // Loop through and apply each of the raw threshold values @@ -1727,7 +1727,7 @@ void process_scores() { cs << "-" << conf_info.vx_opt[i].wave_1d_end[j]; } - shc.set_interp_mthd(cs, GridTemplateFactory::GridTemplate_None); + shc.set_interp_mthd(cs, GridTemplateFactory::GridTemplates::None); shc.set_interp_pnts(bad_data_int); // Loop through the masks to be applied @@ -2592,7 +2592,7 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, // Append smoothing info for all but nearest neighbor if(interp_pnts > 1 || - interp_mthd == interpmthd_to_string(InterpMthd_Gaussian)) { + interp_mthd == interpmthd_to_string(InterpMthd::Gaussian)) { interp_str << "_" << interp_mthd << "_" << interp_pnts; } // Append Fourier decomposition info @@ -2882,7 +2882,7 @@ void write_nbrhd_nc(const DataPlane &fcst_dp, const DataPlane &obs_dp, NcVar obs_var; // Get the interpolation strings - mthd_str = interpmthd_to_string(InterpMthd_Nbrhd); + mthd_str = interpmthd_to_string(InterpMthd::Nbrhd); if(wdth > 1) nbrhd_str << "_" << mthd_str << "_" << wdth*wdth; int deflate_level = compress_level; 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 cd1a00b593..d277783684 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -804,9 +804,9 @@ void GridStatVxOpt::process_config( mthd = string_to_interpmthd(interp_info.method[i].c_str()); // Check for unsupported interpolation methods - if(mthd == InterpMthd_DW_Mean || - mthd == InterpMthd_LS_Fit || - mthd == InterpMthd_Bilin) { + if(mthd == InterpMthd::DW_Mean || + mthd == InterpMthd::LS_Fit || + mthd == InterpMthd::Bilin) { mlog << Error << "\nGridStatVxOpt::process_config() -> " << "Interpolation methods DW_MEAN, LS_FIT, and BILIN are " << "not supported in Grid-Stat.\n\n"; diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index c911779718..38cbc28f40 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -1805,7 +1805,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { bool spfh_flag = conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_specific_humidity() && conf_info.vx_opt[i_vx].vx_pd.obs_info->is_specific_humidity(); - shc.set_interp_mthd(InterpMthd_Nbrhd, + shc.set_interp_mthd(InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.shape); // Loop over the HiRA widths @@ -1841,7 +1841,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { // Get the nearby forecast values get_interp_points(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa, pd_ptr->x_na[j], pd_ptr->y_na[j], - InterpMthd_Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[i], + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[i], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), @@ -1988,7 +1988,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { bool precip_flag = conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_precipitation() && conf_info.vx_opt[i_vx].vx_pd.obs_info->is_precipitation(); - shc.set_interp_mthd(InterpMthd_Nbrhd, + shc.set_interp_mthd(InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.shape); // Loop over categorical thresholds and HiRA widths @@ -2019,7 +2019,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { f_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa, pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], pd_ptr->cmn_na[k], pd_ptr->csd_na[k], - InterpMthd_Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), @@ -2038,7 +2038,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { cmn_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.climo_mn_dpa, pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], pd_ptr->cmn_na[k], pd_ptr->csd_na[k], - InterpMthd_Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index 81a28634d2..4de6c2b2b8 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -303,12 +303,12 @@ void process_ensemble() { // read climatology separately for each member set_climo_ens_mem_id = (conf_info.ens_member_ids.n() > 1) && - ((*var_it)->normalize == NormalizeType_ClimoAnom || - (*var_it)->normalize == NormalizeType_ClimoStdAnom); + ((*var_it)->normalize == NormalizeType::ClimoAnom || + (*var_it)->normalize == NormalizeType::ClimoStdAnom); // Print out the normalization flag cs << cs_erase; - if((*var_it)->normalize != NormalizeType_None) { + if((*var_it)->normalize != NormalizeType::None) { cs << " with normalize = " << normalizetype_to_string((*var_it)->normalize); } @@ -359,8 +359,8 @@ void process_ensemble() { i_ens, cmn_dp, csd_dp); // Compute the ensemble summary data, if needed - if((*var_it)->normalize == NormalizeType_FcstAnom || - (*var_it)->normalize == NormalizeType_FcstStdAnom) { + if((*var_it)->normalize == NormalizeType::FcstAnom || + (*var_it)->normalize == NormalizeType::FcstStdAnom) { get_ens_mean_stdev((*var_it), emn_dp, esd_dp); } else { @@ -394,7 +394,7 @@ void process_ensemble() { } // Normalize, if requested - if((*var_it)->normalize != NormalizeType_None) { + if((*var_it)->normalize != NormalizeType::None) { normalize_data(ctrl_dp, (*var_it)->normalize, &cmn_dp, &csd_dp, &emn_dp, &esd_dp); } @@ -421,7 +421,7 @@ void process_ensemble() { } // Normalize, if requested - if((*var_it)->normalize != NormalizeType_None) { + if((*var_it)->normalize != NormalizeType::None) { normalize_data(ens_dp, (*var_it)->normalize, &cmn_dp, &csd_dp, &emn_dp, &esd_dp); } @@ -950,7 +950,7 @@ void write_ens_nc(GenEnsProdVarInfo *ens_info, int n_ens_vld, // Loop over the neighborhoods for(j=0; jcat_ta[i].get_abbr_str().contents().c_str(), - interpmthd_to_string(InterpMthd_Nbrhd).c_str(), + interpmthd_to_string(InterpMthd::Nbrhd).c_str(), conf_info.nbrhd_prob.width[j]*conf_info.nbrhd_prob.width[j]); write_ens_data_plane(ens_info, nbrhd_dp, ens_dp, type_str, "Neighborhood Ensemble Probability"); @@ -1001,7 +1001,7 @@ void write_ens_nc(GenEnsProdVarInfo *ens_info, int n_ens_vld, // Write neighborhood maximum ensemble probability snprintf(type_str, sizeof(type_str), "ENS_NMEP_%s_%s%i_%s%i", ens_info->cat_ta[i].get_abbr_str().contents().c_str(), - interpmthd_to_string(InterpMthd_Nbrhd).c_str(), + interpmthd_to_string(InterpMthd::Nbrhd).c_str(), conf_info.nbrhd_prob.width[j]*conf_info.nbrhd_prob.width[j], conf_info.nmep_smooth.method[k].c_str(), conf_info.nmep_smooth.width[k]*conf_info.nmep_smooth.width[k]); diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc index 81209ede28..52281061fd 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc @@ -304,9 +304,9 @@ void GenEnsProdConfInfo::process_config(GrdFileType etype, StringArray * ens_fil mthd = string_to_interpmthd(nmep_smooth.method[i].c_str()); // Check for unsupported neighborhood probability smoothing methods - if(mthd == InterpMthd_DW_Mean || - mthd == InterpMthd_LS_Fit || - mthd == InterpMthd_Bilin) { + if(mthd == InterpMthd::DW_Mean || + mthd == InterpMthd::LS_Fit || + mthd == InterpMthd::Bilin) { mlog << Error << "\nGenEnsProdConfInfo::process_config() -> " << "Neighborhood probability smoothing methods DW_MEAN, " << "LS_FIT, and BILIN are not supported for \"" diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 64b6690ecd..d11044dc5f 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -66,7 +66,7 @@ static const int TYPE_GOES = 5; static const int TYPE_GOES_ADP = 6; static const int TYPE_PYTHON = 7; // MET Point Obs NetCDF from PYTHON -static const InterpMthd DefaultInterpMthd = InterpMthd_UW_Mean; +static const InterpMthd DefaultInterpMthd = InterpMthd::UW_Mean; static const int DefaultInterpWdth = 2; static const double DefaultVldThresh = 0.5; @@ -995,9 +995,9 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI int data_count = dataArray.n(); if (0 < data_count) { float to_value; - if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd_Median) { + if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { dataArray.sort_array(); to_value = dataArray[data_count/2]; if (0 == data_count % 2) @@ -1486,9 +1486,9 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, float to_value; int data_cnt = dataArray.n(); if (1 == data_cnt) to_value = dataArray[0]; - else if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd_Median) { + else if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { dataArray.sort_array(); to_value = dataArray[data_cnt/2]; if (0 == data_cnt % 2) @@ -2600,9 +2600,9 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, if (0 < dataArray.n()) { int data_count = dataArray.n(); float to_value; - if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd_Median) { + if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { dataArray.sort_array(); to_value = dataArray[data_count/2]; if (0 == data_count % 2) @@ -2847,9 +2847,9 @@ void set_field(const StringArray &a) { void set_method(const StringArray &a) { InterpMthd method_id = string_to_interpmthd(a[0].c_str()); - if (method_id == InterpMthd_Gaussian || method_id == InterpMthd_MaxGauss ) { + if (method_id == InterpMthd::Gaussian || method_id == InterpMthd::MaxGauss ) { do_gaussian_filter = true; - if (method_id == InterpMthd_MaxGauss) RGInfo.method = InterpMthd_Max; + if (method_id == InterpMthd::MaxGauss) RGInfo.method = InterpMthd::Max; } else RGInfo.method = method_id; opt_override_method = true; diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index 396b30633c..28ec4704ea 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -65,7 +65,7 @@ using namespace netCDF; static ConcatString program_name; // Constants -static const InterpMthd DefaultInterpMthd = InterpMthd_Nearest; +static const InterpMthd DefaultInterpMthd = InterpMthd::Nearest; static const int DefaultInterpWdth = 1; static const double DefaultVldThresh = 0.5; @@ -146,7 +146,7 @@ void process_command_line(int argc, char **argv) { RGInfo.gaussian.radius = default_gaussian_radius; RGInfo.gaussian.trunc_factor = default_trunc_factor; RGInfo.vld_thresh = DefaultVldThresh; - RGInfo.shape = GridTemplateFactory::GridTemplate_Square; + RGInfo.shape = GridTemplateFactory::GridTemplates::Square; // Check for zero arguments if(argc == 1) usage(); @@ -204,7 +204,7 @@ void process_command_line(int argc, char **argv) { } RGInfo.validate(); - if (RGInfo.method == InterpMthd_Gaussian || RGInfo.method == InterpMthd_MaxGauss) + if (RGInfo.method == InterpMthd::Gaussian || RGInfo.method == InterpMthd::MaxGauss) RGInfo.gaussian.compute(); return; diff --git a/src/tools/other/shift_data_plane/shift_data_plane.cc b/src/tools/other/shift_data_plane/shift_data_plane.cc index b86ec79e76..40e2f742bc 100644 --- a/src/tools/other/shift_data_plane/shift_data_plane.cc +++ b/src/tools/other/shift_data_plane/shift_data_plane.cc @@ -72,9 +72,9 @@ static double ToLon = bad_data_double; static ConcatString InputFilename; static ConcatString OutputFilename; static ConcatString FieldString; -static InterpMthd Method = InterpMthd_DW_Mean; +static InterpMthd Method = InterpMthd::DW_Mean; static int Width = 2; -static GridTemplateFactory::GridTemplates Shape = GridTemplateFactory::GridTemplate_Square; +static GridTemplateFactory::GridTemplates Shape = GridTemplateFactory::GridTemplates::Square; static int compress_level = -1; // Static global variables diff --git a/src/tools/other/wwmca_tool/wwmca_ref.cc b/src/tools/other/wwmca_tool/wwmca_ref.cc index b8c2b2f810..f66515ca99 100644 --- a/src/tools/other/wwmca_tool/wwmca_ref.cc +++ b/src/tools/other/wwmca_tool/wwmca_ref.cc @@ -124,7 +124,7 @@ ConfigFilename.clear(); Width = 0; -Method = InterpMthd_None; +Method = InterpMthd::None; interp_func = 0; @@ -335,7 +335,7 @@ const RegridInfo regrid_info = parse_conf_regrid(Config); Width = regrid_info.width; -Method = InterpMthd_Nearest; +Method = InterpMthd::Nearest; Fraction = regrid_info.vld_thresh; @@ -367,15 +367,15 @@ if ( Width > 1 ) { switch ( Method ) { - case InterpMthd_Min: + case InterpMthd::Min: interp_func = &dp_interp_min; break; - case InterpMthd_Max: + case InterpMthd::Max: interp_func = &dp_interp_max; break; - case InterpMthd_UW_Mean: + case InterpMthd::UW_Mean: interp_func = &dp_interp_uw_mean; break; From 15987a1fa99a3b3cbbb899b35b399c79ee8baee4 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 28 Mar 2024 01:16:53 +0000 Subject: [PATCH 041/114] #2830 Moved enum_class_as_integer from header file to cc files --- src/basic/vx_config/config_util.h | 4 ---- src/libcode/vx_shapedata/engine.cc | 9 +++++++++ src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index e5cb69ce6e..3dae869b2b 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -153,10 +153,6 @@ extern int parse_conf_percentile(Dictionary *dict); extern void python_compile_error(const char *caller=nullptr); extern void ugrid_compile_error(const char *caller=nullptr); -template -extern auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type; - /////////////////////////////////////////////////////////////////////////////// #endif /* __CONFIG_UTIL_H__ */ diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index 06b767f579..008115bad9 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -31,6 +31,15 @@ static const int print_interest_log_level = 5; static inline double area_ratio_conf(double t) { return t; } +//////////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + /////////////////////////////////////////////////////////////////////// // // Code for class ModeFuzzyEngine diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index f8ad83eb9a..b644a3dc2f 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -24,6 +24,15 @@ using namespace std; +//////////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_integer(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + //////////////////////////////////////////////////////////////////////// // // Code for class WaveletStatConfInfo From 8a277fa9d4afb5dae82221ce92484465aab45f43 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 1 Apr 2024 21:21:54 +0000 Subject: [PATCH 042/114] #2830 Added enum_as_int.hpp --- src/basic/vx_log/Makefile.am | 2 +- src/basic/vx_log/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/vx_log/Makefile.am b/src/basic/vx_log/Makefile.am index 9e4ba32cf2..49f7f988ff 100644 --- a/src/basic/vx_log/Makefile.am +++ b/src/basic/vx_log/Makefile.am @@ -17,7 +17,7 @@ libvx_log_a_SOURCES = concat_string.cc concat_string.h \ logger.cc logger.h \ string_array.cc string_array.h \ str_wrappers.cc str_wrappers.h \ - vx_log.h + enum_as_int.hpp vx_log.h # Build the library when making a distribution so that # we can make enum_to_string and chk4copyright. diff --git a/src/basic/vx_log/Makefile.in b/src/basic/vx_log/Makefile.in index bfbfb1c4b6..272dddb3ca 100644 --- a/src/basic/vx_log/Makefile.in +++ b/src/basic/vx_log/Makefile.in @@ -350,7 +350,7 @@ libvx_log_a_SOURCES = concat_string.cc concat_string.h \ logger.cc logger.h \ string_array.cc string_array.h \ str_wrappers.cc str_wrappers.h \ - vx_log.h + enum_as_int.hpp vx_log.h all: all-am From fa41fa3a983dc73e7eaf56bef1b34dd849329cef Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 1 Apr 2024 21:22:01 +0000 Subject: [PATCH 043/114] #2830 Added enum_as_int.hpp --- src/basic/vx_log/enum_as_int.hpp | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/basic/vx_log/enum_as_int.hpp diff --git a/src/basic/vx_log/enum_as_int.hpp b/src/basic/vx_log/enum_as_int.hpp new file mode 100644 index 0000000000..ded32a2a09 --- /dev/null +++ b/src/basic/vx_log/enum_as_int.hpp @@ -0,0 +1,34 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + + +////////////////////////////////////////////////////////////////// + + +#ifndef __ENUM_CLASS_AS_INT_HPP__ +#define __ENUM_CLASS_AS_INT_HPP__ + + +////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_int(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + +////////////////////////////////////////////////////////////////// + + +#endif // __ENUM_CLASS_AS_INT_HPP__ + + +////////////////////////////////////////////////////////////////// + + From 5c95525f803237477cfbe78fbbbdee658500a637 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 1 Apr 2024 21:24:17 +0000 Subject: [PATCH 044/114] Deleted enum_class_as_integer and renamed it to enum_class_as_int --- src/basic/vx_config/config_util.cc | 35 ++++++++++++------------------ 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 42e5972444..3885850a70 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -13,6 +13,7 @@ #include #include "config_util.h" +#include "enum_as_int.hpp" #include "vx_math.h" #include "vx_util.h" @@ -264,14 +265,6 @@ RegridInfo &RegridInfo::operator=(const RegridInfo &a) noexcept { return *this; } -/////////////////////////////////////////////////////////////////////////////// - -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} /////////////////////////////////////////////////////////////////////////////// @@ -2812,7 +2805,7 @@ ConcatString fieldtype_to_string(FieldType type) { case FieldType::Obs: s = conf_val_obs; break; default: mlog << Error << "\nfieldtype_to_string() -> " - << "Unexpected FieldType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected FieldType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2881,7 +2874,7 @@ ConcatString setlogic_to_string(SetLogic type) { case SetLogic::SymDiff: s = conf_val_symdiff; break; default: mlog << Error << "\nsetlogic_to_string() -> " - << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2901,7 +2894,7 @@ ConcatString setlogic_to_abbr(SetLogic type) { case SetLogic::SymDiff: s = setlogic_abbr_symdiff; break; default: mlog << Error << "\nsetlogic_to_abbr() -> " - << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2921,7 +2914,7 @@ ConcatString setlogic_to_symbol(SetLogic type) { case SetLogic::SymDiff: s = setlogic_symbol_symdiff; break; default: mlog << Error << "\nsetlogic_to_symbol() -> " - << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3000,7 +2993,7 @@ ConcatString tracktype_to_string(TrackType type) { case TrackType::BDeck: s = conf_val_bdeck; break; default: mlog << Error << "\ntracktype_to_string() -> " - << "Unexpected TrackType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected TrackType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3037,7 +3030,7 @@ ConcatString diagtype_to_string(DiagType type) { case DiagType::SHIPS_Dev: s = ships_diag_dev_str; break; default: mlog << Error << "\ndiagtype_to_string() -> " - << "Unexpected DiagType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected DiagType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3092,7 +3085,7 @@ ConcatString interp12type_to_string(Interp12Type type) { case Interp12Type::Replace: s = conf_val_replace; break; default: mlog << Error << "\ninterp12type_to_string() -> " - << "Unexpected Interp12Type value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected Interp12Type value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3131,7 +3124,7 @@ ConcatString mergetype_to_string(MergeType type) { case MergeType::Engine: s = conf_val_engine; break; default: mlog << Error << "\nmergetype_to_string() -> " - << "Unexpected MergeType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected MergeType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3157,7 +3150,7 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { break; default: mlog << Error << "\nobssummary_to_string() -> " - << "Unexpected ObsSummary value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected ObsSummary value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3196,7 +3189,7 @@ ConcatString matchtype_to_string(MatchType type) { case MatchType::NoMerge: s = conf_val_no_merge; break; default: mlog << Error << "\nmatchtype_to_string() -> " - << "Unexpected MatchType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected MatchType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3263,7 +3256,7 @@ ConcatString disttype_to_string(DistType type) { case DistType::Beta: s = conf_val_beta; break; default: mlog << Error << "\ndisttype_to_string() -> " - << "Unexpected DistType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected DistType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3304,7 +3297,7 @@ ConcatString griddecomptype_to_string(GridDecompType type) { case GridDecompType::Pad: s = conf_val_pad; break; default: mlog << Error << "\ngriddecomptype_to_string() -> " - << "Unexpected GridDecompType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected GridDecompType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3327,7 +3320,7 @@ ConcatString wavelettype_to_string(WaveletType type) { case WaveletType::BSpline_Cntr: s = conf_val_bspline_cntr; break; default: mlog << Error << "\nwavlettype_to_string() -> " - << "Unexpected WaveletType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected WaveletType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } From 62acda76cab025b02929efa23acb99e13c6f3d51 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 1 Apr 2024 21:24:17 +0000 Subject: [PATCH 045/114] Removed redundant paranthese --- src/basic/vx_log/logger.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/vx_log/logger.h b/src/basic/vx_log/logger.h index 7f0e2ca95a..d88333e98b 100644 --- a/src/basic/vx_log/logger.h +++ b/src/basic/vx_log/logger.h @@ -79,9 +79,9 @@ class MsgLevel ////////////////////////////////////////////////////////////////// -inline int MsgLevel::value() const { return (Value); } +inline int MsgLevel::value() const { return Value; } -inline MsgLevel::operator const int & () const { return (Value); } +inline MsgLevel::operator const int & () const { return Value; } ////////////////////////////////////////////////////////////////// From 6ac387f8a6761e3380d58cf6e03576a518f2b972 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 1 Apr 2024 21:37:46 +0000 Subject: [PATCH 046/114] #2830 Changed enum to enumclass --- src/basic/vx_util/GridTemplate.h | 2 +- src/libcode/vx_analysis_util/stat_job.cc | 4 +- src/libcode/vx_analysis_util/stat_job.h | 2 +- src/libcode/vx_tc_util/atcf_line_base.cc | 66 ++++----- src/libcode/vx_tc_util/atcf_line_base.h | 28 ++-- src/libcode/vx_tc_util/atcf_offsets.h | 6 +- src/libcode/vx_tc_util/atcf_prob_line.cc | 4 +- src/libcode/vx_tc_util/atcf_track_line.cc | 68 ++++----- src/libcode/vx_tc_util/atcf_track_line.h | 4 +- src/libcode/vx_tc_util/prob_gen_info.cc | 2 +- src/libcode/vx_tc_util/prob_info_array.cc | 8 +- src/libcode/vx_tc_util/prob_info_base.cc | 8 +- src/libcode/vx_tc_util/prob_rirw_info.cc | 2 +- src/libcode/vx_tc_util/prob_rirw_pair_info.cc | 2 +- src/libcode/vx_tc_util/tc_stat_line.cc | 28 ++-- src/libcode/vx_tc_util/tc_stat_line.h | 12 +- src/libcode/vx_tc_util/track_pair_info.cc | 8 +- .../vx_time_series/time_series_util.cc | 12 +- src/libcode/vx_time_series/time_series_util.h | 8 +- src/tools/core/mode/mode_exec.cc | 40 +++--- src/tools/core/mode/mode_exec.h | 14 +- src/tools/core/mode/mode_ps_file.cc | 20 +-- src/tools/core/mode/mode_ps_file.h | 2 +- src/tools/core/mode/page_1.cc | 4 +- src/tools/core/mode/plot_engine.cc | 12 +- src/tools/core/pcp_combine/pcp_combine.cc | 36 ++--- .../core/series_analysis/series_analysis.cc | 21 +-- .../core/series_analysis/series_analysis.h | 14 +- .../core/stat_analysis/stat_analysis_job.cc | 14 +- src/tools/other/ascii2nc/ascii2nc.cc | 78 +++++----- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 135 +++++++++--------- src/tools/other/gen_vx_mask/gen_vx_mask.h | 32 ++--- src/tools/other/ioda2nc/ioda2nc.cc | 14 +- src/tools/other/madis2nc/madis2nc.cc | 61 ++++---- src/tools/other/madis2nc/madis2nc.h | 38 ++--- .../mode_graphics/mode_nc_output_file.cc | 16 +-- .../other/mode_graphics/mode_nc_output_file.h | 10 +- .../other/mode_graphics/plot_mode_field.cc | 38 ++--- src/tools/tc_utils/tc_gen/tc_gen.cc | 4 +- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 4 +- src/tools/tc_utils/tc_stat/tc_stat_files.cc | 10 +- src/tools/tc_utils/tc_stat/tc_stat_job.cc | 52 +++---- src/tools/tc_utils/tc_stat/tc_stat_job.h | 22 +-- 43 files changed, 484 insertions(+), 481 deletions(-) diff --git a/src/basic/vx_util/GridTemplate.h b/src/basic/vx_util/GridTemplate.h index 05df9ac644..ed58165f4d 100644 --- a/src/basic/vx_util/GridTemplate.h +++ b/src/basic/vx_util/GridTemplate.h @@ -158,7 +158,7 @@ class GridTemplateFactory { // do not assign specific values to these enumes. // other code requires them to start at zero and increase by 1 - // make sure GridTemplate_NUM_TEMPLATES is always last. + // make sure GridTemplate::NUM_TEMPLATES is always last. enum class GridTemplates { None, Square, diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index e65db03548..858d93a6e8 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -2743,7 +2743,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { // ramp_type js << "-ramp_type " << timeseriestype_to_string(ramp_type) << " "; - if(ramp_type == TimeSeriesType_DyDt) { + if(ramp_type == TimeSeriesType::DyDt) { // ramp_time if(ramp_time_fcst == ramp_time_obs) { @@ -2767,7 +2767,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } } - if(ramp_type == TimeSeriesType_Swing) { + if(ramp_type == TimeSeriesType::Swing) { // swing_width js << "-swing_width " << swing_width << " "; diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 36d00c8dfa..12002ec447 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -37,7 +37,7 @@ static const bool default_column_union = false; // // Ramp job type defaults // -static const TimeSeriesType default_ramp_type = TimeSeriesType_DyDt; +static const TimeSeriesType default_ramp_type = TimeSeriesType::DyDt; static const char default_ramp_line_type[] = "MPR"; static const char default_ramp_out_line_type[] = "CTC,CTS"; static const char default_ramp_fcst_col[] = "FCST"; diff --git a/src/libcode/vx_tc_util/atcf_line_base.cc b/src/libcode/vx_tc_util/atcf_line_base.cc index d49ffbb7f5..ff0aa402d8 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.cc +++ b/src/libcode/vx_tc_util/atcf_line_base.cc @@ -146,7 +146,7 @@ void ATCFLineBase::clear() { // Do not reset pointers: // BasinMap, BestTechnique, OperTechnique, TechSuffix - Type = NoATCFLineType; + Type = ATCFLineType::None; Basin.clear(); Technique.clear(); IsBestTrack = false; @@ -210,14 +210,14 @@ ConcatString ATCFLineBase::get_item(int i) const { ConcatString cs; int i_col = i; - // For ATCFLineType_GenTrack: + // For ATCFLineType::GenTrack: // Columns 1 and 2 are consistent: // Use offsets 0 and 1 // Column 3 for is an EXTRA column for this line type: // Add special handling in storm_id() - // Columns 4-20 are the same as columns 3-19 of ATCFLineType_Track: + // Columns 4-20 are the same as columns 3-19 of ATCFLineType::Track: // Shift those column indices by 1. - if(Type == ATCFLineType_GenTrack && i >= 2 && i <= 18) i_col++; + if(Type == ATCFLineType::GenTrack && i >= 2 && i <= 18) i_col++; cs = DataLine::get_item(i_col); @@ -361,9 +361,9 @@ int ATCFLineBase::lead() const { ConcatString ATCFLineBase::storm_id() const { ConcatString cs; - // For ATCFLineType_GenTrack, use the contents of the extra 3rd column + // For ATCFLineType::GenTrack, use the contents of the extra 3rd column // Call DataLine::get_item() to avoid the column shifting logic - if(Type == ATCFLineType_GenTrack) { + if(Type == ATCFLineType::GenTrack) { cs = DataLine::get_item(GenStormIdOffset); } else { @@ -481,21 +481,21 @@ int parse_int_check_zero(const char *s) { ATCFLineType string_to_atcflinetype(const char *s) { ATCFLineType t; - if(!s) t = NoATCFLineType; + if(!s) t = ATCFLineType::None; // YYYYMMDDHH in the 4th column for Genesis Tracks - else if(is_yyyymmddhh(s)) t = ATCFLineType_GenTrack; - else if(is_number(s)) t = ATCFLineType_Track; // ADECK - else if(m_strlen(s) == 0) t = ATCFLineType_Track; // BDECK - else if(strcasecmp(s, "TR") == 0) t = ATCFLineType_ProbTR; - else if(strcasecmp(s, "IN") == 0) t = ATCFLineType_ProbIN; - else if(strcasecmp(s, "RI") == 0) t = ATCFLineType_ProbRI; - else if(strcasecmp(s, "RW") == 0) t = ATCFLineType_ProbRW; - else if(strcasecmp(s, "WR") == 0) t = ATCFLineType_ProbWR; - else if(strcasecmp(s, "PR") == 0) t = ATCFLineType_ProbPR; - else if(strcasecmp(s, "GN") == 0) t = ATCFLineType_ProbGN; - else if(strcasecmp(s, "GS") == 0) t = ATCFLineType_ProbGS; - else if(strcasecmp(s, "ER") == 0) t = ATCFLineType_ProbER; - else t = NoATCFLineType; + else if(is_yyyymmddhh(s)) t = ATCFLineType::GenTrack; + else if(is_number(s)) t = ATCFLineType::Track; // ADECK + else if(m_strlen(s) == 0) t = ATCFLineType::Track; // BDECK + else if(strcasecmp(s, "TR") == 0) t = ATCFLineType::ProbTR; + else if(strcasecmp(s, "IN") == 0) t = ATCFLineType::ProbIN; + else if(strcasecmp(s, "RI") == 0) t = ATCFLineType::ProbRI; + else if(strcasecmp(s, "RW") == 0) t = ATCFLineType::ProbRW; + else if(strcasecmp(s, "WR") == 0) t = ATCFLineType::ProbWR; + else if(strcasecmp(s, "PR") == 0) t = ATCFLineType::ProbPR; + else if(strcasecmp(s, "GN") == 0) t = ATCFLineType::ProbGN; + else if(strcasecmp(s, "GS") == 0) t = ATCFLineType::ProbGS; + else if(strcasecmp(s, "ER") == 0) t = ATCFLineType::ProbER; + else t = ATCFLineType::None; return t; } @@ -506,19 +506,19 @@ ConcatString atcflinetype_to_string(const ATCFLineType t) { const char *s = (const char *) nullptr; switch(t) { - case ATCFLineType_Track: s = "Track"; break; - case ATCFLineType_GenTrack: s = "GenTrack"; break; - case ATCFLineType_ProbTR: s = "ProbTR"; break; - case ATCFLineType_ProbIN: s = "ProbIN"; break; - case ATCFLineType_ProbRI: s = "ProbRI"; break; - case ATCFLineType_ProbRW: s = "ProbRW"; break; - case ATCFLineType_ProbWR: s = "ProbWR"; break; - case ATCFLineType_ProbPR: s = "ProbPR"; break; - case ATCFLineType_ProbGN: s = "ProbGN"; break; - case ATCFLineType_ProbGS: s = "ProbGS"; break; - case ATCFLineType_ProbER: s = "ProbER"; break; - case NoATCFLineType: s = na_str; break; - default: s = na_str; break; + case ATCFLineType::Track: s = "Track"; break; + case ATCFLineType::GenTrack: s = "GenTrack"; break; + case ATCFLineType::ProbTR: s = "ProbTR"; break; + case ATCFLineType::ProbIN: s = "ProbIN"; break; + case ATCFLineType::ProbRI: s = "ProbRI"; break; + case ATCFLineType::ProbRW: s = "ProbRW"; break; + case ATCFLineType::ProbWR: s = "ProbWR"; break; + case ATCFLineType::ProbPR: s = "ProbPR"; break; + case ATCFLineType::ProbGN: s = "ProbGN"; break; + case ATCFLineType::ProbGS: s = "ProbGS"; break; + case ATCFLineType::ProbER: s = "ProbER"; break; + case ATCFLineType::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); diff --git a/src/libcode/vx_tc_util/atcf_line_base.h b/src/libcode/vx_tc_util/atcf_line_base.h index d7c04863d1..8b1141ffad 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.h +++ b/src/libcode/vx_tc_util/atcf_line_base.h @@ -29,20 +29,20 @@ //////////////////////////////////////////////////////////////////////// -enum ATCFLineType { - ATCFLineType_Track, // Track and intensity line type (numeric) - ATCFLineType_GenTrack, // Genesis Track and intensity line type (numeric) - ATCFLineType_ProbTR, // Track probability (TR) - ATCFLineType_ProbIN, // Intensity probability (IN) - ATCFLineType_ProbRI, // Rapid intensification probability (RI) - ATCFLineType_ProbRW, // Rapid weakening probability (RW) - ATCFLineType_ProbWR, // Wind radii probability (WR) - ATCFLineType_ProbPR, // Pressure probability (PR) - ATCFLineType_ProbGN, // TC genesis probability (GN) - ATCFLineType_ProbGS, // TC genesis shape probability (GS) - ATCFLineType_ProbER, // Eyewall replacement probability (ER) - - NoATCFLineType +enum class ATCFLineType { + Track, // Track and intensity line type (numeric) + GenTrack, // Genesis Track and intensity line type (numeric) + ProbTR, // Track probability (TR) + ProbIN, // Intensity probability (IN) + ProbRI, // Rapid intensification probability (RI) + ProbRW, // Rapid weakening probability (RW) + ProbWR, // Wind radii probability (WR) + ProbPR, // Pressure probability (PR) + ProbGN, // TC genesis probability (GN) + ProbGS, // TC genesis shape probability (GS) + ProbER, // Eyewall replacement probability (ER) + + None }; extern ATCFLineType string_to_atcflinetype(const char *); diff --git a/src/libcode/vx_tc_util/atcf_offsets.h b/src/libcode/vx_tc_util/atcf_offsets.h index deb4758cb8..50f2df28e2 100644 --- a/src/libcode/vx_tc_util/atcf_offsets.h +++ b/src/libcode/vx_tc_util/atcf_offsets.h @@ -30,7 +30,7 @@ static const int LonTenthsOffset = 7; // // Offsets specific to the ADECK and BDECK track lines // http://www.nrlmry.navy.mil/atcf_web/docs/database/new/abrdeck.html -// Offsets for columns common to ATCFLineType_Track and ATCFLineType_GenTrack +// Offsets for columns common to ATCFLineType::Track and ATCFLineType::GenTrack // static const int VMaxOffset = 8; @@ -49,7 +49,7 @@ static const int IsobarRadiusOffset = 18; static const int MaxWindRadiusOffset = 19; // -// Offsets for columns specific to the ATCFLineType_Track +// Offsets for columns specific to the ATCFLineType::Track // static const int GustsOffset = 20; @@ -76,7 +76,7 @@ static const int WarmCoreOffset = 39; static const char ThermoParams_Str[] = "THERMO PARARMS"; // -// Offsets for columns specific to the ATCFLineType_GenTrack +// Offsets for columns specific to the ATCFLineType::GenTrack // Reference: https://dtcenter.org/HurrWRF/users/docs/users_guide/HWRF-UG-2018.pdf // diff --git a/src/libcode/vx_tc_util/atcf_prob_line.cc b/src/libcode/vx_tc_util/atcf_prob_line.cc index c5cc659a9d..8b320eb912 100644 --- a/src/libcode/vx_tc_util/atcf_prob_line.cc +++ b/src/libcode/vx_tc_util/atcf_prob_line.cc @@ -120,11 +120,11 @@ int ATCFProbLine::read_line(LineDataFile * ldf) { // Check the line type switch(Type) { - case ATCFLineType_ProbRI: + case ATCFLineType::ProbRI: n_expect = MinATCFProbRIRWElements; break; - case ATCFLineType_ProbGN: + case ATCFLineType::ProbGN: n_expect = MinATCFProbGNElements; break; diff --git a/src/libcode/vx_tc_util/atcf_track_line.cc b/src/libcode/vx_tc_util/atcf_track_line.cc index d6368e38a3..ae9806b64b 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.cc +++ b/src/libcode/vx_tc_util/atcf_track_line.cc @@ -143,8 +143,8 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { if(!status) return 0; // Check the line type - if(Type != ATCFLineType_Track && - Type != ATCFLineType_GenTrack) { + if(Type != ATCFLineType::Track && + Type != ATCFLineType::GenTrack) { mlog << Warning << "\nint ATCFTrackLine::read_line(LineDataFile * ldf) -> " << "unexpected ATCF line type (" @@ -153,9 +153,9 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { } // Check for the minumum number of track line elements - if((Type == ATCFLineType_Track && + if((Type == ATCFLineType::Track && n_items() < MinATCFTrackElements) || - (Type == ATCFLineType_GenTrack && + (Type == ATCFLineType::GenTrack && n_items() < MinATCFGenTrackElements)) { mlog << Warning << "\nint ATCFTrackLine::read_line(LineDataFile * ldf) -> " @@ -267,11 +267,11 @@ int ATCFTrackLine::max_wind_radius() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::storm_direction() const { - if(Type == ATCFLineType_Track && + if(Type == ATCFLineType::Track && StormDirectionOffset < N_items) { return parse_int(get_item(StormDirectionOffset).c_str()); } - else if(Type == ATCFLineType_GenTrack && + else if(Type == ATCFLineType::GenTrack && StormDirectionOffset < N_items) { return parse_int(get_item(GenStormDirectionOffset).c_str()); } @@ -281,11 +281,11 @@ int ATCFTrackLine::storm_direction() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::storm_speed() const { - if(Type == ATCFLineType_Track && + if(Type == ATCFLineType::Track && StormSpeedOffset < N_items) { return parse_int(get_item(StormSpeedOffset).c_str()); } - else if(Type == ATCFLineType_GenTrack && + else if(Type == ATCFLineType::GenTrack && StormSpeedOffset < N_items) { return parse_int(get_item(GenStormSpeedOffset).c_str()); } @@ -294,18 +294,18 @@ int ATCFTrackLine::storm_speed() const { //////////////////////////////////////////////////////////////////////// // -// For ATCFLineType_Track, only valid when UserDefined = THERMO PARAMS -// For ATCFLineType_GenTrack, get the warm core column +// For ATCFLineType::Track, only valid when UserDefined = THERMO PARAMS +// For ATCFLineType::GenTrack, get the warm core column // //////////////////////////////////////////////////////////////////////// bool ATCFTrackLine::warm_core() const { - if(Type == ATCFLineType_Track && + if(Type == ATCFLineType::Track && WarmCoreOffset < N_items) { return(get_item(UserDefinedOffset).comparecase(ThermoParams_Str) == 0 && get_item(WarmCoreOffset).comparecase("Y") == 0); } - else if(Type == ATCFLineType_GenTrack && + else if(Type == ATCFLineType::GenTrack && GenWarmCoreOffset < N_items) { return(get_item(GenWarmCoreOffset).comparecase("Y") == 0); } @@ -314,12 +314,12 @@ bool ATCFTrackLine::warm_core() const { //////////////////////////////////////////////////////////////////////// // -// Specific to ATCFLineType_Track +// Specific to ATCFLineType::Track // //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::gusts() const { - return(Type == ATCFLineType_Track && GustsOffset < N_items ? + return(Type == ATCFLineType::Track && GustsOffset < N_items ? parse_int_check_zero(get_item(GustsOffset).c_str()) : bad_data_int); } @@ -327,7 +327,7 @@ int ATCFTrackLine::gusts() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::eye_diameter() const { - return(Type == ATCFLineType_Track && EyeDiameterOffset < N_items ? + return(Type == ATCFLineType::Track && EyeDiameterOffset < N_items ? parse_int_check_zero(get_item(EyeDiameterOffset).c_str()) : bad_data_int); } @@ -335,7 +335,7 @@ int ATCFTrackLine::eye_diameter() const { //////////////////////////////////////////////////////////////////////// SubregionCode ATCFTrackLine::subregion() const { - return(Type == ATCFLineType_Track && SubRegionOffset < N_items ? + return(Type == ATCFLineType::Track && SubRegionOffset < N_items ? string_to_subregioncode(get_item(SubRegionOffset).c_str()) : NoSubregionCode); } @@ -343,7 +343,7 @@ SubregionCode ATCFTrackLine::subregion() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::max_seas() const { - return(Type == ATCFLineType_Track && MaxSeasOffset < N_items ? + return(Type == ATCFLineType::Track && MaxSeasOffset < N_items ? parse_int_check_zero(get_item(MaxSeasOffset).c_str()) : bad_data_int); } @@ -351,7 +351,7 @@ int ATCFTrackLine::max_seas() const { //////////////////////////////////////////////////////////////////////// ConcatString ATCFTrackLine::initials() const { - return(Type == ATCFLineType_Track && InitialsOffset < N_items ? + return(Type == ATCFLineType::Track && InitialsOffset < N_items ? (string) get_item(InitialsOffset) : (string) ""); } @@ -359,7 +359,7 @@ ConcatString ATCFTrackLine::initials() const { //////////////////////////////////////////////////////////////////////// ConcatString ATCFTrackLine::storm_name() const { - return(Type == ATCFLineType_Track && StormNameOffset < N_items ? + return(Type == ATCFLineType::Track && StormNameOffset < N_items ? (string) get_item(StormNameOffset) : (string) ""); } @@ -367,7 +367,7 @@ ConcatString ATCFTrackLine::storm_name() const { //////////////////////////////////////////////////////////////////////// SystemsDepth ATCFTrackLine::depth() const { - return(Type == ATCFLineType_Track && DepthOffset < N_items ? + return(Type == ATCFLineType::Track && DepthOffset < N_items ? string_to_systemsdepth(get_item(DepthOffset).c_str()) : NoSystemsDepth); } @@ -375,7 +375,7 @@ SystemsDepth ATCFTrackLine::depth() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::wave_height() const { - return(Type == ATCFLineType_Track && WaveHeightOffset < N_items ? + return(Type == ATCFLineType::Track && WaveHeightOffset < N_items ? parse_int_check_zero(get_item(WaveHeightOffset).c_str()) : bad_data_int); } @@ -383,7 +383,7 @@ int ATCFTrackLine::wave_height() const { //////////////////////////////////////////////////////////////////////// QuadrantType ATCFTrackLine::seas_code() const { - return(Type == ATCFLineType_Track && SeasCodeOffset < N_items ? + return(Type == ATCFLineType::Track && SeasCodeOffset < N_items ? string_to_quadranttype(get_item(SeasCodeOffset).c_str()) : NoQuadrantType); } @@ -391,7 +391,7 @@ QuadrantType ATCFTrackLine::seas_code() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius1() const { - return(Type == ATCFLineType_Track && SeasRadius1Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius1Offset < N_items ? parse_int_check_zero(get_item(SeasRadius1Offset).c_str()) : bad_data_int); } @@ -399,7 +399,7 @@ int ATCFTrackLine::seas_radius1() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius2() const { - return(Type == ATCFLineType_Track && SeasRadius2Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius2Offset < N_items ? parse_int_check_zero(get_item(SeasRadius2Offset).c_str()) : bad_data_int); } @@ -407,7 +407,7 @@ int ATCFTrackLine::seas_radius2() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius3() const { - return(Type == ATCFLineType_Track && SeasRadius3Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius3Offset < N_items ? parse_int_check_zero(get_item(SeasRadius3Offset).c_str()) : bad_data_int); } @@ -415,19 +415,19 @@ int ATCFTrackLine::seas_radius3() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius4() const { - return(Type == ATCFLineType_Track && SeasRadius4Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius4Offset < N_items ? parse_int_check_zero(get_item(SeasRadius4Offset).c_str()) : bad_data_int); } //////////////////////////////////////////////////////////////////////// // -// Specific to ATCFLineType_Track +// Specific to ATCFLineType::Track // //////////////////////////////////////////////////////////////////////// double ATCFTrackLine::parameter_b() const { - int v = (Type == ATCFLineType_GenTrack && GenParameterBOffset < N_items ? + int v = (Type == ATCFLineType::GenTrack && GenParameterBOffset < N_items ? parse_int(get_item(GenParameterBOffset).c_str(), -999) : bad_data_int); return(!is_bad_data(v) ? v/10.0 : bad_data_double); @@ -436,7 +436,7 @@ double ATCFTrackLine::parameter_b() const { //////////////////////////////////////////////////////////////////////// double ATCFTrackLine::therm_wind_lower() const { - int v = (Type == ATCFLineType_GenTrack && GenThermWindLowerOffset < N_items ? + int v = (Type == ATCFLineType::GenTrack && GenThermWindLowerOffset < N_items ? parse_int(get_item(GenThermWindLowerOffset).c_str(), -9999) : bad_data_int); return(!is_bad_data(v) ? v/10.0 : bad_data_double); @@ -445,7 +445,7 @@ double ATCFTrackLine::therm_wind_lower() const { //////////////////////////////////////////////////////////////////////// double ATCFTrackLine::therm_wind_upper() const { - int v = (Type == ATCFLineType_GenTrack && GenThermWindUpperOffset < N_items ? + int v = (Type == ATCFLineType::GenTrack && GenThermWindUpperOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); return(!is_bad_data(v) ? v/10.0 : bad_data_double); @@ -454,7 +454,7 @@ double ATCFTrackLine::therm_wind_upper() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::mean_850_vort() const { - return(Type == ATCFLineType_GenTrack && GenMean850VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMean850VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -462,7 +462,7 @@ int ATCFTrackLine::mean_850_vort() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::max_850_vort() const { - return(Type == ATCFLineType_GenTrack && GenMax850VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMax850VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -470,7 +470,7 @@ int ATCFTrackLine::max_850_vort() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::mean_700_vort() const { - return(Type == ATCFLineType_GenTrack && GenMean700VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMean700VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -478,7 +478,7 @@ int ATCFTrackLine::mean_700_vort() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::max_700_vort() const { - return(Type == ATCFLineType_GenTrack && GenMax700VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMax700VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } diff --git a/src/libcode/vx_tc_util/atcf_track_line.h b/src/libcode/vx_tc_util/atcf_track_line.h index d5ebb5555b..9fc3896071 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.h +++ b/src/libcode/vx_tc_util/atcf_track_line.h @@ -177,7 +177,7 @@ class ATCFTrackLine : public ATCFLineBase { bool warm_core () const; // - // specific to ATCFLineType_Track + // specific to ATCFLineType::Track // int gusts () const; @@ -198,7 +198,7 @@ class ATCFTrackLine : public ATCFLineBase { int seas_radius4 () const; // - // specific to ATCFLineType_GenTrack + // specific to ATCFLineType::GenTrack // double parameter_b () const; diff --git a/src/libcode/vx_tc_util/prob_gen_info.cc b/src/libcode/vx_tc_util/prob_gen_info.cc index 900142610a..7f3f37b83a 100644 --- a/src/libcode/vx_tc_util/prob_gen_info.cc +++ b/src/libcode/vx_tc_util/prob_gen_info.cc @@ -200,7 +200,7 @@ bool ProbGenInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { } // Initialize the header information, if necessary - if(Type == NoATCFLineType) initialize(l, dland); + if(Type == ATCFLineType::None) initialize(l, dland); // Check for matching header information if(!is_match(l)) return false; diff --git a/src/libcode/vx_tc_util/prob_info_array.cc b/src/libcode/vx_tc_util/prob_info_array.cc index 9cfa6196a1..35a37708e2 100644 --- a/src/libcode/vx_tc_util/prob_info_array.cc +++ b/src/libcode/vx_tc_util/prob_info_array.cc @@ -244,7 +244,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { // Store based on the input line type switch(l.type()) { - case(ATCFLineType_ProbRI): + case(ATCFLineType::ProbRI): // Add line to an existing entry if(ProbRIRW.size() > 0 && @@ -260,7 +260,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { } break; - case(ATCFLineType_ProbGN): + case(ATCFLineType::ProbGN): // Add line to an existing entry if(ProbGen.size() > 0 && @@ -276,14 +276,14 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { if(gi.gen_or_dis() != "genFcst") { mlog << Debug(4) << "bool ProbInfoArray::add() -> " - << "skipping ATCF " << atcflinetype_to_string(ATCFLineType_ProbGN) + << "skipping ATCF " << atcflinetype_to_string(ATCFLineType::ProbGN) << " line with non-genesis probability type (" << gi.gen_or_dis() << " != genFcst).\n"; } else if(is_bad_data(gi.lat()) || is_bad_data(gi.lon())) { mlog << Debug(4) << "bool ProbInfoArray::add() -> " - << "skipping ATCF " << atcflinetype_to_string(ATCFLineType_ProbGN) + << "skipping ATCF " << atcflinetype_to_string(ATCFLineType::ProbGN) << " line with no predicted genesis location.\n"; } else { diff --git a/src/libcode/vx_tc_util/prob_info_base.cc b/src/libcode/vx_tc_util/prob_info_base.cc index 65e1a1abdc..762a9bfd88 100644 --- a/src/libcode/vx_tc_util/prob_info_base.cc +++ b/src/libcode/vx_tc_util/prob_info_base.cc @@ -71,7 +71,7 @@ void ProbInfoBase::init_from_scratch() { void ProbInfoBase::clear() { - Type = NoATCFLineType; + Type = ATCFLineType::None; StormId.clear(); Basin.clear(); Cyclone.clear(); @@ -266,7 +266,7 @@ bool ProbInfoBase::add(const ATCFProbLine &l, double dland, bool check_dup) { } // Initialize the header information, if necessary - if(Type == NoATCFLineType) initialize(l, dland); + if(Type == ATCFLineType::None) initialize(l, dland); // Check for matching header information if(!is_match(l)) return false; @@ -292,8 +292,8 @@ void ProbInfoBase::set(const TCStatLine &l) { // Store column information switch(l.type()) { - case TCStatLineType_ProbRIRW: - Type = ATCFLineType_ProbRI; + case TCStatLineType::ProbRIRW: + Type = ATCFLineType::ProbRI; break; default: diff --git a/src/libcode/vx_tc_util/prob_rirw_info.cc b/src/libcode/vx_tc_util/prob_rirw_info.cc index 8c31b24f87..ea662ef4c3 100644 --- a/src/libcode/vx_tc_util/prob_rirw_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_info.cc @@ -191,7 +191,7 @@ bool ProbRIRWInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { } // Initialize the header information, if necessary - if(Type == NoATCFLineType) initialize(l, dland); + if(Type == ATCFLineType::None) initialize(l, dland); // Check for matching header information if(!is_match(l)) return false; diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc index fe2f5f07a4..3bd91a89af 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc @@ -268,7 +268,7 @@ void ProbRIRWPairInfo::set(const TCStatLine &l) { clear(); // Check the line type - if(l.type() != TCStatLineType_ProbRIRW) return; + if(l.type() != TCStatLineType::ProbRIRW) return; // Parse ProbRIRWInfo ProbRIRW.set(l); diff --git a/src/libcode/vx_tc_util/tc_stat_line.cc b/src/libcode/vx_tc_util/tc_stat_line.cc index b8aa0c8b5d..a8556a7dd2 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.cc +++ b/src/libcode/vx_tc_util/tc_stat_line.cc @@ -99,7 +99,7 @@ void TCStatLine::clear() { DataLine::clear(); - Type = NoTCStatLineType; + Type = TCStatLineType::None; HdrLine = (AsciiHeaderLine *) nullptr; return; @@ -126,7 +126,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { // Check for a header line // if(strcmp(get_item(0), "VERSION") == 0) { - Type = TCStatLineType_Header; + Type = TCStatLineType::Header; return 1; } @@ -136,7 +136,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { offset = METHdrTable.col_offset(get_item(0), "TCST", na_str, "LINE_TYPE"); if(is_bad_data(offset) || n_items() < (offset + 1)) { - Type = NoTCStatLineType; + Type = TCStatLineType::None; return 0; } @@ -159,7 +159,7 @@ bool TCStatLine::is_ok() const { //////////////////////////////////////////////////////////////////////// bool TCStatLine::is_header() const { - return(Type == TCStatLineType_Header); + return(Type == TCStatLineType::Header); } //////////////////////////////////////////////////////////////////////// @@ -370,11 +370,11 @@ ConcatString TCStatLine::header() const { TCStatLineType string_to_tcstatlinetype(const char *s) { TCStatLineType t; - if(strcmp(s, TCStatLineType_TCMPR_Str) == 0) t = TCStatLineType_TCMPR; - else if(strcmp(s, TCStatLineType_TCDIAG_Str) == 0) t = TCStatLineType_TCDIAG; - else if(strcmp(s, TCStatLineType_ProbRIRW_Str) == 0) t = TCStatLineType_ProbRIRW; - else if(strcmp(s, TCStatLineType_Header_Str) == 0) t = TCStatLineType_Header; - else t = NoTCStatLineType; + if(strcmp(s, TCStatLineType_TCMPR_Str) == 0) t = TCStatLineType::TCMPR; + else if(strcmp(s, TCStatLineType_TCDIAG_Str) == 0) t = TCStatLineType::TCDIAG; + else if(strcmp(s, TCStatLineType_ProbRIRW_Str) == 0) t = TCStatLineType::ProbRIRW; + else if(strcmp(s, TCStatLineType_Header_Str) == 0) t = TCStatLineType::Header; + else t = TCStatLineType::None; return t; } @@ -385,11 +385,11 @@ ConcatString tcstatlinetype_to_string(const TCStatLineType t) { const char *s = (const char *) nullptr; switch(t) { - case TCStatLineType_TCMPR: s = TCStatLineType_TCMPR_Str; break; - case TCStatLineType_TCDIAG: s = TCStatLineType_TCDIAG_Str; break; - case TCStatLineType_ProbRIRW: s = TCStatLineType_ProbRIRW_Str; break; - case TCStatLineType_Header: s = TCStatLineType_Header_Str; break; - default: s = na_str; break; + case TCStatLineType::TCMPR: s = TCStatLineType_TCMPR_Str; break; + case TCStatLineType::TCDIAG: s = TCStatLineType_TCDIAG_Str; break; + case TCStatLineType::ProbRIRW: s = TCStatLineType_ProbRIRW_Str; break; + case TCStatLineType::Header: s = TCStatLineType_Header_Str; break; + default: s = na_str; break; } return ConcatString(s); diff --git a/src/libcode/vx_tc_util/tc_stat_line.h b/src/libcode/vx_tc_util/tc_stat_line.h index 6c3ead9365..2e75fda869 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.h +++ b/src/libcode/vx_tc_util/tc_stat_line.h @@ -24,11 +24,11 @@ // Enumerate all the possible line types enum TCStatLineType { - TCStatLineType_TCMPR, - TCStatLineType_TCDIAG, - TCStatLineType_ProbRIRW, - TCStatLineType_Header, - NoTCStatLineType + TCMPR, + TCDIAG, + ProbRIRW, + Header, + None }; @@ -103,7 +103,7 @@ class TCStatLine : public DataLine { //////////////////////////////////////////////////////////////////////// -inline TCStatLineType TCStatLine::type() const { return(Type); } +inline TCStatLineType TCStatLine::type() const { return Type; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_pair_info.cc b/src/libcode/vx_tc_util/track_pair_info.cc index 8206db0bc7..0a807f2862 100644 --- a/src/libcode/vx_tc_util/track_pair_info.cc +++ b/src/libcode/vx_tc_util/track_pair_info.cc @@ -311,8 +311,8 @@ void TrackPairInfo::add(const TrackPoint &a, const TrackPoint &b, void TrackPairInfo::add(const TCStatLine &l) { // Check the line type - if(l.type() == TCStatLineType_TCMPR) add_tcmpr_line(l); - else if(l.type() == TCStatLineType_TCDIAG) add_tcdiag_line(l); + if(l.type() == TCStatLineType::TCMPR) add_tcmpr_line(l); + else if(l.type() == TCStatLineType::TCDIAG) add_tcdiag_line(l); return; } @@ -327,7 +327,7 @@ void TrackPairInfo::add_tcmpr_line(const TCStatLine &l) { int i, j; // Check the line type - if(l.type() != TCStatLineType_TCMPR) return; + if(l.type() != TCStatLineType::TCMPR) return; // Store the input TCMPR line and TCDIAG placeholder TCMPRLine.push_back(l); @@ -439,7 +439,7 @@ void TrackPairInfo::add_tcdiag_line(const TCStatLine &l) { ConcatString cs; // Check the line type - if(l.type() != TCStatLineType_TCDIAG) return; + if(l.type() != TCStatLineType::TCDIAG) return; // Should have already parsed TCMPR if(NPoints == 0) { diff --git a/src/libcode/vx_time_series/time_series_util.cc b/src/libcode/vx_time_series/time_series_util.cc index 145de93009..d3e40c1201 100644 --- a/src/libcode/vx_time_series/time_series_util.cc +++ b/src/libcode/vx_time_series/time_series_util.cc @@ -27,9 +27,9 @@ using namespace std; TimeSeriesType string_to_timeseriestype(const char *s) { TimeSeriesType t; - if(strcasecmp(s, timeseriestype_dydt_str) == 0) t = TimeSeriesType_DyDt; - else if(strcasecmp(s, timeseriestype_swing_str) == 0) t = TimeSeriesType_Swing; - else t = TimeSeriesType_None; + if(strcasecmp(s, timeseriestype_dydt_str) == 0) t = TimeSeriesType::DyDt; + else if(strcasecmp(s, timeseriestype_swing_str) == 0) t = TimeSeriesType::Swing; + else t = TimeSeriesType::None; return t; } @@ -40,9 +40,9 @@ const char * timeseriestype_to_string(const TimeSeriesType t) { const char *s = (const char *) nullptr; switch(t) { - case(TimeSeriesType_DyDt): s = timeseriestype_dydt_str; break; - case(TimeSeriesType_Swing): s = timeseriestype_swing_str; break; - default: s = na_str; break; + case(TimeSeriesType::DyDt): s = timeseriestype_dydt_str; break; + case(TimeSeriesType::Swing): s = timeseriestype_swing_str; break; + default: s = na_str; break; } return s; diff --git a/src/libcode/vx_time_series/time_series_util.h b/src/libcode/vx_time_series/time_series_util.h index a03176afcc..92adbe0ae2 100644 --- a/src/libcode/vx_time_series/time_series_util.h +++ b/src/libcode/vx_time_series/time_series_util.h @@ -21,10 +21,10 @@ // Enumeration for time-series analysis types // -enum TimeSeriesType { - TimeSeriesType_None, // Default - TimeSeriesType_DyDt, // Threshold change over time window - TimeSeriesType_Swing // Apply swinging door algorithm +enum class TimeSeriesType { + None, // Default + DyDt, // Threshold change over time window + Swing // Apply swinging door algorithm }; static const char timeseriestype_dydt_str[] = "DYDT"; diff --git a/src/tools/core/mode/mode_exec.cc b/src/tools/core/mode/mode_exec.cc index fde469e92f..fb783ead42 100644 --- a/src/tools/core/mode/mode_exec.cc +++ b/src/tools/core/mode/mode_exec.cc @@ -2155,16 +2155,16 @@ void ModeExecutive::write_poly_netcdf(NcFile * f_out) // present. // if(engine.n_fcst > 0) { - write_poly_netcdf(f_out, FcstSimpBdyPoly); - write_poly_netcdf(f_out, FcstSimpHullPoly); + write_poly_netcdf(f_out, ObjPolyType::FcstSimpBdy); + write_poly_netcdf(f_out, ObjPolyType::FcstSimpHull); } if(engine.n_obs > 0) { - write_poly_netcdf(f_out, ObsSimpBdyPoly); - write_poly_netcdf(f_out, ObsSimpHullPoly); + write_poly_netcdf(f_out, ObjPolyType::ObsSimpBdy); + write_poly_netcdf(f_out, ObjPolyType::ObsSimpHull); } if(engine.n_clus > 0) { - write_poly_netcdf(f_out, FcstClusHullPoly); - write_poly_netcdf(f_out, ObsClusHullPoly); + write_poly_netcdf(f_out, ObjPolyType::FcstClusHull); + write_poly_netcdf(f_out, ObjPolyType::ObsClusHull); } return; @@ -2217,7 +2217,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) // and set up strings switch(poly_type) { - case FcstSimpBdyPoly: + case ObjPolyType::FcstSimpBdy: n_poly = engine.n_fcst; field_name = "fcst"; field_long = "Forecast"; @@ -2225,7 +2225,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Boundary"; break; - case ObsSimpBdyPoly: + case ObjPolyType::ObsSimpBdy: n_poly = engine.n_obs; field_name = "obs"; field_long = "Observation"; @@ -2233,7 +2233,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Boundary"; break; - case FcstSimpHullPoly: + case ObjPolyType::FcstSimpHull: n_poly = engine.n_fcst; field_name = "fcst"; field_long = "Forecast"; @@ -2241,7 +2241,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Convex Hull"; break; - case ObsSimpHullPoly: + case ObjPolyType::ObsSimpHull: n_poly = engine.n_obs; field_name = "obs"; field_long = "Observation"; @@ -2249,7 +2249,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Convex Hull"; break; - case FcstClusHullPoly: + case ObjPolyType::FcstClusHull: n_poly = engine.n_clus; field_name = "fcst"; field_long = "Forecast"; @@ -2257,7 +2257,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Cluster Convex Hull"; break; - case ObsClusHullPoly: + case ObjPolyType::ObsClusHull: n_poly = engine.n_clus; field_name = "obs"; field_long = "Observation"; @@ -2270,8 +2270,8 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) } // Setup dimension name strings - if(poly_type == FcstClusHullPoly || - poly_type == ObsClusHullPoly) { + if(poly_type == ObjPolyType::FcstClusHull || + poly_type == ObjPolyType::ObsClusHull) { obj_dim_name << cs_erase << field_name << "_clus"; } else { @@ -2301,27 +2301,27 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) switch(poly_type) { - case FcstSimpBdyPoly: + case ObjPolyType::FcstSimpBdy: poly[i] = &engine.fcst_single[i].boundary[0]; break; - case ObsSimpBdyPoly: + case ObjPolyType::ObsSimpBdy: poly[i] = &engine.obs_single[i].boundary[0]; break; - case FcstSimpHullPoly: + case ObjPolyType::FcstSimpHull: poly[i] = &engine.fcst_single[i].convex_hull; break; - case ObsSimpHullPoly: + case ObjPolyType::ObsSimpHull: poly[i] = &engine.obs_single[i].convex_hull; break; - case FcstClusHullPoly: + case ObjPolyType::FcstClusHull: poly[i] = &engine.fcst_cluster[i].convex_hull; break; - case ObsClusHullPoly: + case ObjPolyType::ObsClusHull: poly[i] = &engine.obs_cluster[i].convex_hull; break; diff --git a/src/tools/core/mode/mode_exec.h b/src/tools/core/mode/mode_exec.h index e2ad110dda..184a2e0a74 100644 --- a/src/tools/core/mode/mode_exec.h +++ b/src/tools/core/mode/mode_exec.h @@ -51,13 +51,13 @@ static const int n_cts = 2; //////////////////////////////////////////////////////////////////////// -enum ObjPolyType { - FcstSimpBdyPoly = 0, - ObsSimpBdyPoly = 1, - FcstSimpHullPoly = 2, - ObsSimpHullPoly = 3, - FcstClusHullPoly = 4, - ObsClusHullPoly = 5 +enum class ObjPolyType { + FcstSimpBdy = 0, + ObsSimpBdy = 1, + FcstSimpHull = 2, + ObsSimpHull = 3, + FcstClusHull = 4, + ObsClusHull = 5 }; diff --git a/src/tools/core/mode/mode_ps_file.cc b/src/tools/core/mode/mode_ps_file.cc index 605fea24e5..3daa7427ae 100644 --- a/src/tools/core/mode/mode_ps_file.cc +++ b/src/tools/core/mode/mode_ps_file.cc @@ -552,7 +552,7 @@ void ModePsFile::make_plot(bool isMultivarSuper) << ConfInfo->Obs->var_info->level_attr(); } - plot_engine(*Engine, FOEng, s.c_str()); + plot_engine(*Engine, EngineType::FOEng, s.c_str()); if ( (fcst_merge_flag == MergeType::Both) || (fcst_merge_flag == MergeType::Thresh) ) { @@ -562,7 +562,7 @@ void ModePsFile::make_plot(bool isMultivarSuper) if ( (fcst_merge_flag == MergeType::Both) || (fcst_merge_flag == MergeType::Engine) ) { - plot_engine(*(Engine->fcst_engine), FFEng, "Forecast: ModeFuzzyEngine Merging"); + plot_engine(*(Engine->fcst_engine), EngineType::FFEng, "Forecast: ModeFuzzyEngine Merging"); } @@ -574,7 +574,7 @@ void ModePsFile::make_plot(bool isMultivarSuper) if ( (obs_merge_flag == MergeType::Both) || (obs_merge_flag == MergeType::Engine) ) { - plot_engine(*(Engine->obs_engine), OOEng, "Observation: ModeFuzzyEngine Merging"); + plot_engine(*(Engine->obs_engine), EngineType::OOEng, "Observation: ModeFuzzyEngine Merging"); } @@ -633,12 +633,12 @@ void ModePsFile::plot_threshold_merging (ModeFuzzyEngine & eng, const char * tit if ( fcst ) { comment("threshold merging page: fcst raw"); - render_ppm(eng, FOEng, *(eng.fcst_raw), fcst, 0); + render_ppm(eng, EngineType::FOEng, *(eng.fcst_raw), fcst, 0); } else { comment("threshold merging page: obs raw"); - render_ppm(eng, FOEng, *(eng.obs_raw), fcst, 0); + render_ppm(eng, EngineType::FOEng, *(eng.obs_raw), fcst, 0); } @@ -661,12 +661,12 @@ void ModePsFile::plot_threshold_merging (ModeFuzzyEngine & eng, const char * tit if ( fcst ) { comment("threshold merging page: fcst raw"); - render_ppm(eng, FOEng, *(eng.fcst_split), fcst, 2); + render_ppm(eng, EngineType::FOEng, *(eng.fcst_split), fcst, 2); } else { comment("threshold merging page: obs split"); - render_ppm(eng, FOEng, *(eng.obs_split), fcst, 2); + render_ppm(eng, EngineType::FOEng, *(eng.obs_split), fcst, 2); } @@ -1021,17 +1021,17 @@ void ModePsFile::render_ppm(ModeFuzzyEngine & eng, EngineType eng_type, const Sh // Set up pointers to the appropriate colortable and fill color values // - if ( eng_type == FFEng ) { + if ( eng_type == EngineType::FFEng ) { ct = &FcstRawCtable; fill_color = FcstFillColor; - } else if ( eng_type == OOEng ) { + } else if ( eng_type == EngineType::OOEng ) { ct = &ObsRawCtable; fill_color = ObsFillColor; - } else { // eng_type == FOEng + } else { // eng_type == EngineType::FOEng if ( fcst ) { diff --git a/src/tools/core/mode/mode_ps_file.h b/src/tools/core/mode/mode_ps_file.h index 6b9318a827..284a45484b 100644 --- a/src/tools/core/mode/mode_ps_file.h +++ b/src/tools/core/mode/mode_ps_file.h @@ -36,7 +36,7 @@ static const bool use_zlib = true; //////////////////////////////////////////////////////////////////////// -enum EngineType { +enum class EngineType { NoEng = 0, FOEng = 1, FFEng = 2, diff --git a/src/tools/core/mode/page_1.cc b/src/tools/core/mode/page_1.cc index 74b757f734..9c1f3d0079 100644 --- a/src/tools/core/mode/page_1.cc +++ b/src/tools/core/mode/page_1.cc @@ -576,8 +576,8 @@ void ModePsFile::do_page_1(ModeFuzzyEngine & eng, EngineType eng_type, const cha Htab_b = Htab_a + 5.0*TextSep; Htab_c = Htab_a + 10.0*TextSep; - if ( eng_type == FOEng ) do_page_1_FOEng (eng, eng_type, title); - else do_page_1_other (eng, eng_type, title); + if ( eng_type == EngineType::FOEng ) do_page_1_FOEng (eng, eng_type, title); + else do_page_1_other (eng, eng_type, title); showpage(); diff --git a/src/tools/core/mode/plot_engine.cc b/src/tools/core/mode/plot_engine.cc index 5a92e5643c..50a839a869 100644 --- a/src/tools/core/mode/plot_engine.cc +++ b/src/tools/core/mode/plot_engine.cc @@ -38,21 +38,21 @@ void ModePsFile::plot_engine(ModeFuzzyEngine & eng, EngineType eng_type, const c // setup fcst & obs strings // - if ( eng_type == FOEng ) { // Plot forecast versus observation + if ( eng_type == EngineType::FOEng ) { // Plot forecast versus observation FcstString = "Forecast"; FcstShortString = "Fcst"; ObsString = "Observation"; ObsShortString = "Obs"; - } else if ( eng_type == FFEng ) { // Plot forecast versus forecast + } else if ( eng_type == EngineType::FFEng ) { // Plot forecast versus forecast FcstString = "Forecast"; FcstShortString = "Fcst"; ObsString = "Forecast"; ObsShortString = "Fcst"; - } else if ( eng_type == OOEng ) { // Plot observation versus observation + } else if ( eng_type == EngineType::OOEng ) { // Plot observation versus observation FcstString = "Observation"; FcstShortString = "Obs"; @@ -67,11 +67,11 @@ void ModePsFile::plot_engine(ModeFuzzyEngine & eng, EngineType eng_type, const c do_page_1(eng, eng_type, title); - if ( (eng_type == FOEng) || (eng_type == FFEng) ) do_fcst_enlarge_page(eng, eng_type, title); + if ( (eng_type == EngineType::FOEng) || (eng_type == EngineType::FFEng) ) do_fcst_enlarge_page(eng, eng_type, title); - if ( (eng_type == FOEng) || (eng_type == OOEng) ) do_obs_enlarge_page(eng, eng_type, title); + if ( (eng_type == EngineType::FOEng) || (eng_type == EngineType::OOEng) ) do_obs_enlarge_page(eng, eng_type, title); - if ( eng_type == FOEng ) { + if ( eng_type == EngineType::FOEng ) { do_overlap_page(eng, eng_type, title); do_cluster_page(eng, eng_type, title); diff --git a/src/tools/core/pcp_combine/pcp_combine.cc b/src/tools/core/pcp_combine/pcp_combine.cc index 7adf584e07..8ff4742b68 100644 --- a/src/tools/core/pcp_combine/pcp_combine.cc +++ b/src/tools/core/pcp_combine/pcp_combine.cc @@ -119,10 +119,10 @@ static const char derive_options [] = "sum, min, max, range, mean, stdev, vld_count"; // Run Command enumeration -enum RunCommand { sum = 0, add = 1, sub = 2, der = 3 }; +enum class RunCommand { sum = 0, add = 1, sub = 2, der = 3 }; // Variables for top-level command line arguments -static RunCommand run_command = sum; +static RunCommand run_command = RunCommand::sum; // Variables common to all commands static int n_files; @@ -232,8 +232,8 @@ int met_main(int argc, char *argv[]) { // Perform the requested run or subtract command. // Derive handles add and derive. // - if(run_command == sum) do_sum_command(); - else if(run_command == sub) do_sub_command(); + if(run_command == RunCommand::sum) do_sum_command(); + else if(run_command == RunCommand::sub) do_sub_command(); else do_derive_command(); } @@ -264,7 +264,7 @@ void process_command_line(int argc, char **argv) { // // Default to running the sum command // - run_command = sum; + run_command = RunCommand::sum; derive_list.add("sum"); // @@ -305,8 +305,8 @@ void process_command_line(int argc, char **argv) { // // Process the specific command arguments. // - if(run_command == sum) process_sum_args(cline); - else process_add_sub_derive_args(cline); + if(run_command == RunCommand::sum) process_sum_args(cline); + else process_add_sub_derive_args(cline); // // If -field not set, set to a list of length 1 with an empty string. @@ -1295,21 +1295,21 @@ void open_nc(const Grid &grid) { // Add global attributes. write_netcdf_global(nc_out, out_filename.c_str(), program_name.c_str()); - if(run_command == sum) { + if(run_command == RunCommand::sum) { command_str << cs_erase << "Sum: " << n_files << " files with accumulations of " << sec_to_hhmmss(in_accum) << '.'; - } else if(run_command == add) { + } else if(run_command == RunCommand::add) { command_str << cs_erase << "Addition: " << n_files << " files."; } - else if(run_command == sub) { + else if(run_command == RunCommand::sub) { command_str << cs_erase << "Subtraction: " << file_list[0] << " minus " << file_list[1]; } - else { // run_command = der + else { // run_command = RunCommand::der command_str << cs_erase << "Derive: " << write_css(derive_list) << " of " << n_files << " files."; @@ -1391,7 +1391,7 @@ void write_nc_data(unixtime nc_init, unixtime nc_valid, int nc_accum, // // Append the derivation string. // - if(run_command == der) var_str << "_" << derive_str; + if(run_command == RunCommand::der) var_str << "_" << derive_str; } mlog << Debug(2) @@ -1408,8 +1408,8 @@ void write_nc_data(unixtime nc_init, unixtime nc_valid, int nc_accum, // Add variable attributes. add_att(&nc_var, "name", var_str.c_str()); - if(run_command == der) cs = long_name_prefix; - else cs.clear(); + if(run_command == RunCommand::der) cs = long_name_prefix; + else cs.clear(); cs << var_info->long_name_attr(); add_att(&nc_var, "long_name", cs.c_str()); @@ -1624,7 +1624,7 @@ void usage() { //////////////////////////////////////////////////////////////////////// void set_sum(const StringArray &) { - run_command = sum; + run_command = RunCommand::sum; derive_list.clear(); derive_list.add("sum"); } @@ -1632,7 +1632,7 @@ void set_sum(const StringArray &) { //////////////////////////////////////////////////////////////////////// void set_add(const StringArray &) { - run_command = add; + run_command = RunCommand::add; derive_list.clear(); derive_list.add("sum"); } @@ -1640,7 +1640,7 @@ void set_add(const StringArray &) { //////////////////////////////////////////////////////////////////////// void set_subtract(const StringArray &) { - run_command = sub; + run_command = RunCommand::sub; derive_list.clear(); derive_list.add("diff"); } @@ -1648,7 +1648,7 @@ void set_subtract(const StringArray &) { //////////////////////////////////////////////////////////////////////// void set_derive(const StringArray & a) { - run_command = der; + run_command = RunCommand::der; derive_list.clear(); StringArray sa; diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 3b1108b709..2aa3b73945 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -59,6 +59,7 @@ #include "vx_nc_util.h" #include "vx_regrid.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; using namespace netCDF; @@ -262,35 +263,35 @@ void process_command_line(int argc, char **argv) { // - Forecast file list // - Observation file list if(conf_info.get_n_fcst() > 1) { - series_type = SeriesType_Fcst_Conf; + series_type = SeriesType::Fcst_Conf; n_series = conf_info.get_n_fcst(); mlog << Debug(1) << "Series defined by the \"fcst.field\" configuration entry " << "of length " << n_series << ".\n"; } else if(conf_info.get_n_obs() > 1) { - series_type = SeriesType_Obs_Conf; + series_type = SeriesType::Obs_Conf; n_series = conf_info.get_n_obs(); mlog << Debug(1) << "Series defined by the \"obs.field\" configuration entry " << "of length " << n_series << ".\n"; } else if(fcst_files.n() > 1) { - series_type = SeriesType_Fcst_Files; + series_type = SeriesType::Fcst_Files; n_series = fcst_files.n(); mlog << Debug(1) << "Series defined by the forecast file list of length " << n_series << ".\n"; } else if(obs_files.n() > 1) { - series_type = SeriesType_Obs_Files; + series_type = SeriesType::Obs_Files; n_series = obs_files.n(); mlog << Debug(1) << "Series defined by the observation file list of length " << n_series << ".\n"; } else { - series_type = SeriesType_Fcst_Conf; + series_type = SeriesType::Fcst_Conf; n_series = 1; mlog << Debug(1) << "The \"fcst.field\" and \"obs.field\" configuration entries " @@ -424,7 +425,7 @@ void get_series_data(int i_series, // Switch on the series type switch(series_type) { - case SeriesType_Fcst_Conf: + case SeriesType::Fcst_Conf: get_series_entry(i_series, fcst_info, fcst_files, ftype, found_fcst_files, fcst_dp, fcst_grid); if(conf_info.get_n_obs() == 1) { @@ -438,7 +439,7 @@ void get_series_data(int i_series, otype, found_obs_files, obs_dp, obs_grid); break; - case SeriesType_Obs_Conf: + case SeriesType::Obs_Conf: get_series_entry(i_series, obs_info, obs_files, otype, found_obs_files, obs_dp, obs_grid); if(conf_info.get_n_fcst() == 1) { @@ -452,7 +453,7 @@ void get_series_data(int i_series, ftype, found_fcst_files, fcst_dp, fcst_grid); break; - case SeriesType_Fcst_Files: + case SeriesType::Fcst_Files: found_fcst_files.set(i_series, fcst_files[i_series]); get_series_entry(i_series, fcst_info, fcst_files, ftype, found_fcst_files, fcst_dp, fcst_grid); @@ -470,7 +471,7 @@ void get_series_data(int i_series, otype, found_obs_files, obs_dp, obs_grid); break; - case SeriesType_Obs_Files: + case SeriesType::Obs_Files: found_obs_files.set(i_series, obs_files[i_series]); get_series_entry(i_series, obs_info, obs_files, otype, found_obs_files, obs_dp, obs_grid); @@ -491,7 +492,7 @@ void get_series_data(int i_series, default: mlog << Error << "\nget_series_data() -> " << "unexpected SeriesType value: " - << series_type << "\n\n"; + << enum_class_as_int(series_type) << "\n\n"; exit(1); } diff --git a/src/tools/core/series_analysis/series_analysis.h b/src/tools/core/series_analysis/series_analysis.h index d50df6cb94..2540540015 100644 --- a/src/tools/core/series_analysis/series_analysis.h +++ b/src/tools/core/series_analysis/series_analysis.h @@ -120,14 +120,14 @@ static Met2dDataFile *obs_mtddf = (Met2dDataFile *) nullptr; static gsl_rng *rng_ptr = (gsl_rng *) nullptr; // Enumeration of ways that a series can be defined -enum SeriesType { - SeriesType_None, // Undefined series type - SeriesType_Fcst_Conf, // Defined by fcst.field configuration - SeriesType_Obs_Conf, // Defined by obs.field configuration - SeriesType_Fcst_Files, // Defined by -fcst command line option - SeriesType_Obs_Files // Defined by -obs command line option +enum class SeriesType { + None, // Undefined series type + Fcst_Conf, // Defined by fcst.field configuration + Obs_Conf, // Defined by obs.field configuration + Fcst_Files, // Defined by -fcst command line option + Obs_Files // Defined by -obs command line option }; -static SeriesType series_type = SeriesType_None; +static SeriesType series_type = SeriesType::None; // Series length static int n_series = 0; diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index d47c82c080..a1c875bf80 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -3794,7 +3794,7 @@ void write_job_ramp(STATAnalysisJob &job, vals_part = it->second.f_na.subset(ts.index(beg[i]), ts.index(end[i])); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { compute_dydt_ramps(cs.c_str(), vals_part, ts_part, job.ramp_time_fcst, job.ramp_exact_fcst, job.ramp_thresh_fcst, ramp_part, dat_part); @@ -3823,7 +3823,7 @@ void write_job_ramp(STATAnalysisJob &job, vals_part = it->second.o_na.subset(ts.index(beg[i]), ts.index(end[i])); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { compute_dydt_ramps(cs.c_str(), vals_part, ts_part, job.ramp_time_obs, job.ramp_exact_obs, job.ramp_thresh_obs, ramp_part, dat_part); @@ -3948,7 +3948,7 @@ void write_job_ramp(STATAnalysisJob &job, mpr_at.set_entry(r_mpr, c++, unix_to_yyyymmdd_hhmmss(init_ut)); mpr_at.set_entry(r_mpr, c++, sec_to_hhmmss((int) valid_ut - init_ut)); mpr_at.set_entry(r_mpr, c++, unix_to_yyyymmdd_hhmmss(valid_ut)); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { mpr_at.set_entry(r_mpr, c++, fdat[k]); mpr_at.set_entry(r_mpr, c++, it->second.f_na[k]); mpr_at.set_entry(r_mpr, c++, (is_bad_data(fdat[k]) || is_bad_data(it->second.f_na[k]) ? @@ -3960,7 +3960,7 @@ void write_job_ramp(STATAnalysisJob &job, mpr_at.set_entry(r_mpr, c++, fdat[k]); } mpr_at.set_entry(r_mpr, c++, (is_bad_data(f) ? na_str : bool_to_string(f))); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { mpr_at.set_entry(r_mpr, c++, odat[k]); mpr_at.set_entry(r_mpr, c++, it->second.o_na[k]); mpr_at.set_entry(r_mpr, c++, (is_bad_data(odat[k]) || is_bad_data(it->second.o_na[k]) ? @@ -4329,8 +4329,8 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, // // Check the ramp type // - if(job.ramp_type != TimeSeriesType_DyDt && - job.ramp_type != TimeSeriesType_Swing) { + if(job.ramp_type != TimeSeriesType::DyDt && + job.ramp_type != TimeSeriesType::Swing) { mlog << Error << "\ndo_job_ramp() -> " << "unsupported \"-ramp_type\" option: " << jobstring << "\n\n"; @@ -4340,7 +4340,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, // // Check swing_width for the swinging door algorithm // - if(job.ramp_type == TimeSeriesType_Swing && + if(job.ramp_type == TimeSeriesType::Swing && is_bad_data(job.swing_width)) { mlog << Error << "\ndo_job_ramp() -> " << "the \"-swing_width\" option is required for \"-ramp_type SWING\": " diff --git a/src/tools/other/ascii2nc/ascii2nc.cc b/src/tools/other/ascii2nc/ascii2nc.cc index d3ef7062d7..a0c76e0082 100644 --- a/src/tools/other/ascii2nc/ascii2nc.cc +++ b/src/tools/other/ascii2nc/ascii2nc.cc @@ -106,22 +106,22 @@ static const char *DEFAULT_CONFIG_FILENAME = //////////////////////////////////////////////////////////////////////// // Supported input ASCII formats -enum ASCIIFormat { - ASCIIFormat_None, - ASCIIFormat_MET, - ASCIIFormat_Little_R, - ASCIIFormat_SurfRad, - ASCIIFormat_WWSIS, - ASCIIFormat_Airnow_dailyv2, - ASCIIFormat_Airnow_hourlyaqobs, - ASCIIFormat_Airnow_hourly, - ASCIIFormat_NDBC_standard, - ASCIIFormat_ISMN, - ASCIIFormat_Aeronet_v2, - ASCIIFormat_Aeronet_v3, - ASCIIFormat_Python, +enum class ASCIIFormat { + None, + MET, + Little_R, + SurfRad, + WWSIS, + Airnow_dailyv2, + Airnow_hourlyaqobs, + Airnow_hourly, + NDBC_standard, + ISMN, + Aeronet_v2, + Aeronet_v3, + Python, }; -static ASCIIFormat ascii_format = ASCIIFormat_None; +static ASCIIFormat ascii_format = ASCIIFormat::None; //////////////////////////////////////////////////////////////////////// @@ -286,63 +286,63 @@ FileHandler *create_file_handler(const ASCIIFormat format, const ConcatString &a // file to guess the format. // switch(format) { - case ASCIIFormat_MET: { + case ASCIIFormat::MET: { return (FileHandler *) new MetHandler(program_name); } - case ASCIIFormat_Little_R: { + case ASCIIFormat::Little_R: { return (FileHandler *) new LittleRHandler(program_name); } - case ASCIIFormat_SurfRad: { + case ASCIIFormat::SurfRad: { return (FileHandler *) new SurfradHandler(program_name); } - case ASCIIFormat_WWSIS: { + case ASCIIFormat::WWSIS: { return (FileHandler *) new WwsisHandler(program_name); } - case ASCIIFormat_Airnow_dailyv2: { + case ASCIIFormat::Airnow_dailyv2: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_DAILYV2); return (FileHandler *) handler; } - case ASCIIFormat_Airnow_hourlyaqobs: { + case ASCIIFormat::Airnow_hourlyaqobs: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_HOURLYAQOBS); return (FileHandler *) handler; } - case ASCIIFormat_Airnow_hourly: { + case ASCIIFormat::Airnow_hourly: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_HOURLY); return (FileHandler *) handler; } - case ASCIIFormat_NDBC_standard: { + case ASCIIFormat::NDBC_standard: { NdbcHandler *handler = new NdbcHandler(program_name); handler->setFormatVersion(NdbcHandler::NDBC_FORMAT_VERSION_STANDARD); return (FileHandler *) handler; } - case ASCIIFormat_ISMN: { + case ASCIIFormat::ISMN: { return (FileHandler *) new IsmnHandler(program_name); } - case ASCIIFormat_Aeronet_v2: { + case ASCIIFormat::Aeronet_v2: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(2); return (FileHandler *) handler; } - case ASCIIFormat_Aeronet_v3: { + case ASCIIFormat::Aeronet_v3: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(3); return (FileHandler *) handler; } #ifdef ENABLE_PYTHON - case ASCIIFormat_Python: { + case ASCIIFormat::Python: { setup_wrapper_path(); ph = new PythonHandler(program_name, ascii_filename.text()); return (FileHandler *) ph; @@ -583,42 +583,42 @@ void usage() { void set_format(const StringArray & a) { if(MetHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_MET; + ascii_format = ASCIIFormat::MET; } else if(LittleRHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_Little_R; + ascii_format = ASCIIFormat::Little_R; } else if(SurfradHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_SurfRad; + ascii_format = ASCIIFormat::SurfRad; } else if(WwsisHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_WWSIS; + ascii_format = ASCIIFormat::WWSIS; } else if(AirnowHandler::getFormatStringDailyV2() == a[0]) { - ascii_format = ASCIIFormat_Airnow_dailyv2; + ascii_format = ASCIIFormat::Airnow_dailyv2; } else if(AirnowHandler::getFormatStringHourlyAqObs() == a[0]) { - ascii_format = ASCIIFormat_Airnow_hourlyaqobs; + ascii_format = ASCIIFormat::Airnow_hourlyaqobs; } else if(AirnowHandler::getFormatStringHourly() == a[0]) { - ascii_format = ASCIIFormat_Airnow_hourly; + ascii_format = ASCIIFormat::Airnow_hourly; } else if(NdbcHandler::getFormatStringStandard() == a[0]) { - ascii_format = ASCIIFormat_NDBC_standard; + ascii_format = ASCIIFormat::NDBC_standard; } else if(IsmnHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_ISMN; + ascii_format = ASCIIFormat::ISMN; } else if(AeronetHandler::getFormatString() == a[0] || AeronetHandler::getFormatString_v2() == a[0]) { - ascii_format = ASCIIFormat_Aeronet_v2; + ascii_format = ASCIIFormat::Aeronet_v2; } else if(AeronetHandler::getFormatString_v3() == a[0]) { - ascii_format = ASCIIFormat_Aeronet_v3; + ascii_format = ASCIIFormat::Aeronet_v3; } #ifdef ENABLE_PYTHON else if(PythonHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_Python; + ascii_format = ASCIIFormat::Python; } #endif else if("python" == a[0]) { diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 4f1fbd4837..621a48ec92 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -53,6 +53,7 @@ #include "grib_classes.h" +#include "enum_as_int.hpp" #include "vx_log.h" #include "nav.h" #include "vx_math.h" @@ -82,11 +83,11 @@ int met_main(int argc, char *argv[]) { process_mask_file(dp_mask); // Apply combination logic if the current mask is binary - if(mask_type == MaskType_Poly || - mask_type == MaskType_Poly_XY || - mask_type == MaskType_Shape || - mask_type == MaskType_Box || - mask_type == MaskType_Grid || + if(mask_type == MaskType::Poly || + mask_type == MaskType::Poly_XY || + mask_type == MaskType::Shape || + mask_type == MaskType::Box || + mask_type == MaskType::Grid || thresh.get_type() != thresh_na) { dp_out = combine(dp_data, dp_mask, set_logic); } @@ -155,7 +156,7 @@ void process_command_line(int argc, char **argv) { out_filename = cline[2]; // Check for the mask type (from -type string) - if(mask_type == MaskType_None) { + if(mask_type == MaskType::None) { mlog << Error << "\n" << program_name << " -> " << "the -type command line requirement must be set to a specific masking type!\n" << "\t\t \"poly\", \"box\", \"circle\", \"track\", \"grid\", " @@ -223,11 +224,11 @@ void process_mask_file(DataPlane &dp) { solar_ut = (unixtime) 0; // Process the mask file as a lat/lon polyline file - if(mask_type == MaskType_Poly || - mask_type == MaskType_Poly_XY || - mask_type == MaskType_Box || - mask_type == MaskType_Circle || - mask_type == MaskType_Track) { + if(mask_type == MaskType::Poly || + mask_type == MaskType::Poly_XY || + mask_type == MaskType::Box || + mask_type == MaskType::Circle || + mask_type == MaskType::Track) { poly_mask.clear(); poly_mask.load(mask_filename.c_str()); @@ -238,7 +239,7 @@ void process_mask_file(DataPlane &dp) { } // Process the mask from a shapefile - else if(mask_type == MaskType_Shape) { + else if(mask_type == MaskType::Shape) { // If -shape_str was specified, find the matching records if(shape_str_map.size() > 0) get_shapefile_strings(); @@ -272,8 +273,8 @@ void process_mask_file(DataPlane &dp) { } // Nothing to do for Lat/Lon masking types - else if(mask_type == MaskType_Lat || - mask_type == MaskType_Lon) { + else if(mask_type == MaskType::Lat || + mask_type == MaskType::Lon) { } // Otherwise, process the mask file as a named grid, grid specification @@ -282,7 +283,7 @@ void process_mask_file(DataPlane &dp) { // For the grid mask type, support named grids and grid // specification strings - if(mask_type == MaskType_Grid) { + if(mask_type == MaskType::Grid) { // Parse the mask file as a white-space separated string StringArray sa; @@ -311,7 +312,7 @@ void process_mask_file(DataPlane &dp) { // Read the mask grid and data plane, if requested get_data_plane(mask_filename, mask_field_str, - mask_type == MaskType_Data, + mask_type == MaskType::Data, dp, grid_mask); } @@ -320,7 +321,7 @@ void process_mask_file(DataPlane &dp) { << " (" << grid_mask.nx() << " x " << grid_mask.ny() << ")\n"; // Check for matching grids - if(mask_type == MaskType_Data && grid != grid_mask) { + if(mask_type == MaskType::Data && grid != grid_mask) { mlog << Error << "\nprocess_mask_file() -> " << "The input grid and mask grid must be identical for " << "\"data\" masking.\n" @@ -348,7 +349,7 @@ void process_mask_file(DataPlane &dp) { } // Check that mask_field has been set for data masking - if(mask_type == MaskType_Data && mask_field_str.length() == 0) { + if(mask_type == MaskType::Data && mask_field_str.length() == 0) { mlog << Error << "\nprocess_mask_file() -> " << "use \"-mask_field\" to specify the field for " << "\"data\" masking.\n\n"; @@ -361,51 +362,51 @@ void process_mask_file(DataPlane &dp) { // Construct the mask switch(mask_type) { - case MaskType_Poly: + case MaskType::Poly: apply_poly_mask(dp); break; - case MaskType_Poly_XY: + case MaskType::Poly_XY: apply_poly_xy_mask(dp); break; - case MaskType_Box: + case MaskType::Box: apply_box_mask(dp); break; - case MaskType_Circle: + case MaskType::Circle: apply_circle_mask(dp); break; - case MaskType_Track: + case MaskType::Track: apply_track_mask(dp); break; - case MaskType_Grid: + case MaskType::Grid: apply_grid_mask(dp); break; - case MaskType_Data: + case MaskType::Data: apply_data_mask(dp); break; - case MaskType_Solar_Alt: - case MaskType_Solar_Azi: + case MaskType::Solar_Alt: + case MaskType::Solar_Azi: apply_solar_mask(dp); break; - case MaskType_Lat: - case MaskType_Lon: + case MaskType::Lat: + case MaskType::Lon: apply_lat_lon_mask(dp); break; - case MaskType_Shape: + case MaskType::Shape: apply_shape_mask(dp); break; default: mlog << Error << "\nprocess_mask_file() -> " - << "Unxpected MaskType value (" << mask_type << ")\n\n"; + << "Unxpected MaskType value (" << enum_class_as_int(mask_type) << ")\n\n"; exit(1); } @@ -1135,7 +1136,7 @@ void apply_solar_mask(DataPlane &dp) { // Compute the solar altitude and azimuth solar_altaz(solar_ut, lat, lon, alt, azi); - v = (mask_type == MaskType_Solar_Alt ? alt : azi); + v = (mask_type == MaskType::Solar_Alt ? alt : azi); // Apply threshold, if specified if(thresh.get_type() != thresh_na) { @@ -1162,7 +1163,7 @@ void apply_solar_mask(DataPlane &dp) { << masktype_to_string(mask_type) << " mask.\n"; } - const char *mask_str = (mask_type == MaskType_Solar_Alt ? + const char *mask_str = (mask_type == MaskType::Solar_Alt ? "Altitude" : "Azimuth"); // List the number of points inside the mask @@ -1205,7 +1206,7 @@ void apply_lat_lon_mask(DataPlane &dp) { // Lat/Lon value for the current grid point grid.xy_to_latlon(x, y, lat, lon); - v = (mask_type == MaskType_Lat ? lat : + v = (mask_type == MaskType::Lat ? lat : rescale_deg(-1.0*lon, -180.0, 180.0)); // Apply threshold, if specified @@ -1233,7 +1234,7 @@ void apply_lat_lon_mask(DataPlane &dp) { << masktype_to_string(mask_type) << " mask.\n"; } - const char *mask_str = (mask_type == MaskType_Lat ? + const char *mask_str = (mask_type == MaskType::Lat ? "Latitude" : "Longitude"); // List the number of points inside the mask @@ -1426,10 +1427,10 @@ void write_netcdf(const DataPlane &dp) { // Set the mask_name, if not already set if(mask_name.length() == 0) { - if(mask_type == MaskType_Poly || - mask_type == MaskType_Poly_XY || - mask_type == MaskType_Circle || - mask_type == MaskType_Track) { + if(mask_type == MaskType::Poly || + mask_type == MaskType::Poly_XY || + mask_type == MaskType::Circle || + mask_type == MaskType::Track) { mask_name = poly_mask.name(); } else { @@ -1495,26 +1496,26 @@ void write_netcdf(const DataPlane &dp) { //////////////////////////////////////////////////////////////////////// bool is_solar_masktype(MaskType t) { - return(t == MaskType_Solar_Alt || t == MaskType_Solar_Azi); + return(t == MaskType::Solar_Alt || t == MaskType::Solar_Azi); } //////////////////////////////////////////////////////////////////////// MaskType string_to_masktype(const char *s) { - MaskType t = MaskType_None; - - if(strcasecmp(s, "poly") == 0) t = MaskType_Poly; - else if(strcasecmp(s, "poly_xy") == 0) t = MaskType_Poly_XY; - else if(strcasecmp(s, "box") == 0) t = MaskType_Box; - else if(strcasecmp(s, "circle") == 0) t = MaskType_Circle; - else if(strcasecmp(s, "track") == 0) t = MaskType_Track; - else if(strcasecmp(s, "grid") == 0) t = MaskType_Grid; - else if(strcasecmp(s, "data") == 0) t = MaskType_Data; - else if(strcasecmp(s, "solar_alt") == 0) t = MaskType_Solar_Alt; - else if(strcasecmp(s, "solar_azi") == 0) t = MaskType_Solar_Azi; - else if(strcasecmp(s, "lat") == 0) t = MaskType_Lat; - else if(strcasecmp(s, "lon") == 0) t = MaskType_Lon; - else if(strcasecmp(s, "shape") == 0) t = MaskType_Shape; + MaskType t = MaskType::None; + + if(strcasecmp(s, "poly") == 0) t = MaskType::Poly; + else if(strcasecmp(s, "poly_xy") == 0) t = MaskType::Poly_XY; + else if(strcasecmp(s, "box") == 0) t = MaskType::Box; + else if(strcasecmp(s, "circle") == 0) t = MaskType::Circle; + else if(strcasecmp(s, "track") == 0) t = MaskType::Track; + else if(strcasecmp(s, "grid") == 0) t = MaskType::Grid; + else if(strcasecmp(s, "data") == 0) t = MaskType::Data; + else if(strcasecmp(s, "solar_alt") == 0) t = MaskType::Solar_Alt; + else if(strcasecmp(s, "solar_azi") == 0) t = MaskType::Solar_Azi; + else if(strcasecmp(s, "lat") == 0) t = MaskType::Lat; + else if(strcasecmp(s, "lon") == 0) t = MaskType::Lon; + else if(strcasecmp(s, "shape") == 0) t = MaskType::Shape; else { mlog << Error << "\nstring_to_masktype() -> " << "unsupported masking type \"" << s << "\"\n\n"; @@ -1530,19 +1531,19 @@ const char * masktype_to_string(const MaskType t) { const char *s = (const char *) nullptr; switch(t) { - case MaskType_Poly: s = "poly"; break; - case MaskType_Poly_XY: s = "poly_xy"; break; - case MaskType_Box: s = "box"; break; - case MaskType_Circle: s = "circle"; break; - case MaskType_Track: s = "track"; break; - case MaskType_Grid: s = "grid"; break; - case MaskType_Data: s = "data"; break; - case MaskType_Solar_Alt: s = "solar_alt"; break; - case MaskType_Solar_Azi: s = "solar_azi"; break; - case MaskType_Lat: s = "lat"; break; - case MaskType_Lon: s = "lon"; break; - case MaskType_Shape: s = "shape"; break; - case MaskType_None: s = na_str; break; + case MaskType::Poly: s = "poly"; break; + case MaskType::Poly_XY: s = "poly_xy"; break; + case MaskType::Box: s = "box"; break; + case MaskType::Circle: s = "circle"; break; + case MaskType::Track: s = "track"; break; + case MaskType::Grid: s = "grid"; break; + case MaskType::Data: s = "data"; break; + case MaskType::Solar_Alt: s = "solar_alt"; break; + case MaskType::Solar_Azi: s = "solar_azi"; break; + case MaskType::Lat: s = "lat"; break; + case MaskType::Lon: s = "lon"; break; + case MaskType::Shape: s = "shape"; break; + case MaskType::None: s = na_str; break; default: s = (const char *) nullptr; break; } diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.h b/src/tools/other/gen_vx_mask/gen_vx_mask.h index e6f985808c..962693f0c4 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.h +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.h @@ -17,7 +17,7 @@ // 000 12/09/14 Halley Gotway New // 001 06/02/16 Halley Gotway Add box masking type. // 002 11/15/16 Halley Gotway Add solar masking types. -// 003 06/03/21 Seth Linden Changed default mask type to MaskType_None. +// 003 06/03/21 Seth Linden Changed default mask type to MaskType::None. // 004 08/30/21 Halley Gotway MET #1891 fix input and mask fields. // 005 05/05/22 Halley Gotway MET #2152 Add -type poly_xy. // 006 09/29/22 Prestopnik MET #2227 Remove namespace std from header files @@ -47,27 +47,27 @@ static const char *program_name = "gen_vx_mask"; //////////////////////////////////////////////////////////////////////// -enum MaskType { +enum class MaskType { - MaskType_Poly, // Polyline masking in lat/lon space - MaskType_Poly_XY, // Polyline masking in grid x/y space + Poly, // Polyline masking in lat/lon space + Poly_XY, // Polyline masking in grid x/y space - MaskType_Box, // Box masking type - MaskType_Circle, // Circle masking region + Box, // Box masking type + Circle, // Circle masking region - MaskType_Track, // Track masking region - MaskType_Grid, // Grid masking type - MaskType_Data, // Data masking type + Track, // Track masking region + Grid, // Grid masking type + Data, // Data masking type - MaskType_Solar_Alt, // Solar altitude masking type - MaskType_Solar_Azi, // Solar azimuth masking type + Solar_Alt, // Solar altitude masking type + Solar_Azi, // Solar azimuth masking type - MaskType_Lat, // Latitude masking type - MaskType_Lon, // Longitude masking type + Lat, // Latitude masking type + Lon, // Longitude masking type - MaskType_Shape, // Shapefile + Shape, // Shapefile - MaskType_None + None }; @@ -81,7 +81,7 @@ extern const char * masktype_to_string(MaskType); // //////////////////////////////////////////////////////////////////////// -static const MaskType default_mask_type = MaskType_None; +static const MaskType default_mask_type = MaskType::None; static const double default_mask_val = 1.0; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/ioda2nc/ioda2nc.cc b/src/tools/other/ioda2nc/ioda2nc.cc index 9c4233ded4..da466c79d2 100644 --- a/src/tools/other/ioda2nc/ioda2nc.cc +++ b/src/tools/other/ioda2nc/ioda2nc.cc @@ -73,7 +73,7 @@ static const char *qc_postfix = "PreQC"; static const char *obs_group_name = "ObsValue"; static const char *derived_obs_group_name = "DerivedObsValue"; -enum e_ioda_format { ioda_v1, ioda_v2 }; +enum class e_ioda_format { v1, v2 }; //////////////////////////////////////////////////////////////////////// @@ -439,7 +439,7 @@ void process_ioda_file(int i_pb) { StringArray metadata_vars; StringArray obs_value_vars; bool error_out = true; - e_ioda_format ioda_format = ioda_v2; + e_ioda_format ioda_format = e_ioda_format::v2; get_dim_names(f_in, &dim_names); ConcatString nlocs_name = find_meta_name("nlocs", dim_names); @@ -447,9 +447,9 @@ void process_ioda_file(int i_pb) { nvars = bad_data_int ; nstring = string_data_len; - if (! has_nc_group(f_in, obs_group_name)) ioda_format = ioda_v1; + if (! has_nc_group(f_in, obs_group_name)) ioda_format = e_ioda_format::v1; - if ( ioda_format == ioda_v1 ) { + if ( ioda_format == e_ioda_format::v1 ) { StringArray var_names; get_var_names(f_in, &var_names); for(idx=0; idx " @@ -1349,7 +1349,7 @@ bool get_obs_data_float(NcFile *f_in, const ConcatString var_name, if(var_name.length() > 0) { ConcatString qc_name = var_name; ConcatString qc_group = qc_postfix; - if (ioda_format == ioda_v2) { + if (ioda_format == e_ioda_format::v2) { NcGroup nc_grp = get_nc_group(f_in, qc_postfix); if (IS_INVALID_NC(nc_grp)) qc_group = qc_group_name; StringArray qc_names = conf_info.obs_to_qc_map[var_name]; diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index 7e026610b9..2c2c4f3853 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -59,6 +59,7 @@ #include "vx_cal.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" #include "nc_point_obs_out.h" using namespace std; @@ -300,45 +301,45 @@ void process_madis_file(const char *madis_file) { exit(1); } // If the MADIS type is not already set, try to guess. - if(my_mtype == madis_none) my_mtype = get_madis_type(f_in); + if(my_mtype == MadisType::none) my_mtype = get_madis_type(f_in); // Switch on the MADIS type and process accordingly. switch(my_mtype) { - case(madis_metar): + case(MadisType::metar): process_madis_metar(f_in); break; - case(madis_raob): + case(MadisType::raob): process_madis_raob(f_in); break; - case (madis_profiler): + case (MadisType::profiler): process_madis_profiler(f_in); break; - case(madis_maritime): + case(MadisType::maritime): process_madis_maritime(f_in); break; - case(madis_mesonet): + case(MadisType::mesonet): process_madis_mesonet(f_in); break; - case(madis_acarsProfiles): + case(MadisType::acarsProfiles): process_madis_acarsProfiles(f_in); break; - case(madis_coop): - case(madis_HDW): - case(madis_HDW1h): - case(madis_hydro): - case(madis_POES): - case(madis_acars): - case(madis_radiometer): - case(madis_sao): - case(madis_satrad): - case(madis_snow): - case(madis_none): + case(MadisType::coop): + case(MadisType::HDW): + case(MadisType::HDW1h): + case(MadisType::hydro): + case(MadisType::POES): + case(MadisType::acars): + case(MadisType::radiometer): + case(MadisType::sao): + case(MadisType::satrad): + case(MadisType::snow): + case(MadisType::none): default: mlog << Error << "\nprocess_madis_file() -> " - << "MADIS type (" << my_mtype + << "MADIS type (" << enum_class_as_int(my_mtype) << ") not currently supported.\n\n"; exit(1); } @@ -662,18 +663,18 @@ int process_obs(const int in_gc, const float conversion, //////////////////////////////////////////////////////////////////////// MadisType get_madis_type(NcFile *&f_in) { - MadisType madis_type = madis_none; + MadisType madis_type = MadisType::none; ConcatString attr_value; // // FUTURE WORK: Interrogate the MADIS file and determine it's type. // if (get_global_att(f_in, (string)"id", attr_value)) { - if (attr_value == "MADIS_MARITIME") madis_type = madis_maritime; - else if (attr_value == "MADIS_MESONET") madis_type = madis_mesonet; - else if (attr_value == "MADIS_METAR") madis_type = madis_metar; + if (attr_value == "MADIS_MARITIME") madis_type = MadisType::maritime; + else if (attr_value == "MADIS_MESONET") madis_type = MadisType::mesonet; + else if (attr_value == "MADIS_METAR") madis_type = MadisType::metar; } else if (get_global_att(f_in, (string)"title", attr_value)) { - if (attr_value.contents("MADIS ACARS") != "") madis_type = madis_acarsProfiles; + if (attr_value.contents("MADIS ACARS") != "") madis_type = MadisType::acarsProfiles; } return madis_type; } @@ -3629,22 +3630,22 @@ void set_type(const StringArray & a) // Parse the MADIS type // if(strcasecmp(a[0].c_str(), metar_str) == 0) { - mtype = madis_metar; + mtype = MadisType::metar; } else if(strcasecmp(a[0].c_str(), raob_str) == 0) { - mtype = madis_raob; + mtype = MadisType::raob; } else if(strcasecmp(a[0].c_str(), profiler_str) == 0) { - mtype = madis_profiler; + mtype = MadisType::profiler; } else if(strcasecmp(a[0].c_str(), maritime_str) == 0) { - mtype = madis_maritime; + mtype = MadisType::maritime; } else if(strcasecmp(a[0].c_str(), mesonet_str) == 0) { - mtype = madis_mesonet; + mtype = MadisType::mesonet; } else if(strcasecmp(a[0].c_str(), acarsProfiles_str) == 0) { - mtype = madis_acarsProfiles; + mtype = MadisType::acarsProfiles; } else { mlog << Error << "\nprocess_command_line() -> " diff --git a/src/tools/other/madis2nc/madis2nc.h b/src/tools/other/madis2nc/madis2nc.h index aea7ec5b48..e397d5ba2b 100644 --- a/src/tools/other/madis2nc/madis2nc.h +++ b/src/tools/other/madis2nc/madis2nc.h @@ -47,24 +47,24 @@ // Enumeration of possible MADIS observation types -enum MadisType { - madis_none, - madis_coop, - madis_HDW, - madis_HDW1h, - madis_hydro, - madis_POES, - madis_acars, - madis_acarsProfiles, - madis_maritime, - madis_metar, - madis_mesonet, - madis_profiler, - madis_radiometer, - madis_raob, - madis_sao, - madis_satrad, - madis_snow +enum class MadisType { + none, + coop, + HDW, + HDW1h, + hydro, + POES, + acars, + acarsProfiles, + maritime, + metar, + mesonet, + profiler, + radiometer, + raob, + sao, + satrad, + snow }; // Constants @@ -103,7 +103,7 @@ static const char *in_recNum_str = "recNum"; static ConcatString mdfile; static ConcatString ncfile; -static MadisType mtype = madis_none; +static MadisType mtype = MadisType::none; static StringArray qc_dd_sa; static StringArray lvl_dim_sa; static int rec_beg = 0; diff --git a/src/tools/other/mode_graphics/mode_nc_output_file.cc b/src/tools/other/mode_graphics/mode_nc_output_file.cc index c39ca2465a..3247be997a 100644 --- a/src/tools/other/mode_graphics/mode_nc_output_file.cc +++ b/src/tools/other/mode_graphics/mode_nc_output_file.cc @@ -719,19 +719,19 @@ for (x=0; xtype() == ATCFLineType_ProbRI) probs.add(p.prob_rirw(i)); + if(p[i]->type() == ATCFLineType::ProbRI) probs.add(p.prob_rirw(i)); } // Print summary filtering info diff --git a/src/tools/tc_utils/tc_stat/tc_stat_files.cc b/src/tools/tc_utils/tc_stat/tc_stat_files.cc index 77a6b9d11b..a8c63c592c 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_files.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_files.cc @@ -165,8 +165,8 @@ bool TCStatFiles::operator>>(TrackPairInfo &pair) { // Skip header and non-TCMPR/TCDIAG lines if(line.is_header() || - (line.type() != TCStatLineType_TCMPR && - line.type() != TCStatLineType_TCDIAG)) continue; + (line.type() != TCStatLineType::TCMPR && + line.type() != TCStatLineType::TCDIAG)) continue; // Add the current point pair.add(line); @@ -177,7 +177,7 @@ bool TCStatFiles::operator>>(TrackPairInfo &pair) { // Check for a trailing TCDIAG line if(CurLDF.peek_line(line)) { - if(line.type() == TCStatLineType_TCDIAG) { + if(line.type() == TCStatLineType::TCDIAG) { pair.add(line); CurLDF >> line; } @@ -231,7 +231,7 @@ bool TCStatFiles::operator>>(ProbRIRWPairInfo &pair) { while((status = (CurLDF >> line))) { // Skip header and non-PROBRIRW lines - if(line.is_header() || line.type() != TCStatLineType_ProbRIRW) continue; + if(line.is_header() || line.type() != TCStatLineType::ProbRIRW) continue; // Add the current point pair.set(line); @@ -280,7 +280,7 @@ bool TCStatFiles::operator>>(TCStatLine &line) { while((status = (CurLDF >> line))) { // Skip header and invalid line types - if(line.is_header() || line.type() == NoTCStatLineType) continue; + if(line.is_header() || line.type() == TCStatLineType::None) continue; break; diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index d09dcd52f3..4fb93c24ef 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -54,7 +54,7 @@ static bool check_masks (const MaskPoly &, const Grid &, const Ma TCStatJob *TCStatJobFactory::new_tc_stat_job_type(const char *type_str) { TCStatJob *job = (TCStatJob *) nullptr; - TCStatJobType type = NoTCStatJobType; + TCStatJobType type = TCStatJobType::None; // Determine the TCStatJobType type = string_to_tcstatjobtype((string)type_str); @@ -63,23 +63,23 @@ TCStatJob *TCStatJobFactory::new_tc_stat_job_type(const char *type_str) { // The TCStatJob object is allocated and needs to be deleted by caller. switch(type) { - case TCStatJobType_Filter: + case TCStatJobType::Filter: job = new TCStatJobFilter; break; - case TCStatJobType_Summary: + case TCStatJobType::Summary: job = new TCStatJobSummary; break; - case TCStatJobType_RIRW: + case TCStatJobType::RIRW: job = new TCStatJobRIRW; break; - case TCStatJobType_ProbRIRW: + case TCStatJobType::ProbRIRW: job = new TCStatJobProbRIRW; break; - case NoTCStatJobType: + case TCStatJobType::None: default: mlog << Error << "\nTCStatJobFactory::new_tc_stat_job_type() -> " << "unsupported job type \"" << type_str << "\"\n\n"; @@ -196,7 +196,7 @@ void TCStatJob::clear() { Precision = default_precision; - JobType = NoTCStatJobType; + JobType = TCStatJobType::None; AModel.clear(); BModel.clear(); @@ -712,7 +712,7 @@ bool TCStatJob::is_keeper_line(const TCStatLine &line, TCPointCounts &n) const { // Does not apply to TCDIAG lines - if(line.type() == TCStatLineType_TCDIAG) return true; + if(line.type() == TCStatLineType::TCDIAG) return true; bool keep = true; double v_dbl, alat, alon, blat, blon; @@ -767,7 +767,7 @@ bool TCStatJob::is_keeper_line(const TCStatLine &line, !LineType.has(line.line_type())) { keep = false; n.RejLineType++; } // Check that PROBRIRW lines include the requested probability type - else if(line.type() == TCStatLineType_ProbRIRW && + else if(line.type() == TCStatLineType::ProbRIRW && !is_bad_data(ProbRIRWThresh) && is_bad_data(get_probrirw_value(line, ProbRIRWThresh))) { keep = false; @@ -885,7 +885,7 @@ double TCStatJob::get_column_double(const TCStatLine &line, // Check for PROBRIRW_PROB special case if(strcasecmp(column.c_str(), "PROBRIRW_PROB") == 0 && - line.type() == TCStatLineType_ProbRIRW) { + line.type() == TCStatLineType::ProbRIRW) { v = get_probrirw_value(line, ProbRIRWThresh); return v; } @@ -1289,7 +1289,7 @@ ConcatString TCStatJob::serialize() const { s.clear(); s.set_precision(get_precision()); - if(JobType != NoTCStatJobType) + if(JobType != TCStatJobType::None) s << "-job " << tcstatjobtype_to_string(JobType) << " "; for(i=0; i Date: Mon, 1 Apr 2024 21:41:44 +0000 Subject: [PATCH 047/114] #2830 Changed enum_class_as_integer to enum_class_as_int --- src/basic/vx_util/GridTemplate.cc | 24 +++++++------------ src/basic/vx_util/data_plane_util.cc | 9 ++----- src/basic/vx_util/interp_util.cc | 16 ++++--------- src/basic/vx_util/normalize.cc | 14 +++-------- src/libcode/vx_shapedata/engine.cc | 12 ++-------- src/libcode/vx_statistics/pair_data_point.cc | 12 ++-------- .../wavelet_stat/wavelet_stat_conf_info.cc | 16 ++++--------- 7 files changed, 25 insertions(+), 78 deletions(-) diff --git a/src/basic/vx_util/GridTemplate.cc b/src/basic/vx_util/GridTemplate.cc index 58bc284741..58ea643be5 100644 --- a/src/basic/vx_util/GridTemplate.cc +++ b/src/basic/vx_util/GridTemplate.cc @@ -29,6 +29,7 @@ #include "vx_log.h" #include "nint.h" +#include "enum_as_int.hpp" #include "GridTemplate.h" #include "GridOffset.h" @@ -40,15 +41,6 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - -/////////////////////////////////////////////////////////////////////////////// - GridTemplate::GridTemplate(void) : _wrapLon(false) { // Do nothing @@ -600,11 +592,11 @@ void GridTemplate::_setEdgeOffsets() { /////////////////////////////////////////////////////////////////////////////// GridTemplateFactory::GridTemplateFactory() { - enum_to_string.resize(enum_class_as_integer(GridTemplates::NUM_TEMPLATES)); + enum_to_string.resize(enum_class_as_int(GridTemplates::NUM_TEMPLATES)); - enum_to_string[enum_class_as_integer(GridTemplates::None)] = ""; - enum_to_string[enum_class_as_integer(GridTemplates::Square)] = "SQUARE"; - enum_to_string[enum_class_as_integer(GridTemplates::Circle)] = "CIRCLE"; + enum_to_string[enum_class_as_int(GridTemplates::None)] = ""; + enum_to_string[enum_class_as_int(GridTemplates::Square)] = "SQUARE"; + enum_to_string[enum_class_as_int(GridTemplates::Circle)] = "CIRCLE"; } /////////////////////////////////////////////////////////////////////////////// @@ -621,7 +613,7 @@ GridTemplateFactory::~GridTemplateFactory() { GridTemplateFactory::GridTemplates GridTemplateFactory::string2Enum(string target) { - for(unsigned int ix = 0; ix < enum_class_as_integer(GridTemplates::NUM_TEMPLATES); ix++) { + for(unsigned int ix = 0; ix < enum_class_as_int(GridTemplates::NUM_TEMPLATES); ix++) { if(enum_to_string[ix] == target) { return static_cast(ix); } @@ -641,7 +633,7 @@ string GridTemplateFactory::enum2String(GridTemplates target) { if(static_cast(target) > enum_to_string.size() - 1) { mlog << Error << "\nGridTemplateFactory::enum2String() -> " - << "target out of range " << enum_class_as_integer(target) << " > " + << "target out of range " << enum_class_as_int(target) << " > " << (static_cast(enum_to_string.size()) - 1) << ".\n\n"; exit(1); @@ -676,7 +668,7 @@ GridTemplate* GridTemplateFactory::buildGT(GridTemplates gt, int width, bool wra default: mlog << Error << "\nbuildGT() -> " - << "Unexpected GridTemplates value (" << enum_class_as_integer(gt) << ").\n\n"; + << "Unexpected GridTemplates value (" << enum_class_as_int(gt) << ").\n\n"; exit(1); } } diff --git a/src/basic/vx_util/data_plane_util.cc b/src/basic/vx_util/data_plane_util.cc index 16beac9e3c..6b15ed7b88 100644 --- a/src/basic/vx_util/data_plane_util.cc +++ b/src/basic/vx_util/data_plane_util.cc @@ -26,6 +26,7 @@ #include "vx_gsl_prob.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" #include "GridTemplate.h" @@ -37,12 +38,6 @@ using namespace std; // //////////////////////////////////////////////////////////////////////// -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} //////////////////////////////////////////////////////////////////////// // @@ -164,7 +159,7 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, default: mlog << Error << "\nsmooth_field() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index db776d737e..aeb08d31ae 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -23,19 +23,11 @@ #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; -//////////////////////////////////////////////////////////////////////// - -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - //////////////////////////////////////////////////////////////////////// // // Code for struct SurfaceInfo @@ -1029,7 +1021,7 @@ double compute_sfc_interp(const DataPlane &dp, default: mlog << Error << "\ncompute_sfc_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } @@ -1203,7 +1195,7 @@ double compute_horz_interp(const DataPlane &dp, default: mlog << Error << "\ncompute_horz_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } @@ -1348,7 +1340,7 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, default: mlog << Error << "\nvalid_time_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << enum_class_as_integer(mthd) << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } diff --git a/src/basic/vx_util/normalize.cc b/src/basic/vx_util/normalize.cc index 5ad26ddfa3..ab9669e0b8 100644 --- a/src/basic/vx_util/normalize.cc +++ b/src/basic/vx_util/normalize.cc @@ -16,18 +16,10 @@ #include "config_util.h" #include "normalize.h" +#include "enum_as_int.hpp" using namespace std; -//////////////////////////////////////////////////////////////////////// - -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - /////////////////////////////////////////////////////////////////////////////// ConcatString normalizetype_to_string(const NormalizeType type) { @@ -58,7 +50,7 @@ ConcatString normalizetype_to_string(const NormalizeType type) { default: mlog << Error << "\nnormalizetype_to_string() -> " - << "Unexpected NormalizeType value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected NormalizeType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -125,7 +117,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, default: mlog << Error << "\nnormalize_data() -> " << "unexpected NormalizeType value (" - << enum_class_as_integer(type) << ")\n\n"; + << enum_class_as_int(type) << ")\n\n"; exit(1); } // end switch diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index 008115bad9..0bafe99679 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -17,6 +17,7 @@ #include #include +#include "enum_as_int.hpp" #include "engine.h" #include "mode_columns.h" #include "vx_util.h" @@ -31,15 +32,6 @@ static const int print_interest_log_level = 5; static inline double area_ratio_conf(double t) { return t; } -//////////////////////////////////////////////////////////////////////// - -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - /////////////////////////////////////////////////////////////////////// // // Code for class ModeFuzzyEngine @@ -1062,7 +1054,7 @@ void ModeFuzzyEngine::do_matching() { } else { mlog << Error << "\nModeFuzzyEngine::do_matching() -> " - << "invalid match_flag value of " << enum_class_as_integer(conf_info.match_flag) + << "invalid match_flag value of " << enum_class_as_int(conf_info.match_flag) << " specified.\n\n"; exit(1); } diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index dd84a4e440..cac91ea6c1 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -25,18 +25,10 @@ #include "vx_grid.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; -//////////////////////////////////////////////////////////////////////// - -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - //////////////////////////////////////////////////////////////////////// // // Code for class PairDataPoint @@ -1619,7 +1611,7 @@ bool check_fo_thresh(double f, double o, double cmn, double csd, default: mlog << Error << "\ncheck_fo_thresh() -> " - << "Unexpected SetLogic value of " << enum_class_as_integer(type) << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index b644a3dc2f..68b2c670d7 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -21,18 +21,10 @@ #include "vx_data2d_factory.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; -//////////////////////////////////////////////////////////////////////// - -template -auto enum_class_as_integer(Enumeration const value) - -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - //////////////////////////////////////////////////////////////////////// // // Code for class WaveletStatConfInfo @@ -349,7 +341,7 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, case(WaveletType::None): default: mlog << Error << "\nWaveletStatConfInfo::process_config() -> " - << "Unsupported wavelet type value of " << enum_class_as_integer(wvlt_type) << ".\n\n"; + << "Unsupported wavelet type value of " << enum_class_as_int(wvlt_type) << ".\n\n"; exit(1); } @@ -395,7 +387,7 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, case(WaveletType::None): default: mlog << Error << "\nWaveletStatConfInfo::process_config() -> " - << "Unsupported wavelet type value of " << enum_class_as_integer(wvlt_type) << ".\n\n"; + << "Unsupported wavelet type value of " << enum_class_as_int(wvlt_type) << ".\n\n"; exit(1); } @@ -574,7 +566,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { default: mlog << Error << "\nWaveletStatConfInfo::process_tiles() -> " << "Unsupported grid decomposition type of " - << enum_class_as_integer(grid_decomp_flag) << ".\n\n"; + << enum_class_as_int(grid_decomp_flag) << ".\n\n"; exit(1); } // end switch From 2c72a1bf844ad48ff4ba01ad88ebfcbed2179d42 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 2 Apr 2024 15:16:02 -0600 Subject: [PATCH 048/114] Feature #2379 sonarqube gha (#2847) * Per #2379, testing initial GHA SonarQube setup. * Per #2379, switch to only analyzing the src directory. * Per #2379, move more config logic from sonar-project.properties into the workflow. #ci-skip-all * Per #2379, try removing + symbols * Per #2379, move projectKey into xml workflow and remove sonar-project.properties. * Per #2379, try following the instructions at https://github.com/sonarsource-cfamily-examples/linux-autotools-gh-actions-sq/blob/main/.github/workflows/build.yml ci-skip-all * Per #2379, see details of progress described in this issue comment: https://github.com/dtcenter/MET/issues/2379#issuecomment-2000242425 * Unrelated to #2379, just removing spurious space that gets flagged as a diff when re-running enum_to_string on seneca. * Per #2379, try running SonarQube through GitHub. * Per #2379, remove empty env section and also disable the testing workflow temporarily during sonarqube development. * Per #2379, fix docker image name. * Per #2379, delete unneeded script. * Per #2379, update GHA to scan Python code and push to the correct SonarQube projects. * Per #2379, update GHA SonarQube project names * Per #2379, update the build job name * Per #2379, update the comile step name * Per #2379, switch to consistent SONAR variable names. * Per #2379, fix type in sed expressions. * Per #2379, just rename the log artifact * Per #2379, use time_command wrapper instead of run_command. * Per #2379, fix bad env var name * Per #2379, switch from egrep to grep. * Per #2379, just try cat-ting the logfile * Per #2379, test whether cat-ting the log file actually works. * Per #2379, revert back * Per #2379, mention SonarQube in the PR template. Make workflow name more succinct. * Per #2379, add SONAR_REFERENCE_BRANCH setting to define the sonar.newCode.referenceBranch property. The goal is to define the comparison reference branch for each SonarQube scan. * Per #2379, have the sonarqube.yml job print the reference branch it's using * Per #2379, intentionally introduce a new code smell to see if SonarQube correctly flag it as appearing in new code. * Per #2379, trying adding the SonarQube quality gate check. * Per #2379, add logic for using the report-task.txt output files to check the quality gate status for both the python and cxx scans. * Per #2379 must use unique GHA id's * Per #2379, working on syntax for quality gate checks * Per #2379, try again. * Per #2379, try again * Per #2379, try again * Per #2379, try again * Per #2379, try again * Per #2379, try again * Per #2379, try yet again * Per #2379 * Per #2379, add more debug * Per #2379, remove -it option from docker run commands * Per #2379, again * Per #2379, now that the scan works as expected, remove the intentional SonarQube code smell as well as debug logging. --- .github/jobs/build_docker_image.sh | 2 +- .github/jobs/build_sonarqube_image.sh | 46 ++++++ .github/pull_request_template.md | 3 + .github/workflows/sonarqube.yml | 103 +++++++++++++ internal/scripts/docker/Dockerfile.sonarqube | 95 ++++++++++++ .../scripts/docker/build_met_sonarqube.sh | 136 ++++++++++++++++++ .../sonarqube/python.sonar-project.properties | 12 +- internal/scripts/sonarqube/run_sonarqube.sh | 30 ++-- .../sonarqube/sonar-project.properties | 12 +- .../vx_config/configobjecttype_to_string.cc | 2 +- 10 files changed, 415 insertions(+), 26 deletions(-) create mode 100755 .github/jobs/build_sonarqube_image.sh create mode 100644 .github/workflows/sonarqube.yml create mode 100644 internal/scripts/docker/Dockerfile.sonarqube create mode 100755 internal/scripts/docker/build_met_sonarqube.sh diff --git a/.github/jobs/build_docker_image.sh b/.github/jobs/build_docker_image.sh index 47dc46e20a..f216c0aa0e 100755 --- a/.github/jobs/build_docker_image.sh +++ b/.github/jobs/build_docker_image.sh @@ -15,7 +15,7 @@ time_command docker build -t ${DOCKERHUB_TAG} \ --build-arg MET_CONFIG_OPTS \ -f $DOCKERFILE_PATH ${GITHUB_WORKSPACE} if [ $? != 0 ]; then - cat ${GITHUB_WORKSPACE}/docker_build.log + cat ${CMD_LOGFILE} exit 1 fi diff --git a/.github/jobs/build_sonarqube_image.sh b/.github/jobs/build_sonarqube_image.sh new file mode 100755 index 0000000000..9cdeea3395 --- /dev/null +++ b/.github/jobs/build_sonarqube_image.sh @@ -0,0 +1,46 @@ +#! /bin/bash + +source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh + +DOCKERHUB_TAG=met-sonarqube-gha + +DOCKERFILE_PATH=${GITHUB_WORKSPACE}/internal/scripts/docker/Dockerfile.sonarqube + +CMD_LOGFILE=${GITHUB_WORKSPACE}/sonarqube_build.log + +# +# Define the $SONAR_REFERENCE_BRANCH as the +# - Target of any requests +# - Manual setting for workflow dispatch +# - Source branch for any pushes (e.g. develop) +# +if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then + export SONAR_REFERENCE_BRANCH=${GITHUB_BASE_REF} +elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then + export SONAR_REFERENCE_BRANCH=${WD_REFERENCE_BRANCH} +else + export SONAR_REFERENCE_BRANCH=${SOURCE_BRANCH} +fi + +echo SONAR_REFERENCE_BRANCH=${SONAR_REFERENCE_BRANCH} + +time_command docker build -t ${DOCKERHUB_TAG} \ + --build-arg MET_BASE_REPO \ + --build-arg MET_BASE_TAG \ + --build-arg SOURCE_BRANCH \ + --build-arg MET_CONFIG_OPTS \ + --build-arg SONAR_SCANNER_VERSION \ + --build-arg SONAR_HOST_URL \ + --build-arg SONAR_TOKEN \ + --build-arg SONAR_REFERENCE_BRANCH \ + -f $DOCKERFILE_PATH ${GITHUB_WORKSPACE} +if [ $? != 0 ]; then + cat ${CMD_LOGFILE} + exit 1 +fi + +# Copy the .scannerwork directory from the image +id=$(docker create ${DOCKERHUB_TAG}) +time_command docker cp $id:/met/.scannerwork /tmp/met_scannerwork +docker rm -v $id + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d3a97c7a05..0ed1004546 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -22,6 +22,9 @@ If **yes**, describe the new output and/or changes to the existing output:
- [ ] Will this PR result in changes to existing METplus Use Cases? **[Yes or No]**
If **yes**, create a new **Update Truth** [METplus issue](https://github.com/dtcenter/METplus/issues/new/choose) to describe them. +- [ ] Do these changes introduce new SonarQube findings? **[Yes or No]**
+If **yes**, please describe: + - [ ] Please complete this pull request review by **[Fill in date]**.
## Pull Request Checklist ## diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000000..36c2ccc02d --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,103 @@ +name: SonarQube Scan + +# Run SonarQube for Pull Requests and changes to the develop and main_vX.Y branches + +on: + + # Trigger analysis for pushes to develop and main_vX.Y branches + push: + branches: + - develop + - 'main_v**' + paths-ignore: + - 'docs/**' + - '.github/pull_request_template.md' + - '.github/ISSUE_TEMPLATE/**' + - '.github/labels/**' + - '**/README.md' + - '**/LICENSE.md' + + # Trigger analysis for pull requests to develop and main_vX.Y branches + pull_request: + types: [opened, synchronize, reopened] + branches: + - develop + - 'main_v**' + paths-ignore: + - 'docs/**' + - '.github/pull_request_template.md' + - '.github/ISSUE_TEMPLATE/**' + - '.github/labels/**' + - '**/README.md' + - '**/LICENSE.md' + + workflow_dispatch: + inputs: + reference_branch: + description: 'Reference Branch' + default: develop + type: string + +jobs: + build: + name: SonarQube Scan + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + with: + # Disable shallow clones for better analysis + fetch-depth: 0 + + - name: Create output directories + run: mkdir -p ${RUNNER_WORKSPACE}/logs + + - name: Get branch name + id: get_branch_name + run: echo branch_name=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT + + - name: SonarQube Scan in Docker + run: .github/jobs/build_sonarqube_image.sh + env: + MET_BASE_REPO: met-base + MET_BASE_TAG: v3.2 + SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }} + WD_REFERENCE_BRANCH: ${{ github.event.inputs.reference_branch }} + MET_CONFIG_OPTS: '--enable-all' + SONAR_SCANNER_VERSION: 5.0.1.3006 + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: SonarQube Python Quality Gate check + id: sonarqube-python-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + with: + scanMetadataReportFile: /tmp/met_scannerwork/python-report-task.txt + timeout-minutes: 5 + env: + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: SonarQube CXX Quality Gate check + id: sonarqube-cxx-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + with: + scanMetadataReportFile: /tmp/met_scannerwork/cxx-report-task.txt + timeout-minutes: 5 + env: + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Copy log files into logs directory + if: always() + run: cp ${GITHUB_WORKSPACE}/*.log ${RUNNER_WORKSPACE}/logs/ + + - name: Upload logs as artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs_sonarqube + path: ${{ runner.workspace }}/logs + if-no-files-found: ignore + diff --git a/internal/scripts/docker/Dockerfile.sonarqube b/internal/scripts/docker/Dockerfile.sonarqube new file mode 100644 index 0000000000..156fa14bf7 --- /dev/null +++ b/internal/scripts/docker/Dockerfile.sonarqube @@ -0,0 +1,95 @@ +ARG MET_BASE_REPO=met-base +ARG MET_BASE_TAG=v3.2 + +FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG} +MAINTAINER John Halley Gotway + +# +# This Dockerfile checks out MET from GitHub and runs the +# SonarQube static code analysis on the specified branch or tag. +# https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ +# +ARG SONAR_SCANNER_VERSION=5.0.1.3006 +ARG SONAR_HOST_URL +ARG SONAR_TOKEN +ARG SOURCE_BRANCH +ARG SONAR_REFERENCE_BRANCH + +# +# SONAR_HOST_URL is required. +# +RUN if [ "x${SONAR_HOST_URL}" = "x" ]; then \ + echo "ERROR: SONAR_HOST_URL undefined! Rebuild with \"--build-arg SONAR_HOST_URL={url}\""; \ + exit 1; \ + fi + +# +# SONAR_TOKEN is required. +# +RUN if [ "x${SONAR_TOKEN}" = "x" ]; then \ + echo "ERROR: SONAR_TOKEN undefined! Rebuild with \"--build-arg SONAR_TOKEN={token}\""; \ + exit 1; \ + fi + +# +# SOURCE_BRANCH is the branch name of the MET source code. +# +RUN if [ "x${SOURCE_BRANCH}" = "x" ]; then \ + echo "ERROR: SOURCE_BRANCH undefined! Rebuild with \"--build-arg SOURCE_BRANCH={branch name}\""; \ + exit 1; \ + else \ + echo "Build Argument SOURCE_BRANCH=${SOURCE_BRANCH}"; \ + fi + +# +# SONAR_REFERENCE_BRANCH defines to the version against which this scan should be compared. +# +RUN if [ "x${SONAR_REFERENCE_BRANCH}" = "x" ]; then \ + echo "ERROR: SONAR_REFERENCE_BRANCH undefined! Rebuild with \"--build-arg SONAR_REFERENCE_BRANCH={branch name}\""; \ + exit 1; \ + else \ + echo "Build Argument SONAR_REFERENCE_BRANCH=${SONAR_REFERENCE_BRANCH}"; \ + fi + +ENV MET_GIT_NAME ${SOURCE_BRANCH} +ENV MET_REPO_DIR /met/MET-${MET_GIT_NAME} +ENV MET_GIT_URL https://github.com/dtcenter/MET + +# +# Download and install the Sonar software. +# +RUN echo "Installing SonarQube into $HOME/.sonar" \ + && mkdir -p $HOME/.sonar \ + && curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip \ + && unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ \ + && echo export PATH="$HOME/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:\$PATH" >> $HOME/.bashrc \ + && curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip \ + && unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ \ + && echo export PATH="$HOME/.sonar/build-wrapper-linux-x86:\$PATH" >> $HOME/.bashrc + +# +# Update the OS, as needed. +# +RUN apt update + +# +# Set the working directory. +# +WORKDIR /met + +# +# Copy MET Download and install MET. +# +RUN echo "Copying MET into ${MET_REPO_DIR}" \ + && mkdir -p ${MET_REPO_DIR} + +COPY . ${MET_REPO_DIR} + +RUN if [ ! -e "${MET_REPO_DIR}/configure.ac" ]; then \ + echo "ERROR: docker build must be run from the MET directory: `ls`"; \ + exit 1; \ + fi + +RUN cd ${MET_REPO_DIR} \ + && internal/scripts/docker/build_met_sonarqube.sh + diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh new file mode 100755 index 0000000000..5f3c13aecc --- /dev/null +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -0,0 +1,136 @@ +#!/bin/bash +# +# Run SonarQube Source Code Analyzer within a Docker container +#======================================================================= +# +# This build_met_sonarqube.sh script must be run from the top-level +# directory of the MET repository to be analyzed. It runs SonarQube to +# scan both the Python and C/C++ MET source code. +# +# Usage: internal/scripts/docker/build_met_sonarqube.sh +# +# Required Enviornment Variables: +# SONAR_HOST_URL +# SONAR_TOKEN +# MET_GIT_NAME +# SONAR_REFERENCE_BRANCH +# +#======================================================================= + +# Check that this is being run from the top-level MET directory +if [ ! -e internal/scripts/docker/build_met_sonarqube.sh ]; then + echo "ERROR: ${0} -> must be run from the top-level MET directory" + exit 1 +fi + +echo "Running script to scan MET with SonarQube in Docker" + +# Source the docker build environment +source ~/.bashrc +source internal/scripts/environment/development.docker +source .github/jobs/bash_functions.sh + +# Check required environment variables +if [ -z ${SONAR_HOST_URL+x} ]; then + echo "ERROR: ${0} -> \$SONAR_HOST_URL not defined!" + exit 1 +fi +if [ -z ${SONAR_TOKEN+x} ]; then + echo "ERROR: ${0} -> \$SONAR_TOKEN not defined!" + exit 1 +fi +if [ -z ${MET_GIT_NAME+x} ]; then + echo "ERROR: ${0} -> \$MET_GIT_NAME not defined!" + exit 1 +fi +if [ -z ${SONAR_REFERENCE_BRANCH+x} ]; then + echo "ERROR: ${0} -> \$SONAR_REFERENCE_BRANCH not defined!" + exit 1 +fi + +# Check whether MET_CONFIG_OPTS is defined +if [ -z ${MET_CONFIG_OPTS+x} ]; then + MET_CONFIG_OPTS='--enable-all' + echo "Setting MET_CONFIG_OPTS=${MET_CONFIG_OPTS} to scan all available options." +fi + +# Locate the wrapper +WRAPPER_NAME=build-wrapper-linux-x86-64 +SONAR_WRAPPER=$(which $WRAPPER_NAME 2> /dev/null) + +if [ ! -e $SONAR_WRAPPER ]; then + echo "ERROR: ${0} -> $WRAPPER_NAME not found in the path" + exit 1 +else + echo "SONAR_WRAPPER=$SONAR_WRAPPER" +fi + +# Locate the scanner +SCANNER_NAME=sonar-scanner +SONAR_SCANNER=$(which $SCANNER_NAME 2> /dev/null) + +if [ ! -e $SONAR_SCANNER ]; then + echo "ERROR: ${0} -> $SCANNER_NAME not found in the path" + exit 1 +else + echo "SONAR_SCANNER=$SONAR_SCANNER" +fi + +# Set output directory name +if [ -z ${SONARQUBE_OUT_DIR} ]; then + export SONARQUBE_OUT_DIR=bw-outputs +fi + +# Store the full path to the scripts directory +SONAR_PROPERTIES_DIR=internal/scripts/sonarqube +SONAR_PROPERTIES=sonar-project.properties + +# Copy sonar-project.properties for Python code +[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES +sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_PROJECT_KEY|MET-GHA-Python|" \ + -e "s|SONAR_PROJECT_NAME|MET GHA Python|" \ + -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ + -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ + $SONAR_PROPERTIES_DIR/python.sonar-project.properties > $SONAR_PROPERTIES + +# Run SonarQube scan for Python code +time_command $SONAR_SCANNER + +# Copy the Python scan report-task.txt file +mkdir -p /met/.scannerwork +cp .scannerwork/report-task.txt /met/.scannerwork/python-report-task.txt + +# Copy sonar-project.properties for C/C++ code +[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES +sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_PROJECT_KEY|MET-GHA-CXX|" \ + -e "s|SONAR_PROJECT_NAME|MET GHA CXX|" \ + -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ + -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ + $SONAR_PROPERTIES_DIR/sonar-project.properties > $SONAR_PROPERTIES + +# Run the configure script +time_command ./configure \ + BUFRLIB_NAME=${BUFRLIB_NAME} \ + GRIB2CLIB_NAME=${GRIB2CLIB_NAME} \ + ${MET_CONFIG_OPTS} \ + CPPFLAGS="-I/usr/local/include -I/usr/local/include/freetype2 -I/usr/local/include/cairo" \ + LIBS="-ltirpc" + +# Run make clean +time_command make clean + +# Run SonarQube make +time_command $SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make + +# Run SonarQube scan for C/C++ code +time_command $SONAR_SCANNER + +# Copy the C/C++ scan report-task.txt file +mkdir -p /met/.scannerwork +cp .scannerwork/report-task.txt /met/.scannerwork/cxx-report-task.txt + +[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES diff --git a/internal/scripts/sonarqube/python.sonar-project.properties b/internal/scripts/sonarqube/python.sonar-project.properties index f304a07204..98b30436d7 100644 --- a/internal/scripts/sonarqube/python.sonar-project.properties +++ b/internal/scripts/sonarqube/python.sonar-project.properties @@ -1,5 +1,5 @@ -sonar.projectKey=MET_python_NB -sonar.projectName=MET python Nightly Build +sonar.projectKey=SONAR_PROJECT_KEY +sonar.projectName=SONAR_PROJECT_NAME sonar.projectVersion=1.0 sonar.sources=scripts/python,data/wrappers @@ -11,8 +11,8 @@ sonar.python.version=3.6.3 sonar.sourceEncoding=UTF-8 #----- Default SonarQube server -#sonar.host.url=http://localhost:9000 -sonar.host.url=SONAR_SERVER_URL +sonar.host.url=SONAR_HOST_URL -sonar.token=SONAR_TOKEN_VALUE -sonar.branch.name=develop +sonar.token=SONAR_TOKEN +sonar.branch.name=SONAR_BRANCH_NAME +sonar.newCode.referenceBranch=SONAR_REFERENCE_BRANCH diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 31264f2f9b..0509a4a86d 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -111,13 +111,7 @@ run_command "git checkout ${1}" export MET_DEVELOPMENT=true # Run the configure script -run_command "./configure --prefix=`pwd` \ - --enable-grib2 \ - --enable-modis \ - --enable-mode_graphics \ - --enable-lidar2nc \ - --enable-python \ - --enable-ugrid" +run_command "./configure --prefix=`pwd` --enable-all" # Set the build id #BUILD_ID="MET-${1}" @@ -126,19 +120,31 @@ SONAR_PROPERTIES=sonar-project.properties # Copy sonar-project.properties for Python code [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -[ -z "$SONAR_SERVER_URL" ] && SONAR_SERVER_URL="http://localhost:9000" -if [ -z "$SONAR_TOKEN_VALUE" ]; then - echo " == ERROR == SONAR_TOKEN_VALUE is not defined" +[ -z "$SONAR_HOST_URL" ] && SONAR_HOST_URL="http://localhost:9000" +if [ -z "$SONAR_TOKEN" ]; then + echo " == ERROR == SONAR_TOKEN is not defined" exit 1 else - sed -e "s|SONAR_TOKEN_VALUE|$SONAR_TOKEN_VALUE|" -e "s|SONAR_SERVER_URL|$SONAR_SERVER_URL|" $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES + sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_PROJECT_KEY|MET_python_NB|" \ + -e "s|SONAR_PROJECT_NAME|MET python Nightly Build|" \ + -e "s|SONAR_BRANCH_NAME|develop|" \ + -e "s|SONAR_REFERENCE_BRANCH|develop|" \ + $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES # Run SonarQube scan for Python code run_command "$SONAR_SCANNER" # Copy sonar-project.properties for C/C++ code [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES - sed -e "s|SONAR_TOKEN_VALUE|$SONAR_TOKEN_VALUE|" -e "s|SONAR_SERVER_URL|$SONAR_SERVER_URL|" $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES + sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_PROJECT_KEY|MET_develop_NB|" \ + -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ + -e "s|SONAR_BRANCH_NAME|develop|" \ + -e "s|SONAR_REFERENCE_BRANCH|develop|" \ + $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES # Run SonarQube clean run_command "make clean" diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index ec39576c4f..f486654e21 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -1,5 +1,5 @@ -sonar.projectKey=MET_develop_NB -sonar.projectName=MET Nightly Build +sonar.projectKey=SONAR_PROJECT_KEY +sonar.projectName=SONAR_PROJECT_NAME sonar.projectVersion=1.0 sonar.sources=src @@ -11,8 +11,8 @@ sonar.cfamily.build-wrapper-output=bw-outputs sonar.sourceEncoding=UTF-8 #----- Default SonarQube server -#sonar.host.url=http://localhost:9000 -sonar.host.url=SONAR_SERVER_URL +sonar.host.url=SONAR_HOST_URL -sonar.token=SONAR_TOKEN_VALUE -sonar.branch.name=develop +sonar.token=SONAR_TOKEN +sonar.branch.name=SONAR_BRANCH_NAME +sonar.newCode.referenceBranch=SONAR_REFERENCE_BRANCH diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index d8088d406c..8bb9f296b8 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -62,7 +62,7 @@ switch ( t ) { } // switch -return ConcatString (s); +return ConcatString(s); } From a72e8c56745bc3b500ff2c088363060c70222e0c Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 2 Apr 2024 15:56:19 -0600 Subject: [PATCH 049/114] Hotfix related to #2379. The sonar.newCode.referenceBranch and sonar.branch.name cannot be set to the same string! Only add the newCode definition when they differ. --- internal/scripts/docker/build_met_sonarqube.sh | 10 ++++++++++ .../scripts/sonarqube/python.sonar-project.properties | 1 - internal/scripts/sonarqube/run_sonarqube.sh | 2 -- internal/scripts/sonarqube/sonar-project.properties | 1 - 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index 5f3c13aecc..f726d8b3b9 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -95,6 +95,11 @@ sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ $SONAR_PROPERTIES_DIR/python.sonar-project.properties > $SONAR_PROPERTIES +# The source and reference branches must differ to define new code +if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then + echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES +fi + # Run SonarQube scan for Python code time_command $SONAR_SCANNER @@ -112,6 +117,11 @@ sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ $SONAR_PROPERTIES_DIR/sonar-project.properties > $SONAR_PROPERTIES +# The source and reference branches must differ to define new code +if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then + echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES +fi + # Run the configure script time_command ./configure \ BUFRLIB_NAME=${BUFRLIB_NAME} \ diff --git a/internal/scripts/sonarqube/python.sonar-project.properties b/internal/scripts/sonarqube/python.sonar-project.properties index 98b30436d7..71b6b36b71 100644 --- a/internal/scripts/sonarqube/python.sonar-project.properties +++ b/internal/scripts/sonarqube/python.sonar-project.properties @@ -15,4 +15,3 @@ sonar.host.url=SONAR_HOST_URL sonar.token=SONAR_TOKEN sonar.branch.name=SONAR_BRANCH_NAME -sonar.newCode.referenceBranch=SONAR_REFERENCE_BRANCH diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 0509a4a86d..917158b461 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -130,7 +130,6 @@ else -e "s|SONAR_PROJECT_KEY|MET_python_NB|" \ -e "s|SONAR_PROJECT_NAME|MET python Nightly Build|" \ -e "s|SONAR_BRANCH_NAME|develop|" \ - -e "s|SONAR_REFERENCE_BRANCH|develop|" \ $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES # Run SonarQube scan for Python code @@ -143,7 +142,6 @@ else -e "s|SONAR_PROJECT_KEY|MET_develop_NB|" \ -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ -e "s|SONAR_BRANCH_NAME|develop|" \ - -e "s|SONAR_REFERENCE_BRANCH|develop|" \ $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES # Run SonarQube clean diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index f486654e21..c09f1d31b1 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -15,4 +15,3 @@ sonar.host.url=SONAR_HOST_URL sonar.token=SONAR_TOKEN sonar.branch.name=SONAR_BRANCH_NAME -sonar.newCode.referenceBranch=SONAR_REFERENCE_BRANCH From 2bef141691011a6ecaa614ed9ee742a7ced6bc1a Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 3 Apr 2024 17:13:56 +0000 Subject: [PATCH 050/114] #2830 Changed enum STATJobType to enum class --- src/libcode/vx_analysis_util/stat_job.cc | 41 ++++++++++--------- src/libcode/vx_analysis_util/stat_job.h | 36 ++++++++-------- .../core/stat_analysis/aggr_stat_line.cc | 2 +- src/tools/core/stat_analysis/stat_analysis.cc | 14 +++---- .../core/stat_analysis/stat_analysis_job.cc | 34 +++++++-------- 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 858d93a6e8..ba4f325e17 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -22,6 +22,7 @@ #include "vx_statistics.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; @@ -110,7 +111,7 @@ void STATAnalysisJob::clear() { precision = default_precision; - job_type = no_stat_job_type; + job_type = STATJobType::None; model.clear(); desc.clear(); @@ -1704,7 +1705,7 @@ int STATAnalysisJob::set_job_type(const char *c) { job_type = string_to_statjobtype(c); - if(job_type == no_stat_job_type) return 1; + if(job_type == STATJobType::None) return 1; else return 0; } @@ -2347,7 +2348,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { js.clear(); // job type - if(job_type != no_stat_job_type) { + if(job_type != STATJobType::None) { js << "-job " << statjobtype_to_string(job_type) << " "; } @@ -2690,7 +2691,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // out_cnt_logic - if(job_type == stat_job_aggr_stat && + if(job_type == STATJobType::aggr_stat && line_type.has(stat_mpr_str) && (out_line_type.has(stat_cnt_str) || out_line_type.has(stat_sl1l2_str)) && (out_fcst_thresh.n() > 0 || out_obs_thresh.n() > 0)) { @@ -2716,7 +2717,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // out_wind_logic - if(job_type == stat_job_aggr_stat && + if(job_type == STATJobType::aggr_stat && line_type.has(stat_mpr_str) && out_line_type.has(stat_wdir_str) && (out_fcst_wind_thresh.get_type() != thresh_na || @@ -2725,7 +2726,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Jobs which use out_alpha - if(job_type == stat_job_summary || + if(job_type == STATJobType::summary || out_line_type.has(stat_cts_str) || out_line_type.has(stat_mcts_str) || out_line_type.has(stat_cnt_str) || @@ -2738,7 +2739,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Ramp jobs - if(job_type == stat_job_ramp) { + if(job_type == STATJobType::ramp) { // ramp_type js << "-ramp_type " << timeseriestype_to_string(ramp_type) << " "; @@ -2837,9 +2838,9 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Jobs which compute the skill score index - if(job_type == stat_job_go_index || - job_type == stat_job_cbs_index || - job_type == stat_job_ss_index) { + if(job_type == STATJobType::go_index || + job_type == STATJobType::cbs_index || + job_type == STATJobType::ss_index) { // ss_index_name js << "-ss_index_name " << ss_index_name << " "; @@ -2937,7 +2938,7 @@ int STATAnalysisJob::is_in_mask_sid(const char *sid) const { //////////////////////////////////////////////////////////////////////// const char * statjobtype_to_string(const STATJobType t) { - return statjobtype_str[t]; + return statjobtype_str[enum_class_as_int(t)]; } //////////////////////////////////////////////////////////////////////// @@ -2956,23 +2957,23 @@ STATJobType string_to_statjobtype(const char *str) { STATJobType t; if( strcasecmp(str, statjobtype_str[0]) == 0) - t = stat_job_filter; + t = STATJobType::filter; else if(strcasecmp(str, statjobtype_str[1]) == 0) - t = stat_job_summary; + t = STATJobType::summary; else if(strcasecmp(str, statjobtype_str[2]) == 0) - t = stat_job_aggr; + t = STATJobType::aggr; else if(strcasecmp(str, statjobtype_str[3]) == 0) - t = stat_job_aggr_stat; + t = STATJobType::aggr_stat; else if(strcasecmp(str, statjobtype_str[4]) == 0) - t = stat_job_go_index; + t = STATJobType::go_index; else if(strcasecmp(str, statjobtype_str[5]) == 0) - t = stat_job_cbs_index; + t = STATJobType::cbs_index; else if(strcasecmp(str, statjobtype_str[6]) == 0) - t = stat_job_ss_index; + t = STATJobType::ss_index; else if(strcasecmp(str, statjobtype_str[7]) == 0) - t = stat_job_ramp; + t = STATJobType::ramp; else - t = no_stat_job_type; + t = STATJobType::None; return t; } diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 12002ec447..0916056e19 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -57,30 +57,30 @@ static const int dump_stat_buffer_cols = 512; // // Enumerate all the possible STAT Analysis Job Types // -enum STATJobType { +enum class STATJobType { - stat_job_filter = 0, // Filter out the STAT data and write the - // lines to the filename specified. + filter = 0, /* Filter out the STAT data and write the + lines to the filename specified. */ - stat_job_summary = 1, // Compute min, max, mean, stdev and - // percentiles for a column of data. + summary = 1, /* Compute min, max, mean, stdev and + percentiles for a column of data. */ - stat_job_aggr = 2, // Aggregate the input counts/scores and - // generate the same output line type - // containing the aggregated counts/scores. + aggr = 2, /* Aggregate the input counts/scores and + generate the same output line type + containing the aggregated counts/scores. */ - stat_job_aggr_stat = 3, // Aggregate the input counts/scores and - // generate the requested output line type. + aggr_stat = 3, /* Aggregate the input counts/scores and + // generate the requested output line type. */ - stat_job_go_index = 4, // Compute the GO Index. + go_index = 4, /* Compute the GO Index. */ - stat_job_cbs_index = 5, // Compute the CBS Index. + cbs_index = 5, /* Compute the CBS Index. */ - stat_job_ss_index = 6, // Compute the Skill Score Index. + ss_index = 6, /* Compute the Skill Score Index. */ - stat_job_ramp = 7, // Time-series ramp evaluation. + ramp = 7, /* Time-series ramp evaluation. */ - no_stat_job_type = 8 // Default value + None = 8 /* Default value */ }; static const int n_statjobtypes = 9; @@ -267,14 +267,14 @@ class STATAnalysisJob { NumArray out_eclv_points; // output ECLV points // - // Variables used for the stat_job_summary job type + // Variables used for the STATJobType::summary job type // bool do_derive; StringArray wmo_sqrt_stats; StringArray wmo_fisher_stats; // - // Variables used for the stat_job_aggr_mpr job type + // Variables used for the STATJobType::aggr_mpr job type // ConcatString mask_grid_str; ConcatString mask_poly_str; @@ -286,7 +286,7 @@ class STATAnalysisJob { StringArray mask_sid; // - // Variables used for the stat_job_ramp job type + // Variables used for the STATJobType::ramp job type // TimeSeriesType ramp_type; int ramp_time_fcst; // stored in seconds diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index dd53c0a3e6..69804173cf 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -3769,7 +3769,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, // and set the type to aggregation // fcst_term = job; - fcst_term.set_job_type(stat_job_aggr); + fcst_term.set_job_type(STATJobType::aggr); // // line_type diff --git a/src/tools/core/stat_analysis/stat_analysis.cc b/src/tools/core/stat_analysis/stat_analysis.cc index 42fba3bf5e..19918c2845 100644 --- a/src/tools/core/stat_analysis/stat_analysis.cc +++ b/src/tools/core/stat_analysis/stat_analysis.cc @@ -193,7 +193,7 @@ int met_main(int argc, char * argv []) { // // If a job was specified on the command line, run it. // - if(default_job.job_type != no_stat_job_type) { + if(default_job.job_type != STATJobType::None) { process_job(command_line_job_options.c_str(), 1); } // @@ -470,14 +470,14 @@ void process_search_dirs() { // // Apply the GO Index or CBS Index filtering criteria. // - if(default_job.job_type == stat_job_go_index || - default_job.job_type == stat_job_cbs_index) { + if(default_job.job_type == STATJobType::go_index || + default_job.job_type == STATJobType::cbs_index) { MetConfig ss_index_conf; STATAnalysisJob ss_index_job; ConcatString config_file = - (default_job.job_type == stat_job_go_index ? + (default_job.job_type == STATJobType::go_index ? replace_path(go_index_config_file) : replace_path(cbs_index_config_file)); @@ -677,14 +677,14 @@ void process_job(const char * jobstring, int n_job) { // // Special processing for the GO Index and CBS Index jobs. // - if(job.job_type == stat_job_go_index || - job.job_type == stat_job_cbs_index) { + if(job.job_type == STATJobType::go_index || + job.job_type == STATJobType::cbs_index) { MetConfig ss_index_conf; STATAnalysisJob ss_index_job; ConcatString config_file = - (job.job_type == stat_job_go_index ? + (job.job_type == STATJobType::go_index ? replace_path(go_index_config_file) : replace_path(cbs_index_config_file)); diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index a1c875bf80..06959f819f 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -201,13 +201,13 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // Print warning for by_column option // if(job.by_column.n() > 0 && - job.job_type != stat_job_summary && - job.job_type != stat_job_aggr && - job.job_type != stat_job_aggr_stat && - job.job_type != stat_job_ramp && - job.job_type != stat_job_go_index && - job.job_type != stat_job_cbs_index && - job.job_type != stat_job_ss_index) { + job.job_type != STATJobType::summary && + job.job_type != STATJobType::aggr && + job.job_type != STATJobType::aggr_stat && + job.job_type != STATJobType::ramp && + job.job_type != STATJobType::go_index && + job.job_type != STATJobType::cbs_index && + job.job_type != STATJobType::ss_index) { mlog << Warning << "\nThe -by option is ignored for the \"" << statjobtype_to_string(job.job_type) << "\" job type.\n\n"; } @@ -216,8 +216,8 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // Set up the random number generator and seed value // for the summary and aggregate stat jobs. // - if(job.job_type == stat_job_summary || - job.job_type == stat_job_aggr_stat) { + if(job.job_type == STATJobType::summary || + job.job_type == STATJobType::aggr_stat) { rng_set(rng_ptr, job.boot_rng, job.boot_seed); } @@ -226,29 +226,29 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // switch(job.job_type) { - case(stat_job_filter): + case(STATJobType::filter): do_job_filter(jobstring, f, job, n_in, n_out, sa_out); break; - case(stat_job_summary): + case(STATJobType::summary): do_job_summary(jobstring, f, job, n_in, n_out, sa_out, rng_ptr); break; - case(stat_job_aggr): + case(STATJobType::aggr): do_job_aggr(jobstring, f, job, n_in, n_out, sa_out); break; - case(stat_job_aggr_stat): + case(STATJobType::aggr_stat): do_job_aggr_stat(jobstring, f, job, n_in, n_out, sa_out, tmp_dir, rng_ptr); break; - case(stat_job_go_index): - case(stat_job_cbs_index): - case(stat_job_ss_index): + case(STATJobType::go_index): + case(STATJobType::cbs_index): + case(STATJobType::ss_index): do_job_ss_index(jobstring, f, job, n_in, n_out, sa_out); break; - case(stat_job_ramp): + case(STATJobType::ramp): do_job_ramp(jobstring, f, job, n_in, n_out, sa_out); break; From 9e0cd6db43975d7742b47f43a7e3a611af1ab36b Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 04:42:12 +0000 Subject: [PATCH 051/114] #2830 Changed STATLineType to enum class --- src/basic/vx_config/config_constants.h | 84 +-- src/basic/vx_config/config_util.cc | 178 +++--- src/basic/vx_util/GridTemplate.cc | 4 +- src/basic/vx_util/data_plane_util.cc | 12 +- src/libcode/vx_analysis_util/stat_job.cc | 202 +++---- src/libcode/vx_analysis_util/stat_line.cc | 8 +- src/libcode/vx_plot_util/vx_plot_util.h | 2 +- .../ensemble_stat/ensemble_stat_conf_info.h | 6 +- .../core/grid_stat/grid_stat_conf_info.h | 56 +- .../core/point_stat/point_stat_conf_info.h | 52 +- .../core/series_analysis/series_analysis.cc | 68 +-- .../series_analysis_conf_info.cc | 28 +- .../core/stat_analysis/aggr_stat_line.cc | 72 +-- .../stat_analysis/skill_score_index_job.cc | 12 +- src/tools/core/stat_analysis/stat_analysis.cc | 4 +- .../core/stat_analysis/stat_analysis_job.cc | 518 +++++++++--------- .../wavelet_stat/wavelet_stat_conf_info.h | 2 +- src/tools/tc_utils/tc_gen/tc_gen.cc | 44 +- src/tools/tc_utils/tc_gen/tc_gen_conf_info.h | 16 +- src/tools/tc_utils/tc_stat/tc_stat_job.cc | 38 +- 20 files changed, 703 insertions(+), 703 deletions(-) diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index 3081357d5d..deb9a425fe 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -129,48 +129,48 @@ enum class Interp12Type { // Enumeration for all the possible STAT line types // -enum STATLineType { - - stat_sl1l2, - stat_sal1l2, - stat_vl1l2, - stat_val1l2, - - stat_vcnt, - - stat_fho, - stat_ctc, - stat_cts, - stat_mctc, - stat_mcts, - stat_cnt, - stat_pct, - stat_pstd, - stat_pjc, - stat_prc, - stat_mpr, - stat_seeps, - stat_seeps_mpr, - stat_nbrctc, - stat_nbrcts, - stat_nbrcnt, - stat_isc, - stat_wdir, - stat_ecnt, - stat_rps, - stat_rhist, - stat_phist, - stat_orank, - stat_ssvar, - stat_relp, - stat_eclv, - stat_grad, - stat_dmap, - stat_genmpr, - stat_ssidx, - stat_header, - - no_stat_line_type +enum class STATLineType { + + sl1l2, + sal1l2, + vl1l2, + val1l2, + + vcnt, + + fho, + ctc, + cts, + mctc, + mcts, + cnt, + pct, + pstd, + pjc, + prc, + mpr, + seeps, + seeps_mpr, + nbrctc, + nbrcts, + nbrcnt, + isc, + wdir, + ecnt, + rps, + rhist, + phist, + orank, + ssvar, + relp, + eclv, + grad, + dmap, + genmpr, + ssidx, + header, + + none }; diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 3885850a70..344f997bea 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -2611,52 +2611,52 @@ const char * statlinetype_to_string(const STATLineType t) { const char *s = (const char *) nullptr; switch(t) { - case stat_sl1l2: s = stat_sl1l2_str; break; - case stat_sal1l2: s = stat_sal1l2_str; break; - case stat_vl1l2: s = stat_vl1l2_str; break; - case stat_val1l2: s = stat_val1l2_str; break; - case stat_vcnt: s = stat_vcnt_str; break; - - case stat_fho: s = stat_fho_str; break; - case stat_ctc: s = stat_ctc_str; break; - case stat_cts: s = stat_cts_str; break; - case stat_mctc: s = stat_mctc_str; break; - case stat_mcts: s = stat_mcts_str; break; - - case stat_cnt: s = stat_cnt_str; break; - case stat_pct: s = stat_pct_str; break; - case stat_pstd: s = stat_pstd_str; break; - case stat_pjc: s = stat_pjc_str; break; - case stat_prc: s = stat_prc_str; break; - - case stat_eclv: s = stat_eclv_str; break; - case stat_mpr: s = stat_mpr_str; break; - case stat_seeps: s = stat_seeps_str; break; - case stat_seeps_mpr: s = stat_seeps_mpr_str; break; - case stat_nbrctc: s = stat_nbrctc_str; break; - - case stat_nbrcts: s = stat_nbrcts_str; break; - case stat_nbrcnt: s = stat_nbrcnt_str; break; - case stat_grad: s = stat_grad_str; break; - case stat_dmap: s = stat_dmap_str; break; - case stat_isc: s = stat_isc_str; break; - - case stat_wdir: s = stat_wdir_str; break; - case stat_ecnt: s = stat_ecnt_str; break; - case stat_rps: s = stat_rps_str; break; - case stat_rhist: s = stat_rhist_str; break; - case stat_phist: s = stat_phist_str; break; - - case stat_orank: s = stat_orank_str; break; - case stat_ssvar: s = stat_ssvar_str; break; - case stat_relp: s = stat_relp_str; break; - case stat_genmpr: s = stat_genmpr_str; break; - case stat_ssidx: s = stat_ssidx_str; break; + case STATLineType::sl1l2: s = stat_sl1l2_str; break; + case STATLineType::sal1l2: s = stat_sal1l2_str; break; + case STATLineType::vl1l2: s = stat_vl1l2_str; break; + case STATLineType::val1l2: s = stat_val1l2_str; break; + case STATLineType::vcnt: s = stat_vcnt_str; break; + + case STATLineType::fho: s = stat_fho_str; break; + case STATLineType::ctc: s = stat_ctc_str; break; + case STATLineType::cts: s = stat_cts_str; break; + case STATLineType::mctc: s = stat_mctc_str; break; + case STATLineType::mcts: s = stat_mcts_str; break; + + case STATLineType::cnt: s = stat_cnt_str; break; + case STATLineType::pct: s = stat_pct_str; break; + case STATLineType::pstd: s = stat_pstd_str; break; + case STATLineType::pjc: s = stat_pjc_str; break; + case STATLineType::prc: s = stat_prc_str; break; + + case STATLineType::eclv: s = stat_eclv_str; break; + case STATLineType::mpr: s = stat_mpr_str; break; + case STATLineType::seeps: s = stat_seeps_str; break; + case STATLineType::seeps_mpr: s = stat_seeps_mpr_str; break; + case STATLineType::nbrctc: s = stat_nbrctc_str; break; + + case STATLineType::nbrcts: s = stat_nbrcts_str; break; + case STATLineType::nbrcnt: s = stat_nbrcnt_str; break; + case STATLineType::grad: s = stat_grad_str; break; + case STATLineType::dmap: s = stat_dmap_str; break; + case STATLineType::isc: s = stat_isc_str; break; + + case STATLineType::wdir: s = stat_wdir_str; break; + case STATLineType::ecnt: s = stat_ecnt_str; break; + case STATLineType::rps: s = stat_rps_str; break; + case STATLineType::rhist: s = stat_rhist_str; break; + case STATLineType::phist: s = stat_phist_str; break; + + case STATLineType::orank: s = stat_orank_str; break; + case STATLineType::ssvar: s = stat_ssvar_str; break; + case STATLineType::relp: s = stat_relp_str; break; + case STATLineType::genmpr: s = stat_genmpr_str; break; + case STATLineType::ssidx: s = stat_ssidx_str; break; - case stat_header: s = stat_header_str; break; + case STATLineType::header: s = stat_header_str; break; - case no_stat_line_type: - default: s = stat_na_str; break; + /*case STATLineType::none:*/ + default: s = stat_na_str; break; } return s; @@ -2677,51 +2677,51 @@ void statlinetype_to_string(const STATLineType t, char *out) { STATLineType string_to_statlinetype(const char *s) { STATLineType t; - if(strcasecmp(s, stat_sl1l2_str) == 0) t = stat_sl1l2; - else if(strcasecmp(s, stat_sal1l2_str) == 0) t = stat_sal1l2; - else if(strcasecmp(s, stat_vl1l2_str) == 0) t = stat_vl1l2; - else if(strcasecmp(s, stat_val1l2_str) == 0) t = stat_val1l2; - else if(strcasecmp(s, stat_vcnt_str) == 0) t = stat_vcnt; - - else if(strcasecmp(s, stat_fho_str) == 0) t = stat_fho; - else if(strcasecmp(s, stat_ctc_str) == 0) t = stat_ctc; - else if(strcasecmp(s, stat_cts_str) == 0) t = stat_cts; - else if(strcasecmp(s, stat_mctc_str) == 0) t = stat_mctc; - else if(strcasecmp(s, stat_mcts_str) == 0) t = stat_mcts; - - else if(strcasecmp(s, stat_cnt_str) == 0) t = stat_cnt; - else if(strcasecmp(s, stat_pct_str) == 0) t = stat_pct; - else if(strcasecmp(s, stat_pstd_str) == 0) t = stat_pstd; - else if(strcasecmp(s, stat_pjc_str) == 0) t = stat_pjc; - else if(strcasecmp(s, stat_prc_str) == 0) t = stat_prc; - - else if(strcasecmp(s, stat_eclv_str) == 0) t = stat_eclv; - else if(strcasecmp(s, stat_mpr_str) == 0) t = stat_mpr; - else if(strcasecmp(s, stat_seeps_str) == 0) t = stat_seeps; - else if(strcasecmp(s, stat_seeps_mpr_str) == 0) t = stat_seeps_mpr; - else if(strcasecmp(s, stat_nbrctc_str) == 0) t = stat_nbrctc; - - else if(strcasecmp(s, stat_nbrcts_str) == 0) t = stat_nbrcts; - else if(strcasecmp(s, stat_nbrcnt_str) == 0) t = stat_nbrcnt; - else if(strcasecmp(s, stat_grad_str) == 0) t = stat_grad; - else if(strcasecmp(s, stat_dmap_str) == 0) t = stat_dmap; - else if(strcasecmp(s, stat_isc_str) == 0) t = stat_isc; - - else if(strcasecmp(s, stat_wdir_str) == 0) t = stat_wdir; - else if(strcasecmp(s, stat_ecnt_str) == 0) t = stat_ecnt; - else if(strcasecmp(s, stat_rps_str) == 0) t = stat_rps; - else if(strcasecmp(s, stat_rhist_str) == 0) t = stat_rhist; - else if(strcasecmp(s, stat_phist_str) == 0) t = stat_phist; - - else if(strcasecmp(s, stat_orank_str) == 0) t = stat_orank; - else if(strcasecmp(s, stat_ssvar_str) == 0) t = stat_ssvar; - else if(strcasecmp(s, stat_relp_str) == 0) t = stat_relp; - else if(strcasecmp(s, stat_genmpr_str) == 0) t = stat_genmpr; - else if(strcasecmp(s, stat_ssidx_str) == 0) t = stat_ssidx; - - else if(strcasecmp(s, stat_header_str) == 0) t = stat_header; - - else t = no_stat_line_type; + if(strcasecmp(s, stat_sl1l2_str) == 0) t = STATLineType::sl1l2; + else if(strcasecmp(s, stat_sal1l2_str) == 0) t = STATLineType::sal1l2; + else if(strcasecmp(s, stat_vl1l2_str) == 0) t = STATLineType::vl1l2; + else if(strcasecmp(s, stat_val1l2_str) == 0) t = STATLineType::val1l2; + else if(strcasecmp(s, stat_vcnt_str) == 0) t = STATLineType::vcnt; + + else if(strcasecmp(s, stat_fho_str) == 0) t = STATLineType::fho; + else if(strcasecmp(s, stat_ctc_str) == 0) t = STATLineType::ctc; + else if(strcasecmp(s, stat_cts_str) == 0) t = STATLineType::cts; + else if(strcasecmp(s, stat_mctc_str) == 0) t = STATLineType::mctc; + else if(strcasecmp(s, stat_mcts_str) == 0) t = STATLineType::mcts; + + else if(strcasecmp(s, stat_cnt_str) == 0) t = STATLineType::cnt; + else if(strcasecmp(s, stat_pct_str) == 0) t = STATLineType::pct; + else if(strcasecmp(s, stat_pstd_str) == 0) t = STATLineType::pstd; + else if(strcasecmp(s, stat_pjc_str) == 0) t = STATLineType::pjc; + else if(strcasecmp(s, stat_prc_str) == 0) t = STATLineType::prc; + + else if(strcasecmp(s, stat_eclv_str) == 0) t = STATLineType::eclv; + else if(strcasecmp(s, stat_mpr_str) == 0) t = STATLineType::mpr; + else if(strcasecmp(s, stat_seeps_str) == 0) t = STATLineType::seeps; + else if(strcasecmp(s, stat_seeps_mpr_str) == 0) t = STATLineType::seeps_mpr; + else if(strcasecmp(s, stat_nbrctc_str) == 0) t = STATLineType::nbrctc; + + else if(strcasecmp(s, stat_nbrcts_str) == 0) t = STATLineType::nbrcts; + else if(strcasecmp(s, stat_nbrcnt_str) == 0) t = STATLineType::nbrcnt; + else if(strcasecmp(s, stat_grad_str) == 0) t = STATLineType::grad; + else if(strcasecmp(s, stat_dmap_str) == 0) t = STATLineType::dmap; + else if(strcasecmp(s, stat_isc_str) == 0) t = STATLineType::isc; + + else if(strcasecmp(s, stat_wdir_str) == 0) t = STATLineType::wdir; + else if(strcasecmp(s, stat_ecnt_str) == 0) t = STATLineType::ecnt; + else if(strcasecmp(s, stat_rps_str) == 0) t = STATLineType::rps; + else if(strcasecmp(s, stat_rhist_str) == 0) t = STATLineType::rhist; + else if(strcasecmp(s, stat_phist_str) == 0) t = STATLineType::phist; + + else if(strcasecmp(s, stat_orank_str) == 0) t = STATLineType::orank; + else if(strcasecmp(s, stat_ssvar_str) == 0) t = STATLineType::ssvar; + else if(strcasecmp(s, stat_relp_str) == 0) t = STATLineType::relp; + else if(strcasecmp(s, stat_genmpr_str) == 0) t = STATLineType::genmpr; + else if(strcasecmp(s, stat_ssidx_str) == 0) t = STATLineType::ssidx; + + else if(strcasecmp(s, stat_header_str) == 0) t = STATLineType::header; + + else t = STATLineType::none; return t; } diff --git a/src/basic/vx_util/GridTemplate.cc b/src/basic/vx_util/GridTemplate.cc index 58ea643be5..c2c21bf038 100644 --- a/src/basic/vx_util/GridTemplate.cc +++ b/src/basic/vx_util/GridTemplate.cc @@ -660,10 +660,10 @@ GridTemplate* GridTemplateFactory::buildGT(string gt, int width, bool wrap_lon) GridTemplate* GridTemplateFactory::buildGT(GridTemplates gt, int width, bool wrap_lon) { switch (gt) { - case(GridTemplates::Square): + case GridTemplates::Square: return new RectangularTemplate(width, width, wrap_lon); - case(GridTemplates::Circle): + case GridTemplates::Circle: return new CircularTemplate(width, wrap_lon); default: diff --git a/src/basic/vx_util/data_plane_util.cc b/src/basic/vx_util/data_plane_util.cc index 6b15ed7b88..f07da09913 100644 --- a/src/basic/vx_util/data_plane_util.cc +++ b/src/basic/vx_util/data_plane_util.cc @@ -128,27 +128,27 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, // Compute the smoothed value based on the interpolation method switch(mthd) { - case(InterpMthd::Min): // Minimum + case InterpMthd::Min: // Minimum v = interp_min(dp, *gt, x, y, t); break; - case(InterpMthd::Max): // Maximum + case InterpMthd::Max: // Maximum v = interp_max(dp, *gt, x, y, t); break; - case(InterpMthd::Median): // Median + case InterpMthd::Median: // Median v = interp_median(dp, *gt, x, y, t); break; - case(InterpMthd::UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, t); break; - case(InterpMthd::Gaussian): // For Gaussian, pass the data through + case InterpMthd::Gaussian: // For Gaussian, pass the data through v = dp.get(x, y); break; - case(InterpMthd::MaxGauss): // For Max Gaussian, compute the max + case InterpMthd::MaxGauss: // For Max Gaussian, compute the max v = interp_max(dp, *gt, x, y, 0); break; diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index ba4f325e17..df2335067a 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -1004,7 +1004,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // For MPR lines, check mask_grid, mask_poly, and mask_sid // - if(string_to_statlinetype(L.line_type()) == stat_mpr) { + if(string_to_statlinetype(L.line_type()) == STATLineType::mpr) { double lat = atof(L.get_item("OBS_LAT")); double lon = atof(L.get_item("OBS_LON")); @@ -1965,7 +1965,7 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { out_sa = (out_line_type.n() > 0 ? out_line_type : line_type); out_lt = (out_sa.n() == 1 ? - string_to_statlinetype(out_sa[0].c_str()) : no_stat_line_type); + string_to_statlinetype(out_sa[0].c_str()) : STATLineType::none); // // Loop through the output line types and determine the number of @@ -1974,38 +1974,38 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { for(i=0, c=0, n_col=0; i " << "unexpected stat line type \"" << statlinetype_to_string(cur_lt) @@ -2045,44 +2045,44 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { // Write the STAT header row // switch(out_lt) { - case stat_sl1l2: write_header_row (sl1l2_columns, n_sl1l2_columns, 1, stat_at, 0, 0); break; - case stat_sal1l2: write_header_row (sal1l2_columns, n_sal1l2_columns, 1, stat_at, 0, 0); break; - case stat_vl1l2: write_header_row (vl1l2_columns, n_vl1l2_columns, 1, stat_at, 0, 0); break; - case stat_val1l2: write_header_row (val1l2_columns, n_val1l2_columns, 1, stat_at, 0, 0); break; - case stat_fho: write_header_row (fho_columns, n_fho_columns, 1, stat_at, 0, 0); break; - case stat_ctc: write_header_row (ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break; - case stat_cts: write_header_row (cts_columns, n_cts_columns, 1, stat_at, 0, 0); break; - case stat_mctc: write_mctc_header_row (1, n, stat_at, 0, 0); break; - case stat_mcts: write_header_row (mcts_columns, n_mcts_columns, 1, stat_at, 0, 0); break; - case stat_cnt: write_header_row (cnt_columns, n_cnt_columns, 1, stat_at, 0, 0); break; - case stat_vcnt: write_header_row (vcnt_columns, n_vcnt_columns, 1, stat_at, 0, 0); break; - case stat_pct: write_pct_header_row (1, n, stat_at, 0, 0); break; - case stat_pstd: write_pstd_header_row (1, n, stat_at, 0, 0); break; - case stat_pjc: write_pjc_header_row (1, n, stat_at, 0, 0); break; - case stat_prc: write_prc_header_row (1, n, stat_at, 0, 0); break; - case stat_eclv: write_eclv_header_row (1, n, stat_at, 0, 0); break; - case stat_mpr: write_header_row (mpr_columns, n_mpr_columns, 1, stat_at, 0, 0); break; - case stat_nbrctc: write_header_row (nbrctc_columns, n_nbrctc_columns, 1, stat_at, 0, 0); break; - case stat_nbrcts: write_header_row (nbrcts_columns, n_nbrcts_columns, 1, stat_at, 0, 0); break; - case stat_nbrcnt: write_header_row (nbrcnt_columns, n_nbrcnt_columns, 1, stat_at, 0, 0); break; - case stat_grad: write_header_row (grad_columns, n_grad_columns, 1, stat_at, 0, 0); break; - case stat_isc: write_header_row (isc_columns, n_isc_columns, 1, stat_at, 0, 0); break; - case stat_wdir: write_header_row (job_wdir_columns, n_job_wdir_columns, 1, stat_at, 0, 0); break; - case stat_ecnt: write_header_row (ecnt_columns, n_ecnt_columns, 1, stat_at, 0, 0); break; - case stat_rps: write_header_row (rps_columns, n_rps_columns, 1, stat_at, 0, 0); break; - case stat_rhist: write_rhist_header_row (1, n, stat_at, 0, 0); break; - case stat_phist: write_phist_header_row (1, n, stat_at, 0, 0); break; - case stat_relp: write_relp_header_row (1, n, stat_at, 0, 0); break; - case stat_orank: write_header_row (orank_columns, n_orank_columns, 1, stat_at, 0, 0); break; - case stat_ssvar: write_header_row (ssvar_columns, n_ssvar_columns, 1, stat_at, 0, 0); break; - case stat_genmpr: write_header_row (genmpr_columns, n_genmpr_columns, 1, stat_at, 0, 0); break; - case stat_ssidx: write_header_row (ssidx_columns, n_ssidx_columns, 1, stat_at, 0, 0); break; + case STATLineType::sl1l2: write_header_row (sl1l2_columns, n_sl1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::sal1l2: write_header_row (sal1l2_columns, n_sal1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::vl1l2: write_header_row (vl1l2_columns, n_vl1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::val1l2: write_header_row (val1l2_columns, n_val1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::fho: write_header_row (fho_columns, n_fho_columns, 1, stat_at, 0, 0); break; + case STATLineType::ctc: write_header_row (ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break; + case STATLineType::cts: write_header_row (cts_columns, n_cts_columns, 1, stat_at, 0, 0); break; + case STATLineType::mctc: write_mctc_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::mcts: write_header_row (mcts_columns, n_mcts_columns, 1, stat_at, 0, 0); break; + case STATLineType::cnt: write_header_row (cnt_columns, n_cnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::vcnt: write_header_row (vcnt_columns, n_vcnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::pct: write_pct_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::pstd: write_pstd_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::pjc: write_pjc_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::prc: write_prc_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::eclv: write_eclv_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::mpr: write_header_row (mpr_columns, n_mpr_columns, 1, stat_at, 0, 0); break; + case STATLineType::nbrctc: write_header_row (nbrctc_columns, n_nbrctc_columns, 1, stat_at, 0, 0); break; + case STATLineType::nbrcts: write_header_row (nbrcts_columns, n_nbrcts_columns, 1, stat_at, 0, 0); break; + case STATLineType::nbrcnt: write_header_row (nbrcnt_columns, n_nbrcnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::grad: write_header_row (grad_columns, n_grad_columns, 1, stat_at, 0, 0); break; + case STATLineType::isc: write_header_row (isc_columns, n_isc_columns, 1, stat_at, 0, 0); break; + case STATLineType::wdir: write_header_row (job_wdir_columns, n_job_wdir_columns, 1, stat_at, 0, 0); break; + case STATLineType::ecnt: write_header_row (ecnt_columns, n_ecnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::rps: write_header_row (rps_columns, n_rps_columns, 1, stat_at, 0, 0); break; + case STATLineType::rhist: write_rhist_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::phist: write_phist_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::relp: write_relp_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::orank: write_header_row (orank_columns, n_orank_columns, 1, stat_at, 0, 0); break; + case STATLineType::ssvar: write_header_row (ssvar_columns, n_ssvar_columns, 1, stat_at, 0, 0); break; + case STATLineType::genmpr: write_header_row (genmpr_columns, n_genmpr_columns, 1, stat_at, 0, 0); break; + case STATLineType::ssidx: write_header_row (ssidx_columns, n_ssidx_columns, 1, stat_at, 0, 0); break; // // Write only header columns for unspecified line type // - case no_stat_line_type: - write_header_row ((const char **) 0, 0, 1, stat_at, 0, 0); break; + case STATLineType::none: + write_header_row ((const char **) 0, 0, 1, stat_at, 0, 0); break; default: mlog << Error << "\nSTATAnalysisJob::setup_stat_file() -> " @@ -2176,91 +2176,91 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, if(line_type.n() == 1) { switch(string_to_statlinetype(line_type[0].c_str())) { - case(stat_fho): + case STATLineType::fho: write_header_row(fho_columns, n_fho_columns, 1, dump_at, 0, 0); break; - case(stat_ctc): + case STATLineType::ctc: write_header_row(ctc_columns, n_ctc_columns, 1, dump_at, 0, 0); break; - case(stat_cts): + case STATLineType::cts: write_header_row(cts_columns, n_cts_columns, 1, dump_at, 0, 0); break; - case(stat_cnt): + case STATLineType::cnt: write_header_row(cnt_columns, n_cnt_columns, 1, dump_at, 0, 0); break; - case(stat_sl1l2): + case STATLineType::sl1l2: write_header_row(sl1l2_columns, n_sl1l2_columns, 1, dump_at, 0, 0); break; - case(stat_sal1l2): + case STATLineType::sal1l2: write_header_row(sal1l2_columns, n_sal1l2_columns, 1, dump_at, 0, 0); break; - case(stat_vl1l2): + case STATLineType::vl1l2: write_header_row(vl1l2_columns, n_vl1l2_columns, 1, dump_at, 0, 0); break; - case(stat_val1l2): + case STATLineType::val1l2: write_header_row(val1l2_columns, n_val1l2_columns, 1, dump_at, 0, 0); break; - case(stat_mpr): + case STATLineType::mpr: write_header_row(mpr_columns, n_mpr_columns, 1, dump_at, 0, 0); break; - case(stat_nbrctc): + case STATLineType::nbrctc: write_header_row(nbrctc_columns, n_nbrctc_columns, 1, dump_at, 0, 0); break; - case(stat_nbrcts): + case STATLineType::nbrcts: write_header_row(nbrcts_columns, n_nbrcts_columns, 1, dump_at, 0, 0); break; - case(stat_nbrcnt): + case STATLineType::nbrcnt: write_header_row(nbrcnt_columns, n_nbrcnt_columns, 1, dump_at, 0, 0); break; - case(stat_grad): + case STATLineType::grad: write_header_row(grad_columns, n_grad_columns, 1, dump_at, 0, 0); break; - case(stat_ecnt): + case STATLineType::ecnt: write_header_row(ecnt_columns, n_ecnt_columns, 1, dump_at, 0, 0); break; - case(stat_isc): + case STATLineType::isc: write_header_row(isc_columns, n_isc_columns, 1, dump_at, 0, 0); break; - case(stat_ssvar): + case STATLineType::ssvar: write_header_row(ssvar_columns, n_ssvar_columns, 1, dump_at, 0, 0); break; - case(stat_seeps): + case STATLineType::seeps: write_header_row(seeps_columns, n_seeps_columns, 1, dump_at, 0, 0); break; - case(stat_seeps_mpr): + case STATLineType::seeps_mpr: write_header_row(seeps_mpr_columns, n_seeps_mpr_columns, 1, dump_at, 0, 0); break; // Just write a STAT header line for indeterminant line types - case(stat_mctc): - case(stat_mcts): - case(stat_pct): - case(stat_pstd): - case(stat_pjc): - case(stat_prc): - case(stat_eclv): - case(stat_rhist): - case(stat_phist): - case(stat_relp): - case(stat_orank): - case(stat_genmpr): + case STATLineType::mctc: + case STATLineType::mcts: + case STATLineType::pct: + case STATLineType::pstd: + case STATLineType::pjc: + case STATLineType::prc: + case STATLineType::eclv: + case STATLineType::rhist: + case STATLineType::phist: + case STATLineType::relp: + case STATLineType::orank: + case STATLineType::genmpr: write_header_row((const char **) 0, 0, 1, dump_at, 0, 0); break; @@ -2790,7 +2790,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { // Jobs which use out_bin_size if(line_type.n() > 0) { - if(string_to_statlinetype(line_type[0].c_str()) == stat_orank && + if(string_to_statlinetype(line_type[0].c_str()) == STATLineType::orank && (out_line_type.has(stat_phist_str) || out_line_type.has(stat_ecnt_str))) { @@ -2801,7 +2801,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { // Jobs which use out_eclv_points if(line_type.n() > 0) { - if(string_to_statlinetype(line_type[0].c_str()) == stat_mpr && + if(string_to_statlinetype(line_type[0].c_str()) == STATLineType::mpr && out_line_type.has(stat_eclv_str)) { // out_eclv_points @@ -2814,7 +2814,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { // Jobs which perform bootstrapping if(line_type.n() > 0) { type = string_to_statlinetype(line_type[0].c_str()); - if(type == stat_mpr && + if(type == STATLineType::mpr && (out_line_type.has(stat_cts_str) || out_line_type.has(stat_mcts_str) || out_line_type.has(stat_cnt_str) || diff --git a/src/libcode/vx_analysis_util/stat_line.cc b/src/libcode/vx_analysis_util/stat_line.cc index 9ea8949eda..c3006b5189 100644 --- a/src/libcode/vx_analysis_util/stat_line.cc +++ b/src/libcode/vx_analysis_util/stat_line.cc @@ -140,7 +140,7 @@ void STATLine::clear() DataLine::clear(); -Type = no_stat_line_type; +Type = STATLineType::none; HdrLine = (AsciiHeaderLine *) nullptr; return; @@ -265,7 +265,7 @@ if ( !status || n_items() == 0 ) { if ( strcmp(get_item(0), "VERSION") == 0 ) { - Type = stat_header; + Type = STATLineType::header; return 1; } @@ -278,7 +278,7 @@ offset = METHdrTable.col_offset(get_item(0), "STAT", na_str, "LINE_TYPE"); if( is_bad_data(offset) || n_items() < (offset + 1) ) { - Type = no_stat_line_type; + Type = STATLineType::none; return 0; } @@ -315,7 +315,7 @@ bool STATLine::is_header() const { -return ( Type == stat_header ); +return ( Type == STATLineType::header ); } diff --git a/src/libcode/vx_plot_util/vx_plot_util.h b/src/libcode/vx_plot_util/vx_plot_util.h index 5ba9a597bb..f6aee66625 100644 --- a/src/libcode/vx_plot_util/vx_plot_util.h +++ b/src/libcode/vx_plot_util/vx_plot_util.h @@ -37,7 +37,7 @@ //////////////////////////////////////////////////////////////////////////////// -typedef enum {satellite, lambert, mercator} Projection; +//enum Projection {satellite, lambert, mercator} Projection; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h index 83183eddd4..9d9177cdab 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h @@ -43,9 +43,9 @@ static const int n_txt = 12; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_ecnt, stat_rps, stat_rhist, stat_phist, - stat_orank, stat_ssvar, stat_relp, stat_pct, - stat_pstd, stat_pjc, stat_prc, stat_eclv + STATLineType::ecnt, STATLineType::rps, STATLineType::rhist, STATLineType::phist, + STATLineType::orank, STATLineType::ssvar, STATLineType::relp, STATLineType::pct, + STATLineType::pstd, STATLineType::pjc, STATLineType::prc, STATLineType::eclv }; //////////////////////////////////////////////////////////////////////// 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 c2efe1cd54..33418fbfbb 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.h +++ b/src/tools/core/grid_stat/grid_stat_conf_info.h @@ -66,34 +66,34 @@ static const int n_txt = 22; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_fho, // 0 - stat_ctc, // 1 - stat_cts, // 2 - - stat_mctc, // 3 - stat_mcts, // 4 - stat_cnt, // 5 - - stat_sl1l2, // 6 - stat_sal1l2, // 7 - stat_vl1l2, // 8 - - stat_val1l2, // 9 - stat_pct, // 10 - stat_pstd, // 11 - - stat_pjc, // 12 - stat_prc, // 13 - stat_eclv, // 14 - - stat_nbrctc, // 15 - stat_nbrcts, // 16 - stat_nbrcnt, // 17 - - stat_grad, // 18 - stat_vcnt, // 19 - stat_dmap, // 20 - stat_seeps // 21 + STATLineType::fho, // 0 + STATLineType::ctc, // 1 + STATLineType::cts, // 2 + + STATLineType::mctc, // 3 + STATLineType::mcts, // 4 + STATLineType::cnt, // 5 + + STATLineType::sl1l2, // 6 + STATLineType::sal1l2, // 7 + STATLineType::vl1l2, // 8 + + STATLineType::val1l2, // 9 + STATLineType::pct, // 10 + STATLineType::pstd, // 11 + + STATLineType::pjc, // 12 + STATLineType::prc, // 13 + STATLineType::eclv, // 14 + + STATLineType::nbrctc, // 15 + STATLineType::nbrcts, // 16 + STATLineType::nbrcnt, // 17 + + STATLineType::grad, // 18 + STATLineType::vcnt, // 19 + STATLineType::dmap, // 20 + STATLineType::seeps // 21 }; diff --git a/src/tools/core/point_stat/point_stat_conf_info.h b/src/tools/core/point_stat/point_stat_conf_info.h index 365f9c64fc..5e3db2184a 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.h +++ b/src/tools/core/point_stat/point_stat_conf_info.h @@ -59,32 +59,32 @@ static const int n_txt = 22; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_fho, // 0 - stat_ctc, // 1 - stat_cts, // 2 - stat_mctc, // 3 - stat_mcts, // 4 - - stat_cnt, // 5 - stat_sl1l2, // 6 - stat_sal1l2, // 7 - stat_vl1l2, // 8 - stat_val1l2, // 9 - - stat_pct, // 10 - stat_pstd, // 11 - stat_pjc, // 12 - stat_prc, // 13 - stat_ecnt, // 14 - - stat_orank, // 15 - stat_rps, // 16 - stat_eclv, // 17 - stat_mpr, // 18 - stat_vcnt, // 19 - - stat_seeps_mpr, // 20 - stat_seeps // 21 + STATLineType::fho, // 0 + STATLineType::ctc, // 1 + STATLineType::cts, // 2 + STATLineType::mctc, // 3 + STATLineType::mcts, // 4 + + STATLineType::cnt, // 5 + STATLineType::sl1l2, // 6 + STATLineType::sal1l2, // 7 + STATLineType::vl1l2, // 8 + STATLineType::val1l2, // 9 + + STATLineType::pct, // 10 + STATLineType::pstd, // 11 + STATLineType::pjc, // 12 + STATLineType::prc, // 13 + STATLineType::ecnt, // 14 + + STATLineType::orank, // 15 + STATLineType::rps, // 16 + STATLineType::eclv, // 17 + STATLineType::mpr, // 18 + STATLineType::vcnt, // 19 + + STATLineType::seeps_mpr, // 20 + STATLineType::seeps // 21 }; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 2aa3b73945..ebbb43e27a 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -820,38 +820,38 @@ void process_scores() { // Compute contingency table counts and statistics if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_fho].n() + - conf_info.output_stats[stat_ctc].n() + - conf_info.output_stats[stat_cts].n()) > 0) { + (conf_info.output_stats[STATLineType::fho].n() + + conf_info.output_stats[STATLineType::ctc].n() + + conf_info.output_stats[STATLineType::cts].n()) > 0) { do_cts(i_point+i, &pd_ptr[i]); } // Compute multi-category contingency table counts and statistics if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_mctc].n() + - conf_info.output_stats[stat_mcts].n()) > 0) { + (conf_info.output_stats[STATLineType::mctc].n() + + conf_info.output_stats[STATLineType::mcts].n()) > 0) { do_mcts(i_point+i, &pd_ptr[i]); } // Compute continuous statistics if(!conf_info.fcst_info[0]->is_prob() && - conf_info.output_stats[stat_cnt].n() > 0) { + conf_info.output_stats[STATLineType::cnt].n() > 0) { do_cnt(i_point+i, &pd_ptr[i]); } // Compute partial sums if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_sl1l2].n() > 0 || - conf_info.output_stats[stat_sal1l2].n() > 0)) { + (conf_info.output_stats[STATLineType::sl1l2].n() > 0 || + conf_info.output_stats[STATLineType::sal1l2].n() > 0)) { do_sl1l2(i_point+i, &pd_ptr[i]); } // Compute probabilistics counts and statistics if(conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_pct].n() + - conf_info.output_stats[stat_pstd].n() + - conf_info.output_stats[stat_pjc].n() + - conf_info.output_stats[stat_prc].n()) > 0) { + (conf_info.output_stats[STATLineType::pct].n() + + conf_info.output_stats[STATLineType::pstd].n() + + conf_info.output_stats[STATLineType::pjc].n() + + conf_info.output_stats[STATLineType::prc].n()) > 0) { do_pct(i_point+i, &pd_ptr[i]); } } // end for i @@ -948,20 +948,20 @@ void do_cts(int n, const PairDataPoint *pd_ptr) { for(i=0; i 0; - bool do_cnt = (output_stats[stat_sl1l2].n() + - output_stats[stat_sal1l2].n() + - output_stats[stat_cnt].n()) > 0; + bool do_cat = (output_stats[STATLineType::fho].n() + + output_stats[STATLineType::ctc].n() + + output_stats[STATLineType::cts].n() + + output_stats[STATLineType::mctc].n() + + output_stats[STATLineType::mcts].n() + + output_stats[STATLineType::pct].n() + + output_stats[STATLineType::pstd].n() + + output_stats[STATLineType::pjc].n() + + output_stats[STATLineType::prc].n()) > 0; + bool do_cnt = (output_stats[STATLineType::sl1l2].n() + + output_stats[STATLineType::sal1l2].n() + + output_stats[STATLineType::cnt].n()) > 0; // Conf: fcst.field and obs.field fdict = conf.lookup_array(conf_key_fcst_field); @@ -384,8 +384,8 @@ void SeriesAnalysisConfInfo::process_config(GrdFileType ftype, // Verifying with multi-category contingency tables if(!fcst_info[0]->is_prob() && - (output_stats[stat_mctc].n() > 0 || - output_stats[stat_mcts].n() > 0)) { + (output_stats[STATLineType::mctc].n() > 0 || + output_stats[STATLineType::mcts].n() > 0)) { check_mctc_thresh(fcat_ta); check_mctc_thresh(ocat_ta); } diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 69804173cf..7f3c16af10 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -783,18 +783,18 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Derive categorical statistics // - if(do_cts && line.type() == stat_fho) { + if(do_cts && line.type() == STATLineType::fho) { parse_fho_ctable(line, cts_info.cts); } - else if(do_cts && line.type() == stat_ctc) { + else if(do_cts && line.type() == STATLineType::ctc) { parse_ctc_ctable(line, cts_info.cts); } // // Derive continuous statistics // - else if(do_cnt && (line.type() == stat_sl1l2 || - line.type() == stat_sal1l2)) { + else if(do_cnt && (line.type() == STATLineType::sl1l2 || + line.type() == STATLineType::sal1l2)) { parse_sl1l2_line(line, sl1l2_info); compute_cntinfo(sl1l2_info, 0, cnt_info); } @@ -802,7 +802,7 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Derive vector continuous statistics // - else if(do_vcnt && line.type() == stat_vl1l2) { + else if(do_vcnt && line.type() == STATLineType::vl1l2) { parse_vl1l2_line(line, vl1l2_info); } @@ -819,20 +819,20 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Retrieve the column value, checking dervied stats // - if((line.type() == stat_fho || - line.type() == stat_ctc) && lty == stat_cts) { + if((line.type() == STATLineType::fho || + line.type() == STATLineType::ctc) && lty == STATLineType::cts) { v = cts_info.get_stat(req_col[i].c_str()); w = cts_info.cts.n(); } - else if(line.type() == stat_sl1l2 && lty == stat_cnt) { + else if(line.type() == STATLineType::sl1l2 && lty == STATLineType::cnt) { v = cnt_info.get_stat(req_col[i].c_str()); w = cnt_info.n; } - else if(line.type() == stat_sal1l2 && lty == stat_cnt) { + else if(line.type() == STATLineType::sal1l2 && lty == STATLineType::cnt) { v = cnt_info.get_stat(req_col[i].c_str()); w = cnt_info.n; } - else if(line.type() == stat_vl1l2 && lty == stat_vcnt) { + else if(line.type() == STATLineType::vl1l2 && lty == STATLineType::vcnt) { v = vl1l2_info.get_stat(req_col[i].c_str()); w = vl1l2_info.vcount; } @@ -923,15 +923,15 @@ void aggr_ctc_lines(LineDataFile &f, STATAnalysisJob &job, // switch(line.type()) { - case(stat_fho): + case STATLineType::fho: parse_fho_ctable(line, cur.cts); break; - case(stat_ctc): + case STATLineType::ctc: parse_ctc_ctable(line, cur.cts); break; - case(stat_nbrctc): + case STATLineType::nbrctc: parse_nbrctc_ctable(line, cur.cts); break; @@ -1126,7 +1126,7 @@ void aggr_mctc_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_mctc) { + if(line.type() != STATLineType::mctc) { mlog << Error << "\naggr_mctc_lines() -> " << "should only encounter multi-category contingency table count " << "(MCTC) line types.\n" @@ -1306,7 +1306,7 @@ void aggr_pct_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_pct) { + if(line.type() != STATLineType::pct) { mlog << Error << "\naggr_pct_lines() -> " << "should only encounter probability contingency table (PCT) " << "line types.\n" @@ -1523,23 +1523,23 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, // switch(line.type()) { - case(stat_sl1l2): + case STATLineType::sl1l2: parse_sl1l2_line(line, cur_sl1l2); break; - case(stat_sal1l2): + case STATLineType::sal1l2: parse_sal1l2_line(line, cur_sl1l2); break; - case(stat_vl1l2): + case STATLineType::vl1l2: parse_vl1l2_line(line, cur_vl1l2); break; - case(stat_val1l2): + case STATLineType::val1l2: parse_val1l2_line(line, cur_vl1l2); break; - case(stat_nbrcnt): + case STATLineType::nbrcnt: parse_nbrcnt_line(line, cur_nbrcnt); break; @@ -1584,7 +1584,7 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, // // Keep track of scores for each time step for VIF // - if(line.type() == stat_sl1l2 && job.vif_flag) { + if(line.type() == STATLineType::sl1l2 && job.vif_flag) { // // Cannot compute VIF when the times are not unique @@ -1701,7 +1701,7 @@ void aggr_grad_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_grad) { + if(line.type() != STATLineType::grad) { mlog << Error << "\naggr_grad_lines() -> " << "should only encounter gradient (GRAD) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -1809,13 +1809,13 @@ void aggr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // switch(line.type()) { - case(stat_vl1l2): + case STATLineType::vl1l2: parse_vl1l2_line(line, cur); convert_u_v_to_unit(cur.uf_bar, cur.vf_bar, uf, vf); convert_u_v_to_unit(cur.uo_bar, cur.vo_bar, uo, vo); break; - case(stat_val1l2): + case STATLineType::val1l2: parse_val1l2_line(line, cur); convert_u_v_to_unit(cur.ufa_bar, cur.vfa_bar, uf, vf); convert_u_v_to_unit(cur.uoa_bar, cur.voa_bar, uo, vo); @@ -2228,7 +2228,7 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_mpr) { + if(line.type() != STATLineType::mpr) { mlog << Error << "\naggr_mpr_lines() -> " << "should only encounter matched pair (MPR) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -2351,7 +2351,7 @@ void aggr_isc_lines(LineDataFile &ldf, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_isc) { + if(line.type() != STATLineType::isc) { mlog << Error << "\naggr_isc_lines() -> " << "should only encounter intensity-scale " << "(ISC) line types.\n" @@ -2609,7 +2609,7 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_ecnt) { + if(line.type() != STATLineType::ecnt) { mlog << Error << "\naggr_ecnt_lines() -> " << "should only encounter ensemble continuous statistics " << "(ECNT) line types.\n" @@ -2760,7 +2760,7 @@ void aggr_rps_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_rps) { + if(line.type() != STATLineType::rps) { mlog << Error << "\naggr_rps_lines() -> " << "should only encounter ranked probability score " << "(RPS) line types.\n" @@ -2852,7 +2852,7 @@ void aggr_rhist_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_rhist) { + if(line.type() != STATLineType::rhist) { mlog << Error << "\naggr_rhist_lines() -> " << "should only encounter ranked histogram " << "(RHIST) line types.\n" @@ -2942,7 +2942,7 @@ void aggr_phist_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_phist) { + if(line.type() != STATLineType::phist) { mlog << Error << "\naggr_phist_lines() -> " << "should only encounter probability integral " << "transform histogram (PHIST) line types.\n" @@ -3033,7 +3033,7 @@ void aggr_relp_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_relp) { + if(line.type() != STATLineType::relp) { mlog << Error << "\naggr_relp_lines() -> " << "should only encounter relative position (RELP) " << "line types.\n" @@ -3125,7 +3125,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_orank) { + if(line.type() != STATLineType::orank) { mlog << Error << "\naggr_orank_lines() -> " << "should only encounter observation rank " << "(ORANK) line types.\n" @@ -3314,7 +3314,7 @@ void aggr_ssvar_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_ssvar) { + if(line.type() != STATLineType::ssvar) { mlog << Error << "\naggr_ssvar_lines() -> " << "should only encounter spread-skill variance " << "(SSVAR) line types.\n" @@ -3419,7 +3419,7 @@ void aggr_seeps_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_seeps) { + if(line.type() != STATLineType::seeps) { mlog << Error << "\naggr_seeps_lines() -> " << "should only encounter SEEPS line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -3503,7 +3503,7 @@ void aggr_seeps_mpr_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_seeps_mpr) { + if(line.type() != STATLineType::seeps_mpr) { mlog << Error << "\naggr_seeps_mpr_lines() -> " << "should only encounter SEEPS_MPR line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -3778,7 +3778,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, fcst_term.line_type.set(job.line_type[i]); STATLineType lt = string_to_statlinetype(job.line_type[i].c_str()); - if(lt != stat_sl1l2 && lt != stat_ctc) { + if(lt != STATLineType::sl1l2 && lt != STATLineType::ctc) { mlog << Error << "\naggr_ss_index() -> " << "a skill score index can only be computed using " << "statistics derived from SL1L2 or CTC line types." diff --git a/src/tools/core/stat_analysis/skill_score_index_job.cc b/src/tools/core/stat_analysis/skill_score_index_job.cc index c82d71763d..9651e50a0d 100644 --- a/src/tools/core/stat_analysis/skill_score_index_job.cc +++ b/src/tools/core/stat_analysis/skill_score_index_job.cc @@ -187,12 +187,12 @@ bool SSIndexJobInfo::add(STATLine &line) { n_fcst_lines.inc(i, 1); // Aggregate SL1L2 - if(job_lt[i] == stat_sl1l2) { + if(job_lt[i] == STATLineType::sl1l2) { parse_sl1l2_line(line, sl1l2); fcst_sl1l2[i] += sl1l2; } // Aggregate CTC - else if(job_lt[i] == stat_ctc) { + else if(job_lt[i] == STATLineType::ctc) { parse_ctc_ctable(line, ctc); fcst_cts[i].cts += ctc; } @@ -204,12 +204,12 @@ bool SSIndexJobInfo::add(STATLine &line) { n_ref_lines.inc(i, 1); // Aggregate SL1L2 - if(job_lt[i] == stat_sl1l2) { + if(job_lt[i] == STATLineType::sl1l2) { parse_sl1l2_line(line, sl1l2); ref_sl1l2[i] += sl1l2; } // Aggregate CTC - else if(job_lt[i] == stat_ctc) { + else if(job_lt[i] == STATLineType::ctc) { parse_ctc_ctable(line, ctc); ref_cts[i].cts += ctc; } @@ -244,14 +244,14 @@ SSIDXData SSIndexJobInfo::compute_ss_index() { for(i=0, n_vld=0, n_diff=0, ss_sum=weight_sum=0.0; i> line) { // Continue if the line is not a valid STAT line. // - if(line.type() == no_stat_line_type) continue; + if(line.type() == STATLineType::none) continue; // // Pass header lines through to the output diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index 06959f819f..5c22c39d5a 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -226,29 +226,29 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // switch(job.job_type) { - case(STATJobType::filter): + case STATJobType::filter: do_job_filter(jobstring, f, job, n_in, n_out, sa_out); break; - case(STATJobType::summary): + case STATJobType::summary: do_job_summary(jobstring, f, job, n_in, n_out, sa_out, rng_ptr); break; - case(STATJobType::aggr): + case STATJobType::aggr: do_job_aggr(jobstring, f, job, n_in, n_out, sa_out); break; - case(STATJobType::aggr_stat): + case STATJobType::aggr_stat: do_job_aggr_stat(jobstring, f, job, n_in, n_out, sa_out, tmp_dir, rng_ptr); break; - case(STATJobType::go_index): - case(STATJobType::cbs_index): - case(STATJobType::ss_index): + case STATJobType::go_index: + case STATJobType::cbs_index: + case STATJobType::ss_index: do_job_ss_index(jobstring, f, job, n_in, n_out, sa_out); break; - case(STATJobType::ramp): + case STATJobType::ramp: do_job_ramp(jobstring, f, job, n_in, n_out, sa_out); break; @@ -444,16 +444,16 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Check that a valid line type has been selected // - if(lt != stat_fho && lt != stat_ctc && - lt != stat_mctc && lt != stat_sl1l2 && - lt != stat_sal1l2 && lt != stat_vl1l2 && - lt != stat_val1l2 && lt != stat_pct && - lt != stat_nbrctc && lt != stat_nbrcnt && - lt != stat_grad && lt != stat_ecnt && - lt != stat_rps && lt != stat_rhist && - lt != stat_phist && lt != stat_relp && - lt != stat_ssvar && lt != stat_isc && - lt != stat_seeps) { + if(lt != STATLineType::fho && lt != STATLineType::ctc && + lt != STATLineType::mctc && lt != STATLineType::sl1l2 && + lt != STATLineType::sal1l2 && lt != STATLineType::vl1l2 && + lt != STATLineType::val1l2 && lt != STATLineType::pct && + lt != STATLineType::nbrctc && lt != STATLineType::nbrcnt && + lt != STATLineType::grad && lt != STATLineType::ecnt && + lt != STATLineType::rps && lt != STATLineType::rhist && + lt != STATLineType::phist && lt != STATLineType::relp && + lt != STATLineType::ssvar && lt != STATLineType::isc && + lt != STATLineType::seeps) { mlog << Error << "\ndo_job_aggr() -> " << "the \"-line_type\" option must be set to one of:\n" << "\tFHO, CTC, MCTC,\n" @@ -472,9 +472,9 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum up the contingency table type lines: // FHO, CTC, NBRCTC // - if(lt == stat_fho || - lt == stat_ctc || - lt == stat_nbrctc) { + if(lt == STATLineType::fho || + lt == STATLineType::ctc || + lt == STATLineType::nbrctc) { aggr_ctc_lines(f, job, ctc_map, n_in, n_out); write_job_aggr_ctc(job, lt, ctc_map, out_at); } @@ -483,7 +483,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum up the multi-category contingency table type lines: // MCTC // - else if(lt == stat_mctc) { + else if(lt == STATLineType::mctc) { aggr_mctc_lines(f, job, mctc_map, n_in, n_out); write_job_aggr_mctc(job, lt, mctc_map, out_at); } @@ -492,7 +492,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum up the Nx2 contingency table lines: // PCT // - else if(lt == stat_pct) { + else if(lt == STATLineType::pct) { aggr_pct_lines(f, job, pct_map, n_in, n_out); write_job_aggr_pct(job, lt, pct_map, out_at); } @@ -501,11 +501,11 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum the partial sum line types: // SL1L2, SAL1L2, VL1L2, VAL1L2, NBRCNT // - else if(lt == stat_sl1l2 || - lt == stat_sal1l2 || - lt == stat_vl1l2 || - lt == stat_val1l2 || - lt == stat_nbrcnt) { + else if(lt == STATLineType::sl1l2 || + lt == STATLineType::sal1l2 || + lt == STATLineType::vl1l2 || + lt == STATLineType::val1l2 || + lt == STATLineType::nbrcnt) { aggr_psum_lines(f, job, psum_map, n_in, n_out); write_job_aggr_psum(job, lt, psum_map, out_at); } @@ -514,7 +514,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum the gradient line type: // GRAD // - else if(lt == stat_grad) { + else if(lt == STATLineType::grad) { aggr_grad_lines(f, job, grad_map, n_in, n_out); write_job_aggr_grad(job, lt, grad_map, out_at); } @@ -522,7 +522,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the ISC line types // - else if(lt == stat_isc) { + else if(lt == STATLineType::isc) { aggr_isc_lines(f, job, isc_map, n_in, n_out); write_job_aggr_isc(job, lt, isc_map, out_at); } @@ -530,7 +530,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the ECNT line types // - else if(lt == stat_ecnt) { + else if(lt == STATLineType::ecnt) { aggr_ecnt_lines(f, job, ens_map, n_in, n_out); write_job_aggr_ecnt(job, lt, ens_map, out_at); } @@ -538,7 +538,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the RPS line types // - else if(lt == stat_rps) { + else if(lt == STATLineType::rps) { aggr_rps_lines(f, job, rps_map, n_in, n_out); write_job_aggr_rps(job, lt, rps_map, out_at); } @@ -546,7 +546,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the RHIST line types // - else if(lt == stat_rhist) { + else if(lt == STATLineType::rhist) { aggr_rhist_lines(f, job, ens_map, n_in, n_out); write_job_aggr_rhist(job, lt, ens_map, out_at); } @@ -554,7 +554,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the PHIST line types // - else if(lt == stat_phist) { + else if(lt == STATLineType::phist) { aggr_phist_lines(f, job, ens_map, n_in, n_out); write_job_aggr_phist(job, lt, ens_map, out_at); } @@ -562,7 +562,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the RELP line types // - else if(lt == stat_relp) { + else if(lt == STATLineType::relp) { aggr_relp_lines(f, job, ens_map, n_in, n_out); write_job_aggr_relp(job, lt, ens_map, out_at); } @@ -570,7 +570,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the SSVAR line types // - else if(lt == stat_ssvar) { + else if(lt == STATLineType::ssvar) { aggr_ssvar_lines(f, job, ssvar_map, n_in, n_out); write_job_aggr_ssvar(job, lt, ssvar_map, out_at); } @@ -578,7 +578,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the SEEPS line types // - else if(lt == stat_seeps) { + else if(lt == STATLineType::seeps) { aggr_seeps_lines(f, job, seeps_map, n_in, n_out); write_job_aggr_seeps(job, lt, seeps_map, out_at); } @@ -679,12 +679,12 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // FHO, CTC -> CTS, ECLV // NBRCTC -> NBRCTS // - if(((in_lt == stat_fho || - in_lt == stat_ctc) && - (has_line_type(out_lt, stat_cts) || - has_line_type(out_lt, stat_eclv))) || - (in_lt == stat_nbrctc && - has_line_type(out_lt, stat_nbrcts))) { + if(((in_lt == STATLineType::fho || + in_lt == STATLineType::ctc) && + (has_line_type(out_lt, STATLineType::cts) || + has_line_type(out_lt, STATLineType::eclv))) || + (in_lt == STATLineType::nbrctc && + has_line_type(out_lt, STATLineType::nbrcts))) { aggr_ctc_lines(f, job, ctc_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_ctc(job, *it, ctc_map, out_at); @@ -696,8 +696,8 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum up the multi-category contingency table type lines: // MCTC -> MCTS // - else if(in_lt == stat_mctc && - has_line_type(out_lt, stat_mcts)) { + else if(in_lt == STATLineType::mctc && + has_line_type(out_lt, STATLineType::mcts)) { aggr_mctc_lines(f, job, mctc_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_mctc(job, *it, mctc_map, out_at); @@ -709,11 +709,11 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum up the Nx2 contingency table lines: // PCT -> PSTD, PJC, PRC, ECLV // - else if(in_lt == stat_pct && - (has_line_type(out_lt, stat_pstd) || - has_line_type(out_lt, stat_pjc) || - has_line_type(out_lt, stat_prc) || - has_line_type(out_lt, stat_eclv))) { + else if(in_lt == STATLineType::pct && + (has_line_type(out_lt, STATLineType::pstd) || + has_line_type(out_lt, STATLineType::pjc) || + has_line_type(out_lt, STATLineType::prc) || + has_line_type(out_lt, STATLineType::eclv))) { aggr_pct_lines(f, job, pct_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_pct(job, *it, pct_map, out_at); @@ -726,9 +726,9 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // SL1L2, SAL1L2 -> CNT // NBRCTC -> NBRCNT // - else if((in_lt == stat_sl1l2 || - in_lt == stat_sal1l2) && - has_line_type(out_lt, stat_cnt)) { + else if((in_lt == STATLineType::sl1l2 || + in_lt == STATLineType::sal1l2) && + has_line_type(out_lt, STATLineType::cnt)) { aggr_psum_lines(f, job, psum_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_psum(job, *it, psum_map, out_at); @@ -740,9 +740,9 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the vector partial sum line types: // VL1L2, VAL1L2 -> VCNT // - else if((in_lt == stat_vl1l2 || - in_lt == stat_val1l2) && - has_line_type(out_lt, stat_vcnt)) { + else if((in_lt == STATLineType::vl1l2 || + in_lt == STATLineType::val1l2) && + has_line_type(out_lt, STATLineType::vcnt)) { aggr_psum_lines(f, job, psum_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_psum(job, *it, psum_map, out_at); @@ -754,9 +754,9 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the vector partial sum line types: // VL1L2, VAL1L2 -> WDIR // - else if((in_lt == stat_vl1l2 || - in_lt == stat_val1l2) && - has_line_type(out_lt, stat_wdir)) { + else if((in_lt == STATLineType::vl1l2 || + in_lt == STATLineType::val1l2) && + has_line_type(out_lt, STATLineType::wdir)) { aggr_wind_lines(f, job, wind_map, n_in, n_out); write_job_aggr_wind(job, in_lt, wind_map, out_at); if(!job.stat_out) write_table(out_at, sa_out); @@ -766,10 +766,10 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the UGRD and VGRD matched pair lines: // MPR -> WDIR // - else if(in_lt == stat_mpr && - (has_line_type(out_lt, stat_wdir) || - has_line_type(out_lt, stat_vl1l2) || - has_line_type(out_lt, stat_vcnt))) { + else if(in_lt == STATLineType::mpr && + (has_line_type(out_lt, STATLineType::wdir) || + has_line_type(out_lt, STATLineType::vl1l2) || + has_line_type(out_lt, STATLineType::vcnt))) { mlog << Debug(4) << "do_job_aggr_stat() -> " << "For MPR wind aggregation, searching for UGRD and VGRD MPR lines.\n"; @@ -780,7 +780,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, aggr_mpr_wind_lines(f, job, wind_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { - if(*it == stat_wdir) { + if(*it == STATLineType::wdir) { write_job_aggr_wind(job, in_lt, wind_map, out_at); if(!job.stat_out) write_table(out_at, sa_out); } @@ -795,18 +795,18 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the observation rank line types: // ORANK -> ECNT, RPS, RHIST, PHIST, RELP, SSVAR // - else if(in_lt == stat_orank && - (has_line_type(out_lt, stat_ecnt) || - has_line_type(out_lt, stat_rps) || - has_line_type(out_lt, stat_rhist) || - has_line_type(out_lt, stat_phist) || - has_line_type(out_lt, stat_relp) || - has_line_type(out_lt, stat_ssvar))) { + else if(in_lt == STATLineType::orank && + (has_line_type(out_lt, STATLineType::ecnt) || + has_line_type(out_lt, STATLineType::rps) || + has_line_type(out_lt, STATLineType::rhist) || + has_line_type(out_lt, STATLineType::phist) || + has_line_type(out_lt, STATLineType::relp) || + has_line_type(out_lt, STATLineType::ssvar))) { // // Check forecast thresholds for RPS // - if(has_line_type(out_lt, stat_rps)) { + if(has_line_type(out_lt, STATLineType::rps)) { if(job.out_fcst_thresh.n() == 0) { mlog << Error << "\ndo_job_aggr_stat() -> " @@ -828,8 +828,8 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the SEEPS_MPR lines: // SEEPS_MPR -> SEEPS // - else if(in_lt == stat_seeps_mpr && - has_line_type(out_lt, stat_seeps)) { + else if(in_lt == STATLineType::seeps_mpr && + has_line_type(out_lt, STATLineType::seeps)) { aggr_seeps_mpr_lines(f, job, seeps_mpr_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { @@ -844,27 +844,27 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // MPR -> FHO, CTC, CTS, MCTC, MCTS, CNT, // SL1L2, SAL1L2, PCT, PSTD, PJC, PRC, ECLV // - else if(in_lt == stat_mpr && - (has_line_type(out_lt, stat_fho) || - has_line_type(out_lt, stat_ctc) || - has_line_type(out_lt, stat_cts) || - has_line_type(out_lt, stat_mctc) || - has_line_type(out_lt, stat_mcts) || - has_line_type(out_lt, stat_cnt) || - has_line_type(out_lt, stat_sl1l2) || - has_line_type(out_lt, stat_sal1l2) || - has_line_type(out_lt, stat_pct) || - has_line_type(out_lt, stat_pstd) || - has_line_type(out_lt, stat_pjc) || - has_line_type(out_lt, stat_prc) || - has_line_type(out_lt, stat_eclv))) { + else if(in_lt == STATLineType::mpr && + (has_line_type(out_lt, STATLineType::fho) || + has_line_type(out_lt, STATLineType::ctc) || + has_line_type(out_lt, STATLineType::cts) || + has_line_type(out_lt, STATLineType::mctc) || + has_line_type(out_lt, STATLineType::mcts) || + has_line_type(out_lt, STATLineType::cnt) || + has_line_type(out_lt, STATLineType::sl1l2) || + has_line_type(out_lt, STATLineType::sal1l2) || + has_line_type(out_lt, STATLineType::pct) || + has_line_type(out_lt, STATLineType::pstd) || + has_line_type(out_lt, STATLineType::pjc) || + has_line_type(out_lt, STATLineType::prc) || + has_line_type(out_lt, STATLineType::eclv))) { // // Check output thresholds for continuous line types // - if(has_line_type(out_lt, stat_cnt) || - has_line_type(out_lt, stat_sl1l2) || - has_line_type(out_lt, stat_sal1l2)) { + if(has_line_type(out_lt, STATLineType::cnt) || + has_line_type(out_lt, STATLineType::sl1l2) || + has_line_type(out_lt, STATLineType::sal1l2)) { if(job.out_fcst_thresh.n() != job.out_obs_thresh.n()) { mlog << Error << "\ndo_job_aggr_stat() -> " @@ -885,10 +885,10 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // // Check output threshold values for 2x2 contingency table // - if(has_line_type(out_lt, stat_fho) || - has_line_type(out_lt, stat_ctc) || - has_line_type(out_lt, stat_cts) || - has_line_type(out_lt, stat_eclv)) { + if(has_line_type(out_lt, STATLineType::fho) || + has_line_type(out_lt, STATLineType::ctc) || + has_line_type(out_lt, STATLineType::cts) || + has_line_type(out_lt, STATLineType::eclv)) { if(job.out_fcst_thresh.n() == 0 || job.out_obs_thresh.n() == 0 || @@ -906,8 +906,8 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // // Check output threshold values for NxN contingency table // - if(has_line_type(out_lt, stat_mctc) || - has_line_type(out_lt, stat_mcts)) { + if(has_line_type(out_lt, STATLineType::mctc) || + has_line_type(out_lt, STATLineType::mcts)) { if(job.out_fcst_thresh.n() <= 1 || job.out_fcst_thresh.n() != job.out_obs_thresh.n()) { @@ -943,10 +943,10 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // // Check for output threshold values // - if(has_line_type(out_lt, stat_pct) || - has_line_type(out_lt, stat_pstd) || - has_line_type(out_lt, stat_pjc) || - has_line_type(out_lt, stat_prc)) { + if(has_line_type(out_lt, STATLineType::pct) || + has_line_type(out_lt, STATLineType::pstd) || + has_line_type(out_lt, STATLineType::pjc) || + has_line_type(out_lt, STATLineType::prc)) { if(job.out_obs_thresh.n() != 1) { mlog << Error << "\ndo_job_aggr_stat() -> " @@ -1255,24 +1255,24 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_fho) n_col += n_fho_columns; - else if(lt == stat_ctc) n_col += n_ctc_columns; - else if(lt == stat_cts) n_col += n_cts_columns; - else if(lt == stat_eclv) n_col += get_n_eclv_columns(n_pnt); - else if(lt == stat_nbrctc) n_col += n_nbrctc_columns; - else if(lt == stat_nbrcts) n_col += n_nbrcts_columns; + if(lt == STATLineType::fho) n_col += n_fho_columns; + else if(lt == STATLineType::ctc) n_col += n_ctc_columns; + else if(lt == STATLineType::cts) n_col += n_cts_columns; + else if(lt == STATLineType::eclv) n_col += get_n_eclv_columns(n_pnt); + else if(lt == STATLineType::nbrctc) n_col += n_nbrctc_columns; + else if(lt == STATLineType::nbrcts) n_col += n_nbrcts_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the output header row // c = 1 + job.by_column.n(); - if(lt == stat_fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); - else if(lt == stat_ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); - else if(lt == stat_cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); - else if(lt == stat_eclv) write_eclv_header_row( 0, n_pnt, at, 0, c); - else if(lt == stat_nbrctc) write_header_row(nbrctc_columns, n_nbrctc_columns, 0, at, 0, c); - else if(lt == stat_nbrcts) write_header_row(nbrcts_columns, n_nbrcts_columns, 0, at, 0, c); + if(lt == STATLineType::fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); + else if(lt == STATLineType::ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); + else if(lt == STATLineType::cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); + else if(lt == STATLineType::eclv) write_eclv_header_row( 0, n_pnt, at, 0, c); + else if(lt == STATLineType::nbrctc) write_header_row(nbrctc_columns, n_nbrctc_columns, 0, at, 0, c); + else if(lt == STATLineType::nbrcts) write_header_row(nbrcts_columns, n_nbrcts_columns, 0, at, 0, c); // // Setup the output STAT file @@ -1293,7 +1293,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_cts || lt == stat_nbrcts) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::cts || lt == STATLineType::nbrcts) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -1305,7 +1305,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // FHO output line // - if(lt == stat_fho) { + if(lt == STATLineType::fho) { if(job.stat_out) { write_fho_cols(it->second.cts_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1319,7 +1319,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // CTC output line // - else if(lt == stat_ctc) { + else if(lt == STATLineType::ctc) { if(job.stat_out) { write_ctc_cols(it->second.cts_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1333,7 +1333,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // CTS output line // - else if(lt == stat_cts) { + else if(lt == STATLineType::cts) { // // Store the alpha information in the CTSInfo object @@ -1364,7 +1364,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // ECLV output line // - else if(lt == stat_eclv) { + else if(lt == STATLineType::eclv) { if(job.stat_out) { write_eclv_cols(it->second.cts_info.cts, job.out_eclv_points, job.stat_at, @@ -1379,7 +1379,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // NBRCTC output line // - else if(lt == stat_nbrctc) { + else if(lt == STATLineType::nbrctc) { nbrcts_info.clear(); nbrcts_info.cts_info = it->second.cts_info; @@ -1397,7 +1397,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // NBRCTS output line // - else if(lt == stat_nbrcts) { + else if(lt == STATLineType::nbrcts) { nbrcts_info.clear(); nbrcts_info.cts_info = it->second.cts_info; @@ -1463,16 +1463,16 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_mctc) n_col += get_n_mctc_columns(n); - else if(lt == stat_mcts) n_col += n_mcts_columns; + if(lt == STATLineType::mctc) n_col += get_n_mctc_columns(n); + else if(lt == STATLineType::mcts) n_col += n_mcts_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_mctc) write_mctc_header_row(0, n, at, 0, c); - else if(lt == stat_mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); + if(lt == STATLineType::mctc) write_mctc_header_row(0, n, at, 0, c); + else if(lt == STATLineType::mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); // // Setup the output STAT file @@ -1493,7 +1493,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_mcts) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::mcts) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -1505,7 +1505,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, // // MCTC output line // - if(lt == stat_mctc) { + if(lt == STATLineType::mctc) { if(job.stat_out) { write_mctc_cols(it->second.mcts_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1519,7 +1519,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, // // MCTS output line // - else if(lt == stat_mcts) { + else if(lt == STATLineType::mcts) { // // Store the alpha information in the CTSInfo object @@ -1582,31 +1582,31 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // Setup the output table // - if(lt == stat_eclv) n_row = 1 + m.size() * n; - else n_row = 1 + m.size(); + if(lt == STATLineType::eclv) n_row = 1 + m.size() * n; + else n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_pct) n_col += get_n_pct_columns(n); - else if(lt == stat_pstd) n_col += get_n_pstd_columns(n); - else if(lt == stat_pjc) n_col += get_n_pjc_columns(n); - else if(lt == stat_prc) n_col += get_n_prc_columns(n); - else if(lt == stat_eclv) n_col += get_n_eclv_columns(n_pnt); + if(lt == STATLineType::pct) n_col += get_n_pct_columns(n); + else if(lt == STATLineType::pstd) n_col += get_n_pstd_columns(n); + else if(lt == STATLineType::pjc) n_col += get_n_pjc_columns(n); + else if(lt == STATLineType::prc) n_col += get_n_prc_columns(n); + else if(lt == STATLineType::eclv) n_col += get_n_eclv_columns(n_pnt); write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_pct) write_pct_header_row (0, n, at, 0, c); - else if(lt == stat_pstd) write_pstd_header_row(0, n, at, 0, c); - else if(lt == stat_pjc) write_pjc_header_row (0, n, at, 0, c); - else if(lt == stat_prc) write_prc_header_row (0, n, at, 0, c); - else if(lt == stat_eclv) write_eclv_header_row(0, n_pnt, at, 0, c); + if(lt == STATLineType::pct) write_pct_header_row (0, n, at, 0, c); + else if(lt == STATLineType::pstd) write_pstd_header_row(0, n, at, 0, c); + else if(lt == STATLineType::pjc) write_pjc_header_row (0, n, at, 0, c); + else if(lt == STATLineType::prc) write_prc_header_row (0, n, at, 0, c); + else if(lt == STATLineType::eclv) write_eclv_header_row(0, n_pnt, at, 0, c); // // Setup the output STAT file // - if(lt == stat_eclv) job.setup_stat_file(n_row, n_pnt); - else job.setup_stat_file(n_row, n); + if(lt == STATLineType::eclv) job.setup_stat_file(n_row, n_pnt); + else job.setup_stat_file(n_row, n); mlog << Debug(2) << "Computing output for " << (int) m.size() << " case(s).\n"; @@ -1622,7 +1622,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_pstd) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::pstd) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -1634,7 +1634,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PCT output line // - if(lt == stat_pct) { + if(lt == STATLineType::pct) { if(job.stat_out) { write_pct_cols(it->second.pct_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1648,7 +1648,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PSTD output line // - else if(lt == stat_pstd) { + else if(lt == STATLineType::pstd) { // // Store the alpha information in the PCTInfo object @@ -1679,7 +1679,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PJC output line // - else if(lt == stat_pjc) { + else if(lt == STATLineType::pjc) { if(job.stat_out) { write_pjc_cols(it->second.pct_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1693,7 +1693,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PRC output line // - else if(lt == stat_prc) { + else if(lt == STATLineType::prc) { if(job.stat_out) { write_prc_cols(it->second.pct_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1707,7 +1707,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // ECLV output lines // - else if(lt == stat_eclv) { + else if(lt == STATLineType::eclv) { ThreshArray prob_ta = string_to_prob_thresh(shc.get_fcst_thresh_str().c_str()); for(i=0; isecond.pct_info.pct.nrows(); i++) { if(job.stat_out) { @@ -1753,26 +1753,26 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_sl1l2) n_col += n_sl1l2_columns; - else if(lt == stat_sal1l2) n_col += n_sal1l2_columns; - else if(lt == stat_vl1l2) n_col += n_vl1l2_columns; - else if(lt == stat_val1l2) n_col += n_val1l2_columns; - else if(lt == stat_cnt) n_col += n_cnt_columns; - else if(lt == stat_vcnt) n_col += n_vcnt_columns; - else if(lt == stat_nbrcnt) n_col += n_nbrcnt_columns; + if(lt == STATLineType::sl1l2) n_col += n_sl1l2_columns; + else if(lt == STATLineType::sal1l2) n_col += n_sal1l2_columns; + else if(lt == STATLineType::vl1l2) n_col += n_vl1l2_columns; + else if(lt == STATLineType::val1l2) n_col += n_val1l2_columns; + else if(lt == STATLineType::cnt) n_col += n_cnt_columns; + else if(lt == STATLineType::vcnt) n_col += n_vcnt_columns; + else if(lt == STATLineType::nbrcnt) n_col += n_nbrcnt_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); - else if(lt == stat_sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); - else if(lt == stat_vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); - else if(lt == stat_val1l2) write_header_row(val1l2_columns, n_val1l2_columns, 0, at, 0, c); - else if(lt == stat_cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); - else if(lt == stat_vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); - else if(lt == stat_nbrcnt) write_header_row(nbrcnt_columns, n_nbrcnt_columns, 0, at, 0, c); + if(lt == STATLineType::sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::val1l2) write_header_row(val1l2_columns, n_val1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); + else if(lt == STATLineType::vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); + else if(lt == STATLineType::nbrcnt) write_header_row(nbrcnt_columns, n_nbrcnt_columns, 0, at, 0, c); // // Setup the output STAT file @@ -1793,7 +1793,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_cnt || lt == stat_vcnt || lt == stat_nbrcnt) { + if(lt == STATLineType::cnt || lt == STATLineType::vcnt || lt == STATLineType::nbrcnt) { shc.set_alpha(job.out_alpha); } write_header_cols(shc, job.stat_at, job.stat_row); @@ -1807,7 +1807,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // SL1L2 output line // - if(lt == stat_sl1l2) { + if(lt == STATLineType::sl1l2) { if(job.stat_out) { write_sl1l2_cols(it->second.sl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1821,7 +1821,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // SAL1L2 output line // - else if(lt == stat_sal1l2) { + else if(lt == STATLineType::sal1l2) { if(job.stat_out) { write_sal1l2_cols(it->second.sl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1835,7 +1835,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // VL1L2 output line // - else if(lt == stat_vl1l2) { + else if(lt == STATLineType::vl1l2) { if(job.stat_out) { write_vl1l2_cols(it->second.vl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1849,7 +1849,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // VAL1L2 output line // - else if(lt == stat_val1l2) { + else if(lt == STATLineType::val1l2) { if(job.stat_out) { write_val1l2_cols(it->second.vl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1863,7 +1863,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // CNT output line // - else if(lt == stat_cnt) { + else if(lt == STATLineType::cnt) { it->second.cnt_info.clear(); @@ -1894,7 +1894,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // VCNT output line // - else if(lt == stat_vcnt) { + else if(lt == STATLineType::vcnt) { if(job.stat_out) { write_vcnt_cols(it->second.vl1l2_info, 0, job.stat_at, job.stat_row++, n_header_columns); @@ -1908,7 +1908,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // NBRCNT output line // - else if(lt == stat_nbrcnt) { + else if(lt == STATLineType::nbrcnt) { // // Allocate space for confidence intervals @@ -2126,14 +2126,14 @@ void write_job_aggr_wind(STATAnalysisJob &job, STATLineType lt, // r++; - if(lt == stat_vl1l2 || lt == stat_mpr) { + if(lt == STATLineType::vl1l2 || lt == STATLineType::mpr) { uf = it->second.vl1l2_info.uf_bar; vf = it->second.vl1l2_info.vf_bar; uo = it->second.vl1l2_info.uo_bar; vo = it->second.vl1l2_info.vo_bar; count = it->second.vl1l2_info.vcount; } - else if(lt == stat_val1l2) { + else if(lt == STATLineType::val1l2) { uf = it->second.vl1l2_info.ufa_bar; vf = it->second.vl1l2_info.vfa_bar; uo = it->second.vl1l2_info.uoa_bar; @@ -2859,10 +2859,10 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // - Ensemble members for RELP // for(it = m.begin(), n = 0; it != m.end(); it++) { - if(lt == stat_rhist) n = max(it->second.ens_pd.rhist_na.n(), n); - else if(lt == stat_phist) n = max(it->second.ens_pd.phist_na.n(), n); - else if(lt == stat_relp) n = max(it->second.ens_pd.n_ens, n); - else if(lt == stat_ssvar) { + if(lt == STATLineType::rhist) n = max(it->second.ens_pd.rhist_na.n(), n); + else if(lt == STATLineType::phist) n = max(it->second.ens_pd.phist_na.n(), n); + else if(lt == STATLineType::relp) n = max(it->second.ens_pd.n_ens, n); + else if(lt == STATLineType::ssvar) { it->second.ens_pd.compute_ssvar(); if(it->second.ens_pd.ssvar_bins) n += it->second.ens_pd.ssvar_bins[0].n_bin; } @@ -2873,27 +2873,27 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // n_row = 0; n_col = 1 + job.by_column.n(); - if(lt == stat_ecnt) { + if(lt == STATLineType::ecnt) { n_row = 1 + m.size(); n_col += n_ecnt_columns; } - if(lt == stat_rps) { + if(lt == STATLineType::rps) { n_row = 1 + m.size(); n_col += n_rps_columns; } - else if(lt == stat_rhist) { + else if(lt == STATLineType::rhist) { n_row = 1 + m.size(); n_col += get_n_rhist_columns(n); } - else if(lt == stat_phist) { + else if(lt == STATLineType::phist) { n_row = 1 + m.size(); n_col += get_n_phist_columns(n); } - else if(lt == stat_relp) { + else if(lt == STATLineType::relp) { n_row = 1 + m.size(); n_col += get_n_relp_columns(n); } - else if(lt == stat_ssvar) { + else if(lt == STATLineType::ssvar) { n_row = 1 + n; n_col += n_ssvar_columns; } @@ -2903,22 +2903,22 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_ecnt) write_header_row(ecnt_columns, n_ecnt_columns, 0, at, 0, c); - else if(lt == stat_rps) write_header_row(rps_columns, n_rps_columns, 0, at, 0, c); - else if(lt == stat_rhist) write_rhist_header_row(0, n, at, 0, c); - else if(lt == stat_phist) write_phist_header_row(0, n, at, 0, c); - else if(lt == stat_relp) write_relp_header_row (0, n, at, 0, c); - else if(lt == stat_ssvar) write_header_row(ssvar_columns, n_ssvar_columns, 0, at, 0, c); + if(lt == STATLineType::ecnt) write_header_row(ecnt_columns, n_ecnt_columns, 0, at, 0, c); + else if(lt == STATLineType::rps) write_header_row(rps_columns, n_rps_columns, 0, at, 0, c); + else if(lt == STATLineType::rhist) write_rhist_header_row(0, n, at, 0, c); + else if(lt == STATLineType::phist) write_phist_header_row(0, n, at, 0, c); + else if(lt == STATLineType::relp) write_relp_header_row (0, n, at, 0, c); + else if(lt == STATLineType::ssvar) write_header_row(ssvar_columns, n_ssvar_columns, 0, at, 0, c); // // Setup the output STAT file // - if(lt == stat_ecnt) job.setup_stat_file(n_row, 0); - else if(lt == stat_rps) job.setup_stat_file(n_row, 0); - else if(lt == stat_rhist) job.setup_stat_file(n_row, n); - else if(lt == stat_phist) job.setup_stat_file(n_row, n); - else if(lt == stat_relp) job.setup_stat_file(n_row, n); - else if(lt == stat_ssvar) job.setup_stat_file(n_row, 0); + if(lt == STATLineType::ecnt) job.setup_stat_file(n_row, 0); + else if(lt == STATLineType::rps) job.setup_stat_file(n_row, 0); + else if(lt == STATLineType::rhist) job.setup_stat_file(n_row, n); + else if(lt == STATLineType::phist) job.setup_stat_file(n_row, n); + else if(lt == STATLineType::relp) job.setup_stat_file(n_row, n); + else if(lt == STATLineType::ssvar) job.setup_stat_file(n_row, 0); mlog << Debug(2) << "Computing output for " << (int) m.size() << " case(s).\n"; @@ -2937,7 +2937,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // Set SSVAR alpha value // - if(lt == stat_ssvar) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::ssvar) shc.set_alpha(job.out_alpha); // // Initialize @@ -2947,7 +2947,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // ECNT output line // - if(lt == stat_ecnt) { + if(lt == STATLineType::ecnt) { ECNTInfo ecnt_info; ecnt_info.set(it->second.ens_pd); @@ -2965,7 +2965,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // RPS output line // - else if(lt == stat_rps) { + else if(lt == STATLineType::rps) { RPSInfo rps_info; rps_info.fthresh = job.out_fcst_thresh; rps_info.set(it->second.ens_pd); @@ -2985,7 +2985,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // RHIST output line // - else if(lt == stat_rhist) { + else if(lt == STATLineType::rhist) { it->second.ens_pd.compute_rhist(); if(job.stat_out) { @@ -3002,7 +3002,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // PHIST output line // - else if(lt == stat_phist) { + else if(lt == STATLineType::phist) { if(job.stat_out) { write_header_cols(shc, job.stat_at, job.stat_row); write_phist_cols(&(it->second.ens_pd), job.stat_at, @@ -3017,7 +3017,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // RELP output line // - else if(lt == stat_relp) { + else if(lt == STATLineType::relp) { it->second.ens_pd.compute_relp(); if(job.stat_out) { @@ -3034,7 +3034,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // SSVAR output lines // - else if(lt == stat_ssvar) { + else if(lt == STATLineType::ssvar) { if(!it->second.ens_pd.ssvar_bins) continue; @@ -3160,10 +3160,10 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // Number of rows n_row = 1; - if(lt == stat_fho || lt == stat_ctc || - lt == stat_cts || lt == stat_eclv || - lt == stat_cnt || lt == stat_sl1l2 || - lt == stat_sal1l2) { + if(lt == STATLineType::fho || lt == STATLineType::ctc || + lt == STATLineType::cts || lt == STATLineType::eclv || + lt == STATLineType::cnt || lt == STATLineType::sl1l2 || + lt == STATLineType::sal1l2) { n_row += job.out_fcst_thresh.n() * m.size(); } else { @@ -3172,44 +3172,44 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // Number of columns n_col = 1 + job.by_column.n(); - if(lt == stat_fho) { n_col += n_fho_columns; } - else if(lt == stat_ctc) { n_col += n_ctc_columns; } - else if(lt == stat_cts) { n_col += n_cts_columns; } - else if(lt == stat_eclv) { n = job.out_eclv_points.n(); - n_col += get_n_eclv_columns(n); } - else if(lt == stat_mctc) { n = job.out_fcst_thresh.n()+1; - n_col += get_n_mctc_columns(n); } - else if(lt == stat_mcts) { n_col += n_mcts_columns; } - else if(lt == stat_cnt) { n_col += n_cnt_columns; } - else if(lt == stat_sl1l2) { n_col += n_sl1l2_columns; } - else if(lt == stat_sal1l2) { n_col += n_sal1l2_columns; } - else if(lt == stat_pct) { n = job.out_fcst_thresh.n(); - n_col += get_n_pct_columns(n); } - else if(lt == stat_pstd) { n = job.out_fcst_thresh.n(); - n_col += get_n_pstd_columns(n); } - else if(lt == stat_pjc) { n = job.out_fcst_thresh.n(); - n_col += get_n_pjc_columns(n); } - else if(lt == stat_prc) { n = job.out_fcst_thresh.n(); - n_col += get_n_prc_columns(n); } + if(lt == STATLineType::fho) { n_col += n_fho_columns; } + else if(lt == STATLineType::ctc) { n_col += n_ctc_columns; } + else if(lt == STATLineType::cts) { n_col += n_cts_columns; } + else if(lt == STATLineType::eclv) { n = job.out_eclv_points.n(); + n_col += get_n_eclv_columns(n); } + else if(lt == STATLineType::mctc) { n = job.out_fcst_thresh.n()+1; + n_col += get_n_mctc_columns(n); } + else if(lt == STATLineType::mcts) { n_col += n_mcts_columns; } + else if(lt == STATLineType::cnt) { n_col += n_cnt_columns; } + else if(lt == STATLineType::sl1l2) { n_col += n_sl1l2_columns; } + else if(lt == STATLineType::sal1l2) { n_col += n_sal1l2_columns; } + else if(lt == STATLineType::pct) { n = job.out_fcst_thresh.n(); + n_col += get_n_pct_columns(n); } + else if(lt == STATLineType::pstd) { n = job.out_fcst_thresh.n(); + n_col += get_n_pstd_columns(n); } + else if(lt == STATLineType::pjc) { n = job.out_fcst_thresh.n(); + n_col += get_n_pjc_columns(n); } + else if(lt == STATLineType::prc) { n = job.out_fcst_thresh.n(); + n_col += get_n_prc_columns(n); } write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); - else if(lt == stat_ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); - else if(lt == stat_cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); - else if(lt == stat_eclv) write_eclv_header_row(0, n, at, 0, c); - else if(lt == stat_mctc) write_mctc_header_row(0, n, at, 0, c); - else if(lt == stat_mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); - else if(lt == stat_cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); - else if(lt == stat_sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); - else if(lt == stat_sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); - else if(lt == stat_pct) write_pct_header_row (0, n, at, 0, c); - else if(lt == stat_pstd) write_pstd_header_row(0, n, at, 0, c); - else if(lt == stat_pjc) write_pjc_header_row (0, n, at, 0, c); - else if(lt == stat_prc) write_prc_header_row (0, n, at, 0, c); + if(lt == STATLineType::fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); + else if(lt == STATLineType::ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); + else if(lt == STATLineType::cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); + else if(lt == STATLineType::eclv) write_eclv_header_row(0, n, at, 0, c); + else if(lt == STATLineType::mctc) write_mctc_header_row(0, n, at, 0, c); + else if(lt == STATLineType::mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); + else if(lt == STATLineType::cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); + else if(lt == STATLineType::sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::pct) write_pct_header_row (0, n, at, 0, c); + else if(lt == STATLineType::pstd) write_pstd_header_row(0, n, at, 0, c); + else if(lt == STATLineType::pjc) write_pjc_header_row (0, n, at, 0, c); + else if(lt == STATLineType::prc) write_prc_header_row (0, n, at, 0, c); // // Setup the output STAT file @@ -3238,7 +3238,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // FHO output line // - if(lt == stat_fho) { + if(lt == STATLineType::fho) { for(i=0; isecond, i, cts_info); if(job.stat_out) { @@ -3259,7 +3259,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // CTC output line // - else if(lt == stat_ctc) { + else if(lt == STATLineType::ctc) { for(i=0; isecond, i, cts_info); if(job.stat_out) { @@ -3280,7 +3280,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // CTS output line // - else if(lt == stat_cts) { + else if(lt == STATLineType::cts) { for(i=0; isecond, i, cts_info, tmp_dir, rng_ptr); if(job.stat_out) { @@ -3302,7 +3302,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // ECLV output line // - else if(lt == stat_eclv) { + else if(lt == STATLineType::eclv) { for(i=0; isecond, i, cts_info); if(job.stat_out) { @@ -3323,7 +3323,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // MCTC output line // - else if(lt == stat_mctc) { + else if(lt == STATLineType::mctc) { mpr_to_mctc(job, it->second, mcts_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3342,7 +3342,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // MCTS output line // - else if(lt == stat_mcts) { + else if(lt == STATLineType::mcts) { mpr_to_mcts(job, it->second, mcts_info, tmp_dir, rng_ptr); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3362,7 +3362,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // CNT output line // - else if(lt == stat_cnt) { + else if(lt == STATLineType::cnt) { for(i=0; isecond, i, cnt_info, tmp_dir, rng_ptr); if(cnt_info.n == 0) continue; @@ -3386,7 +3386,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // SL1L2 output line // - else if(lt == stat_sl1l2) { + else if(lt == STATLineType::sl1l2) { for(i=0; isecond, i, sl1l2_info); if(sl1l2_info.scount == 0) continue; @@ -3409,7 +3409,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // SAL1L2 output line // - else if(lt == stat_sal1l2) { + else if(lt == STATLineType::sal1l2) { for(i=0; isecond, i, sl1l2_info); if(sl1l2_info.sacount == 0) continue; @@ -3432,7 +3432,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PCT output line // - else if(lt == stat_pct) { + else if(lt == STATLineType::pct) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3451,7 +3451,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PSTD output line // - else if(lt == stat_pstd) { + else if(lt == STATLineType::pstd) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3471,7 +3471,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PJC output line // - else if(lt == stat_pjc) { + else if(lt == STATLineType::pjc) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3491,7 +3491,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PRC output line // - else if(lt == stat_prc) { + else if(lt == STATLineType::prc) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3541,16 +3541,16 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_vl1l2) n_col += n_vl1l2_columns; - else if(lt == stat_vcnt) n_col += n_vcnt_columns; + if(lt == STATLineType::vl1l2) n_col += n_vl1l2_columns; + else if(lt == STATLineType::vcnt) n_col += n_vcnt_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); - else if(lt == stat_vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); + if(lt == STATLineType::vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); // // Setup the output STAT file @@ -3571,7 +3571,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_cnt || lt == stat_nbrcnt) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::cnt || lt == STATLineType::nbrcnt) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -3583,7 +3583,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, // // VL1L2 output line // - if(lt == stat_vl1l2) { + if(lt == STATLineType::vl1l2) { if(job.stat_out) { write_vl1l2_cols(it->second.vl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -3597,7 +3597,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, // // VCNT output line // - else if(lt == stat_vcnt) { + else if(lt == STATLineType::vcnt) { if(job.stat_out) { write_vcnt_cols(it->second.vl1l2_info, 0, job.stat_at, job.stat_row++, n_header_columns); @@ -3992,7 +3992,7 @@ void write_job_ramp(STATAnalysisJob &job, // ctc_shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, - stat_ctc); + STATLineType::ctc); // // Compute contingency table statistics, if requested @@ -4000,7 +4000,7 @@ void write_job_ramp(STATAnalysisJob &job, if(job.out_line_type.has(stat_cts_str)) { cts_shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, - stat_cts); + STATLineType::cts); cts_shc.set_alpha(job.out_alpha); cts_info.compute_stats(); cts_info.compute_ci(); @@ -4160,7 +4160,7 @@ void write_job_ss_index(STATAnalysisJob &job, // Format the output STAT header columns // shc = it->second.hdr.get_shc(it->first, job.by_column, - job.hdr_name, job.hdr_value, stat_ssidx); + job.hdr_name, job.hdr_value, STATLineType::ssidx); // // Set FCST/OBS_VAR = skill score index type diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h index 238ec65629..1380ecc6b3 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h @@ -34,7 +34,7 @@ static const int n_txt = 1; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_isc + STATLineType::isc }; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index 1ac8d60822..b2ca4dc124 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -1734,7 +1734,7 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { int i, n_rows, n_cols, stat_rows, stat_cols, n_prob; // Check to see if the stat file stream has already been setup - bool init_from_scratch = (stat_out == (ofstream *) 0); + bool init_from_scratch = (stat_out == (ofstream *) nullptr); // Get the maximum number of probability thresholds n_prob = conf_info.get_max_n_prob_thresh(); @@ -1970,13 +1970,13 @@ void write_ctc_stats(const PairDataGenesis &gpd, na_str : gci.VxOpt->VxMaskName.c_str()); // Write out FHO - if(gci.VxOpt->output_map(stat_fho) != STATOutputType::None) { + if(gci.VxOpt->output_map(STATLineType::fho) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { shc.set_fcst_var(genesis_dev_name); shc.set_obs_var (genesis_dev_name); write_fho_row(shc, gci.CTSDev, - gci.VxOpt->output_map(stat_fho), + gci.VxOpt->output_map(STATLineType::fho), stat_at, i_stat_row, txt_at[i_fho], i_txt_row[i_fho]); } @@ -1985,20 +1985,20 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_ops_name); shc.set_obs_var (genesis_ops_name); write_fho_row(shc, gci.CTSOps, - gci.VxOpt->output_map(stat_fho), + gci.VxOpt->output_map(STATLineType::fho), stat_at, i_stat_row, txt_at[i_fho], i_txt_row[i_fho]); } } // Write out CTC - if(gci.VxOpt->output_map(stat_ctc) != STATOutputType::None) { + if(gci.VxOpt->output_map(STATLineType::ctc) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { shc.set_fcst_var(genesis_dev_name); shc.set_obs_var (genesis_dev_name); write_ctc_row(shc, gci.CTSDev, - gci.VxOpt->output_map(stat_ctc), + gci.VxOpt->output_map(STATLineType::ctc), stat_at, i_stat_row, txt_at[i_ctc], i_txt_row[i_ctc]); } @@ -2007,14 +2007,14 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_ops_name); shc.set_obs_var (genesis_ops_name); write_ctc_row(shc, gci.CTSOps, - gci.VxOpt->output_map(stat_ctc), + gci.VxOpt->output_map(STATLineType::ctc), stat_at, i_stat_row, txt_at[i_ctc], i_txt_row[i_ctc]); } } // Write out CTS - if(gci.VxOpt->output_map(stat_cts) != STATOutputType::None) { + if(gci.VxOpt->output_map(STATLineType::cts) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { gci.CTSDev.compute_stats(); @@ -2023,7 +2023,7 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_dev_name); shc.set_obs_var (genesis_dev_name); write_cts_row(shc, gci.CTSDev, - gci.VxOpt->output_map(stat_cts), + gci.VxOpt->output_map(STATLineType::cts), stat_at, i_stat_row, txt_at[i_cts], i_txt_row[i_cts]); } @@ -2035,18 +2035,18 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_ops_name); shc.set_obs_var (genesis_ops_name); write_cts_row(shc, gci.CTSOps, - gci.VxOpt->output_map(stat_cts), + gci.VxOpt->output_map(STATLineType::cts), stat_at, i_stat_row, txt_at[i_cts], i_txt_row[i_cts]); } } // Write out GENMPR - if(gci.VxOpt->output_map(stat_genmpr) != STATOutputType::None) { + if(gci.VxOpt->output_map(STATLineType::genmpr) != STATOutputType::None) { shc.set_fcst_var(genesis_name); shc.set_obs_var (genesis_name); write_ctc_genmpr_row(shc, gpd, - gci.VxOpt->output_map(stat_genmpr), + gci.VxOpt->output_map(STATLineType::genmpr), stat_at, i_stat_row, txt_at[i_genmpr], i_txt_row[i_genmpr]); } @@ -2219,43 +2219,43 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { shc.set_obs_valid_end(pgi.BestEnd); // Write PCT output - if(pgi.VxOpt->output_map(stat_pct) != STATOutputType::None) { + if(pgi.VxOpt->output_map(STATLineType::pct) != STATOutputType::None) { write_pct_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_pct), + pgi.VxOpt->output_map(STATLineType::pct), 1, 1, stat_at, i_stat_row, txt_at[i_pct], i_txt_row[i_pct]); } // Write PSTD output - if(pgi.VxOpt->output_map(stat_pstd) != STATOutputType::None) { + if(pgi.VxOpt->output_map(STATLineType::pstd) != STATOutputType::None) { pgi.PCTMap[lead_hr].compute_stats(); pgi.PCTMap[lead_hr].compute_ci(); write_pstd_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_pstd), + pgi.VxOpt->output_map(STATLineType::pstd), 1, 1, stat_at, i_stat_row, txt_at[i_pstd], i_txt_row[i_pstd]); } // Write PJC output - if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType::None) { + if(pgi.VxOpt->output_map(STATLineType::pjc) != STATOutputType::None) { write_pjc_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_pjc), + pgi.VxOpt->output_map(STATLineType::pjc), 1, 1, stat_at, i_stat_row, txt_at[i_pjc], i_txt_row[i_pjc]); } // Write PRC output - if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType::None) { + if(pgi.VxOpt->output_map(STATLineType::pjc) != STATOutputType::None) { write_prc_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_prc), + pgi.VxOpt->output_map(STATLineType::prc), 1, 1, stat_at, i_stat_row, txt_at[i_prc], i_txt_row[i_prc]); } // Write out GENMPR - if(pgi.VxOpt->output_map(stat_genmpr) != STATOutputType::None) { + if(pgi.VxOpt->output_map(STATLineType::genmpr) != STATOutputType::None) { write_pct_genmpr_row(shc, pgi, lead_hr, - pgi.VxOpt->output_map(stat_genmpr), + pgi.VxOpt->output_map(STATLineType::genmpr), stat_at, i_stat_row, txt_at[i_genmpr], i_txt_row[i_genmpr]); } diff --git a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h index 65ddd1b3de..900745f43b 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h +++ b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h @@ -39,14 +39,14 @@ static const int n_txt = 8; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_fho, // 0 - stat_ctc, // 1 - stat_cts, // 2 - stat_pct, // 3 - stat_pstd, // 4 - stat_pjc, // 5 - stat_prc, // 6 - stat_genmpr // 7 + STATLineType::fho, // 0 + STATLineType::ctc, // 1 + STATLineType::cts, // 2 + STATLineType::pct, // 3 + STATLineType::pstd, // 4 + STATLineType::pjc, // 5 + STATLineType::prc, // 6 + STATLineType::genmpr // 7 }; // Output data type names diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index 4fb93c24ef..0c29ff4c9d 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -3689,7 +3689,7 @@ void TCStatJobRIRW::setup_stat_file(int n_row) { OutLineType : LineType); out_lt = (out_sa.n() == 1 ? - string_to_statlinetype(out_sa[0].c_str()) : no_stat_line_type); + string_to_statlinetype(out_sa[0].c_str()) : STATLineType::none); // // Loop through the output line types and determine the number of @@ -3698,8 +3698,8 @@ void TCStatJobRIRW::setup_stat_file(int n_row) { for(i=0, c=0, n_col=0; i " << "unexpected stat line type \"" << statlinetype_to_string(cur_lt) @@ -3741,16 +3741,16 @@ void TCStatJobRIRW::setup_stat_file(int n_row) { // Write the STAT header row // switch(out_lt) { - case stat_ctc: + case STATLineType::ctc: write_header_row(ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break; - case stat_cts: + case STATLineType::cts: write_header_row(cts_columns, n_cts_columns, 1, stat_at, 0, 0); break; // Write only header columns for unspecified line type - case no_stat_line_type: + case STATLineType::none: write_header_row((const char **) 0, 0, 1, stat_at, 0, 0); break; @@ -4337,10 +4337,10 @@ void TCStatJobProbRIRW::do_output(ostream &out) { out_lt = string_to_statlinetype(OutLineType[i].c_str()); // Write the header columns - if(out_lt == stat_pct) lt_cols = get_n_pct_columns (n); - else if(out_lt == stat_pstd) lt_cols = get_n_pstd_columns(n); - else if(out_lt == stat_prc) lt_cols = get_n_prc_columns (n); - else if(out_lt == stat_pjc) lt_cols = get_n_pjc_columns (n); + if(out_lt == STATLineType::pct) lt_cols = get_n_pct_columns (n); + else if(out_lt == STATLineType::pstd) lt_cols = get_n_pstd_columns(n); + else if(out_lt == STATLineType::prc) lt_cols = get_n_prc_columns (n); + else if(out_lt == STATLineType::pjc) lt_cols = get_n_pjc_columns (n); else { mlog << Error << "\nvoid TCStatJobProbRIRW::do_output(ostream &out) -> " << "unsupported output line type \"" << OutLineType[i] << "\"\n\n"; @@ -4371,10 +4371,10 @@ void TCStatJobProbRIRW::do_output(ostream &out) { out_at.set_entry(r, c++, ByColumn[j]); // Write the header columns - if(out_lt == stat_pct) write_pct_header_row (0, n, out_at, r, c); - else if(out_lt == stat_pstd) write_pstd_header_row(0, n, out_at, r, c); - else if(out_lt == stat_prc) write_prc_header_row (0, n, out_at, r, c); - else if(out_lt == stat_pjc) write_pjc_header_row (0, n, out_at, r, c); + if(out_lt == STATLineType::pct) write_pct_header_row (0, n, out_at, r, c); + else if(out_lt == STATLineType::pstd) write_pstd_header_row(0, n, out_at, r, c); + else if(out_lt == STATLineType::prc) write_prc_header_row (0, n, out_at, r, c); + else if(out_lt == STATLineType::pjc) write_pjc_header_row (0, n, out_at, r, c); // Loop over the map entries and populate the output table for(it=ProbRIRWMap.begin(),r=1; it!=ProbRIRWMap.end(); it++,r++) { @@ -4399,7 +4399,7 @@ void TCStatJobProbRIRW::do_output(ostream &out) { out_at.set_entry(r, c++, sa[j]); // Compute PSTD statistics - if(out_lt == stat_pstd) { + if(out_lt == STATLineType::pstd) { it->second.Info.allocate_n_alpha(1); it->second.Info.alpha[0] = OutAlpha; it->second.Info.compute_stats(); @@ -4407,10 +4407,10 @@ void TCStatJobProbRIRW::do_output(ostream &out) { } // Write output columns - if(out_lt == stat_pct) write_pct_cols (it->second.Info, out_at, r, c); - else if(out_lt == stat_pstd) write_pstd_cols(it->second.Info, 0, out_at, r, c); - else if(out_lt == stat_prc) write_prc_cols (it->second.Info, out_at, r, c); - else if(out_lt == stat_pjc) write_pjc_cols (it->second.Info, out_at, r, c); + if(out_lt == STATLineType::pct) write_pct_cols (it->second.Info, out_at, r, c); + else if(out_lt == STATLineType::pstd) write_pstd_cols(it->second.Info, 0, out_at, r, c); + else if(out_lt == STATLineType::prc) write_prc_cols (it->second.Info, out_at, r, c); + else if(out_lt == STATLineType::pjc) write_pjc_cols (it->second.Info, out_at, r, c); } // end for it // Write the table for the current output line type From 8fad8f24e6ef09bf197f099ed97d42834d7ccbfe Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 05:17:58 +0000 Subject: [PATCH 052/114] #2830 Changed Action to enum class --- src/libcode/vx_pb_util/pblock.cc | 4 ++-- src/libcode/vx_pb_util/pblock.h | 2 +- src/tools/dev_utils/pbtime.cc | 2 +- src/tools/other/pb2nc/pb2nc.cc | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcode/vx_pb_util/pblock.cc b/src/libcode/vx_pb_util/pblock.cc index 057720e528..f8b2f3cecc 100644 --- a/src/libcode/vx_pb_util/pblock.cc +++ b/src/libcode/vx_pb_util/pblock.cc @@ -67,11 +67,11 @@ void pblock(const char *infile, const char *outfile, Action action) { // switch(action) { - case block: + case Action::block: do_blocking(in, out, padsize); break; - case unblock: + case Action::unblock: do_unblocking(in, out, padsize); break; diff --git a/src/libcode/vx_pb_util/pblock.h b/src/libcode/vx_pb_util/pblock.h index 015daaa4c1..43a4b32fe5 100644 --- a/src/libcode/vx_pb_util/pblock.h +++ b/src/libcode/vx_pb_util/pblock.h @@ -31,7 +31,7 @@ enum class PadSize { //////////////////////////////////////////////////////////////////////// -enum Action { +enum class Action { block, unblock, diff --git a/src/tools/dev_utils/pbtime.cc b/src/tools/dev_utils/pbtime.cc index 85a228d41f..fc63f7952f 100644 --- a/src/tools/dev_utils/pbtime.cc +++ b/src/tools/dev_utils/pbtime.cc @@ -78,7 +78,7 @@ int met_main(int argc, char *argv[]) { blk_file = make_temp_file_name("/tmp/tmp_pbtime_blk", nullptr); // Block the PrepBufr file and open it for reading. - pblock(pb_file.c_str(), blk_file.c_str(), block); + pblock(pb_file.c_str(), blk_file.c_str(), Action::block); // Open the blocked temp PrepBufr file for reading openpb_(blk_file.c_str(), &file_unit); diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index b4d4456882..2561288484 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -930,7 +930,7 @@ void process_pbfile(int i_pb) { // Assume that the input PrepBufr file is unblocked. // Block the PrepBufr file and open it for reading. - pblock(file_name.c_str(), blk_file.c_str(), block); + pblock(file_name.c_str(), blk_file.c_str(), Action::block); // Dump the contents of the PrepBufr file to ASCII files if(dump_flag) { @@ -2140,7 +2140,7 @@ void process_pbfile_metadata(int i_pb) { // Assume that the input PrepBufr file is unblocked. // Block the PrepBufr file and open it for reading. - pblock(file_name.c_str(), blk_file.c_str(), block); + pblock(file_name.c_str(), blk_file.c_str(), Action::block); unit = dump_unit + i_pb + file_unit; if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { From 6d8a3c7053f28a17177fa1701ce0d5165a7e42f9 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 05:24:37 +0000 Subject: [PATCH 053/114] #2830 Changed ModeDataType to enum class --- src/libcode/vx_shapedata/engine.cc | 14 ++-- src/libcode/vx_shapedata/mode_conf_info.cc | 74 +++++++++++----------- src/libcode/vx_shapedata/mode_conf_info.h | 4 +- src/libcode/vx_shapedata/mode_data_type.h | 16 ++--- src/tools/core/mode/mode_exec.cc | 14 ++-- src/tools/core/mode/multivar_data.cc | 2 +- src/tools/core/mode/multivar_frontend.cc | 12 ++-- 7 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index 0bafe99679..dcc5840a47 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -192,7 +192,7 @@ void ModeFuzzyEngine::init_from_scratch() { clear_features(); - data_type = ModeDataType_Traditional; + data_type = ModeDataType::Traditional; return; } @@ -249,9 +249,9 @@ void ModeFuzzyEngine::clear_colors() { void ModeFuzzyEngine::set(const ShapeData &fcst_wd, const ShapeData &obs_wd) { - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { set_fcst(fcst_wd); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { set_obs(obs_wd); } else { ConcatString path; @@ -280,9 +280,9 @@ void ModeFuzzyEngine::set(const ShapeData &fcst_wd, const ShapeData &obs_wd) void ModeFuzzyEngine::set_no_conv(const ShapeData &fcst_wd, const ShapeData &obs_wd) { - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { set_fcst_no_conv(fcst_wd); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { set_obs_no_conv ( obs_wd); } else { ConcatString path; @@ -311,9 +311,9 @@ void ModeFuzzyEngine::set_only_split(const ShapeData &fcst_wd, const ShapeData & { - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { set_fcst_only_split (fcst_wd); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { set_obs_only_split ( obs_wd); } else { ConcatString path; diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index a46d678289..642db14034 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -267,7 +267,7 @@ void ModeConfInfo::clear() Obs = 0; // so traditional mode will have the right value - data_type = ModeDataType_Traditional; + data_type = ModeDataType::Traditional; N_fields_f = 0; N_fields_o = 0; @@ -301,7 +301,7 @@ void ModeConfInfo::read_config(const char * default_file_name, const char * user void ModeConfInfo::process_config_traditional(GrdFileType ftype, GrdFileType otype) { process_config_except_fields(); - process_config_field (ftype, otype, ModeDataType_Traditional, 0); + process_config_field (ftype, otype, ModeDataType::Traditional, 0); } //////////////////////////////////////////////////////////////////////// @@ -513,11 +513,11 @@ void ModeConfInfo::process_config_field(GrdFileType ftype, GrdFileType otype, { set_data_type(dt); - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { process_config_fcst(ftype, field_index); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { process_config_obs(otype, field_index); @@ -580,7 +580,7 @@ void ModeConfInfo::process_config_both(GrdFileType ftype, GrdFileType otype, evaluate_fcst_settings(field_index); evaluate_obs_settings(field_index); - if (data_type == ModeDataType_Traditional) { + if (data_type == ModeDataType::Traditional) { if ( fcst_array[field_index].conv_radius_array.n_elements() != obs_array[field_index].conv_radius_array.n_elements() ) { @@ -702,7 +702,7 @@ void ModeConfInfo::config_set_all_percentile_thresholds(const std::vectoris_array() ) { const DictionaryEntry * e = 0; const Dictionary & D = *field; - if (data_type == ModeDataType_Traditional) { + if (data_type == ModeDataType::Traditional) { // traditional mode, extra test if ( (N_fields_f > 0) && (N != N_fields_f) ) { mlog << Error @@ -1098,7 +1098,7 @@ return pwl_if; void ModeConfInfo::set_field_index(int k) { - if (data_type == ModeDataType_MvMode_Obs) { + if (data_type == ModeDataType::MvMode_Obs) { if ( (k < 0) || (k >= N_fields_o) ) { mlog << Error << "\nModeConfInfo::set_field_index(int) -> range check error\n\n"; @@ -1108,7 +1108,7 @@ void ModeConfInfo::set_field_index(int k) Field_Index_f = -1; Obs = obs_array + k; } - else if (data_type == ModeDataType_MvMode_Fcst) { + else if (data_type == ModeDataType::MvMode_Fcst) { if ( (k < 0) || (k >= N_fields_f) ) { mlog << Error << "\nModeConfInfo::set_field_index(int) -> range check error\n\n"; @@ -1144,10 +1144,10 @@ if ( (f_index < 0) || (f_index >= N_fields_f) || (o_index < 0) || Field_Index_f = f_index; Field_Index_o = o_index; -if (data_type != ModeDataType_MvMode_Fcst) { +if (data_type != ModeDataType::MvMode_Fcst) { Obs = obs_array + o_index; } -if (data_type != ModeDataType_MvMode_Obs) { +if (data_type != ModeDataType::MvMode_Obs) { Fcst = fcst_array + f_index; } return; @@ -1220,9 +1220,9 @@ void ModeConfInfo::set_perc_thresh(const DataPlane &dp) // Mode_Field_Info *F; - if (data_type == ModeDataType_MvMode_Obs) { + if (data_type == ModeDataType::MvMode_Obs) { F = Obs; - } else if (data_type == ModeDataType_MvMode_Fcst) { + } else if (data_type == ModeDataType::MvMode_Fcst) { F = Fcst; } else { mlog << Warning @@ -1337,7 +1337,7 @@ return; void ModeConfInfo::set_conv_radius_by_index(int k) { - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if ( (k < 0) || (k >= Fcst->conv_radius_array.n_elements()) ) { mlog << Error << "\nModeConfInfo::set_conv_radius_by_index(int) -> " @@ -1346,7 +1346,7 @@ void ModeConfInfo::set_conv_radius_by_index(int k) } Fcst->conv_radius = Fcst->conv_radius_array[k]; } - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if ( (k < 0) || (k >= Obs->conv_radius_array.n_elements()) ) { mlog << Error @@ -1365,10 +1365,10 @@ void ModeConfInfo::set_conv_radius_by_index(int k) void ModeConfInfo::set_conv_thresh(SingleThresh s) { - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { Fcst->conv_thresh = s; } - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { Obs->conv_thresh = s; } } @@ -1377,10 +1377,10 @@ void ModeConfInfo::set_conv_thresh(SingleThresh s) void ModeConfInfo::set_conv_radius(int r) { - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { Fcst->conv_radius = r; } - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { Obs->conv_radius = r; } } @@ -1390,7 +1390,7 @@ void ModeConfInfo::set_conv_radius(int r) void ModeConfInfo::set_conv_thresh_by_index(int k) { - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if ( (k < 0) || (k >= Obs->conv_thresh_array.n_elements()) ) { mlog << Error << "\nModeConfInfo::set_conv_thresh_by_index(int) -> " @@ -1399,7 +1399,7 @@ void ModeConfInfo::set_conv_thresh_by_index(int k) } Obs->conv_thresh = Obs->conv_thresh_array[k]; } - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if ( (k < 0) || (k >= Fcst->conv_thresh_array.n_elements()) ) { mlog << Error @@ -1417,10 +1417,10 @@ void ModeConfInfo::set_conv_thresh_by_index(int k) void ModeConfInfo::set_merge_thresh_by_index(int k) { - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if ( Obs->need_merge_thresh () ) set_obs_merge_thresh_by_index (k); } - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if ( Fcst->need_merge_thresh () ) set_fcst_merge_thresh_by_index (k); } } @@ -1431,7 +1431,7 @@ void ModeConfInfo::set_merge_thresh_by_index(int k) void ModeConfInfo::set_fcst_merge_thresh_by_index(int k) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_merge_thresh_by_index(int) -> " @@ -1451,10 +1451,10 @@ void ModeConfInfo::set_fcst_merge_thresh_by_index(int k) void ModeConfInfo::set_conv_thresh_by_merge_index(int k) { - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if (Obs->need_merge_thresh()) set_obs_conv_thresh_by_merge_index (k); } - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if (Fcst->need_merge_thresh()) set_fcst_conv_thresh_by_merge_index (k); } } @@ -1465,7 +1465,7 @@ void ModeConfInfo::set_conv_thresh_by_merge_index(int k) void ModeConfInfo::set_fcst_conv_thresh_by_merge_index(int k) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_conv_thresh_by_merge_index(int) -> " @@ -1485,7 +1485,7 @@ void ModeConfInfo::set_fcst_conv_thresh_by_merge_index(int k) void ModeConfInfo::set_obs_conv_thresh_by_merge_index(int k) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_conv_thresh_by_merge_index(int) -> " @@ -1502,7 +1502,7 @@ void ModeConfInfo::set_obs_conv_thresh_by_merge_index(int k) void ModeConfInfo::set_fcst_merge_flag(MergeType t) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_merge_flag(int) -> " @@ -1516,7 +1516,7 @@ void ModeConfInfo::set_fcst_merge_flag(MergeType t) void ModeConfInfo::set_obs_merge_flag(MergeType t) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_merge_flag(int) -> " @@ -1530,7 +1530,7 @@ void ModeConfInfo::set_obs_merge_flag(MergeType t) void ModeConfInfo::set_fcst_merge_thresh(SingleThresh s) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_merge_thresh(int) -> " @@ -1544,7 +1544,7 @@ void ModeConfInfo::set_fcst_merge_thresh(SingleThresh s) void ModeConfInfo::set_obs_merge_thresh(SingleThresh s) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_merge_thresh(int) -> " @@ -1560,7 +1560,7 @@ void ModeConfInfo::set_obs_merge_thresh(SingleThresh s) void ModeConfInfo::set_obs_merge_thresh_by_index(int k) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_merge_thresh_by_index(int) -> " @@ -1734,7 +1734,7 @@ void ModeConfInfo::check_multivar_not_implemented() } for (int i=0; iconv_radius_array.n_elements() ); } else { @@ -328,7 +328,7 @@ inline int ModeConfInfo::n_conv_threshs() const { // this could break down if multivar mode relaxes // its limitations on number of thresh (obs and fcst could be different) - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { return ( Obs->conv_thresh_array.n_elements() ); } else { diff --git a/src/libcode/vx_shapedata/mode_data_type.h b/src/libcode/vx_shapedata/mode_data_type.h index 59f4aea3d2..18696d5fe2 100644 --- a/src/libcode/vx_shapedata/mode_data_type.h +++ b/src/libcode/vx_shapedata/mode_data_type.h @@ -20,10 +20,10 @@ using std::string; enum ModeDataType { - ModeDataType_Traditional, // default - ModeDataType_MvMode_Obs, // mvmode, obs data only - ModeDataType_MvMode_Fcst, // mvmode, fcst data only - ModeDataType_MvMode_Both // mvmode, fcst and obs + Traditional, // default + MvMode_Obs, // mvmode, obs data only + MvMode_Fcst, // mvmode, fcst data only + MvMode_Both // mvmode, fcst and obs }; @@ -33,13 +33,13 @@ inline string sprintModeDataType(ModeDataType type) { switch (type) { - case ModeDataType_MvMode_Obs: + case ModeDataType::MvMode_Obs: return "MvMode_Obs"; - case ModeDataType_MvMode_Fcst: + case ModeDataType::MvMode_Fcst: return "MvMode_Fcst"; - case ModeDataType_MvMode_Both: + case ModeDataType::MvMode_Both: return "MvMode_Both"; - case ModeDataType_Traditional: + case ModeDataType::Traditional: default: return "TraditionalMode"; } diff --git a/src/tools/core/mode/mode_exec.cc b/src/tools/core/mode/mode_exec.cc index fb783ead42..578c92acb7 100644 --- a/src/tools/core/mode/mode_exec.cc +++ b/src/tools/core/mode/mode_exec.cc @@ -231,7 +231,7 @@ void ModeExecutive::init_multivar_intensities(const ModeConfInfo &conf) engine.conf_info = conf; // tell the engine which type of data it is - engine.set_data_type(ModeDataType_MvMode_Both); + engine.set_data_type(ModeDataType::MvMode_Both); // check one again for multivar problems engine.conf_info.check_multivar_not_implemented(); @@ -426,7 +426,7 @@ void ModeExecutive::setup_verification_grid(const ModeInputData &fcst, // set this local conf to point to forecast 0, so that that regrid info // can be accessed and it can be decided if we are to use fcst or obs // input - engine.conf_info.set_data_type(ModeDataType_MvMode_Fcst); + engine.conf_info.set_data_type(ModeDataType::MvMode_Fcst); engine.conf_info.set_field_index(0); grid = parse_vx_grid(engine.conf_info.Fcst->var_info->regrid(), &fcst._grid, &obs._grid); @@ -915,7 +915,7 @@ void ModeExecutive::do_conv_thresh_multivar_simple(Processing_t p) // string what; - if (conf.data_type == ModeDataType_MvMode_Obs) { + if (conf.data_type == ModeDataType::MvMode_Obs) { what = "observation field"; } else { what = "forecast field"; @@ -1624,7 +1624,7 @@ MultiVarData *ModeExecutive::get_multivar_data(ModeDataType dtype) switch (dtype) { - case ModeDataType_MvMode_Obs: + case ModeDataType::MvMode_Obs: obs_magic_string = engine.conf_info.Obs->var_info->magic_str().c_str(); // replace forward slashes with underscores to prevent new directories replace(obs_magic_string.begin(), obs_magic_string.end(), '/', '_'); @@ -1636,7 +1636,7 @@ MultiVarData *ModeExecutive::get_multivar_data(ModeDataType dtype) mvd->set_conv_thresh_array(engine.conf_info.Obs->conv_thresh_array, simple); mvd->set_merge_thresh_array(engine.conf_info.Obs->merge_thresh_array, simple); break; - case ModeDataType_MvMode_Fcst: + case ModeDataType::MvMode_Fcst: fcst_magic_string = engine.conf_info.Fcst->var_info->magic_str().c_str(); // replace forward slashes with underscores to prevent new directories replace(fcst_magic_string.begin(), fcst_magic_string.end(), '/', '_'); @@ -1664,14 +1664,14 @@ void ModeExecutive::add_multivar_merge_data(MultiVarData *mvd, ModeDataType dtyp bool simple = false; switch (dtype) { - case ModeDataType_MvMode_Obs: + case ModeDataType::MvMode_Obs: mvd->set_obj(engine.obs_split, simple); mvd->set_raw(engine.obs_raw, simple); mvd->set_shapedata(Obs_sd, simple); mvd->set_conv_thresh_array(engine.conf_info.Obs->conv_thresh_array, simple); mvd->set_merge_thresh_array(engine.conf_info.Obs->merge_thresh_array, simple); break; - case ModeDataType_MvMode_Fcst: + case ModeDataType::MvMode_Fcst: mvd->set_obj(engine.fcst_split, simple); mvd->set_raw(engine.fcst_raw, simple); mvd->set_shapedata(Fcst_sd, simple); diff --git a/src/tools/core/mode/multivar_data.cc b/src/tools/core/mode/multivar_data.cc index 3bcfa136f7..b0979e3b45 100644 --- a/src/tools/core/mode/multivar_data.cc +++ b/src/tools/core/mode/multivar_data.cc @@ -138,7 +138,7 @@ void MultiVarData1::_print_summary(const string &name, int *data, const ShapeDat } MultiVarData::MultiVarData() : - _dataType(ModeDataType_MvMode_Both), + _dataType(ModeDataType::MvMode_Both), _simple(0), _merge(0), _name("notset"), diff --git a/src/tools/core/mode/multivar_frontend.cc b/src/tools/core/mode/multivar_frontend.cc index 8941780df3..baa0537791 100644 --- a/src/tools/core/mode/multivar_frontend.cc +++ b/src/tools/core/mode/multivar_frontend.cc @@ -70,14 +70,14 @@ int MultivarFrontEnd::run(const StringArray & Argv) GrdFileType ft, ot; ft = config.file_type_for_field(true, i); ot = parse_conf_file_type(config.conf.lookup_dictionary(conf_key_obs)); - read_input(fcst_filenames[i], i, ModeDataType_MvMode_Fcst, ft, ot, shift); + read_input(fcst_filenames[i], i, ModeDataType::MvMode_Fcst, ft, ot, shift); } for (int i=0; idata_plane(*(config.Fcst->var_info), dp); fcstInput.push_back(ModeInputData(name, dp, g)); @@ -637,7 +637,7 @@ void MultivarFrontEnd::_simple_objects(ModeExecutive::Processing_t p, int j, int n_files, const string &filename, const ModeInputData &input) { - if (dtype == ModeDataType_MvMode_Fcst) { + if (dtype == ModeDataType::MvMode_Fcst) { _init_exec(p, filename, "None"); mode_exec->init_multivar_simple(j, n_files, dtype, config); mode_exec->setup_multivar_fcst_data(verification_grid, input); From df25b8640d173fd833ea4c9984854639d5658ebe Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 06:18:56 +0000 Subject: [PATCH 054/114] #2830 Changed StepCase to enum class --- src/libcode/vx_shapedata/shapedata.cc | 47 ++++++++++++++------------- src/libcode/vx_shapedata/shapedata.h | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/libcode/vx_shapedata/shapedata.cc b/src/libcode/vx_shapedata/shapedata.cc index 94fed61cba..3e4491e380 100644 --- a/src/libcode/vx_shapedata/shapedata.cc +++ b/src/libcode/vx_shapedata/shapedata.cc @@ -35,6 +35,7 @@ #include "shapedata.h" #include "mode_columns.h" +#include "enum_as_int.hpp" #include "vx_log.h" #include "vx_util.h" #include "vx_math.h" @@ -64,7 +65,7 @@ static const bool do_split_fatten = true; static double dot(double, double, double, double); static void boundary_step(const ShapeData &, int &, int &, int &); -static int get_step_case(bool, bool, bool, bool); +static StepCase get_step_case(bool, bool, bool, bool); /////////////////////////////////////////////////////////////////////////////// // @@ -1698,7 +1699,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { // switch(direction) { - case(plus_x): + case plus_x: if(sd.s_is_on(xn, yn-1, false)) lr = true; if(sd.s_is_on(xn+1, yn-1, false)) ur = true; if(sd.s_is_on(xn+1, yn , false)) ul = true; @@ -1707,7 +1708,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { xn += 1; break; - case(plus_y): + case plus_y: if(sd.s_is_on(xn, yn , false)) lr = true; if(sd.s_is_on(xn, yn+1, false)) ur = true; if(sd.s_is_on(xn-1, yn+1, false)) ul = true; @@ -1716,7 +1717,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { yn += 1; break; - case(minus_x): + case minus_x: if(sd.s_is_on(xn-1, yn , false)) lr = true; if(sd.s_is_on(xn-2, yn , false)) ur = true; if(sd.s_is_on(xn-2, yn-1, false)) ul = true; @@ -1725,7 +1726,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { xn -= 1; break; - case(minus_y): + case minus_y: if(sd.s_is_on(xn-1, yn-1, false)) lr = true; if(sd.s_is_on(xn-1, yn-2, false)) ur = true; if(sd.s_is_on(xn, yn-2, false)) ul = true; @@ -1745,24 +1746,24 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { // switch(get_step_case(lr, ur, ul, ll)) { - case ll_case: - case lr_ul_case: - case lr_ur_ul_case: + case StepCase::ll_case: + case StepCase::lr_ul_case: + case StepCase::lr_ur_ul_case: // Turn left direction = (direction + 1)%4; if(direction < 0) direction += 4; break; - case lr_case: - case ur_ll_case: - case ur_ul_ll_case: + case StepCase::lr_case: + case StepCase::ur_ll_case: + case StepCase::ur_ul_ll_case: // Turn right direction = (direction - 1)%4; if(direction < 0) direction += 4; break; - case ul_ll_case: - case lr_ur_case: + case StepCase::ul_ll_case: + case StepCase::lr_ur_case: // Continue straight: direction remains unchanged break; @@ -1770,7 +1771,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { mlog << Error << "\nboundary_step() -> " << "bad step case: " - << get_step_case(lr, ur, ul, ll) << "\n\n"; + << enum_class_as_int(get_step_case(lr, ur, ul, ll)) << "\n\n"; exit(1); } @@ -1779,38 +1780,38 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { //////////////////////////////////////////////////////////////////////// -int get_step_case(bool lr, bool ur, bool ul, bool ll) { +StepCase get_step_case(bool lr, bool ur, bool ul, bool ll) { // // Valid cases with exactly one cell on // // Lower Left - if(!lr && !ur && !ul && ll) return ll_case; + if(!lr && !ur && !ul && ll) return StepCase::ll_case; // Lower Right - else if(lr && !ur && !ul && !ll) return lr_case; + else if(lr && !ur && !ul && !ll) return StepCase::lr_case; // // Valid cases with exactly two cells on // // Upper Left, Lower Left - else if(!lr && !ur && ul && ll) return ul_ll_case; + else if(!lr && !ur && ul && ll) return StepCase::ul_ll_case; // Lower Right, Upper Right - else if(lr && ur && !ul && !ll) return lr_ur_case; + else if(lr && ur && !ul && !ll) return StepCase::lr_ur_case; // Lower Right, Upper Left - else if(lr && !ur && ul && !ll) return lr_ul_case; + else if(lr && !ur && ul && !ll) return StepCase::lr_ul_case; // Upper Right, Lower Left - else if(!lr && ur && !ul && ll) return ur_ll_case; + else if(!lr && ur && !ul && ll) return StepCase::ur_ll_case; // // Valid cases with exactly three cells on // // Upper Right, Upper Left, Lower Left - else if(!lr && ur && ul && ll) return ur_ul_ll_case; + else if(!lr && ur && ul && ll) return StepCase::ur_ul_ll_case; // Lower Right, Upper Right, Upper Left - else if(lr && ur && ul && !ll) return lr_ur_ul_case; + else if(lr && ur && ul && !ll) return StepCase::lr_ur_ul_case; // // Otherwise, combination is invalid diff --git a/src/libcode/vx_shapedata/shapedata.h b/src/libcode/vx_shapedata/shapedata.h index e1acfb55fd..9654844047 100644 --- a/src/libcode/vx_shapedata/shapedata.h +++ b/src/libcode/vx_shapedata/shapedata.h @@ -39,7 +39,7 @@ // // Enumerations used in computing the boundary of a ShapeData object // -enum StepCase { +enum class StepCase { ll_case = 0, lr_case = 1, ul_ll_case = 2, From 1f1d52534f6d9fe74c8870827482400567b7f8a6 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 06:19:38 +0000 Subject: [PATCH 055/114] #2830 Changed enum to enum class --- src/libcode/vx_tc_util/atcf_track_line.cc | 254 +++++++++--------- src/libcode/vx_tc_util/atcf_track_line.h | 42 +-- src/libcode/vx_tc_util/prob_rirw_pair_info.cc | 7 +- src/libcode/vx_tc_util/track_pair_info.cc | 2 +- src/libcode/vx_tc_util/track_point.cc | 18 +- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 2 +- src/tools/tc_utils/tc_stat/tc_stat_job.cc | 8 +- 7 files changed, 167 insertions(+), 166 deletions(-) diff --git a/src/libcode/vx_tc_util/atcf_track_line.cc b/src/libcode/vx_tc_util/atcf_track_line.cc index ae9806b64b..8dc42d3f42 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.cc +++ b/src/libcode/vx_tc_util/atcf_track_line.cc @@ -189,7 +189,7 @@ int ATCFTrackLine::mslp() const { CycloneLevel ATCFTrackLine::level() const { return(LevelOffset < N_items ? string_to_cyclonelevel(get_item(LevelOffset).c_str()) : - NoCycloneLevel); + CycloneLevel::None); } //////////////////////////////////////////////////////////////////////// @@ -205,7 +205,7 @@ int ATCFTrackLine::wind_intensity() const { QuadrantType ATCFTrackLine::quadrant() const { return(QuadrantOffset < N_items ? string_to_quadranttype(get_item(QuadrantOffset).c_str()) : - NoQuadrantType); + QuadrantType::None); } //////////////////////////////////////////////////////////////////////// @@ -337,7 +337,7 @@ int ATCFTrackLine::eye_diameter() const { SubregionCode ATCFTrackLine::subregion() const { return(Type == ATCFLineType::Track && SubRegionOffset < N_items ? string_to_subregioncode(get_item(SubRegionOffset).c_str()) : - NoSubregionCode); + SubregionCode::None); } //////////////////////////////////////////////////////////////////////// @@ -369,7 +369,7 @@ ConcatString ATCFTrackLine::storm_name() const { SystemsDepth ATCFTrackLine::depth() const { return(Type == ATCFLineType::Track && DepthOffset < N_items ? string_to_systemsdepth(get_item(DepthOffset).c_str()) : - NoSystemsDepth); + SystemsDepth::None); } //////////////////////////////////////////////////////////////////////// @@ -385,7 +385,7 @@ int ATCFTrackLine::wave_height() const { QuadrantType ATCFTrackLine::seas_code() const { return(Type == ATCFLineType::Track && SeasCodeOffset < N_items ? string_to_quadranttype(get_item(SeasCodeOffset).c_str()) : - NoQuadrantType); + QuadrantType::None); } //////////////////////////////////////////////////////////////////////// @@ -500,19 +500,19 @@ WatchWarnType ww_max(const WatchWarnType t1, const WatchWarnType t2) { // GaleWarn, // StormWarn - if(t1 == HurricaneWarn || - t2 == HurricaneWarn ) t = HurricaneWarn; - else if(t1 == TropicalStormWarn || - t2 == TropicalStormWarn ) t = TropicalStormWarn; - else if(t1 == HurricaneWatch || - t2 == HurricaneWatch ) t = HurricaneWatch; - else if(t1 == TropicalStormWatch || - t2 == TropicalStormWatch ) t = TropicalStormWatch; - else if(t1 == GaleWarn || - t2 == GaleWarn ) t = GaleWarn; - else if(t1 == StormWarn || - t2 == StormWarn ) t = StormWarn; - else t = NoWatchWarnType; + if(t1 == WatchWarnType::HurricaneWarn || + t2 == WatchWarnType::HurricaneWarn ) t = WatchWarnType::HurricaneWarn; + else if(t1 == WatchWarnType::TropicalStormWarn || + t2 == WatchWarnType::TropicalStormWarn ) t = WatchWarnType::TropicalStormWarn; + else if(t1 == WatchWarnType::HurricaneWatch || + t2 == WatchWarnType::HurricaneWatch ) t = WatchWarnType::HurricaneWatch; + else if(t1 == WatchWarnType::TropicalStormWatch || + t2 == WatchWarnType::TropicalStormWatch ) t = WatchWarnType::TropicalStormWatch; + else if(t1 == WatchWarnType::GaleWarn || + t2 == WatchWarnType::GaleWarn ) t = WatchWarnType::GaleWarn; + else if(t1 == WatchWarnType::StormWarn || + t2 == WatchWarnType::StormWarn ) t = WatchWarnType::StormWarn; + else t = WatchWarnType::None; return t; } @@ -522,13 +522,13 @@ WatchWarnType ww_max(const WatchWarnType t1, const WatchWarnType t2) { WatchWarnType int_to_watchwarntype(int i) { WatchWarnType t; - if(i == 1) t = TropicalStormWatch; - else if(i == 2) t = TropicalStormWarn; - else if(i == 3) t = GaleWarn; - else if(i == 4) t = StormWarn; - else if(i == 5) t = HurricaneWatch; - else if(i == 6) t = HurricaneWarn; - else t = NoWatchWarnType; + if(i == 1) t = WatchWarnType::TropicalStormWatch; + else if(i == 2) t = WatchWarnType::TropicalStormWarn; + else if(i == 3) t = WatchWarnType::GaleWarn; + else if(i == 4) t = WatchWarnType::StormWarn; + else if(i == 5) t = WatchWarnType::HurricaneWatch; + else if(i == 6) t = WatchWarnType::HurricaneWarn; + else t = WatchWarnType::None; return t; } @@ -539,13 +539,13 @@ WatchWarnType int_to_watchwarntype(int i) { WatchWarnType string_to_watchwarntype(const char *s) { WatchWarnType t; - if(strcasecmp(s, "TSWATCH") == 0) t = TropicalStormWatch; - else if(strcasecmp(s, "TSWARN") == 0) t = TropicalStormWarn; - else if(strcasecmp(s, "GLWARN") == 0) t = GaleWarn; - else if(strcasecmp(s, "STWARN") == 0) t = StormWarn; - else if(strcasecmp(s, "HUWATCH") == 0) t = HurricaneWatch; - else if(strcasecmp(s, "HUWARN") == 0) t = HurricaneWarn; - else t = NoWatchWarnType; + if(strcasecmp(s, "TSWATCH") == 0) t = WatchWarnType::TropicalStormWatch; + else if(strcasecmp(s, "TSWARN") == 0) t = WatchWarnType::TropicalStormWarn; + else if(strcasecmp(s, "GLWARN") == 0) t = WatchWarnType::GaleWarn; + else if(strcasecmp(s, "STWARN") == 0) t = WatchWarnType::StormWarn; + else if(strcasecmp(s, "HUWATCH") == 0) t = WatchWarnType::HurricaneWatch; + else if(strcasecmp(s, "HUWARN") == 0) t = WatchWarnType::HurricaneWarn; + else t = WatchWarnType::None; return t; } @@ -556,14 +556,14 @@ ConcatString watchwarntype_to_string(const WatchWarnType t) { const char *s = (const char *) nullptr; switch(t) { - case TropicalStormWatch: s = "TSWATCH"; break; - case TropicalStormWarn: s = "TSWARN"; break; - case GaleWarn: s = "GLWARN"; break; - case StormWarn: s = "STWARN"; break; - case HurricaneWatch: s = "HUWATCH"; break; - case HurricaneWarn: s = "HUWARN"; break; - case NoWatchWarnType: s = na_str; break; - default: s = na_str; break; + case WatchWarnType::TropicalStormWatch: s = "TSWATCH"; break; + case WatchWarnType::TropicalStormWarn: s = "TSWARN"; break; + case WatchWarnType::GaleWarn: s = "GLWARN"; break; + case WatchWarnType::StormWarn: s = "STWARN"; break; + case WatchWarnType::HurricaneWatch: s = "HUWATCH"; break; + case WatchWarnType::HurricaneWarn: s = "HUWARN"; break; + case WatchWarnType::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -574,22 +574,22 @@ ConcatString watchwarntype_to_string(const WatchWarnType t) { CycloneLevel string_to_cyclonelevel(const char *s) { CycloneLevel l; - if(strcmp(s, "DB") == 0) l = Disturbance; - else if(strcmp(s, "TD") == 0) l = TropicalDepression; - else if(strcmp(s, "TS") == 0) l = TropicalStorm; - else if(strcmp(s, "TY") == 0) l = Typhoon; - else if(strcmp(s, "ST") == 0) l = SuperTyphoon; - else if(strcmp(s, "TC") == 0) l = TropicalCyclone; - else if(strcmp(s, "HU") == 0) l = Hurricane; - else if(strcmp(s, "SD") == 0) l = SubtropicalDepression; - else if(strcmp(s, "SS") == 0) l = SubtropicalStorm; - else if(strcmp(s, "EX") == 0) l = ExtratropicalSystem; - else if(strcmp(s, "IN") == 0) l = Inland; - else if(strcmp(s, "DS") == 0) l = Dissipating; - else if(strcmp(s, "LO") == 0) l = Low; - else if(strcmp(s, "WV") == 0) l = TropicalWave; - else if(strcmp(s, "ET") == 0) l = Extrapolated; - else /* "XX" */ l = NoCycloneLevel; + if(strcmp(s, "DB") == 0) l = CycloneLevel::Disturbance; + else if(strcmp(s, "TD") == 0) l = CycloneLevel::TropicalDepression; + else if(strcmp(s, "TS") == 0) l = CycloneLevel::TropicalStorm; + else if(strcmp(s, "TY") == 0) l = CycloneLevel::Typhoon; + else if(strcmp(s, "ST") == 0) l = CycloneLevel::SuperTyphoon; + else if(strcmp(s, "TC") == 0) l = CycloneLevel::TropicalCyclone; + else if(strcmp(s, "HU") == 0) l = CycloneLevel::Hurricane; + else if(strcmp(s, "SD") == 0) l = CycloneLevel::SubtropicalDepression; + else if(strcmp(s, "SS") == 0) l = CycloneLevel::SubtropicalStorm; + else if(strcmp(s, "EX") == 0) l = CycloneLevel::ExtratropicalSystem; + else if(strcmp(s, "IN") == 0) l = CycloneLevel::Inland; + else if(strcmp(s, "DS") == 0) l = CycloneLevel::Dissipating; + else if(strcmp(s, "LO") == 0) l = CycloneLevel::Low; + else if(strcmp(s, "WV") == 0) l = CycloneLevel::TropicalWave; + else if(strcmp(s, "ET") == 0) l = CycloneLevel::Extrapolated; + else /* "XX" */ l = CycloneLevel::None; return l; } @@ -600,23 +600,23 @@ ConcatString cyclonelevel_to_string(const CycloneLevel t) { const char *s = (const char *) nullptr; switch(t) { - case Disturbance: s = "DB"; break; - case TropicalDepression: s = "TD"; break; - case TropicalStorm: s = "TS"; break; - case Typhoon: s = "TY"; break; - case SuperTyphoon: s = "ST"; break; - case TropicalCyclone: s = "TC"; break; - case Hurricane: s = "HU"; break; - case SubtropicalDepression: s = "SD"; break; - case SubtropicalStorm: s = "SS"; break; - case ExtratropicalSystem: s = "EX"; break; - case Inland: s = "IN"; break; - case Dissipating: s = "DS"; break; - case Low: s = "LO"; break; - case TropicalWave: s = "WV"; break; - case Extrapolated: s = "ET"; break; - case NoCycloneLevel: s = na_str; break; - default: s = na_str; break; + case CycloneLevel::Disturbance: s = "DB"; break; + case CycloneLevel::TropicalDepression: s = "TD"; break; + case CycloneLevel::TropicalStorm: s = "TS"; break; + case CycloneLevel::Typhoon: s = "TY"; break; + case CycloneLevel::SuperTyphoon: s = "ST"; break; + case CycloneLevel::TropicalCyclone: s = "TC"; break; + case CycloneLevel::Hurricane: s = "HU"; break; + case CycloneLevel::SubtropicalDepression: s = "SD"; break; + case CycloneLevel::SubtropicalStorm: s = "SS"; break; + case CycloneLevel::ExtratropicalSystem: s = "EX"; break; + case CycloneLevel::Inland: s = "IN"; break; + case CycloneLevel::Dissipating: s = "DS"; break; + case CycloneLevel::Low: s = "LO"; break; + case CycloneLevel::TropicalWave: s = "WV"; break; + case CycloneLevel::Extrapolated: s = "ET"; break; + case CycloneLevel::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -628,9 +628,9 @@ CycloneLevel wind_speed_to_cyclonelevel(int s) { CycloneLevel l; // Apply logic to convert wind speed to CycloneLevel - if(s <= 33) l = TropicalDepression; - else if(s <= 63) l = TropicalStorm; - else l = Hurricane; + if(s <= 33) l = CycloneLevel::TropicalDepression; + else if(s <= 63) l = CycloneLevel::TropicalStorm; + else l = CycloneLevel::Hurricane; return l; } @@ -640,16 +640,16 @@ CycloneLevel wind_speed_to_cyclonelevel(int s) { QuadrantType string_to_quadranttype(const char *s) { QuadrantType t; - if(strcmp(s, "AAA") == 0) t = FullCircle; - else if(strcmp(s, "NNQ") == 0) t = N_Quadrant; - else if(strcmp(s, "EEQ") == 0) t = E_Quadrant; - else if(strcmp(s, "SSQ") == 0) t = S_Quadrant; - else if(strcmp(s, "WWQ") == 0) t = W_Quadrant; - else if(strcmp(s, "NEQ") == 0) t = NE_Quadrant; - else if(strcmp(s, "SEQ") == 0) t = SE_Quadrant; - else if(strcmp(s, "SWQ") == 0) t = SW_Quadrant; - else if(strcmp(s, "NWQ") == 0) t = NW_Quadrant; - else t = NoQuadrantType; + if(strcmp(s, "AAA") == 0) t = QuadrantType::FullCircle; + else if(strcmp(s, "NNQ") == 0) t = QuadrantType::N; + else if(strcmp(s, "EEQ") == 0) t = QuadrantType::E; + else if(strcmp(s, "SSQ") == 0) t = QuadrantType::S; + else if(strcmp(s, "WWQ") == 0) t = QuadrantType::W; + else if(strcmp(s, "NEQ") == 0) t = QuadrantType::NE; + else if(strcmp(s, "SEQ") == 0) t = QuadrantType::SE; + else if(strcmp(s, "SWQ") == 0) t = QuadrantType::SW; + else if(strcmp(s, "NWQ") == 0) t = QuadrantType::NW; + else t = QuadrantType::None; return t; } @@ -660,17 +660,17 @@ ConcatString quadranttype_to_string(const QuadrantType t) { const char *s = (const char *) nullptr; switch(t) { - case FullCircle: s = "AAA"; break; - case N_Quadrant: s = "NNQ"; break; - case E_Quadrant: s = "EEQ"; break; - case S_Quadrant: s = "SSQ"; break; - case W_Quadrant: s = "WWQ"; break; - case NE_Quadrant: s = "NEQ"; break; - case SE_Quadrant: s = "SEQ"; break; - case SW_Quadrant: s = "SWQ"; break; - case NW_Quadrant: s = "NWQ"; break; - case NoQuadrantType: s = na_str; break; - default: s = na_str; break; + case QuadrantType::FullCircle: s = "AAA"; break; + case QuadrantType::N: s = "NNQ"; break; + case QuadrantType::E: s = "EEQ"; break; + case QuadrantType::S: s = "SSQ"; break; + case QuadrantType::W: s = "WWQ"; break; + case QuadrantType::NE: s = "NEQ"; break; + case QuadrantType::SE: s = "SEQ"; break; + case QuadrantType::SW: s = "SWQ"; break; + case QuadrantType::NW: s = "NWQ"; break; + case QuadrantType::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -681,16 +681,16 @@ ConcatString quadranttype_to_string(const QuadrantType t) { SubregionCode string_to_subregioncode(const char *s) { SubregionCode c; - if(strcmp(s, "A") == 0) c = Arabian_Sea; - else if(strcmp(s, "B") == 0) c = Bay_of_Bengal; - else if(strcmp(s, "C") == 0) c = Central_Pacific; - else if(strcmp(s, "E") == 0) c = Eastern_Pacific; - else if(strcmp(s, "L") == 0) c = Atlantic; - else if(strcmp(s, "P") == 0) c = South_Pacific; - else if(strcmp(s, "Q") == 0) c = South_Atlantic; - else if(strcmp(s, "S") == 0) c = South_IO; - else if(strcmp(s, "W") == 0) c = Western_Pacific; - else c = NoSubregionCode; + if(strcmp(s, "A") == 0) c = SubregionCode::Arabian_Sea; + else if(strcmp(s, "B") == 0) c = SubregionCode::Bay_of_Bengal; + else if(strcmp(s, "C") == 0) c = SubregionCode::Central_Pacific; + else if(strcmp(s, "E") == 0) c = SubregionCode::Eastern_Pacific; + else if(strcmp(s, "L") == 0) c = SubregionCode::Atlantic; + else if(strcmp(s, "P") == 0) c = SubregionCode::South_Pacific; + else if(strcmp(s, "Q") == 0) c = SubregionCode::South_Atlantic; + else if(strcmp(s, "S") == 0) c = SubregionCode::South_IO; + else if(strcmp(s, "W") == 0) c = SubregionCode::Western_Pacific; + else c = SubregionCode::None; return c; } @@ -701,17 +701,17 @@ ConcatString subregioncode_to_string(const SubregionCode t) { const char *s = (const char *) nullptr; switch(t) { - case Arabian_Sea: s = "A"; break; - case Bay_of_Bengal: s = "B"; break; - case Central_Pacific: s = "C"; break; - case Eastern_Pacific: s = "E"; break; - case Atlantic: s = "L"; break; - case South_Pacific: s = "P"; break; - case South_Atlantic: s = "Q"; break; - case South_IO: s = "S"; break; - case Western_Pacific: s = "W"; break; - case NoSubregionCode: s = na_str; break; - default: s = na_str; break; + case SubregionCode::Arabian_Sea: s = "A"; break; + case SubregionCode::Bay_of_Bengal: s = "B"; break; + case SubregionCode::Central_Pacific: s = "C"; break; + case SubregionCode::Eastern_Pacific: s = "E"; break; + case SubregionCode::Atlantic: s = "L"; break; + case SubregionCode::South_Pacific: s = "P"; break; + case SubregionCode::South_Atlantic: s = "Q"; break; + case SubregionCode::South_IO: s = "S"; break; + case SubregionCode::Western_Pacific: s = "W"; break; + case SubregionCode::None : s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -722,10 +722,10 @@ ConcatString subregioncode_to_string(const SubregionCode t) { SystemsDepth string_to_systemsdepth(const char *s) { SystemsDepth d; - if(strcmp(s, "D") == 0) d = DeepDepth; - else if(strcmp(s, "M") == 0) d = MediumDepth; - else if(strcmp(s, "S") == 0) d = ShallowDepth; - else d = NoSystemsDepth; + if(strcmp(s, "D") == 0) d = SystemsDepth::Deep; + else if(strcmp(s, "M") == 0) d = SystemsDepth::Medium; + else if(strcmp(s, "S") == 0) d = SystemsDepth::Shallow; + else d = SystemsDepth::None; return d; } @@ -736,11 +736,11 @@ ConcatString systemsdepth_to_string(const SystemsDepth t) { const char *s = (const char *) nullptr; switch(t) { - case DeepDepth: s = "D"; break; - case MediumDepth: s = "M"; break; - case ShallowDepth: s = "S"; break; - case NoSystemsDepth: s = na_str; break; - default: s = na_str; break; + case SystemsDepth::Deep: s = "D"; break; + case SystemsDepth::Medium: s = "M"; break; + case SystemsDepth::Shallow: s = "S"; break; + case SystemsDepth::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); diff --git a/src/libcode/vx_tc_util/atcf_track_line.h b/src/libcode/vx_tc_util/atcf_track_line.h index 9fc3896071..e7c9606904 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.h +++ b/src/libcode/vx_tc_util/atcf_track_line.h @@ -26,7 +26,7 @@ //////////////////////////////////////////////////////////////////////// -enum WatchWarnType { +enum class WatchWarnType { TropicalStormWatch, // Tropical Storm Watch TropicalStormWarn, // Tropical Storm Warning @@ -36,7 +36,7 @@ enum WatchWarnType { HurricaneWatch, // Hurricane Watch HurricaneWarn, // Hurricane Warning - NoWatchWarnType + None }; extern WatchWarnType ww_max(const WatchWarnType, const WatchWarnType); @@ -46,7 +46,7 @@ extern ConcatString watchwarntype_to_string(const WatchWarnType); //////////////////////////////////////////////////////////////////////// -enum CycloneLevel { +enum class CycloneLevel { Disturbance, // DB TropicalDepression, // TD TropicalStorm, // TS @@ -67,7 +67,7 @@ enum CycloneLevel { TropicalWave, // WV Extrapolated, // ET - NoCycloneLevel // XX + None // XX }; extern CycloneLevel string_to_cyclonelevel(const char *); @@ -76,20 +76,20 @@ extern CycloneLevel wind_speed_to_cyclonelevel(int); //////////////////////////////////////////////////////////////////////// -enum QuadrantType { +enum class QuadrantType { FullCircle, // AAA - N_Quadrant, // NNQ - E_Quadrant, // EEQ - S_Quadrant, // SSQ - W_Quadrant, // WWQ + N, // NNQ + E, // EEQ + S, // SSQ + W, // WWQ - NE_Quadrant, // NEQ - SE_Quadrant, // SEQ - SW_Quadrant, // SWQ - NW_Quadrant, // NWQ + NE, // NEQ + SE, // SEQ + SW, // SWQ + NW, // NWQ - NoQuadrantType + None }; extern QuadrantType string_to_quadranttype(const char *); @@ -97,7 +97,7 @@ extern ConcatString quadranttype_to_string(const QuadrantType); //////////////////////////////////////////////////////////////////////// -enum SubregionCode { +enum class SubregionCode { Arabian_Sea, // A Bay_of_Bengal, // B Central_Pacific, // C @@ -107,7 +107,7 @@ enum SubregionCode { South_Atlantic, // Q South_IO, // S Western_Pacific, // W - NoSubregionCode + None }; extern SubregionCode string_to_subregioncode(const char *); @@ -115,11 +115,11 @@ extern ConcatString subregioncode_to_string(const SubregionCode); //////////////////////////////////////////////////////////////////////// -enum SystemsDepth { - DeepDepth, // D - MediumDepth, // M - ShallowDepth, // S - NoSystemsDepth // X +enum class SystemsDepth { + Deep, // D + Medium, // M + Shallow, // S + None // X }; extern SystemsDepth string_to_systemsdepth(const char *); diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc index 3bd91a89af..94aeaa01fd 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc @@ -15,6 +15,7 @@ #include #include +#include "enum_as_int.hpp" #include "prob_rirw_pair_info.h" using namespace std; @@ -80,7 +81,7 @@ void ProbRIRWPairInfo::clear() { XErr = YErr = bad_data_double; BBegV = BEndV = bad_data_double; BMinV = BMaxV = bad_data_double; - BBegLev = BEndLev = NoCycloneLevel; + BBegLev = BEndLev = CycloneLevel::None; Line.clear(); return; @@ -102,9 +103,9 @@ void ProbRIRWPairInfo::dump(ostream &out, int indent_depth) const { << prefix << "XErr = " << XErr << "\n" << prefix << "YErr = " << YErr << "\n" << prefix << "BBegV = " << BBegV << "\n" - << prefix << "BBegLev = " << BBegLev << "\n" + << prefix << "BBegLev = " << enum_class_as_int(BBegLev) << "\n" << prefix << "BEndV = " << BEndV << "\n" - << prefix << "BEndLev = " << BEndLev << "\n" + << prefix << "BEndLev = " << enum_class_as_int(BEndLev) << "\n" << prefix << "BMinV = " << BMinV << "\n" << prefix << "BMaxV = " << BMaxV << "\n" << prefix << "ProbRIRW: " << "\n"; diff --git a/src/libcode/vx_tc_util/track_pair_info.cc b/src/libcode/vx_tc_util/track_pair_info.cc index 0a807f2862..2fd84368a7 100644 --- a/src/libcode/vx_tc_util/track_pair_info.cc +++ b/src/libcode/vx_tc_util/track_pair_info.cc @@ -567,7 +567,7 @@ int TrackPairInfo::i_init() const { //////////////////////////////////////////////////////////////////////// WatchWarnType TrackPairInfo::watch_warn(int i) const { - WatchWarnType ww_type = NoWatchWarnType; + WatchWarnType ww_type = WatchWarnType::None; // Only check points common to both the ADECK and BDECK tracks if(!is_bad_data(ADeck[i].lat()) && !is_bad_data(ADeck[i].lon()) && diff --git a/src/libcode/vx_tc_util/track_point.cc b/src/libcode/vx_tc_util/track_point.cc index 09ec2d68a5..6a32d4ac9d 100644 --- a/src/libcode/vx_tc_util/track_point.cc +++ b/src/libcode/vx_tc_util/track_point.cc @@ -230,32 +230,32 @@ void QuadInfo::set_quad_vals(QuadrantType ref_quad, switch(ref_quad) { // Full circle radius is stored in the first radius - case(FullCircle): + case QuadrantType::FullCircle: ALVal = rad1; break; - case(NE_Quadrant): + case QuadrantType::NE: NEVal = rad1; SEVal = rad2; SWVal = rad3; NWVal = rad4; break; - case(SE_Quadrant): + case QuadrantType::SE: NEVal = rad4; SEVal = rad1; SWVal = rad2; NWVal = rad3; break; - case(SW_Quadrant): + case QuadrantType::SW: NEVal = rad3; SEVal = rad4; SWVal = rad1; NWVal = rad2; break; - case(NW_Quadrant): + case QuadrantType::NW: NEVal = rad2; SEVal = rad3; SWVal = rad4; @@ -263,7 +263,7 @@ void QuadInfo::set_quad_vals(QuadrantType ref_quad, break; // Nothing to do - case(NoQuadrantType): + case QuadrantType::None: break; default: @@ -441,7 +441,7 @@ void TrackPoint::clear() { Lon = bad_data_double; Vmax = bad_data_int; MSLP = bad_data_int; - Level = NoCycloneLevel; + Level = CycloneLevel::None; RadP = bad_data_double; RRP = bad_data_double; MRD = bad_data_double; @@ -449,9 +449,9 @@ void TrackPoint::clear() { Eye = bad_data_double; Direction = bad_data_double; Speed = bad_data_double; - Depth = NoSystemsDepth; + Depth = SystemsDepth::None; WarmCore = false; - WatchWarn = NoWatchWarnType; + WatchWarn = WatchWarnType::None; NumMembers = bad_data_int; TrackSpread = bad_data_double; diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/src/tools/tc_utils/tc_pairs/tc_pairs.cc index dacdb25a74..1516d8745d 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -2079,7 +2079,7 @@ void process_watch_warn(TrackPairInfoArray &p) { ww_sid.ws_strip(); // Determine the maximum severity watch/warning in effect - for(i=0, ww_type=NoWatchWarnType; i> dl; diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index 0c29ff4c9d..ec8172776c 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -551,10 +551,10 @@ bool TCStatJob::is_keeper_track(const TrackPairInfo &pair, // HUWARN, TSWARN, HUWATCH, TSWATCH if(TrackWatchWarn.has(watchwarntype_to_string(ww_type)) || (TrackWatchWarn.has("ALL") && - (ww_type == HurricaneWarn || - ww_type == TropicalStormWarn || - ww_type == HurricaneWatch || - ww_type == TropicalStormWatch))) { + (ww_type == WatchWarnType::HurricaneWarn || + ww_type == WatchWarnType::TropicalStormWarn || + ww_type == WatchWarnType::HurricaneWatch || + ww_type == WatchWarnType::TropicalStormWatch))) { keep = true; break; } From aebdd2a5f11d66fcc03251d3a416dbf8d4bc31d6 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 15:40:46 +0000 Subject: [PATCH 056/114] #2830 Changed GenesisPairCategory to enum class --- src/libcode/vx_tc_util/pair_data_genesis.cc | 14 ++++++------- src/libcode/vx_tc_util/pair_data_genesis.h | 12 +++++------ src/libcode/vx_tc_util/tc_stat_line.h | 2 +- src/tools/tc_utils/tc_gen/tc_gen.cc | 20 +++++++++---------- src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc | 16 +++++++-------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/libcode/vx_tc_util/pair_data_genesis.cc b/src/libcode/vx_tc_util/pair_data_genesis.cc index fe03b9bf3a..6eba3517d1 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.cc +++ b/src/libcode/vx_tc_util/pair_data_genesis.cc @@ -31,11 +31,11 @@ ConcatString genesispaircategory_to_string(const GenesisPairCategory c) { const char *s = (const char *) nullptr; switch(c) { - case FYOYGenesis: s = "FYOY"; break; - case FYONGenesis: s = "FYON"; break; - case FNOYGenesis: s = "FNOY"; break; - case DiscardGenesis: s = "DISCARD"; break; - default: s = na_str; break; + case GenesisPairCategory::FYOY: s = "FYOY"; break; + case GenesisPairCategory::FYON: s = "FYON"; break; + case GenesisPairCategory::FNOY: s = "FNOY"; break; + case GenesisPairCategory::Discard: s = "DISCARD"; break; + default: s = na_str; break; } return ConcatString(s); @@ -59,8 +59,8 @@ void GenesisPairDiff::clear() { DevDist = bad_data_double; DevDSec = bad_data_int; OpsDSec = bad_data_int; - DevCategory = NoGenesisPairCategory; - OpsCategory = NoGenesisPairCategory; + DevCategory = GenesisPairCategory::None; + OpsCategory = GenesisPairCategory::None; return; } diff --git a/src/libcode/vx_tc_util/pair_data_genesis.h b/src/libcode/vx_tc_util/pair_data_genesis.h index 8b248e2084..89b0a5b2f6 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.h +++ b/src/libcode/vx_tc_util/pair_data_genesis.h @@ -28,12 +28,12 @@ // //////////////////////////////////////////////////////////////////////// -enum GenesisPairCategory { - FYOYGenesis, // Hit - FYONGenesis, // False Alarm - FNOYGenesis, // Miss - DiscardGenesis, // Discard - NoGenesisPairCategory +enum class GenesisPairCategory { + FYOY, // Hit + FYON, // False Alarm + FNOY, // Miss + Discard, // Discard + None }; extern ConcatString genesispaircategory_to_string(const GenesisPairCategory); diff --git a/src/libcode/vx_tc_util/tc_stat_line.h b/src/libcode/vx_tc_util/tc_stat_line.h index 2e75fda869..276fad1638 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.h +++ b/src/libcode/vx_tc_util/tc_stat_line.h @@ -22,7 +22,7 @@ //////////////////////////////////////////////////////////////////////// // Enumerate all the possible line types -enum TCStatLineType { +enum class TCStatLineType { TCMPR, TCDIAG, diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index b2ca4dc124..04e0b0c408 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -705,8 +705,8 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << ") is a dev and ops FALSE ALARM.\n"; // FALSE ALARM for both methods - diff.DevCategory = FYONGenesis; - diff.OpsCategory = FYONGenesis; + diff.DevCategory = GenesisPairCategory::FYON; + diff.OpsCategory = GenesisPairCategory::FYON; } // Unmatched BEST genesis (MISS) @@ -719,8 +719,8 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << ") is a dev and ops MISS.\n"; // MISS for both methods - diff.DevCategory = FNOYGenesis; - diff.OpsCategory = FNOYGenesis; + diff.DevCategory = GenesisPairCategory::FNOY; + diff.OpsCategory = GenesisPairCategory::FNOY; } // Matched genesis pairs (DISCARD, HIT, or FALSE ALARM) @@ -743,8 +743,8 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << " genesis time.\n"; // DISCARD for both methods - diff.DevCategory = DiscardGenesis; - diff.OpsCategory = DiscardGenesis; + diff.DevCategory = GenesisPairCategory::Discard; + diff.OpsCategory = GenesisPairCategory::Discard; } // Check for a HIT else { @@ -769,14 +769,14 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << " is a dev method HIT " << offset_cs; // HIT for the development method - diff.DevCategory = FYOYGenesis; + diff.DevCategory = GenesisPairCategory::FYOY; } else { mlog << Debug(4) << case_cs << " is a dev method FALSE ALARM " << offset_cs; // FALSE ALARM for the development method - diff.DevCategory = FYONGenesis; + diff.DevCategory = GenesisPairCategory::FYON; } // Compute init/genesis time offset @@ -796,14 +796,14 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << " is an ops method HIT " << offset_cs; // HIT for the operational method - diff.OpsCategory = FYOYGenesis; + diff.OpsCategory = GenesisPairCategory::FYOY; } else { mlog << Debug(4) << case_cs << " is an ops method FALSE ALARM " << offset_cs; // FALSE ALARM for the operational method - diff.OpsCategory = FYONGenesis; + diff.OpsCategory = GenesisPairCategory::FYON; } } } diff --git a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc index 274d70d73d..115dad74f6 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc @@ -1067,11 +1067,11 @@ void GenCTCInfo::inc_dev(GenesisPairCategory c, const GenesisInfo *bgi) { // Discard - if(c == DiscardGenesis) { + if(c == GenesisPairCategory::Discard) { return; } // Hits - else if(c == FYOYGenesis) { + else if(c == GenesisPairCategory::FYOY) { CTSDev.cts.inc_fy_oy(); inc_pnt(fgi->lat(), fgi->lon(), fdev_fyoy_str); BestDevHitMap[bgi] += 1; @@ -1082,12 +1082,12 @@ void GenCTCInfo::inc_dev(GenesisPairCategory c, } } // False Alarms - else if(c == FYONGenesis) { + else if(c == GenesisPairCategory::FYON) { CTSDev.cts.inc_fy_on(); inc_pnt(fgi->lat(), fgi->lon(), fdev_fyon_str); } // Misses - else if(c == FNOYGenesis) { + else if(c == GenesisPairCategory::FNOY) { CTSDev.cts.inc_fn_oy(); // Count all BEST track genesis pairs @@ -1110,11 +1110,11 @@ void GenCTCInfo::inc_ops(GenesisPairCategory c, const GenesisInfo *bgi) { // Discard - if(c == DiscardGenesis) { + if(c == GenesisPairCategory::Discard) { return; } // Hits - else if(c == FYOYGenesis) { + else if(c == GenesisPairCategory::FYOY) { CTSOps.cts.inc_fy_oy(); inc_pnt(fgi->lat(), fgi->lon(), fops_fyoy_str); BestOpsHitMap[bgi] += 1; @@ -1125,12 +1125,12 @@ void GenCTCInfo::inc_ops(GenesisPairCategory c, } } // False Alarms - else if(c == FYONGenesis) { + else if(c == GenesisPairCategory::FYON) { CTSOps.cts.inc_fy_on(); inc_pnt(fgi->lat(), fgi->lon(), fops_fyon_str); } // Misses - else if(c == FNOYGenesis) { + else if(c == GenesisPairCategory::FNOY) { CTSOps.cts.inc_fn_oy(); // Count all BEST track genesis pairs From 00380dc5845eaea0a5c68fdecdd546f72d778cae Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 17:21:20 +0000 Subject: [PATCH 057/114] #2830 Removed rediundabt parenrthese --- src/basic/vx_util/interp_util.cc | 76 ++++++++++++++++---------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index aeb08d31ae..b5cb88c412 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -960,61 +960,61 @@ double compute_sfc_interp(const DataPlane &dp, // Compute the interpolated value for the fields above and below switch(mthd) { - case(InterpMthd::Min): // Minimum + case InterpMthd::Min: // Minimum v = interp_min(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd::Max): // Maximum + case InterpMthd::Max: // Maximum v = interp_max(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd::Median): // Median + case InterpMthd::Median: // Median v = interp_median(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd::UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd::DW_Mean): // Distance-Weighted Mean + case InterpMthd::DW_Mean: // Distance-Weighted Mean v = interp_dw_mean(dp, *gt, obs_x, obs_y, dw_mean_pow, interp_thresh, &sfc_mask); break; - case(InterpMthd::LS_Fit): // Least-squares fit + case InterpMthd::LS_Fit: // Least-squares fit v = interp_ls_fit(dp, *gt, obs_x, obs_y, interp_thresh, &sfc_mask); break; - case(InterpMthd::Bilin): // Bilinear interpolation + case InterpMthd::Bilin: // Bilinear interpolation v = interp_bilin(dp, wrap_lon, obs_x, obs_y, &sfc_mask); break; - case(InterpMthd::Nearest): // Nearest Neighbor + case InterpMthd::Nearest: // Nearest Neighbor v = interp_xy(dp, wrap_lon, x, y, &sfc_mask); break; - case(InterpMthd::Best): // Best Match + case InterpMthd::Best: // Best Match v = interp_best(dp, *gt, x, y, obs_v, interp_thresh, &sfc_mask); break; - case(InterpMthd::Upper_Left): // Upper Left corner of the grid box + case InterpMthd::Upper_Left: // Upper Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), ceil(obs_y), &sfc_mask); break; - case(InterpMthd::Upper_Right): // Upper Right corner of the grid box + case InterpMthd::Upper_Right: // Upper Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), ceil(obs_y), &sfc_mask); break; - case(InterpMthd::Lower_Right): // Lower Right corner of the grid box + case InterpMthd::Lower_Right: // Lower Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), floor(obs_y), &sfc_mask); break; - case(InterpMthd::Lower_Left): // Lower Left corner of the grid box + case InterpMthd::Lower_Left: // Lower Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), floor(obs_y), &sfc_mask); break; - case(InterpMthd::Geog_Match): // Geography Match for surface point verification + case InterpMthd::Geog_Match: // Geography Match for surface point verification v = interp_geog_match(dp, *gt, obs_x, obs_y, obs_v, &sfc_mask); break; @@ -1129,66 +1129,66 @@ double compute_horz_interp(const DataPlane &dp, // Compute the interpolated value for the fields above and below switch(mthd) { - case(InterpMthd::Min): // Minimum + case InterpMthd::Min: // Minimum v = interp_min(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd::Max): // Maximum + case InterpMthd::Max: // Maximum v = interp_max(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd::Median): // Median + case InterpMthd::Median: // Median v = interp_median(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd::UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd::DW_Mean): // Distance-Weighted Mean + case InterpMthd::DW_Mean: // Distance-Weighted Mean v = interp_dw_mean(dp, *gt, obs_x, obs_y, dw_mean_pow, interp_thresh); break; - case(InterpMthd::LS_Fit): // Least-squares fit + case InterpMthd::LS_Fit: // Least-squares fit v = interp_ls_fit(dp, *gt, obs_x, obs_y, interp_thresh); break; - case(InterpMthd::Nbrhd): // Neighborhood fractional coverage + case InterpMthd::Nbrhd: // Neighborhood fractional coverage v = interp_nbrhd(dp, *gt, x, y, interp_thresh, cat_thresh, cmn, csd); break; - case(InterpMthd::Bilin): // Bilinear interpolation + case InterpMthd::Bilin: // Bilinear interpolation v = interp_bilin(dp, wrap_lon, obs_x, obs_y); break; - case(InterpMthd::Nearest): // Nearest Neighbor + case InterpMthd::Nearest: // Nearest Neighbor v = interp_xy(dp, wrap_lon, x, y); break; - case(InterpMthd::Best): // Best Match + case InterpMthd::Best: // Best Match v = interp_best(dp, *gt, x, y, obs_v, interp_thresh); break; - case(InterpMthd::Upper_Left): // Upper Left corner of the grid box + case InterpMthd::Upper_Left: // Upper Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), ceil(obs_y)); break; - case(InterpMthd::Upper_Right): // Upper Right corner of the grid box + case InterpMthd::Upper_Right: // Upper Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), ceil(obs_y)); break; - case(InterpMthd::Lower_Right): // Lower Right corner of the grid box + case InterpMthd::Lower_Right: // Lower Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), floor(obs_y)); break; - case(InterpMthd::Lower_Left): // Lower Left corner of the grid box + case InterpMthd::Lower_Left: // Lower Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), floor(obs_y)); break; - case(InterpMthd::Geog_Match): // Geography Match for surface point verification + case InterpMthd::Geog_Match: // Geography Match for surface point verification v = interp_geog_match(dp, *gt, obs_x, obs_y, obs_v); break; @@ -1310,33 +1310,33 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, // Compute interpolation weights switch(mthd) { - case(InterpMthd::Min): // Minimum - case(InterpMthd::Max): // Maximum + case InterpMthd::Min: // Minimum + case InterpMthd::Max: // Maximum w1 = w2 = bad_data_double; break; - case(InterpMthd::UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean w1 = w2 = 0.5; break; - case(InterpMthd::DW_Mean): // Distance-Weighted Mean + case InterpMthd::DW_Mean: // Distance-Weighted Mean w1 = (double) (dp2.valid() - to_ut) / (dp2.valid() - dp1.valid()); w2 = (double) (to_ut - dp1.valid()) / (dp2.valid() - dp1.valid()); break; - case(InterpMthd::Nearest): // Nearest Neighbor + case InterpMthd::Nearest: // Nearest Neighbor use_min = ((to_ut - dp1.valid()) <= (dp2.valid() - to_ut)); w1 = (use_min ? 1.0 : 0.0); w2 = (use_min ? 0.0 : 1.0); break; - case(InterpMthd::AW_Mean): // Area-Weighted Mean - case(InterpMthd::Median): // Median - case(InterpMthd::LS_Fit): // Least-squares fit - case(InterpMthd::Bilin): // Bilinear interpolation + case InterpMthd::AW_Mean: // Area-Weighted Mean + case InterpMthd::Median: // Median + case InterpMthd::LS_Fit: // Least-squares fit + case InterpMthd::Bilin: // Bilinear interpolation default: mlog << Error << "\nvalid_time_interp() -> " << "unsupported interpolation method encountered: " From 42c453ea246f2033db912b59bb5e5a6fd883b2bd Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 17:22:12 +0000 Subject: [PATCH 058/114] #2830 Reduced same if checking --- src/libcode/vx_analysis_util/stat_job.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index df2335067a..616c24e62b 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -2799,8 +2799,8 @@ ConcatString STATAnalysisJob::get_jobstring() const { } } - // Jobs which use out_eclv_points if(line_type.n() > 0) { + // Jobs which use out_eclv_points if(string_to_statlinetype(line_type[0].c_str()) == STATLineType::mpr && out_line_type.has(stat_eclv_str)) { @@ -2809,10 +2809,8 @@ ConcatString STATAnalysisJob::get_jobstring() const { js << "-out_eclv_points " << out_eclv_points[i] << " "; } } - } - // Jobs which perform bootstrapping - if(line_type.n() > 0) { + // Jobs which perform bootstrapping type = string_to_statlinetype(line_type[0].c_str()); if(type == STATLineType::mpr && (out_line_type.has(stat_cts_str) || From 2bd5dcf2f61adcae3acc01efa7bf854162e26889 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 17:23:51 +0000 Subject: [PATCH 059/114] #2830 Cleanup --- src/libcode/vx_analysis_util/stat_job.h | 2 +- src/libcode/vx_plot_util/vx_plot_util.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 0916056e19..208c6d4894 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -70,7 +70,7 @@ enum class STATJobType { containing the aggregated counts/scores. */ aggr_stat = 3, /* Aggregate the input counts/scores and - // generate the requested output line type. */ + generate the requested output line type. */ go_index = 4, /* Compute the GO Index. */ diff --git a/src/libcode/vx_plot_util/vx_plot_util.h b/src/libcode/vx_plot_util/vx_plot_util.h index f6aee66625..4d8aedfe7d 100644 --- a/src/libcode/vx_plot_util/vx_plot_util.h +++ b/src/libcode/vx_plot_util/vx_plot_util.h @@ -37,7 +37,7 @@ //////////////////////////////////////////////////////////////////////////////// -//enum Projection {satellite, lambert, mercator} Projection; +/* enum Projection {satellite, lambert, mercator} Projection; */ //////////////////////////////////////////////////////////////////////////////// From 1f32746d54716acf5a48c8f7b9373def1d896182 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 17:24:22 +0000 Subject: [PATCH 060/114] #2830 USe empty() instead of lebgth checking --- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 621a48ec92..e4c14b557b 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -334,7 +334,7 @@ void process_mask_file(DataPlane &dp) { // For solar masking, parse the valid time from gridded data if(is_solar_masktype(mask_type) && solar_ut == (unixtime) 0) { - if(mask_field_str.length() == 0) { + if(mask_field_str.empty()) { mlog << Error << "\nprocess_mask_file() -> " << "use \"-mask_field\" to specify the data whose valid " << "time should be used for \"solar_alt\" and " @@ -349,7 +349,7 @@ void process_mask_file(DataPlane &dp) { } // Check that mask_field has been set for data masking - if(mask_type == MaskType::Data && mask_field_str.length() == 0) { + if(mask_type == MaskType::Data && mask_field_str.empty()) { mlog << Error << "\nprocess_mask_file() -> " << "use \"-mask_field\" to specify the field for " << "\"data\" masking.\n\n"; From 08117402350d4c78b891c78b558a212065b22e88 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 5 Apr 2024 20:00:04 +0000 Subject: [PATCH 061/114] #2830 Adjusted indentations --- src/libcode/vx_analysis_util/stat_job.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 616c24e62b..573c0f43d6 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -1706,7 +1706,7 @@ int STATAnalysisJob::set_job_type(const char *c) { job_type = string_to_statjobtype(c); if(job_type == STATJobType::None) return 1; - else return 0; + else return 0; } //////////////////////////////////////////////////////////////////////// @@ -2726,7 +2726,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Jobs which use out_alpha - if(job_type == STATJobType::summary || + if(job_type == STATJobType::summary || out_line_type.has(stat_cts_str) || out_line_type.has(stat_mcts_str) || out_line_type.has(stat_cnt_str) || From e71debf96065a7e43e7e861258fab473f34ac382 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Apr 2024 09:37:29 -0600 Subject: [PATCH 062/114] Feature #2379 develop sonarqube updates (#2850) * Per #2379, move rgb2ctable.py into the python utility scripts directory for better organization and to enable convenient SonarQube scanning. * Per #2379, remove point.py from the vx_python3_utils directory which cleary was inadvertenlty added during development 4 years ago. As far as I can tell it isn't being called by any other code and doesn't belong in the repository. Note that scripts/python/met/point.py has the same name but is entirely different. * Per #2379, update the GHA SonarQube scan to do a single one with Python and C++ combined. The nightly build script is still doing 2 separate scans for now. If this all works well, they could also be combined into a single one. * Per #2379, eliminate MET_CONFIG_OPTIONS from the SonarQube workflow since it doesn't need to be and probably shouldn't be configurable. * Per #2379, trying to copy report-task.txt out of the image * Per #2379, update build_met_sonarqube.sh to check the scan return status * Per #2379, fix bash assignment syntax * Per #2379, remove unused SCRIPT_DIR envvar * Per #2379, switch to a single SonarQube scan for MET's nightly build as well --- .github/jobs/build_sonarqube_image.sh | 5 +- .github/workflows/sonarqube.yml | 18 +----- internal/scripts/docker/Dockerfile.sonarqube | 1 - .../scripts/docker/build_met_sonarqube.sh | 62 +++++++------------ .../sonarqube/python.sonar-project.properties | 17 ----- internal/scripts/sonarqube/run_sonarqube.sh | 44 +++++-------- .../sonarqube/sonar-project.properties | 16 +++-- .../python/utility}/rgb2ctable.py | 0 src/libcode/vx_python3_utils/point.py | 39 ------------ 9 files changed, 49 insertions(+), 153 deletions(-) delete mode 100644 internal/scripts/sonarqube/python.sonar-project.properties rename {data/colortables/NCL_colortables => scripts/python/utility}/rgb2ctable.py (100%) delete mode 100644 src/libcode/vx_python3_utils/point.py diff --git a/.github/jobs/build_sonarqube_image.sh b/.github/jobs/build_sonarqube_image.sh index 9cdeea3395..55d558624b 100755 --- a/.github/jobs/build_sonarqube_image.sh +++ b/.github/jobs/build_sonarqube_image.sh @@ -28,7 +28,6 @@ time_command docker build -t ${DOCKERHUB_TAG} \ --build-arg MET_BASE_REPO \ --build-arg MET_BASE_TAG \ --build-arg SOURCE_BRANCH \ - --build-arg MET_CONFIG_OPTS \ --build-arg SONAR_SCANNER_VERSION \ --build-arg SONAR_HOST_URL \ --build-arg SONAR_TOKEN \ @@ -41,6 +40,6 @@ fi # Copy the .scannerwork directory from the image id=$(docker create ${DOCKERHUB_TAG}) -time_command docker cp $id:/met/.scannerwork /tmp/met_scannerwork +time_command mkdir -p /tmp/scannerwork +time_command docker cp $id:/met/.scannerwork/report-task.txt /tmp/scannerwork/report-task.txt docker rm -v $id - diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 36c2ccc02d..6a6627fb69 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -64,26 +64,15 @@ jobs: MET_BASE_TAG: v3.2 SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }} WD_REFERENCE_BRANCH: ${{ github.event.inputs.reference_branch }} - MET_CONFIG_OPTS: '--enable-all' SONAR_SCANNER_VERSION: 5.0.1.3006 SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: SonarQube Python Quality Gate check - id: sonarqube-python-quality-gate-check + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master with: - scanMetadataReportFile: /tmp/met_scannerwork/python-report-task.txt - timeout-minutes: 5 - env: - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - name: SonarQube CXX Quality Gate check - id: sonarqube-cxx-quality-gate-check - uses: sonarsource/sonarqube-quality-gate-action@master - with: - scanMetadataReportFile: /tmp/met_scannerwork/cxx-report-task.txt + scanMetadataReportFile: /tmp/scannerwork/report-task.txt timeout-minutes: 5 env: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} @@ -100,4 +89,3 @@ jobs: name: logs_sonarqube path: ${{ runner.workspace }}/logs if-no-files-found: ignore - diff --git a/internal/scripts/docker/Dockerfile.sonarqube b/internal/scripts/docker/Dockerfile.sonarqube index 156fa14bf7..75dc3c952c 100644 --- a/internal/scripts/docker/Dockerfile.sonarqube +++ b/internal/scripts/docker/Dockerfile.sonarqube @@ -92,4 +92,3 @@ RUN if [ ! -e "${MET_REPO_DIR}/configure.ac" ]; then \ RUN cd ${MET_REPO_DIR} \ && internal/scripts/docker/build_met_sonarqube.sh - diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index f726d8b3b9..45e1d10fc5 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -5,7 +5,7 @@ # # This build_met_sonarqube.sh script must be run from the top-level # directory of the MET repository to be analyzed. It runs SonarQube to -# scan both the Python and C/C++ MET source code. +# scan the MET source code. # # Usage: internal/scripts/docker/build_met_sonarqube.sh # @@ -48,12 +48,6 @@ if [ -z ${SONAR_REFERENCE_BRANCH+x} ]; then exit 1 fi -# Check whether MET_CONFIG_OPTS is defined -if [ -z ${MET_CONFIG_OPTS+x} ]; then - MET_CONFIG_OPTS='--enable-all' - echo "Setting MET_CONFIG_OPTS=${MET_CONFIG_OPTS} to scan all available options." -fi - # Locate the wrapper WRAPPER_NAME=build-wrapper-linux-x86-64 SONAR_WRAPPER=$(which $WRAPPER_NAME 2> /dev/null) @@ -81,52 +75,33 @@ if [ -z ${SONARQUBE_OUT_DIR} ]; then export SONARQUBE_OUT_DIR=bw-outputs fi +# Define the version string +SONAR_PROJECT_VERSION=$(cat docs/version | cut -d'=' -f2 | tr -d '" ') + # Store the full path to the scripts directory SONAR_PROPERTIES_DIR=internal/scripts/sonarqube SONAR_PROPERTIES=sonar-project.properties -# Copy sonar-project.properties for Python code +# Configure the sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ +sed -e "s|SONAR_PROJECT_KEY|MET-GHA|" \ + -e "s|SONAR_PROJECT_NAME|MET GHA|" \ + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET-GHA-Python|" \ - -e "s|SONAR_PROJECT_NAME|MET GHA Python|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ - -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ - $SONAR_PROPERTIES_DIR/python.sonar-project.properties > $SONAR_PROPERTIES + $SONAR_PROPERTIES_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES # The source and reference branches must differ to define new code if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES fi - -# Run SonarQube scan for Python code -time_command $SONAR_SCANNER - -# Copy the Python scan report-task.txt file -mkdir -p /met/.scannerwork -cp .scannerwork/report-task.txt /met/.scannerwork/python-report-task.txt - -# Copy sonar-project.properties for C/C++ code -[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET-GHA-CXX|" \ - -e "s|SONAR_PROJECT_NAME|MET GHA CXX|" \ - -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ - -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ - $SONAR_PROPERTIES_DIR/sonar-project.properties > $SONAR_PROPERTIES -# The source and reference branches must differ to define new code -if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then - echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES -fi - -# Run the configure script +# Run the MET configure script time_command ./configure \ BUFRLIB_NAME=${BUFRLIB_NAME} \ GRIB2CLIB_NAME=${GRIB2CLIB_NAME} \ - ${MET_CONFIG_OPTS} \ + --enable-all \ CPPFLAGS="-I/usr/local/include -I/usr/local/include/freetype2 -I/usr/local/include/cairo" \ LIBS="-ltirpc" @@ -136,11 +111,18 @@ time_command make clean # Run SonarQube make time_command $SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make -# Run SonarQube scan for C/C++ code +# Run SonarQube scan time_command $SONAR_SCANNER +status=$? + +# Check return status +if [[ $status -ne 0 ]]; then + echo "ERROR: ${0} -> the SonarQube scan returned with non-zero status (${status})!" + exit ${status} +fi -# Copy the C/C++ scan report-task.txt file +# Copy the scan report-task.txt file mkdir -p /met/.scannerwork -cp .scannerwork/report-task.txt /met/.scannerwork/cxx-report-task.txt +cp .scannerwork/report-task.txt /met/.scannerwork/report-task.txt [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES diff --git a/internal/scripts/sonarqube/python.sonar-project.properties b/internal/scripts/sonarqube/python.sonar-project.properties deleted file mode 100644 index 71b6b36b71..0000000000 --- a/internal/scripts/sonarqube/python.sonar-project.properties +++ /dev/null @@ -1,17 +0,0 @@ -sonar.projectKey=SONAR_PROJECT_KEY -sonar.projectName=SONAR_PROJECT_NAME -sonar.projectVersion=1.0 - -sonar.sources=scripts/python,data/wrappers -sonar.python.version=3.6.3 - -# The build-wrapper output dir - -# Encoding of the source files -sonar.sourceEncoding=UTF-8 - -#----- Default SonarQube server -sonar.host.url=SONAR_HOST_URL - -sonar.token=SONAR_TOKEN -sonar.branch.name=SONAR_BRANCH_NAME diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 917158b461..1a57b0b726 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -24,10 +24,10 @@ GIT_REPO="https://github.com/dtcenter/${GIT_REPO_NAME}" function usage { - echo - echo "USAGE: $(basename $0) name" - echo " where \"name\" specifies a branch, tag, or hash." - echo + echo + echo "USAGE: $(basename $0) name" + echo " where \"name\" specifies a branch, tag, or hash." + echo } # Check for arguments @@ -90,7 +90,6 @@ function run_command() { return ${STATUS} } - # Store the full path to the scripts directory SCRIPT_DIR=`dirname $0` if [[ ${0:0:1} != "/" ]]; then SCRIPT_DIR=$(pwd)/${SCRIPT_DIR}; fi @@ -113,48 +112,35 @@ export MET_DEVELOPMENT=true # Run the configure script run_command "./configure --prefix=`pwd` --enable-all" -# Set the build id -#BUILD_ID="MET-${1}" +# Define the version string +SONAR_PROJECT_VERSION=$(grep "^version" docs/conf.py | cut -d'=' -f2 | tr -d "\'\" ") SONAR_PROPERTIES=sonar-project.properties -# Copy sonar-project.properties for Python code +# Configure sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES [ -z "$SONAR_HOST_URL" ] && SONAR_HOST_URL="http://localhost:9000" if [ -z "$SONAR_TOKEN" ]; then echo " == ERROR == SONAR_TOKEN is not defined" exit 1 else - sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET_python_NB|" \ - -e "s|SONAR_PROJECT_NAME|MET python Nightly Build|" \ - -e "s|SONAR_BRANCH_NAME|develop|" \ - $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES - - # Run SonarQube scan for Python code - run_command "$SONAR_SCANNER" - - # Copy sonar-project.properties for C/C++ code [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES - sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET_develop_NB|" \ + sed -e "s|SONAR_PROJECT_KEY|MET_NB|" \ -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ - -e "s|SONAR_BRANCH_NAME|develop|" \ - $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_BRANCH_NAME|${1}|" \ + $SCRIPT_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES # Run SonarQube clean run_command "make clean" - # Run SonarQube make + # Run SonarQube build wrapper run_command "$SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make" - # Run SonarQube scan for C/C++ code + # Run SonarQube scan run_command "$SONAR_SCANNER" [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES fi - -# Run SonarQube report generator to make a PDF file -#TODAY=`date +%Y%m%d` diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index c09f1d31b1..215749e75b 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -1,17 +1,15 @@ +# Project and source code settings sonar.projectKey=SONAR_PROJECT_KEY sonar.projectName=SONAR_PROJECT_NAME -sonar.projectVersion=1.0 - -sonar.sources=src +sonar.projectVersion=SONAR_PROJECT_VERSION +sonar.branch.name=SONAR_BRANCH_NAME +sonar.sources=src,scripts/python,data/wrappers +sonar.python.version=3.6.3 +sonar.sourceEncoding=UTF-8 # The build-wrapper output dir sonar.cfamily.build-wrapper-output=bw-outputs -# Encoding of the source files -sonar.sourceEncoding=UTF-8 - -#----- Default SonarQube server +# SonarQube server sonar.host.url=SONAR_HOST_URL - sonar.token=SONAR_TOKEN -sonar.branch.name=SONAR_BRANCH_NAME diff --git a/data/colortables/NCL_colortables/rgb2ctable.py b/scripts/python/utility/rgb2ctable.py similarity index 100% rename from data/colortables/NCL_colortables/rgb2ctable.py rename to scripts/python/utility/rgb2ctable.py diff --git a/src/libcode/vx_python3_utils/point.py b/src/libcode/vx_python3_utils/point.py deleted file mode 100644 index 699aa46e51..0000000000 --- a/src/libcode/vx_python3_utils/point.py +++ /dev/null @@ -1,39 +0,0 @@ - - -############################################################### - - -import sys - - -############################################################### - -print ('============= start point.py ===========') - -print (sys.argv) - - -############################################################### - - -point_data = [[ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 7, 837.0, 1618, 'NA', 1618 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 11, 837.0, 1618, 'NA', 273.05 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 17, 837.0, 1618, 'NA', 271.85 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 52, 837.0, 1618, 'NA', 92 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 53, 837.0, 1618, 'NA', 0.00417 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 7, 826.0, 1724, 'NA', 1724 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 11, 826.0, 1724, 'NA', 274.55 ]] - - -############################################################### - - -print (point_data) - - -print ('============= end point.py ===========') - - -############################################################### - - From 2a26d5927204c3521bf53094d3efdfb4e6d6aef3 Mon Sep 17 00:00:00 2001 From: davidalbo Date: Wed, 10 Apr 2024 09:09:42 -0600 Subject: [PATCH 063/114] Feature 2654 ascii2nc polar buoy support (#2846) * Added iabp data type, and modified file_handler to filter based on time range, which was added as a command line option * handle time using input year, hour, min, and doy * cleanup and switch to position day of year for time computations * Added an ascii2nc unit test for iabp data * Added utility scripts to pull iabp data from the web and find files in a time range * Modified iabp_handler to always output a placeholder 'location' observation with value 1 * added description of IABP data python utility scripts * Fixed syntax error * Fixed Another syntax error. * Slight reformat of documentation * Per #2654, update the Makefiles in scripts/python/utility to include all the python scripts that should be installed. * Per #2654, remove unused code from get_iabp_from_web.py that is getting flagged as a bug by SonarQube. * Per #2654, fix typo in docs --------- Co-authored-by: John Halley Gotway Co-authored-by: MET Tools Test Account --- docs/Users_Guide/reformat_point.rst | 53 +++- internal/test_unit/xml/unit_ascii2nc.xml | 15 + scripts/python/utility/Makefile.am | 5 +- scripts/python/utility/Makefile.in | 5 +- .../python/utility/find_iabp_in_timerange.py | 241 ++++++++++++++++ scripts/python/utility/get_iabp_from_web.py | 235 +++++++++++++++ scripts/python/utility/rgb2ctable.py | 0 src/tools/other/ascii2nc/Makefile.am | 1 + src/tools/other/ascii2nc/Makefile.in | 26 +- src/tools/other/ascii2nc/ascii2nc.cc | 73 ++++- src/tools/other/ascii2nc/file_handler.cc | 51 +++- src/tools/other/ascii2nc/file_handler.h | 9 +- src/tools/other/ascii2nc/iabp_handler.cc | 273 ++++++++++++++++++ src/tools/other/ascii2nc/iabp_handler.h | 133 +++++++++ 14 files changed, 1105 insertions(+), 15 deletions(-) create mode 100755 scripts/python/utility/find_iabp_in_timerange.py create mode 100755 scripts/python/utility/get_iabp_from_web.py mode change 100644 => 100755 scripts/python/utility/rgb2ctable.py create mode 100644 src/tools/other/ascii2nc/iabp_handler.cc create mode 100644 src/tools/other/ascii2nc/iabp_handler.h diff --git a/docs/Users_Guide/reformat_point.rst b/docs/Users_Guide/reformat_point.rst index 32695f36b0..ec09fa3f83 100644 --- a/docs/Users_Guide/reformat_point.rst +++ b/docs/Users_Guide/reformat_point.rst @@ -458,6 +458,8 @@ While initial versions of the ASCII2NC tool only supported a simple 11 column AS • `International Soil Moisture Network (ISMN) Data format `_. +• `International Arctic Buoy Programme (IABP) Data format `_. + • `AErosol RObotic NEtwork (AERONET) versions 2 and 3 format `_ • Python embedding of point observations, as described in :numref:`pyembed-point-obs-data`. See example below in :numref:`ascii2nc-pyembed`. @@ -522,6 +524,8 @@ Once the ASCII point observations have been formatted as expected, the ASCII fil netcdf_file [-format ASCII_format] [-config file] + [-valid_beg time] + [-valid_end time] [-mask_grid string] [-mask_poly file] [-mask_sid file|list] @@ -541,21 +545,25 @@ Required Arguments for ascii2nc Optional Arguments for ascii2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3. The **-format ASCII_format** option may be set to "met_point", "little_r", "surfrad", "wwsis", "airnowhourlyaqobs", "airnowhourly", "airnowdaily_v2", "ndbc_standard", "ismn", "aeronet", "aeronetv2", "aeronetv3", or "python". If passing in ISIS data, use the "surfrad" format flag. +3. The **-format ASCII_format** option may be set to "met_point", "little_r", "surfrad", "wwsis", "airnowhourlyaqobs", "airnowhourly", "airnowdaily_v2", "ndbc_standard", "ismn", "iabp", "aeronet", "aeronetv2", "aeronetv3", or "python". If passing in ISIS data, use the "surfrad" format flag. 4. The **-config file** option is the configuration file for generating time summaries. -5. The **-mask_grid** string option is a named grid or a gridded data file to filter the point observations spatially. +5. The **-valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the retention time window. -6. The **-mask_poly** file option is a polyline masking file to filter the point observations spatially. +6. The **-valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the retention time window. -7. The **-mask_sid** file|list option is a station ID masking file or a comma-separated list of station ID's to filter the point observations spatially. See the description of the "sid" entry in :numref:`config_options`. +7. The **-mask_grid** string option is a named grid or a gridded data file to filter the point observations spatially. -8. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. +8. The **-mask_poly** file option is a polyline masking file to filter the point observations spatially. -9. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. +9. The **-mask_sid** file|list option is a station ID masking file or a comma-separated list of station ID's to filter the point observations spatially. See the description of the "sid" entry in :numref:`config_options`. -10. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. +10. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. + +11. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. + +12. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. An example of the ascii2nc calling sequence is shown below: @@ -1203,3 +1211,34 @@ For how to use the script, issue the command: .. code-block:: none python3 MET_BASE/python/utility/print_pointnc2ascii.py -h + +IABP retrieval Python Utilities +==================================== + +`International Arctic Buoy Programme (IABP) Data `_ is one of the data types supported by ascii2nc. A utility script that pulls all this data from the web and stores it locally, called get_iabp_from_web.py is included. This script accesses the appropriate webpage and downloads the ascii files for all buoys. It is straightforward, but can be time intensive as the archive of this data is extensive and files are downloaded one at a time. + +The script can be found at: + +.. code-block:: none + + MET_BASE/python/utility/get_iabp_from_web.py + +For how to use the script, issue the command: + +.. code-block:: none + + python3 MET_BASE/python/utility/get_iabp_from_web.py -h + +Another IABP utility script is included for users, to be run after all files have been downloaded using get_iabp_from_web.py. This script examines all the files and lists those files that contain entries that fall within a user specified range of days. It is called find_iabp_in_timerange.py. + +The script can be found at: + +.. code-block:: none + + MET_BASE/python/utility/find_iabp_in_timerange.py + +For how to use the script, issue the command: + +.. code-block:: none + + python3 MET_BASE/python/utility/find_iabp_in_timerange.py -h diff --git a/internal/test_unit/xml/unit_ascii2nc.xml b/internal/test_unit/xml/unit_ascii2nc.xml index 2dd9df07e7..4424fd0e33 100644 --- a/internal/test_unit/xml/unit_ascii2nc.xml +++ b/internal/test_unit/xml/unit_ascii2nc.xml @@ -211,4 +211,19 @@ + + &MET_BIN;/ascii2nc + \ + -format iabp \ + -valid_beg 20140101 -valid_end 20140201 \ + &DATA_DIR_OBS;/iabp/090629.dat \ + &DATA_DIR_OBS;/iabp/109320.dat \ + &DATA_DIR_OBS;/iabp/109499.dat \ + &OUTPUT_DIR;/ascii2nc/iabp_20140101_20140201.nc + + + &OUTPUT_DIR;/ascii2nc/iabp_20140101_20140201.nc + + + diff --git a/scripts/python/utility/Makefile.am b/scripts/python/utility/Makefile.am index 5efd02b01e..2509cff62b 100644 --- a/scripts/python/utility/Makefile.am +++ b/scripts/python/utility/Makefile.am @@ -26,8 +26,11 @@ pythonutilitydir = $(pkgdatadir)/python/utility pythonutility_DATA = \ + build_ndbc_stations_from_web.py \ + find_iabp_in_timerange.py \ + get_iabp_from_web.py \ print_pointnc2ascii.py \ - build_ndbc_stations_from_web.py + rgb2ctable.py EXTRA_DIST = ${pythonutility_DATA} diff --git a/scripts/python/utility/Makefile.in b/scripts/python/utility/Makefile.in index 4c379b52a6..0b977854db 100644 --- a/scripts/python/utility/Makefile.in +++ b/scripts/python/utility/Makefile.in @@ -311,8 +311,11 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pythonutilitydir = $(pkgdatadir)/python/utility pythonutility_DATA = \ + build_ndbc_stations_from_web.py \ + find_iabp_in_timerange.py \ + get_iabp_from_web.py \ print_pointnc2ascii.py \ - build_ndbc_stations_from_web.py + rgb2ctable.py EXTRA_DIST = ${pythonutility_DATA} MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/python/utility/find_iabp_in_timerange.py b/scripts/python/utility/find_iabp_in_timerange.py new file mode 100755 index 0000000000..3aa76d1eff --- /dev/null +++ b/scripts/python/utility/find_iabp_in_timerange.py @@ -0,0 +1,241 @@ + #!/usr/bin/env python3 + +from optparse import OptionParser +import urllib.request +import datetime +from datetime import date +import os +import shutil +import shlex +import errno +from subprocess import Popen, PIPE + + + +#---------------------------------------------- +def usage(): + print("Usage: find_iabp_in_timerange.py -s yyyymmdd -e yyyymmdd [-d PATH]") + +#---------------------------------------------- +def is_date_in_range(input_date, start_date, end_date): + return start_date <= input_date <= end_date + +#---------------------------------------------- +def lookFor(name, inlist, filename, printWarning=False): + rval = -1 + try: + rval = inlist.index(name) + except: + if printWarning: + print(name, " not in header line, file=", filename) + + return rval + +#---------------------------------------------- +def pointToInt(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -1 + return int(tokens[index]) + +#---------------------------------------------- +def pointToFloat(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -99.99 + return float(tokens[index]) + +#---------------------------------------------- +class StationHeader: + def __init__(self, headerLine, filename): + tokens = headerLine.split() + self._ok = True + self._idIndex = lookFor('BuoyID', tokens, filename, True) + self._yearIndex = lookFor('Year', tokens, filename, True) + self._hourIndex = lookFor('Hour', tokens, filename, True) + self._minuteIndex = lookFor('Min', tokens, filename, True) + self._doyIndex = lookFor('DOY', tokens, filename, True) + self._posdoyIndex = lookFor('POS_DOY', tokens, filename, True) + self._latIndex = lookFor('Lat', tokens, filename, True) + self._lonIndex = lookFor('Lon', tokens, filename, True) + self._bpIndex = lookFor('BP', tokens, filename, False) + self._tsIndex = lookFor('Ts', tokens, filename, False) + self._taIndex = lookFor('Ta', tokens, filename, False) + self._ok = self._idIndex != -1 and self._yearIndex != -1 and self._hourIndex != -1 \ + and self._minuteIndex != -1 and self._doyIndex != -1 and self._posdoyIndex != -1 \ + and self._latIndex != -1 and self._lonIndex != -1 + if not self._ok: + print("ERROR badly formed header line") + +#---------------------------------------------- +class Station: + def __init__(self, line, filename, stationHeader): + self._ok = True + tokens = line.split() + self._id = pointToInt(stationHeader._idIndex, tokens, filename) + if self._id < 0: + self._ok = False + self._year = pointToInt(stationHeader._yearIndex, tokens, filename) + if self._year < 0: + self._ok = False + self._hour = pointToInt(stationHeader._hourIndex, tokens, filename) + if self._hour < 0: + self._ok = False + self._minute = pointToInt(stationHeader._minuteIndex, tokens, filename) + if self._minute < 0: + self._ok = False + self._doy = pointToFloat(stationHeader._doyIndex, tokens, filename) + if self._doy < 0: + self._ok = False + if self._doy > 365: + self._ok = False + self._posdoy = pointToFloat(stationHeader._posdoyIndex, tokens, filename) + if self._posdoy < 0: + self._ok = False + if self._posdoy > 365: + self._ok = False + self._lat = pointToFloat(stationHeader._latIndex, tokens, filename) + if self._lat == -99.99: + self._ok = False + self._lon = pointToFloat(stationHeader._lonIndex, tokens, filename) + if self._lon == -99.99: + self._ok = False + if stationHeader._bpIndex >= 0: + self._pressure = pointToFloat(stationHeader._bpIndex, tokens, filename) + else: + self._pressure = -99.99 + if stationHeader._tsIndex >= 0: + self._tempsurface = pointToFloat(stationHeader._tsIndex, tokens, filename) + else: + self._tempsurface = -99.99 + if stationHeader._taIndex >= 0: + self._tempair = pointToFloat(stationHeader._taIndex, tokens, filename) + else: + self._tempair = -99.99 + + if self._ok: + d = datetime.datetime(self._year, 1, 1) + datetime.timedelta(self._doy - 1) + self._month = d.month + self._day = d.day + else: + self._month = -1 + self._day = -1 + def timeInRange(self, start_date, end_date): + if self._ok: + input_date = date(self._year, self._month, self._day) + return is_date_in_range(input_date, start_date, end_date) + else: + return False + +#---------------------------------------------- +class StationTimeSeries: + def __init__(self, stationHeader): + self._stationHeader = stationHeader + self._data = [] + def add(self, line, filename): + s = Station(line, filename, self._stationHeader) + if s._ok: + self._data.append(s) + def print(self): + print("Nothing") + def hasTimesInRange(self, start_date, end_date): + for s in self._data: + if (s.timeInRange(start_date, end_date)): + return True + return False + +#---------------------------------------------- +def doCmd(cmd, debug=False): + #print(cmd) + my_env = os.environ.copy() + args = shlex.split(cmd) + proc = Popen(args, stdout=PIPE, stderr=PIPE, env=my_env) + out, err = proc.communicate() + exitcode = proc.returncode + if exitcode == 0: + return str(out) + else: + if debug: + print("Command failed ", cmd) + return "" + +#---------------------------------------------- +def getdatafilenames(aDir): + if (os.path.exists(aDir)): + allFiles = [name for name in os.listdir(aDir) \ + if not os.path.isdir(os.path.join(aDir, name))] + return [s for s in allFiles if '.dat' in s] + else: + return [] + +#---------------------------------------------- +def run2(data_path, start, end): + + if (data_path[0:2] != "./" and data_path[0] != '/'): + inpath = "./" + data_path + else: + inpath = data_path + + print("data_path = ", inpath) + + # could put testing here to make sure strings will convert + print("start = ", start) + print("end = ", end) + + y0 = int(start[0:4]) + m0 = int(start[4:6]) + d0 = int(start[6:8]) + + y1 = int(end[0:4]) + m1 = int(end[4:6]) + d1 = int(end[6:8]) + + print("Looking for file with data in range ", y0, m0, d0, " to ", y1, m1, d1) + + # read each file that ends in .dat + stationfiles = getdatafilenames(inpath) + stationfiles.sort() + + print("We have ", len(stationfiles), " data files to look at") + start_date = date(y0, m0, d0) + end_date = date(y1, m1, d1) + + for i in range(len(stationfiles)): + + #print("Looking at ", stationfiles[i]) + with open(inpath + "/" + stationfiles[i], 'r') as file: + data_all = file.read() + file.close() + lines = data_all.splitlines() + + # first line is a header, remaining lines are a time series + sh = StationHeader(lines[0], stationfiles[i]) + if sh._ok: + lines = lines[1:] + st = StationTimeSeries(sh) + for l in lines: + st.add(l, stationfiles[i]) + + if (st.hasTimesInRange(start_date, end_date)): + print(stationfiles[i]) + +#---------------------------------------------- +def create_parser_options(parser): + parser.add_option("-d", "--data_path", dest="data_path", + default="./iabp_files", help=" path to the station files (.dat) (default: ./iabp_files)") + parser.add_option("-s", "--start", dest="start", + default="notset", help=" starting yyyymmdd. Must be set") + parser.add_option("-e", "--end", dest="end", + default="notset", help=" ending yyyymmdd. Must be set") + return parser.parse_args() + +#---------------------------------------------- +if __name__ == "__main__": + usage_str = "%prog [options]" + parser = OptionParser(usage = usage_str) + options, args = create_parser_options(parser) + if (options.start == "notset" or options.end == "notset"): + usage() + exit(0) + run2(options.data_path, options.start, options.end) + exit(0) diff --git a/scripts/python/utility/get_iabp_from_web.py b/scripts/python/utility/get_iabp_from_web.py new file mode 100755 index 0000000000..b2a931c8fe --- /dev/null +++ b/scripts/python/utility/get_iabp_from_web.py @@ -0,0 +1,235 @@ + #!/usr/bin/env python3 + +from optparse import OptionParser +import urllib.request +import os +import shutil +import shlex +import errno +from subprocess import Popen, PIPE + +#---------------------------------------------------------------------------- +def makeOrScrub(path, debug=False): + if (debug): + print("Recreating path " + path) + if (os.path.exists(path)): + try: + shutil.rmtree(path) + os.makedirs(path) + except: + print('WARNING: ' + path + ' not completely cleaned out.') + else: + os.makedirs(path) + + +#---------------------------------------------- +def lookFor(name, inlist, filename, printWarning=False): + rval = -1 + try: + rval = inlist.index(name) + except: + if printWarning: + print(name, " not in header line, file=", filename) + + return rval + +#---------------------------------------------- +def pointToInt(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -1 + return int(tokens[index]) + +#---------------------------------------------- +def pointToFloat(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -99.99 + return float(tokens[index]) + +#---------------------------------------------- +class StationHeader: + def __init__(self, headerLine, filename): + tokens = headerLine.split() + self._ok = True + self._idIndex = lookFor('BuoyID', tokens, filename, True) + self._yearIndex = lookFor('Year', tokens, filename, True) + self._hourIndex = lookFor('Hour', tokens, filename, True) + self._minuteIndex = lookFor('Min', tokens, filename, True) + self._doyIndex = lookFor('DOY', tokens, filename, True) + self._posdoyIndex = lookFor('POS_DOY', tokens, filename, True) + self._latIndex = lookFor('Lat', tokens, filename, True) + self._lonIndex = lookFor('Lon', tokens, filename, True) + self._bpIndex = lookFor('Lon', tokens, filename, False) + self._tsIndex = lookFor('Lon', tokens, filename, False) + self._taIndex = lookFor('Lon', tokens, filename, False) + self._ok = self._idIndex != -1 and self._yearIndex != -1 and self._hourIndex != -1 \ + and self._minuteIndex != -1 and self._doyIndex != -1 and self._posdoyIndex != -1 \ + and self._latIndex != -1 and self._lonIndex != -1 + if not self._ok: + print("ERROR badly formed header line") + +#---------------------------------------------- +class Station: + def __init__(self, line, filename, stationHeader): + self._ok = True + tokens = line.split() + self._id = pointToInt(stationHeader._idIndex, tokens, filename) + if self._id < 0: + self._ok = False + self._hour = pointToInt(stationHeader._hourIndex, tokens, filename) + if self._hour < 0: + self._ok = False + self._minute = pointToInt(stationHeader._minuteIndex, tokens, filename) + if self._minute < 0: + self._ok = False + self._doy = pointToFloat(stationHeader._doyIndex, tokens, filename) + if self._doy < 0: + self._ok = False + self._posdoy = pointToFloat(stationHeader._posdoyIndex, tokens, filename) + if self._posdoy < 0: + self._ok = False + self._lat = pointToFloat(stationHeader._latIndex, tokens, filename) + if self._lat == -99.99: + self._ok = False + self._lon = pointToFloat(stationHeader._lonIndex, tokens, filename) + if self._lon == -99.99: + self._ok = False + if stationHeader._bpIndex >= 0: + self._pressure = pointToFloat(stationHeader._bpIndex, tokens, filename) + else: + self._pressure = -99.99 + if stationHeader._tsIndex >= 0: + self._tempsurface = pointToFloat(stationHeader._tsIndex, tokens, filename) + else: + self._tempsurface = -99.99 + if stationHeader._taIndex >= 0: + self._tempair = pointToFloat(stationHeader._taIndex, tokens, filename) + else: + self._tempair = -99.99 + +#---------------------------------------------- +class StationTimeSeries: + def __init__(self, stationHeader): + self._stationHeader = stationHeader + self._data = [] + def add(self, line, filename): + s = Station(line, filename, self._stationHeader) + if s._ok: + self._data.append(s) + def print(self): + print("Nothing") + +#---------------------------------------------- +def doCmd(cmd, debug=False): + #print(cmd) + my_env = os.environ.copy() + args = shlex.split(cmd) + proc = Popen(args, stdout=PIPE, stderr=PIPE, env=my_env) + out, err = proc.communicate() + exitcode = proc.returncode + if exitcode == 0: + return str(out) + else: + if debug: + print("Command failed ", cmd) + return "" + +#---------------------------------------------- +def nextStation(data_all, index_all): + + index_all = data_all.find('.dat', index_all) + data = "" + if index_all == -1: + return -1, data + + #is this the weird (bad) .dat.dat situtation? + teststr = data_all[index_all:index_all+8] + if teststr == ".dat.dat": + indexend = data_all.find('.dat.dat<', index_all+1) + if indexend == -1: + print("Unexpected lack of .dat.dat<") + return -1, data + data = data_all[index_all+10:indexend+8] + else: + indexend = data_all.find('.dat<', index_all+1) + if indexend == -1: + print("UNexpected lack of .dat<") + return -1, data + data = data_all[index_all+6:indexend+4] + return indexend+10, data + +#---------------------------------------------- +def getStation(sfile): + cmd = "wget https://iabp.apl.uw.edu/WebData/" + sfile + print(cmd) + doCmd(cmd, True) + + # parse contents (not used for anything just yet) + with open(sfile, 'r') as file: + data_all = file.read() + file.close() + lines = data_all.splitlines() + + # first line is a header, remaining lines are a time series + sh = StationHeader(lines[0], sfile) + if sh._ok: + lines = lines[1:] + st = StationTimeSeries(sh) + for l in lines: + st.add(l, sfile) + + +#---------------------------------------------- +def run(output_path): + + cwd = os.getcwd() + + if (output_path[0:2] != "./" and output_path[0] != '/'): + outpath = "./" + output_path + else: + outpath = output_path + makeOrScrub(outpath, True) + os.chdir(outpath) + + cmd = "wget https://iabp.apl.uw.edu/WebData" + print(cmd) + s = doCmd(cmd, True) + if not s: + status = False + + stationfiles = [] + with open("WebData", 'r') as file: + data_all = file.read().replace('\n', '') + file.close() + index_all = 0 + while index_all < len(data_all): + index_all, data = nextStation(data_all, index_all) + if (index_all == -1): + break; + stationfiles.append(data) + + print("Parsed out ", len(stationfiles), " individual station files") + + # pull down all the station files + for i in range(len(stationfiles)): + getStation(stationfiles[i]) + + print("created ", len(stationfiles), " station files in ", outpath) + os.chdir(cwd) + +#---------------------------------------------- +def create_parser_options(parser): + parser.add_option("-o", "--output_path", dest="output_path", + default="./iabp_files", help=" create an output path or clear out what is there and put output files to that path (default: ./iabp_files)") + #parser.add_option("-H", "--Help", dest="options", action="store_true", default=False, help = " show usage information (optional, default = False)") + return parser.parse_args() + +#---------------------------------------------- +if __name__ == "__main__": + + usage_str = "%prog [options]" + parser = OptionParser(usage = usage_str) + options, args = create_parser_options(parser) + run(options.output_path) + exit(0) diff --git a/scripts/python/utility/rgb2ctable.py b/scripts/python/utility/rgb2ctable.py old mode 100644 new mode 100755 diff --git a/src/tools/other/ascii2nc/Makefile.am b/src/tools/other/ascii2nc/Makefile.am index 0647687561..ab69ead9f1 100644 --- a/src/tools/other/ascii2nc/Makefile.am +++ b/src/tools/other/ascii2nc/Makefile.am @@ -30,6 +30,7 @@ ascii2nc_SOURCES = ascii2nc.cc \ airnow_locations.cc airnow_locations.h \ aeronet_handler.cc aeronet_handler.h \ ismn_handler.cc ismn_handler.h \ + iabp_handler.cc iabp_handler.h \ $(OPT_PYTHON_SOURCES) ascii2nc_CPPFLAGS = ${MET_CPPFLAGS} -I../../../basic/vx_log diff --git a/src/tools/other/ascii2nc/Makefile.in b/src/tools/other/ascii2nc/Makefile.in index 4c364feb94..ccc217163a 100644 --- a/src/tools/other/ascii2nc/Makefile.in +++ b/src/tools/other/ascii2nc/Makefile.in @@ -110,8 +110,8 @@ am__ascii2nc_SOURCES_DIST = ascii2nc.cc ascii2nc_conf_info.cc \ airnow_handler.h ndbc_handler.cc ndbc_handler.h \ ndbc_locations.cc ndbc_locations.h airnow_locations.cc \ airnow_locations.h aeronet_handler.cc aeronet_handler.h \ - ismn_handler.cc ismn_handler.h python_handler.h \ - python_handler.cc + ismn_handler.cc ismn_handler.h iabp_handler.cc iabp_handler.h \ + python_handler.h python_handler.cc @ENABLE_PYTHON_TRUE@am__objects_1 = ascii2nc-python_handler.$(OBJEXT) am__objects_2 = $(am__objects_1) am_ascii2nc_OBJECTS = ascii2nc-ascii2nc.$(OBJEXT) \ @@ -126,7 +126,8 @@ am_ascii2nc_OBJECTS = ascii2nc-ascii2nc.$(OBJEXT) \ ascii2nc-ndbc_locations.$(OBJEXT) \ ascii2nc-airnow_locations.$(OBJEXT) \ ascii2nc-aeronet_handler.$(OBJEXT) \ - ascii2nc-ismn_handler.$(OBJEXT) $(am__objects_2) + ascii2nc-ismn_handler.$(OBJEXT) \ + ascii2nc-iabp_handler.$(OBJEXT) $(am__objects_2) ascii2nc_OBJECTS = $(am_ascii2nc_OBJECTS) am__DEPENDENCIES_1 = ascii2nc_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -155,6 +156,7 @@ am__depfiles_remade = ./$(DEPDIR)/ascii2nc-aeronet_handler.Po \ ./$(DEPDIR)/ascii2nc-ascii2nc.Po \ ./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po \ ./$(DEPDIR)/ascii2nc-file_handler.Po \ + ./$(DEPDIR)/ascii2nc-iabp_handler.Po \ ./$(DEPDIR)/ascii2nc-ismn_handler.Po \ ./$(DEPDIR)/ascii2nc-little_r_handler.Po \ ./$(DEPDIR)/ascii2nc-met_handler.Po \ @@ -392,6 +394,7 @@ ascii2nc_SOURCES = ascii2nc.cc \ airnow_locations.cc airnow_locations.h \ aeronet_handler.cc aeronet_handler.h \ ismn_handler.cc ismn_handler.h \ + iabp_handler.cc iabp_handler.h \ $(OPT_PYTHON_SOURCES) ascii2nc_CPPFLAGS = ${MET_CPPFLAGS} -I../../../basic/vx_log @@ -519,6 +522,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-ascii2nc.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-file_handler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-iabp_handler.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-ismn_handler.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-little_r_handler.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-met_handler.Po@am__quote@ # am--include-marker @@ -730,6 +734,20 @@ ascii2nc-ismn_handler.obj: ismn_handler.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ascii2nc-ismn_handler.obj `if test -f 'ismn_handler.cc'; then $(CYGPATH_W) 'ismn_handler.cc'; else $(CYGPATH_W) '$(srcdir)/ismn_handler.cc'; fi` +ascii2nc-iabp_handler.o: iabp_handler.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ascii2nc-iabp_handler.o -MD -MP -MF $(DEPDIR)/ascii2nc-iabp_handler.Tpo -c -o ascii2nc-iabp_handler.o `test -f 'iabp_handler.cc' || echo '$(srcdir)/'`iabp_handler.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ascii2nc-iabp_handler.Tpo $(DEPDIR)/ascii2nc-iabp_handler.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='iabp_handler.cc' object='ascii2nc-iabp_handler.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ascii2nc-iabp_handler.o `test -f 'iabp_handler.cc' || echo '$(srcdir)/'`iabp_handler.cc + +ascii2nc-iabp_handler.obj: iabp_handler.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ascii2nc-iabp_handler.obj -MD -MP -MF $(DEPDIR)/ascii2nc-iabp_handler.Tpo -c -o ascii2nc-iabp_handler.obj `if test -f 'iabp_handler.cc'; then $(CYGPATH_W) 'iabp_handler.cc'; else $(CYGPATH_W) '$(srcdir)/iabp_handler.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ascii2nc-iabp_handler.Tpo $(DEPDIR)/ascii2nc-iabp_handler.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='iabp_handler.cc' object='ascii2nc-iabp_handler.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ascii2nc-iabp_handler.obj `if test -f 'iabp_handler.cc'; then $(CYGPATH_W) 'iabp_handler.cc'; else $(CYGPATH_W) '$(srcdir)/iabp_handler.cc'; fi` + ascii2nc-python_handler.o: python_handler.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ascii2nc-python_handler.o -MD -MP -MF $(DEPDIR)/ascii2nc-python_handler.Tpo -c -o ascii2nc-python_handler.o `test -f 'python_handler.cc' || echo '$(srcdir)/'`python_handler.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ascii2nc-python_handler.Tpo $(DEPDIR)/ascii2nc-python_handler.Po @@ -877,6 +895,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc.Po -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po -rm -f ./$(DEPDIR)/ascii2nc-file_handler.Po + -rm -f ./$(DEPDIR)/ascii2nc-iabp_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-ismn_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-little_r_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-met_handler.Po @@ -936,6 +955,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc.Po -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po -rm -f ./$(DEPDIR)/ascii2nc-file_handler.Po + -rm -f ./$(DEPDIR)/ascii2nc-iabp_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-ismn_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-little_r_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-met_handler.Po diff --git a/src/tools/other/ascii2nc/ascii2nc.cc b/src/tools/other/ascii2nc/ascii2nc.cc index a0c76e0082..940e12cedf 100644 --- a/src/tools/other/ascii2nc/ascii2nc.cc +++ b/src/tools/other/ascii2nc/ascii2nc.cc @@ -86,6 +86,7 @@ #include "airnow_handler.h" #include "ndbc_handler.h" #include "ismn_handler.h" +#include "iabp_handler.h" #ifdef ENABLE_PYTHON #include "global_python.h" @@ -117,6 +118,7 @@ enum class ASCIIFormat { Airnow_hourly, NDBC_standard, ISMN, + IABP, Aeronet_v2, Aeronet_v3, Python, @@ -137,6 +139,10 @@ static MaskPlane mask_area; static MaskPoly mask_poly; static StringArray mask_sid; +// Beginning and ending times +static unixtime valid_beg_ut; +static unixtime valid_end_ut; + static int compress_level = -1; //////////////////////////////////////////////////////////////////////// @@ -152,6 +158,8 @@ static void set_mask_grid(const StringArray &); static void set_mask_poly(const StringArray &); static void set_mask_sid(const StringArray &); static void set_compress(const StringArray &); +static void set_valid_beg_time(const StringArray &); +static void set_valid_end_time(const StringArray &); static void setup_wrapper_path(); @@ -166,6 +174,9 @@ int met_main(int argc, char *argv[]) { // if(argc == 1) { usage(); return 0; } + // Initialize time range + valid_beg_ut = valid_end_ut = (unixtime) 0; + // // Parse the command line into tokens // @@ -184,6 +195,8 @@ int met_main(int argc, char *argv[]) { cline.add(set_mask_grid, "-mask_grid", 1); cline.add(set_mask_poly, "-mask_poly", 1); cline.add(set_mask_sid, "-mask_sid", 1); + cline.add(set_valid_beg_time, "-valid_beg", 1); + cline.add(set_valid_end_time, "-valid_end", 1); cline.add(set_compress, "-compress", 1); // @@ -211,6 +224,17 @@ int met_main(int argc, char *argv[]) { << "Config File: " << config_filename << "\n"; config_info.read_config(DEFAULT_CONFIG_FILENAME, config_filename.text()); + // Check that valid_end_ut >= valid_beg_ut + if(valid_beg_ut != (unixtime) 0 && + valid_end_ut != (unixtime) 0 && + valid_beg_ut > valid_end_ut) { + mlog << Error << "\nmet_main() -> " + << "the ending time (" << unix_to_yyyymmdd_hhmmss(valid_end_ut) + << ") must be greater than the beginning time (" + << unix_to_yyyymmdd_hhmmss(valid_beg_ut) << ").\n\n"; + exit(1); + } + // // Create the file handler based on the ascii format specified on // the command line. If one wasn't specified, we'll look in the @@ -225,7 +249,8 @@ int met_main(int argc, char *argv[]) { if(deflate_level > 9) deflate_level = config_info.get_compression_level(); file_handler->setCompressionLevel(deflate_level); file_handler->setSummaryInfo(config_info.getSummaryInfo()); - + file_handler->setValidTimeRange(valid_beg_ut, valid_end_ut); + // // Set the masking grid and polyline, if specified. // @@ -330,6 +355,10 @@ FileHandler *create_file_handler(const ASCIIFormat format, const ConcatString &a return (FileHandler *) new IsmnHandler(program_name); } + case ASCIIFormat::IABP: { + return((FileHandler *) new IabpHandler(program_name)); + } + case ASCIIFormat::Aeronet_v2: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(2); @@ -375,6 +404,22 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { exit(1); } + // + // See if this is an IABP file. + // put this first as it can have the same number of columns as some + // other ones, which look only at the number of columns + // + f_in.rewind(); + IabpHandler *iabp_file = new IabpHandler(program_name); + + if(iabp_file->isFileType(f_in)) { + f_in.close(); + return((FileHandler *) iabp_file); + } + + delete iabp_file; + + // // See if this is a MET file. // @@ -505,6 +550,8 @@ void usage() { << "\t[-mask_sid file|list]\n" << "\t[-log file]\n" << "\t[-v level]\n" + << "\t[-valid_beg time]\n" + << "\t[-valid_end time]\n" << "\t[-compress level]\n\n" << "\twhere\t\"ascii_file\" is the formatted ASCII " @@ -524,6 +571,7 @@ void usage() { << AirnowHandler::getFormatStringHourly() << "\", \"" << NdbcHandler::getFormatStringStandard() << "\", \"" << IsmnHandler::getFormatString() << "\", \"" + << IabpHandler::getFormatString() << "\", \"" << AeronetHandler::getFormatString() << "\", \"" << AeronetHandler::getFormatString_v2() << "\", \"" << AeronetHandler::getFormatString_v3() << "\""; @@ -556,6 +604,12 @@ void usage() { << "\t\t\"-v level\" overrides the default level of logging (" << mlog.verbosity_level() << ") (optional).\n" + << "\t\t\"-valid_beg time\" in YYYYMMDD[_HH[MMSS]] sets the " + << "beginning of the processed data time window (optional).\n" + + << "\t\t\"-valid_end time\" in YYYYMMDD[_HH[MMSS]] sets the " + << "end of the processed data time window (optional).\n" + << "\t\t\"-compress level\" overrides the compression level of NetCDF variable (" << config_info.get_compression_level() << ") (optional).\n\n" @@ -609,6 +663,9 @@ void set_format(const StringArray & a) { else if(IsmnHandler::getFormatString() == a[0]) { ascii_format = ASCIIFormat::ISMN; } + else if(IabpHandler::getFormatString() == a[0]) { + ascii_format = ASCIIFormat::IABP; + } else if(AeronetHandler::getFormatString() == a[0] || AeronetHandler::getFormatString_v2() == a[0]) { ascii_format = ASCIIFormat::Aeronet_v2; @@ -702,6 +759,20 @@ void set_mask_sid(const StringArray & a) { //////////////////////////////////////////////////////////////////////// +void set_valid_beg_time(const StringArray & a) +{ + valid_beg_ut = timestring_to_unix(a[0].c_str()); +} + +//////////////////////////////////////////////////////////////////////// + +void set_valid_end_time(const StringArray & a) +{ + valid_end_ut = timestring_to_unix(a[0].c_str()); +} + +//////////////////////////////////////////////////////////////////////// + void set_compress(const StringArray & a) { compress_level = atoi(a[0].c_str()); } diff --git a/src/tools/other/ascii2nc/file_handler.cc b/src/tools/other/ascii2nc/file_handler.cc index 6e2521f0c8..5495c8b6dc 100644 --- a/src/tools/other/ascii2nc/file_handler.cc +++ b/src/tools/other/ascii2nc/file_handler.cc @@ -57,7 +57,9 @@ FileHandler::FileHandler(const string &program_name) : use_var_id(false), do_monitor(false), deflate_level(DEF_DEFLATE_LEVEL), - _dataSummarized(false) + _dataSummarized(false), + valid_beg_ut((time_t)0), + valid_end_ut((time_t)0) { } @@ -77,6 +79,12 @@ bool FileHandler::readAsciiFiles(const vector< ConcatString > &ascii_filename_li // Loop through the ASCII files, reading in the observations. At the end of // this loop, all of the observations will be in the _observations vector. + // + // debug counts + // + num_observations_in_range = 0; + num_observations_out_of_range = 0; + for (vector< ConcatString >::const_iterator ascii_filename = ascii_filename_list.begin(); ascii_filename != ascii_filename_list.end(); ++ascii_filename) { @@ -103,6 +111,9 @@ bool FileHandler::readAsciiFiles(const vector< ConcatString > &ascii_filename_li ascii_file.close(); } + mlog << Debug(2) << " Kept " << num_observations_in_range + << " observations, rejected (out of range) " << num_observations_out_of_range + << " observations\n"; return true; } @@ -172,6 +183,14 @@ void FileHandler::setSummaryInfo(const TimeSummaryInfo &summary_info) { //////////////////////////////////////////////////////////////////////// +void FileHandler::setValidTimeRange(const time_t &valid_beg, const time_t valid_end) +{ + valid_beg_ut = valid_beg; + valid_end_ut = valid_end; +} + +//////////////////////////////////////////////////////////////////////// + bool FileHandler::summarizeObs(const TimeSummaryInfo &summary_info) { bool result = summary_obs.summarizeObs(summary_info); @@ -275,6 +294,16 @@ bool FileHandler::_addObservations(const Observation &obs) // if(filters.is_filtered_sid(obs.getStationId().c_str())) return false; + // + // Check if valid time is in range + // + if (_keep_valid_time(obs.getValidTime())) { + num_observations_in_range++; + } else { + num_observations_out_of_range++; + return false; + } + // Save obs because the obs vector is sorted after time summary _observations.push_back(obs); if (do_summary) summary_obs.addObservationObj(obs); @@ -334,3 +363,23 @@ void FileHandler::debug_print_observations(vector< Observation > my_observation, } //////////////////////////////////////////////////////////////////////// + +bool FileHandler::_keep_valid_time(const time_t &valid_time) const +{ + bool keep = true; + + // If valid times are both set, check the range + if (valid_beg_ut != (time_t) 0 && valid_end_ut != (time_t) 0) { + if (valid_time < valid_beg_ut || valid_time > valid_end_ut) keep = false; + } + // If only beg set, check the lower bound + else if (valid_beg_ut != (time_t) 0 && valid_end_ut == (time_t) 0) { + if (valid_time < valid_beg_ut) keep = false; + } + // If only end set, check the upper bound + else if (valid_beg_ut == (time_t) 0 && valid_end_ut != (time_t) 0) { + if (valid_time > valid_end_ut) keep = false; + } + return(keep); +} + diff --git a/src/tools/other/ascii2nc/file_handler.h b/src/tools/other/ascii2nc/file_handler.h index af721c008c..07d77e54f3 100644 --- a/src/tools/other/ascii2nc/file_handler.h +++ b/src/tools/other/ascii2nc/file_handler.h @@ -66,7 +66,7 @@ class FileHandler void setCompressionLevel(int compressoion_level); void setSummaryInfo(bool new_do_summary); void setSummaryInfo(const TimeSummaryInfo &summary_info); - + void setValidTimeRange(const time_t &valid_beg, const time_t valid_end); protected: @@ -114,6 +114,10 @@ class FileHandler TimeSummaryInfo _summaryInfo; SummaryObs summary_obs; + time_t valid_beg_ut, valid_end_ut; + int num_observations_in_range; + int num_observations_out_of_range; + /////////////////////// // Protected methods // /////////////////////// @@ -143,6 +147,9 @@ class FileHandler void _closeNetcdf(); bool _openNetcdf(const std::string &nc_filename); void debug_print_observations(std::vector< Observation >, std::string); + + bool _keep_valid_time(const time_t &valid_time) const; + }; inline void FileHandler::setCompressionLevel(int compressoion_level) { deflate_level = compressoion_level; } diff --git a/src/tools/other/ascii2nc/iabp_handler.cc b/src/tools/other/ascii2nc/iabp_handler.cc new file mode 100644 index 0000000000..71ce27f10c --- /dev/null +++ b/src/tools/other/ascii2nc/iabp_handler.cc @@ -0,0 +1,273 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +//////////////////////////////////////////////////////////////////////// + +using namespace std; + +#include + +#include "vx_log.h" +#include "vx_math.h" +#include "vx_util.h" + +#include "iabp_handler.h" + +const double IabpHandler::IABP_MISSING_VALUE = -999.0; + + +const int IabpHandler::MIN_NUM_HDR_COLS = 8; + +// days in the month +static int daysOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +static int _lookfor(const DataLine &dl, const string &name); +static int _lookfor(const DataLine &dl, const string &name, const string &ascii_file, bool &ok); +static time_t _time(const string &syear, const string &shour, const string &smin, const string &sdoy); + + +//////////////////////////////////////////////////////////////////////// +// +// Code for class IabpHandler +// +//////////////////////////////////////////////////////////////////////// + +IabpHandler::IabpHandler(const string &program_name) : + FileHandler(program_name) { + use_var_id = true; +} + +//////////////////////////////////////////////////////////////////////// + +IabpHandler::~IabpHandler() { +} + +//////////////////////////////////////////////////////////////////////// + +bool IabpHandler::isFileType(LineDataFile &ascii_file) const { + + // IABP files are identified by having a .dat suffix and + // checking the always present data columns. + // The header look like this: + // BuoyID Year Hour Min DOY POS_DOY Lat Lon [ BP Ts Ta] + + // Initialize using the filename suffix + bool is_file_type = check_prefix_suffix(ascii_file.short_filename(), + nullptr, ".dat"); + + // Read the header line + DataLine dl; + while(dl.n_items() == 0) ascii_file >> dl; + + // Check the minimum number of header columns + if(dl.n_items() < MIN_NUM_HDR_COLS) { + return false; + } + + string line = dl.get_line(); + ConcatString cstring(line); + + StringArray tokens = cstring.split(" "); + if (tokens[0] != "BuoyID") is_file_type = false; + if (tokens[1] != "Year") is_file_type = false; + if (tokens[2] != "Hour") is_file_type = false; + if (tokens[3] != "Min") is_file_type = false; + if (tokens[4] != "DOY") is_file_type = false; + if (tokens[5] != "POS_DOY") is_file_type = false; + if (tokens[6] != "Lat") is_file_type = false; + if (tokens[7] != "Lon") is_file_type = false; + + return(is_file_type); +} + +//////////////////////////////////////////////////////////////////////// +// Private/Protected methods +//////////////////////////////////////////////////////////////////////// + +bool IabpHandler::_readObservations(LineDataFile &ascii_file) +{ + // Read and save the header information + if(!_readHeaderInfo(ascii_file)) return(false); + + string header_type = "IABP_STANDARD"; + + // Process the observation lines + DataLine dl; + while(ascii_file >> dl) { + + // Make sure that the line contains the correct number of tokens + if(dl.n_items() != _numColumns) { + mlog << Error << "\nIabpHandler::_readObervations() -> " + << "unexpected number of columns (" << dl.n_items() + << " != " << _numColumns << ") on line number " + << dl.line_number() << " of IABP file \"" + << ascii_file.filename() << "\"!\n\n"; + return(false); + } + + // Extract the valid time from the data line, using POS_DOY (scientist is most + // interested in location) Use POS_DOY to compute the month and day based on year + // (to handle leap year) + time_t valid_time = _time(dl[_yearPtr], dl[_hourPtr], dl[_minutePtr], dl[_posdoyPtr]); + if(valid_time == 0) { + mlog << Warning << "\nIabpHandler::_readObservations() -> " + << "No valid time computed in file, line number " + << dl.line_number() << " of IABP file \"" + << ascii_file.filename() << "\". Ignore this line\n\n"; + return(false); + } + + double lat = stod(dl[_latPtr]); + double lon = stod(dl[_lonPtr]); + string stationId = dl[_idPtr]; + string quality_flag = na_str; + int grib_code = 0; + double height_m = bad_data_double; + double pres = bad_data_double; + double elev = bad_data_double; + double ts = bad_data_double; + double ta = bad_data_double; + + if (lat == IABP_MISSING_VALUE || lon == IABP_MISSING_VALUE) { + // This is either a rare event or never happens + mlog << Warning << "\nIabpHandler::_readObservations() -> " + << "Latitude/longitude has missing value " << IABP_MISSING_VALUE + << ", line number " << dl.line_number() << " of IABP file \"" + << ascii_file.filename() << "\". Ignore this line\n\n"; + return(false); + } + + if (_bpPtr >= 0) { + // is this the right placeholder for this? To always put it in to the + // fixed slot of an observation? + pres = stod(dl[_bpPtr]); + if (pres == IABP_MISSING_VALUE) { + pres = bad_data_double; + } + } + + // Add a location placeholder observation in case neither of the temps are available + // Otherwise there would be no observations for this entry, and we want to have + // valid entries for every time/lat/lon. + _addObservations(Observation( + header_type, stationId, valid_time, + lat, lon, elev, quality_flag, grib_code, + pres, height_m, 1.0, "Location")); + grib_code++; + + if (_tsPtr >= 0) { + ts = stod(dl[_tsPtr]); + if (ts != IABP_MISSING_VALUE) { + _addObservations(Observation( + header_type, stationId, valid_time, + lat, lon, elev, quality_flag, grib_code, + pres, height_m, ts, "Temp_surface")); + grib_code++; + } + } + if (_taPtr >= 0) { + ta = stod(dl[_taPtr]); + if (ta != IABP_MISSING_VALUE) { + _addObservations(Observation( + header_type, stationId, valid_time, + lat, lon, elev, quality_flag, grib_code, + pres, height_m, ta, "Temp_air")); + } + } + + + + } // end while + + return(true); +} + +// //////////////////////////////////////////////////////////////////////// + +bool IabpHandler::_readHeaderInfo(LineDataFile &ascii_file) { + + DataLine dl; + if (!(ascii_file >> dl)) + { + mlog << Error << "\nIabpHandler::_readHeaderInfo() -> " + << "error reading header line from input ASCII file \"" + << ascii_file.filename() << "\"\n\n"; + return false; + } + + // Check the minimum number of header columns + if(dl.n_items() < MIN_NUM_HDR_COLS) { + mlog << Error << "\nIabpHandler::_readHeaderInfo() -> " + << "unexpected number of header columns (" + << dl.n_items() << " < " << MIN_NUM_HDR_COLS + << ") in IABP file \"" << ascii_file.filename() + << "\"!\n\n"; + return(false); + } + + // Map the header information to column numbers + bool ok = true; + string filename = ascii_file.filename(); + _idPtr = _lookfor(dl, "BuoyID", filename, ok); + _yearPtr = _lookfor(dl, "Year", filename, ok); + _hourPtr = _lookfor(dl, "Hour", filename, ok); + _minutePtr = _lookfor(dl, "Min", filename, ok); + _doyPtr = _lookfor(dl, "DOY", filename, ok); + _posdoyPtr = _lookfor(dl, "POS_DOY", filename, ok); + _latPtr = _lookfor(dl, "Lat", filename, ok); + _lonPtr = _lookfor(dl, "Lon", filename, ok); + _numColumns = MIN_NUM_HDR_COLS; + _bpPtr = _lookfor(dl, "BP"); + if (_bpPtr >= 0) ++_numColumns; + _tsPtr = _lookfor(dl, "Ts"); + if (_tsPtr >= 0) ++_numColumns; + _taPtr = _lookfor(dl, "Ta"); + if (_taPtr >= 0) ++_numColumns; + return ok; +} + +//////////////////////////////////////////////////////////////////////// + +static int _lookfor(const DataLine &dl, const string &name, const string &ascii_file, bool &ok) +{ + for (int i=0; i " + << "reading ASCII file \"" + << ascii_file << "\" did not find expected header item:\"" << name << "\" ignore file\n\n"; + ok = false; + return -1; +} + +//////////////////////////////////////////////////////////////////////// + +static int _lookfor(const DataLine &dl, const string &name) +{ + for (int i=0; i +#include + +#include "file_handler.h" + +//////////////////////////////////////////////////////////////////////// +// +// International Arctic Buoy Programme +// https://iabp.apl.uw.edu/data.html +// Files pulled from: +// https://iabp.apl.uw.edu/WebData/ +// +// +// Dataset file names: +// .dat where is an integer. +// +// Dataset Conents: +// +// Buoy data files are updated daily and made available individually at the WebData URL above. +// Values provided are confined to surface temperature,atmospheric temperature, and barometric pressure when these values are available. +// All buoy files contain at least dates and positions. +// Each file has a header line and one or more data lines. +// +// Header Line example (BP Ts and Ta are not always present, any subset could be there or not): +// +// BuoyID Year Hour Min DOY POS_DOY Lat Lon BP Ts Ta +// +// Record Lines (many per file, typically): +// Each file contains data from all buoys on a given date. +// Data includes: BuoyID, year, hour, minute, Day of Year, Position Day of year, +// latitude, longitude, [Barometric Pressure], [Surface Temp], and [Atmospheric Temp]. +// The last 3 values are optional and depend on the header line. +// +// Record line Example +// +// 5318 2014 02 20 28.0970 28.0930 72.75970 -165.25190 1016.62 -999.00 -13.92 +// +// It looks like the missing data value is -999.0, but this might not always be the case, it seems to not be documented. +// + +//////////////////////////////////////////////////////////////////////// + +class IabpHandler : public FileHandler { + + public: + + IabpHandler(const string &program_name); + virtual ~IabpHandler(); + + virtual bool isFileType(LineDataFile &ascii_file) const; + + static string getFormatString() { return "iabp"; } + + protected: + + ///////////////////////// + // Protected constants + ///////////////////////// + + // The minimum number of columns in the header line in the file. + static const int MIN_NUM_HDR_COLS; + + // a missing data value found in some iabp files + static const double IABP_MISSING_VALUE; + + /////////////////////// + // Protected members + /////////////////////// + + // Store list of unqiue output variable names + StringArray _varNames; + + // pointers based on header content + int _idPtr; + int _yearPtr; + int _hourPtr; + int _minutePtr; + int _doyPtr; + int _posdoyPtr; + int _latPtr; + int _lonPtr; + int _bpPtr; + int _tsPtr; + int _taPtr; + + // depends on which of the optional data types are present in a file + int _numColumns; + + string _buoyId; + time_t _validTime; + double _stationLat; + double _stationLon; + double _stationElv; + double _bp; + double _ts; + double _ta; + + /////////////////////// + // Protected methods + /////////////////////// + + // Read and save the header information from the given file + bool _readHeaderInfo(LineDataFile &ascii_file); + + // Get the valid time from the observation line + // Read the observations and add them to the + // _observations vector + virtual bool _readObservations(LineDataFile &ascii_file); + + // compute the time value from inputs + time_t _time2(const string &syear, const string &shour, const string &smin, const string &sdoy); +}; + +//////////////////////////////////////////////////////////////////////// + +#endif /* __IABP_HANDLER_H__ */ + +//////////////////////////////////////////////////////////////////////// From f78720b861fe6a7f8e1a22fd77ff4fdcf5e168c6 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 17 Apr 2024 14:57:13 -0600 Subject: [PATCH 064/114] Feature #2786 rpss_from_prob (#2861) * Per #2786, small change to a an error message unrelated to this development. * Per #2786, add RPSInfo::set_climo_prob() function to derive the RPS line type from climatology probability bins. And update Ensemble-Stat to call it. * Per #2786, minor change to clarify error log message. * Per #2786, for is_prob = TRUE input, the RPS line type is the only output option. Still need to update docs! * Per #2786, add new call to Ensemble-Stat to test computing RPS from climo probabilities * Per #2786, use name rps_climo_bin_prob to be very explicit. * Per #2786, redefine logic of RPSInfo::set_climo_bin_prob() to match the CPC definition. Note that reliability, resolution, uncertainty, and RPSS based on the sample climatology are all set to bad data. Need to investigate whether they can be computed using these inputs. * Per #2786, remove the requirement that any fcst.prob_cat_thresh thresholds must be defined. If they are defined, pass them through to the FCST_THRESH output column. If not, write NA. Add check to make sure the event occurs in exactly 1 category. * Per #2786, don't enforce fcst.prob_cat_thresh == obs.prob_cat_thresh for probabilistic inputs. And add more is_prob checks so that only the RPS line type can be written when given probabilistic inputs. * updated documentation * Per #2786, call rescale_probability() function to convert from 0-100 probs to 0-1 probs. --------- Co-authored-by: j-opatz --- docs/Users_Guide/ensemble-stat.rst | 34 ++- .../EnsembleStatConfig_rps_climo_bin_prob | 223 ++++++++++++++++++ internal/test_unit/xml/unit_ensemble_stat.xml | 20 ++ src/basic/vx_util/thresh_array.cc | 4 +- src/libcode/vx_statistics/ens_stats.cc | 103 ++++++++ src/libcode/vx_statistics/ens_stats.h | 2 + src/tools/core/ensemble_stat/ensemble_stat.cc | 57 +++-- .../ensemble_stat/ensemble_stat_conf_info.cc | 11 +- 8 files changed, 429 insertions(+), 25 deletions(-) create mode 100644 internal/test_unit/config/EnsembleStatConfig_rps_climo_bin_prob diff --git a/docs/Users_Guide/ensemble-stat.rst b/docs/Users_Guide/ensemble-stat.rst index 9a5574a658..dd221dd1d2 100644 --- a/docs/Users_Guide/ensemble-stat.rst +++ b/docs/Users_Guide/ensemble-stat.rst @@ -63,6 +63,8 @@ When computing the CRPS skill score for (:ref:`Gneiting et al., 2004 + + + + &MET_BIN;/ensemble_stat + + DESC RPS_CLIMO_BIN_PROB + OUTPUT_PREFIX RPS_CLIMO_BIN_PROB + + \ + 1 \ + &DATA_DIR_MODEL;/cpc_climo_prob/gefs-00z_aer-rfcst-cal_tmean_20210101_week2_cats_33-67ptile.nc \ + &CONFIG_DIR;/EnsembleStatConfig_rps_climo_bin_prob \ + -grid_obs &DATA_DIR_MODEL;/cpc_climo_prob/tmean_07d_20210115_cats_33-67ptile.nc \ + -outdir &OUTPUT_DIR;/ensemble_stat -v 1 + + + &OUTPUT_DIR;/ensemble_stat/ensemble_stat_RPS_CLIMO_BIN_PROB_20210101_000000V.stat + + + diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index e315536499..4a0b421ae1 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -684,8 +684,8 @@ bool check_prob_thresh(const ThreshArray &ta, bool error_out) { << "select at least 3 thresholds which include the range [0, 1] " << "(current setting: " << ta.get_str() << ").\n" << "Consider using the \"==n\" shorthand notation to specify " - << "probability bins of equal width, for n < 1, or the integer " - << "number of ensemble members, for n > 1.\n\n"; + << "probability bins of equal width for n < 1, or the integer " + << "number of ensemble members for n > 1.\n\n"; exit(1); } else { diff --git a/src/libcode/vx_statistics/ens_stats.cc b/src/libcode/vx_statistics/ens_stats.cc index 782832b79f..6483e68045 100644 --- a/src/libcode/vx_statistics/ens_stats.cc +++ b/src/libcode/vx_statistics/ens_stats.cc @@ -632,6 +632,109 @@ void RPSInfo::set(const PairDataEnsemble &pd) { //////////////////////////////////////////////////////////////////////// +void RPSInfo::set_climo_bin_prob(const PairDataEnsemble &pd, + const ThreshArray &ocat_ta) { + + // Compute RPS directly from the binned probabilities rather + // than with an Nx2 probabilistic contingency table. + + // Store the dimensions + n_pair = pd.n_pair; + n_prob = pd.n_ens; + + // If no forecast thresholds are provided, store a single NA thresh + if(fthresh.n() == 0) fthresh.add(na_str); + + // Check that the number of observation category thresholds + // and bins match + if(ocat_ta.n() != pd.n_ens) { + mlog << Error << "\nRPSInfo::set_climo_bin_prob() -> " + << "the number of climatology probability bins (" + << pd.n_ens << ") must match the number of observation " + << " category thresholds (" << write_css(ocat_ta) + << ") defined by the \"" << conf_key_prob_cat_thresh + << "\" configuration file option.\n\n"; + exit(1); + } + + // Initialize RPS + rps = rpscl = 0.0; + + // Loop over the observations + for(int i_obs=0; i_obs " + << "unexpected sum of binned probabilities (" + << pfcst_sum << " != 1).\n\n"; + } + + // Increment sums for the event + if(ocat_ta[i_bin].check(pd.o_na[i_obs])) { + n_event++; + rps_obs += (1.0 - pfcst_sum)*(1.0 - pfcst_sum); + rpscl_obs += (1.0 - pclim_sum)*(1.0 - pclim_sum); + } + // Increment sums for the non-event + else { + rps_obs += (0.0 - pfcst_sum)*(0.0 - pfcst_sum); + rpscl_obs += (0.0 - pclim_sum)*(0.0 - pclim_sum); + } + + } // end for i_bin + + // Make sure the event occurs in exactly 1 bin + if(n_event != 1) { + mlog << Warning << "\nRPSInfo::set_climo_bin_prob() -> " + << "the observation value (" << pd.o_na[i_obs] + << ") met " << n_event << " of the observation " + << " category thresholds (" << write_css(ocat_ta) + << ") instead of exactly 1!\n\n"; + } + + // Divide by number of bins minus 1 + rps_obs /= (pd.n_ens - 1); + rpscl_obs /= (pd.n_ens - 1); + + // Increment running sums + rps += rps_obs / pd.n_obs ; + rpscl += rpscl_obs / pd.n_obs; + + } // end for i_obs + + // Compute RPSS relative to climatology + rpss = (!is_eq(rpscl, 0.0) ? + 1.0 - (rps / rpscl) : + bad_data_double); + + // Store other RPS statistics as bad data + rpss_smpl = bad_data_double; + rps_rel = bad_data_double; + rps_res = bad_data_double; + rps_unc = bad_data_double; + + return; +} + +//////////////////////////////////////////////////////////////////////// + double RPSInfo::rps_comp() const { return(is_bad_data(rps) ? bad_data_double : 1.0 - rps); } diff --git a/src/libcode/vx_statistics/ens_stats.h b/src/libcode/vx_statistics/ens_stats.h index 69eca9f4e1..1f5adb51b8 100644 --- a/src/libcode/vx_statistics/ens_stats.h +++ b/src/libcode/vx_statistics/ens_stats.h @@ -140,6 +140,8 @@ class RPSInfo { // Compute statistics void set(const PairDataEnsemble &); + void set_climo_bin_prob(const PairDataEnsemble &, + const ThreshArray &); // Compute the complement of the RPS double rps_comp() const; diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index f00ca74bfd..0ed6b71597 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -69,7 +69,9 @@ // 037 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. // 038 09/06/22 Halley Gotway MET #1908 Remove ensemble processing logic. // 039 09/29/22 Halley Gotway MET #2286 Refine GRIB1 table lookup logic. -// 040 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files +// 040 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from +// header files +// 041 04/16/24 Halley Gotway MET #2786 Compute RPS from climo bin probs. // //////////////////////////////////////////////////////////////////////// @@ -663,6 +665,9 @@ bool get_data_plane(const char *infile, GrdFileType ftype, dp = met_regrid(dp, mtddf->grid(), grid, info->regrid()); } + // Rescale probabilities from [0, 100] to [0, 1] + if(info->is_prob()) rescale_probability(dp); + // Store the valid time, if not already set if(ens_valid_ut == (unixtime) 0) { ens_valid_ut = dp.valid(); @@ -723,6 +728,13 @@ bool get_data_plane_array(const char *infile, GrdFileType ftype, } } + // Rescale probabilities from [0, 100] to [0, 1] + if(info->is_prob()) { + for(i=0; iget_var_info()->is_prob()) { + rps_info.set_climo_bin_prob(*pd_ptr, vx_opt.ocat_ta); + } + // Compute ensemble RPS statistics from ensemble member values + else { + rps_info.set(*pd_ptr); + } // Write out RPS if(vx_opt.output_flag[i_rps] != STATOutputType::None && @@ -2053,6 +2071,9 @@ void write_txt_files(const EnsembleStatVxOpt &vx_opt, int i, j; PairDataEnsemble pd; + // Check for probabilistic input + bool is_prob = vx_opt.vx_pd.fcst_info->get_var_info()->is_prob(); + // Process each observation filtering threshold for(i=0; iget_var_info()->is_prob() && + fcat_ta.n() != ocat_ta.n()) { mlog << Error << "\nEnsembleStatVxOpt::process_config() -> " - << "The number of forecast (" << fcat_ta.n() - << ") and observation (" << ocat_ta.n() + << "The number of forecast (" << write_css(fcat_ta) + << ") and observation (" << write_css(ocat_ta) << ") probability category thresholds in \"" - << conf_key_prob_cat_thresh << "\" must match.\n\n"; + << conf_key_prob_cat_thresh << "\" must match!\n\n"; exit(1); } From 947b061dc6fbaf1fb3b3572952e41eaf6e86cee7 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 17 Apr 2024 16:52:16 -0600 Subject: [PATCH 065/114] Feature #2862 v12.0.0-beta4 (#2864) --- docs/Users_Guide/release-notes.rst | 28 ++++++++++++++++++++++++++++ docs/conf.py | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/Users_Guide/release-notes.rst b/docs/Users_Guide/release-notes.rst index c762149df0..3dce6cb0e3 100644 --- a/docs/Users_Guide/release-notes.rst +++ b/docs/Users_Guide/release-notes.rst @@ -9,6 +9,32 @@ When applicable, release notes are followed by the GitHub issue number which des enhancement, or new feature (`MET GitHub issues `_). Important issues are listed **in bold** for emphasis. +MET Version 12.0.0-beta4 Release Notes (20240417) +------------------------------------------------- + + .. dropdown:: Repository, build, and test + + * Add GitHub action to run SonarQube for MET pull requests and feature branches (`#2379 `_). + * Move namespace specifications below include directives (`#2696 `_). + * Enhance GitHub action compilation options and testing workflows (`#2815 `_). + * Fix the SonarQube findings for MET version 12.0.0 (`#2673 `_). + * SonarQube: Replace "enum" to "enum class" (`#2830 `_). + + .. dropdown:: Bugfixes + + * **Bugfix: Fix the TC-Diag and TC-RMW tools to correctly handle the range and azimuth settings in range/azimuth grids** (`#2833 `_). + + .. dropdown:: Enhancements + + * **Refine configuration options for defining bins in the verification of probabilistic forecasts** (`#2280 `_). + * **Add new wind direction verification statistics for RMSE, Bias, and MAE** (`#2395 `_). + * Add new ECNT statistics that incorporate observational uncertainty as advised in Ferro (2017) (`#2583 `_). + * Enhance ASCII2NC to support IABP/IPAB Arctic and Antarctic drifting buoy observations (`#2654 `_). + * Enhance Multivariate MODE to read input data only once rather than multiple times (`#2707 `_). + * Enhance the calculation of RPSS to support starting from probabilistic data (`#2786 `_). + * Add convex hull to MODE output (`#2819 `_). + * Enhance Point2Grid to check "coordinates" variable attribute for ingesting non-traditional grids (`#2858 `_). + MET Version 12.0.0-beta3 Release Notes (20240207) ------------------------------------------------- @@ -108,3 +134,5 @@ MET Version 12.0.0 Upgrade Instructions * The required `Proj `_ library dependency was added in the 12.0.0-beta1 development cycle (`#2669 `_). * The optional `Atlas `_ library dependency was added in the 12.0.0-beta2 development cycle (`#2574 `_). * The optional `ecKit `_ library dependency was added in the 12.0.0-beta2 development cycle (`#2574 `_). + +* Note that the `#2833 `_ bugfix affects all previously generated output from the TC-Diag and TC-RMW tools. diff --git a/docs/conf.py b/docs/conf.py index ad28a7dd63..3a135308ab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,11 +20,11 @@ project = 'MET' author = 'UCAR/NCAR, NOAA, CSU/CIRA, and CU/CIRES' author_list = 'Prestopnik, J., H. Soh, L. Goodrich, B. Brown, R. Bullock, J. Halley Gotway, K. Newman, J. Opatz, T. Jensen' -version = '12.0.0-beta3' +version = '12.0.0-beta4' verinfo = version release = f'{version}' release_year = '2024' -release_date = f'{release_year}-02-07' +release_date = f'{release_year}-04-17' copyright = f'{release_year}, {author}' # -- General configuration --------------------------------------------------- From 406d99137c5212489b53d08fbd316dea0dba1275 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 18 Apr 2024 09:55:23 -0600 Subject: [PATCH 066/114] Feature #2379 develop single_sq_project (#2865) --- internal/scripts/docker/build_met_sonarqube.sh | 4 +--- internal/scripts/sonarqube/run_sonarqube.sh | 4 +--- internal/scripts/sonarqube/sonar-project.properties | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index 45e1d10fc5..2eea05654e 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -84,9 +84,7 @@ SONAR_PROPERTIES=sonar-project.properties # Configure the sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -sed -e "s|SONAR_PROJECT_KEY|MET-GHA|" \ - -e "s|SONAR_PROJECT_NAME|MET GHA|" \ - -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ +sed -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 1a57b0b726..ac439b8a11 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -125,9 +125,7 @@ if [ -z "$SONAR_TOKEN" ]; then exit 1 else [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES - sed -e "s|SONAR_PROJECT_KEY|MET_NB|" \ - -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ - -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ + sed -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_BRANCH_NAME|${1}|" \ diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index 215749e75b..30ee495c7b 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -1,6 +1,6 @@ # Project and source code settings -sonar.projectKey=SONAR_PROJECT_KEY -sonar.projectName=SONAR_PROJECT_NAME +sonar.projectKey=MET +sonar.projectName=MET sonar.projectVersion=SONAR_PROJECT_VERSION sonar.branch.name=SONAR_BRANCH_NAME sonar.sources=src,scripts/python,data/wrappers From 0a219b50ffe217b5efb347c6eea2ab27c82e0c4d Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 18 Apr 2024 15:05:44 -0600 Subject: [PATCH 067/114] Hotfix to the documentation in the develop branch. Issue #2858 was closed as a duplicate of #2857. I had included it in the MET-12.0.0-beta4 release notes, but the work is not yet actually complete. --- docs/Users_Guide/release-notes.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/Users_Guide/release-notes.rst b/docs/Users_Guide/release-notes.rst index 3dce6cb0e3..c8f2fb0f2c 100644 --- a/docs/Users_Guide/release-notes.rst +++ b/docs/Users_Guide/release-notes.rst @@ -33,7 +33,6 @@ MET Version 12.0.0-beta4 Release Notes (20240417) * Enhance Multivariate MODE to read input data only once rather than multiple times (`#2707 `_). * Enhance the calculation of RPSS to support starting from probabilistic data (`#2786 `_). * Add convex hull to MODE output (`#2819 `_). - * Enhance Point2Grid to check "coordinates" variable attribute for ingesting non-traditional grids (`#2858 `_). MET Version 12.0.0-beta3 Release Notes (20240207) ------------------------------------------------- From d4c4ebac30c00a90cdc954d930f6c433ee38ccf3 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 25 Apr 2024 15:01:21 -0600 Subject: [PATCH 068/114] Feature 2842 ugrid config (#2852) * #2842 Removed UGrid related setting * #2842 Corrected vertical level for data_plane_array * #2842 Do not allow the time range * #2842 The UGridConfig file can be passed as ugrid_dataset * #2842 Changed -config option to -ugrid_config * #2842 Deleted UGrid configurations * 2842 Fix a compile error when UGrid is disabled * #2842 Cleanup * #2842 Added an unittest point_stat_ugrid_mpas_config * #2842 Added a PointStatConfig without UGrid dataset. * #2842 Corrected ty[po at the variable name * Switched from time_centered to time_instant. I think time_centered is the center of the forecast lead window and time_instant is the time the forecast is valid (end of forecast window). * #2842 Removed ugrid_max_distance_km and unused metadata names * #2842 Restored time variable time_instant for LFric * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjusted lon to between -180 to 180 * #2842 Changed variable names * Per #2842, switch from degrees east to west right when the longitudes are read. * #2842, switch from degrees east to west right when the longitudes are read * #2842 Cleanup debug messages --------- Co-authored-by: Howard Soh Co-authored-by: Daniel Adriaansen Co-authored-by: John Halley Gotway --- data/config/GridStatConfig_default | 6 - data/config/PointStatConfig_default | 6 - data/config/UGridConfig_lfric | 17 +- data/config/UGridConfig_mpas | 15 +- .../config/PointStatConfig_ugrid_no_dataset | 167 ++++++++++++++++++ internal/test_unit/xml/unit_ugrid.xml | 26 +++ src/libcode/vx_data2d_ugrid/data2d_ugrid.cc | 23 +-- src/libcode/vx_data2d_ugrid/ugrid_file.cc | 37 ++-- src/libcode/vx_data2d_ugrid/var_info_ugrid.cc | 55 ------ src/libcode/vx_grid/grid_base.cc | 22 +-- src/libcode/vx_grid/unstructured_grid.cc | 74 ++++---- src/libcode/vx_grid/unstructured_grid_defs.h | 8 +- src/libcode/vx_regrid/vx_regrid.cc | 1 - src/tools/core/grid_stat/grid_stat.cc | 26 ++- src/tools/core/grid_stat/grid_stat.h | 2 +- .../core/grid_stat/grid_stat_conf_info.cc | 30 ++-- .../core/grid_stat/grid_stat_conf_info.h | 5 +- src/tools/core/point_stat/point_stat.cc | 28 ++- src/tools/core/point_stat/point_stat.h | 2 +- .../core/point_stat/point_stat_conf_info.cc | 30 ++-- .../core/point_stat/point_stat_conf_info.h | 5 +- 21 files changed, 364 insertions(+), 221 deletions(-) create mode 100644 internal/test_unit/config/PointStatConfig_ugrid_no_dataset diff --git a/data/config/GridStatConfig_default b/data/config/GridStatConfig_default index adbb9a214b..4bec5ecf4b 100644 --- a/data/config/GridStatConfig_default +++ b/data/config/GridStatConfig_default @@ -264,12 +264,6 @@ nc_pairs_flag = { //////////////////////////////////////////////////////////////////////////////// -ugrid_dataset = ""; -ugrid_max_distance_km = 30; -ugrid_coordinates_file = ""; - -//////////////////////////////////////////////////////////////////////////////// - grid_weight_flag = NONE; tmp_dir = "/tmp"; output_prefix = ""; diff --git a/data/config/PointStatConfig_default b/data/config/PointStatConfig_default index 9a8132dccc..d4b277c6a3 100644 --- a/data/config/PointStatConfig_default +++ b/data/config/PointStatConfig_default @@ -299,12 +299,6 @@ output_flag = { //////////////////////////////////////////////////////////////////////////////// -ugrid_dataset = ""; -ugrid_max_distance_km = 30; -ugrid_coordinates_file = ""; - -//////////////////////////////////////////////////////////////////////////////// - tmp_dir = "/tmp"; output_prefix = ""; version = "V12.0.0"; diff --git a/data/config/UGridConfig_lfric b/data/config/UGridConfig_lfric index 7c5e164643..8b12f429f5 100644 --- a/data/config/UGridConfig_lfric +++ b/data/config/UGridConfig_lfric @@ -2,7 +2,7 @@ // // Unstructured grid configuration file. // -// UGridConfig_lfric at the current working directory overrides the settings here. +// UGridConfig_lfric at the current working directory replaces the settings here. // For additional or updated information, please see the MET User's Guide. // //////////////////////////////////////////////////////////////////////////////// @@ -12,23 +12,14 @@ // ugrid_metadata_map = [ { key = "dim_face"; val = "nMesh2d_face"; }, - { key = "dim_node"; val = "nMesh2d_node"; }, - { key = "dim_edge"; val = "nMesh2d_edge"; }, { key = "dim_time"; val = "time_counter"; }, - { key = "dim_vert"; val = "nVertLevels"; }, - { key = "cell_id"; val = "indexToCellID"; }, + { key = "dim_vert"; val = ""; }, // optional { key = "lat_face"; val = "Mesh2d_face_y"; }, { key = "lon_face"; val = "Mesh2d_face_x"; }, - { key = "vert_face"; val = "zCell"; }, - { key = "lat_edge"; val = "Mesh2d_edge_y"; }, - { key = "lon_edge"; val = "Mesh2d_edge_x"; }, - { key = "lat_node"; val = "Mesh2d_node_y"; }, - { key = "lon_node"; val = "Mesh2d_node_x"; }, - { key = "time"; val = "time_centered"; } + { key = "vert_face"; val = ""; }, // optional + { key = "time"; val = "time_instant"; } ]; -ugrid_max_distance_km = 30; - //////////////////////////////////////////////////////////////////////////////// version = "V12.0.0"; diff --git a/data/config/UGridConfig_mpas b/data/config/UGridConfig_mpas index 803daf6767..70fca86f98 100644 --- a/data/config/UGridConfig_mpas +++ b/data/config/UGridConfig_mpas @@ -2,7 +2,7 @@ // // Unstructured grid configuration file. // -// UGridConfig_mpas at the current working directory overrides the settings here. +// UGridConfig_mpas at the current working directory replaces the settings here. // For additional or updated information, please see the MET User's Guide. // //////////////////////////////////////////////////////////////////////////////// @@ -12,23 +12,14 @@ // ugrid_metadata_map = [ { key = "dim_face"; val = "nCells"; }, - { key = "dim_node"; val = "nVertices"; }, - { key = "dim_edge"; val = "nEdges"; }, { key = "dim_time"; val = "Time"; }, - { key = "dim_vert"; val = "nVertLevels"; }, - { key = "cell_id"; val = "indexToCellID"; }, + { key = "dim_vert"; val = "nVertLevels"; }, // optional { key = "lat_face"; val = "latCell"; }, { key = "lon_face"; val = "lonCell"; }, - { key = "vert_face"; val = "zCell"; }, - { key = "lat_edge"; val = "latEdge"; }, - { key = "lon_edge"; val = "lonEdge"; }, - { key = "lat_node"; val = "latVertex"; }, - { key = "lon_node"; val = "lonVertex"; }, + { key = "vert_face"; val = "zCell"; }, // optional { key = "time"; val = "xtime"; } ]; -ugrid_max_distance_km = 30; - //////////////////////////////////////////////////////////////////////////////// version = "V12.0.0"; diff --git a/internal/test_unit/config/PointStatConfig_ugrid_no_dataset b/internal/test_unit/config/PointStatConfig_ugrid_no_dataset new file mode 100644 index 0000000000..e70a3af9ee --- /dev/null +++ b/internal/test_unit/config/PointStatConfig_ugrid_no_dataset @@ -0,0 +1,167 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Point-Stat configuration file. +// +// For additional information, please see the MET User's Guide. +// +//////////////////////////////////////////////////////////////////////////////// + +model = "WRF"; + +// +// Output description to be written +// May be set separately in each "obs.field" entry +// +desc = "NA"; + +//////////////////////////////////////////////////////////////////////////////// + +regrid = { + to_grid = NONE; + method = NEAREST; + width = 1; +} + +//////////////////////////////////////////////////////////////////////////////// + +obs_window = { + beg = ${BEG_DS}; + end = ${END_DS}; +} + +//////////////////////////////////////////////////////////////////////////////// + +mpr_column = []; +mpr_thresh = []; +cnt_thresh = [ NA ]; +cnt_logic = UNION; +wind_thresh = [ NA ]; +wind_logic = UNION; +eclv_points = 0.05; + + +fcst = { + sid_inc = []; + sid_exc = []; + obs_quality_inc = []; + obs_quality_exc = []; + + field = [ + { name = "theta"; level = "L2"; message_type = "ADPSFC"; } + ]; + +} + +obs = { + sid_inc = []; + sid_exc = []; + obs_quality_inc = []; + obs_quality_exc = []; + + field = [ + { name = "TMP"; level = "P1000-500"; message_type = "ADPSFC"; } + ]; + +} + +//////////////////////////////////////////////////////////////////////////////// + +climo_mean = obs; +climo_mean = { + file_name = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +mask = { + grid = []; + poly = []; + sid = []; + llpnt = [{ name = "ALLLATLON"; lat_thresh = NA; lon_thresh = NA; }]; +} + +//////////////////////////////////////////////////////////////////////////////// + +ci_alpha = [ 0.05 ]; + +boot = { + interval = PCTILE; + rep_prop = 1.0; + n_rep = 200; + rng = "mt19937"; + seed = "1"; +} + +//////////////////////////////////////////////////////////////////////////////// + +interp = { + vld_thresh = 1.0; + + type = [ + { + method = NEAREST; + width = 1; + } + ]; +} + +//////////////////////////////////////////////////////////////////////////////// + +hira = { + flag = FALSE; + width = [ 2, 3, 4, 5 ]; + vld_thresh = 1.0; + cov_thresh = [ ==0.25 ]; + shape = SQUARE; + prob_cat_thresh = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +output_flag = { + fho = BOTH; + ctc = BOTH; + cts = BOTH; + mctc = NONE; + mcts = NONE; + cnt = BOTH; + sl1l2 = NONE; + sal1l2 = NONE; + vl1l2 = NONE; + val1l2 = NONE; + vcnt = BOTH; + pct = NONE; + pstd = NONE; + pjc = NONE; + prc = NONE; + ecnt = NONE; + orank = NONE; + rps = NONE; + eclv = BOTH; + mpr = BOTH; + seeps = NONE; + seeps_mpr = NONE; +} + +//////////////////////////////////////////////////////////////////////////////// +// Threshold for SEEPS p1 (Probability of being dry) + +seeps_p1_thresh = NA; + +//////////////////////////////////////////////////////////////////////////////// +// Unstructured Grid (optional ecept ugrid_dataset) + +//ugrid_dataset = "mpas"; +ugrid_max_distance_km = 35; +//ugrid_map_config = ""; +ugrid_coordinates_file = "${MET_TEST_INPUT}/ugrid_data/mpas/static.40962_reduced.nc"; + +//////////////////////////////////////////////////////////////////////////////// + +duplicate_flag = NONE; +rank_corr_flag = TRUE; +tmp_dir = "/tmp"; +output_prefix = "${OUTPUT_PREFIX}"; +version = "V12.0.0"; + +//////////////////////////////////////////////////////////////////////////////// diff --git a/internal/test_unit/xml/unit_ugrid.xml b/internal/test_unit/xml/unit_ugrid.xml index a77d95d886..80211fdc2f 100644 --- a/internal/test_unit/xml/unit_ugrid.xml +++ b/internal/test_unit/xml/unit_ugrid.xml @@ -111,4 +111,30 @@ + + &MET_BIN;/point_stat + + BEG_DS -1800 + END_DS 1800 + OUTPUT_PREFIX UGRID_MPAS_CFG_OUT_TEMP + CONFIG_DIR &CONFIG_DIR; + + \ + &DATA_DIR_UGRID;/mpas/mpasout.2012-04-09_12.00.00_reduced.nc \ + &OUTPUT_DIR;/pb2nc/gdas1.20120409.t12z.prepbufr.nc \ + &CONFIG_DIR;/PointStatConfig_ugrid_no_dataset \ + -ugrid_config ${MET_BASE}/config/UGridConfig_mpas \ + -outdir &OUTPUT_DIR;/point_stat_ugrid -v 1 + + + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V.stat + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_fho.txt + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_ctc.txt + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_cts.txt + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_cnt.txt + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_eclv.txt + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_mpr.txt + + + diff --git a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc index 25e5f3ef6f..7b9ea3b25f 100644 --- a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc +++ b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc @@ -322,27 +322,6 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo, mlog << Error << "\n" << method_name << "LevelType_Time for unstructured grid is not enabled\n\n"; exit(1); - /* Not enabled - const int debug_level = 7; - LongArray time_offsets = collect_time_offsets(vinfo); - if (0 < time_offsets.n_elements()) { - for (int idx=0; idx= debug_level) { - for (int idx=0; idx< time_offsets.n_elements(); idx++ ) { - mlog << Debug(debug_level) << method_name << "time: " - << unix_to_yyyymmdd_hhmmss(_file->ValidTime[time_offsets[idx]]) - << " from index " << time_offsets[idx] << "\n"; - } - } - } - */ } else if (level.type() == LevelType_Pres) { if (nullptr == data_vinfo) { @@ -353,7 +332,7 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo, if (vlevel >= lvl_lower && vlevel <= lvl_upper) { vinfo.set_req_name(vinfo_list[idx]->name.c_str()); if (data_plane(vinfo, plane, vinfo_list[idx])) { - plane_array.add(plane, lvl_lower, lvl_upper); + plane_array.add(plane, vlevel, vlevel); n_rec++; } mlog << Debug(5) << method_name diff --git a/src/libcode/vx_data2d_ugrid/ugrid_file.cc b/src/libcode/vx_data2d_ugrid/ugrid_file.cc index f85a6ea0ea..d157f75f0c 100644 --- a/src/libcode/vx_data2d_ugrid/ugrid_file.cc +++ b/src/libcode/vx_data2d_ugrid/ugrid_file.cc @@ -940,6 +940,9 @@ void UGridFile::read_netcdf_grid() } } + // Convert longitude from degrees east to west + for (int idx=0; idxNedge = data.Nedge; -D->Nnode = data.Nnode; +D->n_edge = data.n_edge; +D->n_node = data.n_node; D->max_distance_km = data.max_distance_km; -D->set_points(data.Nface, data.pointLonLat); +D->set_points(data.n_face, data.point_lonlat); us = D; D = (UnstructuredData *)nullptr; @@ -1690,11 +1690,11 @@ bool is_eq(const UnstructuredData * us1, const UnstructuredData * us2) bool status = false; if (us1 && us2) { if (us1 == us2) status = true; - else status = us1->Nface == us2->Nface - && us1->Nnode == us2->Nnode - && us1->Nedge == us2->Nedge - && us1->pointLonLat[0] == us2->pointLonLat[0] - && (us1->Nface > 0 && us1->pointLonLat[us1->Nface-1] == us2->pointLonLat[us2->Nface-1]) + else status = us1->n_face == us2->n_face + && us1->n_node == us2->n_node + && us1->n_edge == us2->n_edge + && us1->point_lonlat[0] == us2->point_lonlat[0] + && (us1->n_face > 0 && us1->point_lonlat[us1->n_face-1] == us2->point_lonlat[us2->n_face-1]) && is_eq(us1->lat_checksum, us2->lat_checksum) && is_eq(us1->lon_checksum, us2->lon_checksum); } diff --git a/src/libcode/vx_grid/unstructured_grid.cc b/src/libcode/vx_grid/unstructured_grid.cc index 9af740a233..d1a56ff9f0 100644 --- a/src/libcode/vx_grid/unstructured_grid.cc +++ b/src/libcode/vx_grid/unstructured_grid.cc @@ -96,14 +96,14 @@ void UnstructuredGrid::set_from_data(const UnstructuredData &data) { clear(); if (data.name) Name = data.name; - Nx = data.Nface; + Nx = data.n_face; - Data.Nface = Nx; - Data.Nedge = data.Nedge; - Data.Nnode = data.Nnode; + Data.n_face = Nx; + Data.n_edge = data.n_edge; + Data.n_node = data.n_node; Data.max_distance_km = data.max_distance_km; - Data.set_points(Nx, data.pointLonLat); + Data.set_points(Nx, data.point_lonlat); } @@ -120,9 +120,9 @@ void UnstructuredGrid::set_max_distance_km(double max_distance) { void UnstructuredGrid::latlon_to_xy(double lat, double lon, double &x, double &y) const { - PointLonLat _pointLonLat(lon, lat); + PointLonLat _point_lonlat(lon, lat); - IndexKDTree::ValueList neighbor = Data.kdtree->closestPoints(_pointLonLat, 1); + IndexKDTree::ValueList neighbor = Data.kdtree->closestPoints(_point_lonlat, 1); size_t index(neighbor[0].payload()); double distance_km(neighbor[0].distance()/1000.); bool in_distance = Data.is_in_distance(distance_km); @@ -130,16 +130,12 @@ void UnstructuredGrid::latlon_to_xy(double lat, double lon, double &x, double &y x = in_distance ? index : -1.0; y = 0; - //PointLonLat r_lonlat; - //if(_distance > 180.0) atlas_geometry.xyz2lonlat(neighbor[0].point(), r_lonlat); - //else r_lonlat.assign(neighbor[0].point()[0], neighbor[0].point()[1]); - if(mlog.verbosity_level() >= UGRID_DEBUG_LEVEL) mlog << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredGrid::latlon_to_xy() " << "input=(" << lon << ", " << lat << ") ==> (" << x << ", " << y << ") == (" - << Data.pointLonLat[index].x() << ", " << Data.pointLonLat[index].y() + << Data.point_lonlat[index].x() << ", " << Data.point_lonlat[index].y() << ") distance= " << distance_km << "km, " - << _pointLonLat.distance(Data.pointLonLat[index]) + << _point_lonlat.distance(Data.point_lonlat[index]) << " degree" << (in_distance ? " " : ", rejected") << "\n"; } @@ -149,8 +145,8 @@ void UnstructuredGrid::latlon_to_xy(double lat, double lon, double &x, double &y void UnstructuredGrid::xy_to_latlon(double x, double y, double &lat, double &lon) const { - lat = Data.pointLonLat[x].y(); - lon = Data.pointLonLat[x].x(); + lat = Data.point_lonlat[x].y(); + lon = Data.point_lonlat[x].x(); if(mlog.verbosity_level() >= UGRID_DEBUG_LEVEL) mlog << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredGrid::xy_to_latlon() " @@ -213,7 +209,7 @@ else out << "(nul)\n"; out << '\n'; -out << prefix << "Nface = " << Nx << "\n"; +out << prefix << "n_face = " << Nx << "\n"; // // done @@ -234,7 +230,7 @@ ConcatString a; a << "Projection: UnstructuredGrid" << sep; -a << "Nface: " << Nx << sep; +a << "n_face: " << Nx << sep; // // done // @@ -352,13 +348,13 @@ void UnstructuredData::build_tree() { atlas::idx_t n = 0; kdtree = new IndexKDTree(atlas_geometry); - kdtree->reserve(Nface); - for (int i=0; ireserve(n_face); + for (int i=0; iinsert(pointLL, n++); - lat_checksum += (i+1) * pointLonLat[i].y(); - lon_checksum += (i+1) * pointLonLat[i].x(); + lat_checksum += (i+1) * point_lonlat[i].y(); + lon_checksum += (i+1) * point_lonlat[i].x(); } kdtree->build(); @@ -368,18 +364,18 @@ void UnstructuredData::build_tree() { //////////////////////////////////////////////////////////////////////// void UnstructuredData::copy_from(const UnstructuredData &us_data) { - set_points(us_data.Nface, us_data.pointLonLat); - Nedge = us_data.Nedge; - Nnode = us_data.Nnode; + set_points(us_data.n_face, us_data.point_lonlat); + n_edge = us_data.n_edge; + n_node = us_data.n_node; max_distance_km = us_data.max_distance_km; } //////////////////////////////////////////////////////////////////////// void UnstructuredData::copy_from(const UnstructuredData *us_data) { - set_points(us_data->Nface, us_data->pointLonLat); - Nedge = us_data->Nedge; - Nnode = us_data->Nnode; + set_points(us_data->n_face, us_data->point_lonlat); + n_edge = us_data->n_edge; + n_node = us_data->n_node; max_distance_km = us_data->max_distance_km; } @@ -400,15 +396,15 @@ void UnstructuredData::set_points(int count, double *_lon, double *_lat) { clear_data(); - Nface = count; - pointLonLat.reserve(count); + n_face = count; + point_lonlat.reserve(count); for (int i=0; i= UGRID_DEBUG_LEVEL) mlog << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(int, double *, double *) first (" - << pointLonLat[0].x() << ", " << pointLonLat[0].y() << ") and last (" - << pointLonLat[count-1].x() << ", " << pointLonLat[count-1].y() << ") from (" + << point_lonlat[0].x() << ", " << point_lonlat[0].y() << ") and last (" + << point_lonlat[count-1].x() << ", " << point_lonlat[count-1].y() << ") from (" << _lon[0] << ", " << _lat[0] << ") and (" << _lon[count-1] << ", " << _lat[count-1] << ")\n"; @@ -422,15 +418,15 @@ void UnstructuredData::set_points(int count, const std::vector &ptL clear_data(); - Nface = count; - pointLonLat.reserve(count); + n_face = count; + point_lonlat.reserve(count); for (int i=0; i= UGRID_DEBUG_LEVEL) mlog - << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(std::vector &) first: (" - << pointLonLat[0].x() << ", " << pointLonLat[0].y() << ") and last (" - << pointLonLat[count-1].x() << ", " << pointLonLat[count-1].y() << ") from (" + << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(int, std::vector &) first: (" + << point_lonlat[0].x() << ", " << point_lonlat[0].y() << ") and last (" + << point_lonlat[count-1].x() << ", " << point_lonlat[count-1].y() << ") from (" << ptLonLat[0].x() << ", " << ptLonLat[0].y() << ") and (" << ptLonLat[count-1].x() << ", " << ptLonLat[count-1].y() << ")\n"; diff --git a/src/libcode/vx_grid/unstructured_grid_defs.h b/src/libcode/vx_grid/unstructured_grid_defs.h index a363bbab6d..68456d0d35 100644 --- a/src/libcode/vx_grid/unstructured_grid_defs.h +++ b/src/libcode/vx_grid/unstructured_grid_defs.h @@ -36,14 +36,14 @@ struct UnstructuredData { const char * name; // not allocated - int Nface; - int Nedge; - int Nnode; + int n_face; + int n_edge; + int n_node; double max_distance_km; // This should be set after calling set_points() double lat_checksum; double lon_checksum; - std::vector pointLonLat; + std::vector point_lonlat; atlas::util::IndexKDTree *kdtree; UnstructuredData(); diff --git a/src/libcode/vx_regrid/vx_regrid.cc b/src/libcode/vx_regrid/vx_regrid.cc index 7abfee78b4..5fcc970601 100644 --- a/src/libcode/vx_regrid/vx_regrid.cc +++ b/src/libcode/vx_regrid/vx_regrid.cc @@ -133,7 +133,6 @@ to_data.set_accum (from_data.accum()); // // copy data // - for (xt=0; xt<(to_grid.nx()); ++xt) { for (yt=0; yt<(to_grid.ny()); ++yt) { diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 89ac9c8385..6d8e13864d 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -192,11 +192,13 @@ static void finish_txt_files(); static void clean_up(); static void usage(); -static void set_config(const StringArray &); static void set_outdir(const StringArray &); static void set_compress(const StringArray &); static bool read_data_plane(VarInfo* info, DataPlane& dp, Met2dDataFile* mtddf, const ConcatString &filename); +#ifdef WITH_UGRID +static void set_ugrid_config(const StringArray &); +#endif //////////////////////////////////////////////////////////////////////// @@ -248,6 +250,9 @@ void process_command_line(int argc, char **argv) { // Add the options function calls cline.add(set_outdir, "-outdir", 1); cline.add(set_compress, "-compress", 1); +#ifdef WITH_UGRID + cline.add(set_ugrid_config, "-ugrid_config", 1); +#endif // Parse the command line cline.parse(); @@ -271,7 +276,9 @@ void process_command_line(int argc, char **argv) { // Read the config files conf_info.read_config(default_config_file.c_str(), config_file.c_str()); - conf_info.read_configs(config_files); +#ifdef WITH_UGRID + conf_info.read_ugrid_configs(ugrid_config_files, config_file.c_str()); +#endif // Get the forecast and observation file types from config, if present ftype = parse_conf_file_type(conf_info.conf.lookup_dictionary(conf_key_fcst)); @@ -3094,6 +3101,9 @@ void usage() { << "\tfcst_file\n" << "\tobs_file\n" << "\tconfig_file\n" +#ifdef WITH_UGRID + << "\t[-ugrid_config config_file]\n" +#endif << "\t[-outdir path]\n" << "\t[-log file]\n" << "\t[-v level]\n" @@ -3108,8 +3118,10 @@ void usage() { << "\t\t\"config_file\" is a GridStatConfig file containing " << "the desired configuration settings (required).\n" - << "\t\t\"-config config_file\" specifies additional PointStatConfig file containing " - << "the configuration settings for unstructured grid (optional).\n" +#ifdef WITH_UGRID + << "\t\t\"-ugrid_config ugrid_config_file\" is a UGridConfig file containing " + << "the desired configuration settings for unstructured grid (required only for UGrid)\n" +#endif << "\t\t\"-outdir path\" overrides the default output directory " << "(" << out_dir << ") (optional).\n" @@ -3128,10 +3140,12 @@ void usage() { //////////////////////////////////////////////////////////////////////// -void set_config(const StringArray & a) +#ifdef WITH_UGRID +void set_ugrid_config(const StringArray & a) { - config_files.add(a[0]); + ugrid_config_files.add(a[0]); } +#endif //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/grid_stat/grid_stat.h b/src/tools/core/grid_stat/grid_stat.h index b5db513b57..ccd85c82ac 100644 --- a/src/tools/core/grid_stat/grid_stat.h +++ b/src/tools/core/grid_stat/grid_stat.h @@ -113,7 +113,7 @@ static ConcatString obs_file; // Input Config file static ConcatString config_file; -static StringArray config_files; +static StringArray ugrid_config_files; static GridStatConfInfo conf_info; // Optional arguments 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 d277783684..db34b15925 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -49,6 +49,9 @@ void GridStatConfInfo::init_from_scratch() { // Initialize pointers vx_opt = (GridStatVxOpt *) nullptr; +#ifdef WITH_UGRID + ignore_ugrid_dataset = false; +#endif clear(); return; @@ -69,7 +72,7 @@ void GridStatConfInfo::clear() { version.clear(); #ifdef WITH_UGRID ugrid_nc.clear(); - ugrid_dataset.clear(); + if (!ignore_ugrid_dataset) ugrid_dataset.clear(); ugrid_map_config.clear(); ugrid_max_distance_km = bad_data_double; #endif @@ -109,18 +112,25 @@ void GridStatConfInfo::read_config(const char *default_file_name, //////////////////////////////////////////////////////////////////////// -void GridStatConfInfo::read_configs(StringArray user_file_names) { - - const char *file_name; - for (int i=0; i " - << "The configuration file \"" << user_file_names[i]<< "\" does not exist.\n\n"; +#ifdef WITH_UGRID +void GridStatConfInfo::read_ugrid_configs(StringArray ugrid_config_names, const char * user_config) { + + ConcatString file_name; + for (int i=0; i " + << "The configuration file \"" << ugrid_config_names[i]<< "\" does not exist.\n\n"; } + if (file_exists(user_config)) conf.read(user_config); /* to avoid overriding by ugrid_config_names */ return; } +#endif //////////////////////////////////////////////////////////////////////// @@ -154,7 +164,7 @@ void GridStatConfInfo::process_config(GrdFileType ftype, #ifdef WITH_UGRID // Conf: ugrid_dataset - ugrid_dataset = parse_conf_ugrid_dataset(&conf); + if (!ignore_ugrid_dataset) ugrid_dataset = parse_conf_ugrid_dataset(&conf); // Conf: ugrid_nc ugrid_nc = parse_conf_ugrid_coordinates_file(&conf); 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 33418fbfbb..ca529a27e1 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.h +++ b/src/tools/core/grid_stat/grid_stat_conf_info.h @@ -284,6 +284,7 @@ class GridStatConfInfo { ConcatString output_prefix; // String to customize output file name ConcatString version; // Config file version #ifdef WITH_UGRID + bool ignore_ugrid_dataset; ConcatString ugrid_nc; // NetCDF for coordinate variables of unstructured grid ConcatString ugrid_dataset; // UGRid dataset name (mpas, lfric etc) ConcatString ugrid_map_config; // User's configuration file which contains ugrid metadata mapping @@ -299,7 +300,9 @@ class GridStatConfInfo { void clear(); void read_config (const char *, const char *); - void read_configs (StringArray user_file_names); +#ifdef WITH_UGRID + void read_ugrid_configs(StringArray ugrid_config_names, const char * user_config); +#endif void process_config(GrdFileType, GrdFileType); void process_flags (); void process_masks (const Grid &); diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 38cbc28f40..313db804b8 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -175,12 +175,14 @@ static void finish_txt_files(); static void clean_up(); static void usage(); -static void set_config(const StringArray &); static void set_point_obs(const StringArray &); static void set_ncfile(const StringArray &); static void set_obs_valid_beg_time(const StringArray &); static void set_obs_valid_end_time(const StringArray &); static void set_outdir(const StringArray &); +#ifdef WITH_UGRID +static void set_ugrid_config(const StringArray &); +#endif //////////////////////////////////////////////////////////////////////// @@ -240,7 +242,9 @@ void process_command_line(int argc, char **argv) { cline.set_usage(usage); // Add the options function calls - cline.add(set_config, "-config", 1); +#ifdef WITH_UGRID + cline.add(set_ugrid_config, "-ugrid_config", 1); +#endif cline.add(set_point_obs, "-point_obs", 1); cline.add(set_ncfile, "-ncfile", 1); cline.add(set_obs_valid_beg_time, "-obs_valid_beg", 1); @@ -283,7 +287,9 @@ void process_command_line(int argc, char **argv) { // Read the config files conf_info.read_config(default_config_file.c_str(), config_file.c_str()); - conf_info.read_configs(config_files); +#ifdef WITH_UGRID + conf_info.read_ugrid_configs(ugrid_config_files, config_file.c_str()); +#endif // Get the forecast file type from config, if present ftype = parse_conf_file_type(conf_info.conf.lookup_dictionary(conf_key_fcst)); @@ -2203,7 +2209,9 @@ void usage() { << "\tfcst_file\n" << "\tobs_file\n" << "\tconfig_file\n" - << "\t[-config config_file]\n" +#ifdef WITH_UGRID + << "\t[-ugrid_config config_file]\n" +#endif << "\t[-point_obs file]\n" << "\t[-obs_valid_beg time]\n" << "\t[-obs_valid_end time]\n" @@ -2220,8 +2228,10 @@ void usage() { << "\t\t\"config_file\" is a PointStatConfig file containing " << "the desired configuration settings (required).\n" - << "\t\t\"-config config_file\" specifies additional PointStatConfig file containing " - << "the configuration settings for unstructured grid (optional).\n" +#ifdef WITH_UGRID + << "\t\t\"-ugrid_config ugrid_config_file\" is a UGridConfig file containing " + << "the desired configuration settings for unstructured grid (required only for UGrid)\n" +#endif << "\t\t\"-point_obs file\" specifies additional NetCDF point " << "observation files to be used (optional).\n" @@ -2246,10 +2256,12 @@ void usage() { //////////////////////////////////////////////////////////////////////// -void set_config(const StringArray & a) +#ifdef WITH_UGRID +void set_ugrid_config(const StringArray & a) { - config_files.add(a[0]); + ugrid_config_files.add(a[0]); } +#endif //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/point_stat/point_stat.h b/src/tools/core/point_stat/point_stat.h index 7d69a62b62..0804650b0a 100644 --- a/src/tools/core/point_stat/point_stat.h +++ b/src/tools/core/point_stat/point_stat.h @@ -108,7 +108,7 @@ static StringArray obs_file; // Input Config file static ConcatString config_file; -static StringArray config_files; +static StringArray ugrid_config_files; static PointStatConfInfo conf_info; // Optional arguments diff --git a/src/tools/core/point_stat/point_stat_conf_info.cc b/src/tools/core/point_stat/point_stat_conf_info.cc index ce7a0035f7..e05157d5bc 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.cc +++ b/src/tools/core/point_stat/point_stat_conf_info.cc @@ -49,6 +49,9 @@ void PointStatConfInfo::init_from_scratch() { // Initialize pointers vx_opt = (PointStatVxOpt *) nullptr; +#ifdef WITH_UGRID + ignore_ugrid_dataset = false; +#endif clear(); return; @@ -73,7 +76,7 @@ void PointStatConfInfo::clear() { version.clear(); #ifdef WITH_UGRID ugrid_nc.clear(); - ugrid_dataset.clear(); + if (!ignore_ugrid_dataset) ugrid_dataset.clear(); ugrid_map_config.clear(); ugrid_max_distance_km = bad_data_double; #endif @@ -105,18 +108,25 @@ void PointStatConfInfo::read_config(const char *default_file_name, //////////////////////////////////////////////////////////////////////// -void PointStatConfInfo::read_configs(StringArray user_file_names) { - - const char *file_name; - for (int i=0; i " - << "The configuration file \"" << user_file_names[i]<< "\" does not exist.\n\n"; +#ifdef WITH_UGRID +void PointStatConfInfo::read_ugrid_configs(StringArray ugrid_config_names, const char * user_config) { + + ConcatString file_name; + for (int i=0; i " + << "The configuration file \"" << ugrid_config_names[i]<< "\" does not exist.\n\n"; } + if (file_exists(user_config)) conf.read(user_config); /* to avoid overriding by ugrid_config_names */ return; } +#endif //////////////////////////////////////////////////////////////////////// @@ -143,7 +153,7 @@ void PointStatConfInfo::process_config(GrdFileType ftype) { #ifdef WITH_UGRID // Conf: ugrid_dataset - ugrid_dataset = parse_conf_ugrid_dataset(&conf); + if (!ignore_ugrid_dataset) ugrid_dataset = parse_conf_ugrid_dataset(&conf); // Conf: ugrid_nc ugrid_nc = parse_conf_ugrid_coordinates_file(&conf); diff --git a/src/tools/core/point_stat/point_stat_conf_info.h b/src/tools/core/point_stat/point_stat_conf_info.h index 5e3db2184a..befde20349 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.h +++ b/src/tools/core/point_stat/point_stat_conf_info.h @@ -247,6 +247,7 @@ class PointStatConfInfo { ConcatString output_prefix; // String to customize output file name ConcatString version; // Config file version #ifdef WITH_UGRID + bool ignore_ugrid_dataset; ConcatString ugrid_nc; // NetCDF for coordinate variables of unstructured grid ConcatString ugrid_dataset; // UGRid dataset name (mpas, lfric etc) ConcatString ugrid_map_config; // User's configuration file which contains ugrid metadata mapping @@ -261,7 +262,9 @@ class PointStatConfInfo { void clear(); void read_config(const char *, const char *); - void read_configs(StringArray user_file_names); +#ifdef WITH_UGRID + void read_ugrid_configs(StringArray ugrid_config_names, const char * user_config); +#endif void process_config(GrdFileType); void process_grib_codes(); From 3caffb4cda40a119138a089495c6a289d9c59a83 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Mon, 29 Apr 2024 09:53:38 -0600 Subject: [PATCH 069/114] Feature 2753 comp script config (#2868) * set dynamic library file extension to .dylib if running on MacOS and .so otherwise * Added disabling of jasper documentation for compiliation on Hera * Updated * remove extra export of compiler env vars * include full path to log file so it is easier to file the log file to examine when a command fails * send cmake output to a log file * remove redundant semi-colon * use full path to log file so it is easier to examine on failure * use run_cmd to catch if rm command fails * Modifications for compilation on hera, gaea, and orion * Updating * fixed variable name * clean up if/else statements * set TIFF_LIBRARY_RELEASE argument to use full path to dynamic library file to prevent failure installing proj library * set LDFLAGS so that LDFLAGS value set in the user's environment will also be used * Updated based on gaea, orion, and hera installs * Updated * change extension of dynamic library files only if architecture is arm64 because older Macs still use .so * added netcdf library to args to prevent error installing NetCDF-CXX when PROJ has been installed in the same run of the script -- PATH is set in the COMPILE_PROJ if block that causes this flag from being added automatically * clean up how rpath and -L are added to LDFLAGS so that each entry is separate -- prevents errors installing on Mac arm64 because multiple rpath values aren't read using :. Also use MET_PROJLIB * Updated * removed -ltiff from MET libs * only add path to rpath and -L arguments if they are not already included in LDFLAGS * changed from using LIB_TIFF (full path to tiff lib file) to use TIFF_LIB_DIR (dir containing tiff lib file). Added TIFF_INCLUDE_DIR to proj compilation and -DJAS_ENABLE_DOC to jasper compliation taken from @jprestop branch * update comments * ensure all MET_* and MET_*LIB variables are added to the rpath for consistency * remove unnecessary if block and only export LDFLAGS at the end of setting locally * Updated * Added section for adding /lib64 and rearranged placement of ADDTL_DIR * Commenting out the running of the Jasper lib tests * Updating and/or removing files * Updating and/or removing files * Latest udpates which include the addition of the tiff library for proj * Remove commented out line. Co-authored-by: John Halley Gotway * Make indentation consistent. Co-authored-by: John Halley Gotway * Make indentation consistent. Co-authored-by: John Halley Gotway * Make indentation consistent. Co-authored-by: John Halley Gotway * Per 2753, added -lm to configure_lib_args for NetCDF-CXX * Per #2753 updating acorn files * Per #2753, update wcoss2 files * Per #2753, updating acorn file to include MET_PYTHON_EXE * Per #2753, updated files for 12.0.0 for derecho * Per #2753, updated derecho file adding MET_PYTHON_EXE and made corrections * Updating config files * Updating orion files * Updates for gaea's files * Updating gaea modulefile * Removing modulefile for cheyenne * Added MET_PYTHON_EXE * Added MET_PYTHON_EXE to hera too * Adding file for hercules * Removing equals sign from setenv * Adding file for hercules * Updated script to add libjpeg installation for grib2c * Per #2753, Adding file for casper --------- Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> Co-authored-by: John Halley Gotway --- .../scripts/installation/compile_MET_all.sh | 26 ++++++++- ...env.acorn_py3.10 => install_met_env.acorn} | 0 .../config/install_met_env.casper | 54 +++++++++++-------- .../config/install_met_env.derecho | 30 ++++++----- .../installation/config/install_met_env.gaea | 19 +++---- .../installation/config/install_met_env.hera | 4 +- .../config/install_met_env.hercules | 39 ++++++++++++++ .../installation/config/install_met_env.jet | 8 +-- .../installation/config/install_met_env.orion | 18 +++---- ...v.wcoss2_py3.10 => install_met_env.wcoss2} | 4 +- .../installation/modulefiles/11.1.0_cheyenne | 29 ---------- .../installation/modulefiles/12.0.0_acorn | 4 ++ .../installation/modulefiles/12.0.0_casper | 24 +++++++++ .../installation/modulefiles/12.0.0_derecho | 22 ++++++++ .../installation/modulefiles/12.0.0_gaea | 4 +- .../installation/modulefiles/12.0.0_hera | 2 + .../installation/modulefiles/12.0.0_hercules | 20 +++++++ .../installation/modulefiles/12.0.0_jet | 2 + .../installation/modulefiles/12.0.0_orion | 7 +-- 19 files changed, 222 insertions(+), 94 deletions(-) rename internal/scripts/installation/config/{install_met_env.acorn_py3.10 => install_met_env.acorn} (100%) create mode 100644 internal/scripts/installation/config/install_met_env.hercules rename internal/scripts/installation/config/{install_met_env.wcoss2_py3.10 => install_met_env.wcoss2} (98%) delete mode 100644 internal/scripts/installation/modulefiles/11.1.0_cheyenne create mode 100644 internal/scripts/installation/modulefiles/12.0.0_casper create mode 100644 internal/scripts/installation/modulefiles/12.0.0_derecho create mode 100644 internal/scripts/installation/modulefiles/12.0.0_hercules diff --git a/internal/scripts/installation/compile_MET_all.sh b/internal/scripts/installation/compile_MET_all.sh index 98d9fca899..6524aa8563 100755 --- a/internal/scripts/installation/compile_MET_all.sh +++ b/internal/scripts/installation/compile_MET_all.sh @@ -37,7 +37,7 @@ # The compile_MET_all.sh script will compile and install MET and its # external library dependencies, if needed, including: # PROJ (with dependency SQLITE >= 3.11), GSL, BUFRLIB, -# GRIB2C (with dependencies Z, PNG, JASPER), HDF5, NETCDF (C and CXX), +# GRIB2C (with dependencies Z, PNG, JASPER, JPEG), HDF5, NETCDF (C and CXX), # HDF4 (optional for MODIS-Regrid and lidar2nc), HDFEOS (optional for # MODIS-Regrid and lidar2nc), FREETYPE (optional for MODE Graphics), # and CAIRO (optional for MODE Graphics). @@ -51,7 +51,7 @@ # in the input environment configuration file (install_met_env.: # MET_GRIB2CLIB, MET_GRIB2CINC, GRIB2CLIB_NAME, MET_BUFRLIB, BUFRLIB_NAME, # MET_HDF5, MET_NETCDF, MET_PROJ, MET_GSL, LIB_JASPER, LIB_LIBPNG, LIB_Z, -# SQLITE_INCLUDE_DIR, SQLITE_LIB_DIR, TIFF_INCLUDE_DIR, TIFF_LIB_DIR. +# LIB_JPEG, SQLITE_INCLUDE_DIR, SQLITE_LIB_DIR, TIFF_INCLUDE_DIR, TIFF_LIB_DIR. # # The optional libraries ecKit and atlas offer support for unstructured # grids. The optional libraries HDF4, HDFEOS, FREETYPE, and CAIRO are @@ -176,11 +176,13 @@ if [[ -z ${MET_GRIB2CLIB} ]] && [[ -z ${MET_GRIB2C} ]]; then COMPILE_ZLIB=1 COMPILE_LIBPNG=1 COMPILE_JASPER=1 + COMPILE_JPEG=1 COMPILE_G2CLIB=1 else COMPILE_ZLIB=0 COMPILE_LIBPNG=0 COMPILE_JASPER=0 + COMPILE_JPEG=0 COMPILE_G2CLIB=0 fi @@ -269,6 +271,7 @@ if [ ! -z "${SKIP_LIBS}" ]; then COMPILE_ZLIB=0 COMPILE_LIBPNG=0 COMPILE_JASPER=0 + COMPILE_JPEG=0 COMPILE_G2CLIB=0 COMPILE_ECKIT=0 COMPILE_ATLAS=0 @@ -570,6 +573,7 @@ if [[ $COMPILE_LIBPNG -eq 1 && $HOST != ys* ]]; then run_cmd "make ${MAKE_ARGS} install > $(pwd)/libpng.make_install.log 2>&1" fi + # Compile JASPER if [ $COMPILE_JASPER -eq 1 ]; then @@ -594,6 +598,24 @@ if [ $COMPILE_JASPER -eq 1 ]; then run_cmd "make ${MAKE_ARGS} install > $(pwd)/jasper.make_install.log 2>&1" fi +# Compile JPEG +if [ $COMPILE_JPEG -eq 1 ]; then + + vrs="9e" + + echo + echo "Compiling JPEG at `date`" + mkdir -p ${LIB_DIR}/jpeg + rm -rf ${LIB_DIR}/jpeg/jpeg* + tar -xf ${TAR_DIR}/jpegsrc.v${vrs}.tar.gz -C ${LIB_DIR}/jpeg + cd ${LIB_DIR}/jpeg/jpeg-${vrs} + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} LDFLAGS=-L${LIB_DIR}/lib CPPFLAGS=-I${LIB_DIR}/include > $(pwd)/libjpeg.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/libjpeg.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/libjpeg.make_install.log 2>&1" +fi + + # Compile G2CLIB if [ $COMPILE_G2CLIB -eq 1 ]; then diff --git a/internal/scripts/installation/config/install_met_env.acorn_py3.10 b/internal/scripts/installation/config/install_met_env.acorn similarity index 100% rename from internal/scripts/installation/config/install_met_env.acorn_py3.10 rename to internal/scripts/installation/config/install_met_env.acorn diff --git a/internal/scripts/installation/config/install_met_env.casper b/internal/scripts/installation/config/install_met_env.casper index c9e9f06a91..703be5e531 100644 --- a/internal/scripts/installation/config/install_met_env.casper +++ b/internal/scripts/installation/config/install_met_env.casper @@ -1,30 +1,40 @@ -module load ncarenv/1.3 -module load intel/2021.2 -module load netcdf/4.8.0 +module load ncarenv/23.10 +module load intel-classic/2023.2.1 +module load cmake/3.26.3 -export TEST_BASE=/glade/p/ral/jntp/MET/MET_releases/casper/11.1.0 -export COMPILER=intel_2021.2 +export TEST_BASE=/glade/work/dtcrt/METplus/casper/components/MET/installations/12.0.0 +export COMPILER=intel-classic_2023.2.1 export MET_SUBDIR=${TEST_BASE} -export MET_TARBALL=v11.1.0.tar.gz +export MET_TARBALL=v12.0.0.tar.gz export USE_MODULES=TRUE -export MET_PYTHON=/glade/p/ral/jntp/MET/METplus/miniconda/miniconda3/envs/metplus_v5.1_py3.10 +export MET_PYTHON=/glade/work/dtcrt/METplus/casper/miniconda/miniconda3/envs/metplus_v5.1_py3.10 export MET_PYTHON_CC=-I${MET_PYTHON}/include/python3.10 export MET_PYTHON_LD=`${MET_PYTHON}/bin/python3-config --ldflags --embed` -export MET_NETCDF=/glade/u/apps/ch/opt/netcdf/4.8.0/intel/2021.2/ -export MET_HDF5=/glade/u/apps/ch/opt/netcdf/4.8.0/intel/2021.2/ +#export ADDTL_DIR=/usr/lib64 export EXTERNAL_LIBS=${TEST_BASE}/external_libs -#export MET_GSL=${EXTERNAL_LIBS} -#export MET_BUFRLIB=${EXTERNAL_LIBS} -#export BUFRLIB_NAME=-lbufr -#export MET_HDF5=${EXTERNAL_LIBS} -#export MET_GRIB2CLIB=${EXTERNAL_LIBS}/lib -#export MET_GRIB2CINC=${EXTERNAL_LIBS}/include -#export GRIB2CLIB_NAME=-lgrib2c -#export LIB_JASPER=${EXTERNAL_LIBS}/lib -#export LIB_LIBPNG=${EXTERNAL_LIBS}/lib -#export LIB_Z=${EXTERNAL_LIBS}/lib -export SET_D64BIT=FALSE +#export COMPILE_ECKIT=1 +#export COMPILE_ATLAS=1 +export MET_PROJ=${EXTERNAL_LIBS} +export MET_ECKIT=${EXTERNAL_LIBS} +export MET_ATLAS=${EXTERNAL_LIBS} +export MET_GSL=${EXTERNAL_LIBS} +export MET_BUFRLIB=${EXTERNAL_LIBS} +export BUFRLIB_NAME=-lbufr_4 +export MET_GRIB2CLIB=${EXTERNAL_LIBS}/lib64 +export MET_GRIB2CINC=${EXTERNAL_LIBS}/include +export GRIB2CLIB_NAME=-lg2c +export LIB_JASPER=${EXTERNAL_LIBS}/lib64 +export LIB_LIBPNG=${EXTERNAL_LIBS}/lib +export LIB_Z=${EXTERNAL_LIBS}/lib +export LIB_JPEG=${EXTERNAL_LIBS}/lib +export MET_NETCDF=${EXTERNAL_LIBS} +export MET_HDF5=${EXTERNAL_LIBS} +export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib +export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include +export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib +export MAKE_ARGS="-j 5" #export CFLAGS="-Wall -g" #export CXXFLAGS="-Wall -g" -export MAKE_ARGS=-j -export CXXFLAGS="-std=c++11" +#export CXXFLAGS="-std=c++11" +#export SKIP_MET=true diff --git a/internal/scripts/installation/config/install_met_env.derecho b/internal/scripts/installation/config/install_met_env.derecho index 5ad11f3eb7..eb02198760 100644 --- a/internal/scripts/installation/config/install_met_env.derecho +++ b/internal/scripts/installation/config/install_met_env.derecho @@ -1,36 +1,42 @@ -module load ncarenv/23.06 -module load intel-oneapi/2023.0.0 +module load ncarenv/23.09 +module load intel/2023.2.1 module load cmake/3.26.3 -module load hdf5/1.12.2 -module load netcdf/4.9.2 -export TEST_BASE=/glade/p/ral/jntp/MET/MET_releases/12.0.0 -export COMPILER=intel-oneapi_2023.0.0 +export CC=icx +export CXX=icpx +export FC=ifx +export F77=ifx +export F90=ifx + +export TEST_BASE=/glade/work/dtcrt/METplus/derecho/components/MET/installations/12.0.0 +export COMPILER=intel_2023.2.1 export MET_SUBDIR=${TEST_BASE} export MET_TARBALL=v12.0.0.tar.gz export USE_MODULES=TRUE -export MET_PYTHON=/glade/p/ral/jntp/MET/METplus/miniconda/miniconda3/envs/metplus_v5.1_py3.10 +export MET_PYTHON=/glade/work/dtcrt/METplus/derecho/miniconda/miniconda3/envs/metplus_v5.1_py3.10 export MET_PYTHON_CC=-I${MET_PYTHON}/include/python3.10 export MET_PYTHON_LD=`${MET_PYTHON}/bin/python3-config --ldflags --embed` -export MET_NETCDF=/glade/u/apps/derecho/23.06/spack/opt/spack/netcdf/4.9.2/oneapi/2023.0.0/iijr -export MET_HDF5=/glade/u/apps/derecho/23.06/spack/opt/spack/hdf5/1.12.2/oneapi/2023.0.0/d6xa -export ADDTL_DIR=/usr/lib64 export EXTERNAL_LIBS=${TEST_BASE}/external_libs -#export MET_PROJ=${EXTERNAL_LIBS} -#export LIB_TIFF=${ADDTL_DIR}/libtiff.so.5 export COMPILE_ECKIT=1 export COMPILE_ATLAS=1 +#export MET_PROJ=${EXTERNAL_LIBS} #export MET_ECKIT=${EXTERNAL_LIBS} #export MET_ATLAS=${EXTERNAL_LIBS} #export MET_GSL=${EXTERNAL_LIBS} #export MET_BUFRLIB=${EXTERNAL_LIBS} #export BUFRLIB_NAME=-lbufr_4 +#export MET_NETCDF=${EXTERNAL_LIBS} +#export MET_HDF5=${EXTERNAL_LIBS} #export MET_GRIB2CLIB=${EXTERNAL_LIBS}/lib64 #export MET_GRIB2CINC=${EXTERNAL_LIBS}/include #export GRIB2CLIB_NAME=-lg2c #export LIB_JASPER=${EXTERNAL_LIBS}/lib64 #export LIB_LIBPNG=${EXTERNAL_LIBS}/lib #export LIB_Z=${EXTERNAL_LIBS}/lib +#export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib +#export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib export MAKE_ARGS=-j #export CFLAGS="-Wall -g" #export CXXFLAGS="-Wall -g" diff --git a/internal/scripts/installation/config/install_met_env.gaea b/internal/scripts/installation/config/install_met_env.gaea index 78052504da..8a60c93f84 100644 --- a/internal/scripts/installation/config/install_met_env.gaea +++ b/internal/scripts/installation/config/install_met_env.gaea @@ -5,21 +5,18 @@ export F77=ifx export F90=ifx export CC=icx export CXX=icpx -export TEST_BASE=/usw/met/12.0.0-beta2 +export TEST_BASE=/usw/met/12.0.0 export COMPILER=intel-oneapi_2022.0.2 export MET_SUBDIR=${TEST_BASE} -export MET_TARBALL=v12.0.0-beta2.tar.gz +export MET_TARBALL=v12.0.0.tar.gz export USE_MODULES=TRUE -export MET_PYTHON=/lustre/f2/dev/esrl/Julie.Prestopnik/projects/miniconda/miniconda3/envs/metplus_v5.1_py3.10/ +export MET_PYTHON=/gpfs/f5/esrl/proj-shared/Julie.Prestopnik/projects/miniconda/miniconda3/envs/metplus_v5.1_py3.10/ export MET_PYTHON_CC=-I${MET_PYTHON}/include/python3.10 export MET_PYTHON_LD=-L${MET_PYTHON}/lib/python3.10/config-3.10-x86_64-linux-gnu\ -L${MET_PYTHON}/lib\ -lpython3.10\ -lcrypt\ -lpthread\ -ldl\ -lutil\ -lm -export ADDTL_DIR=/usr/lib64 -#export TIFF_INCLUDE_DIR=/lustre/f2/dev/esrl/Julie.Prestopnik/projects/miniconda/miniconda3/pkgs/libtiff-4.4.0-h82bc61c_5/include -#export LIB_TIFF=${ADDTL_DIR}/libtiff.so.5 -#export EXTERNAL_LIBS=/usw/met/12.0.0-beta2/external_libs +export EXTERNAL_LIBS=${TEST_BASE}/external_libs +COMPILE_ATLAS=1 +COMPILE_ECKIT=1 #export MET_PROJ=${EXTERNAL_LIBS} -#COMPILE_ATLAS=1 -#COMPILE_ECKIT=1 #export MET_ATLAS=${EXTERNAL_LIBS} #export MET_ECKIT=${EXTERNAL_LIBS} #export MET_GSL=${EXTERNAL_LIBS} @@ -33,5 +30,9 @@ export ADDTL_DIR=/usr/lib64 #export LIB_JASPER=${EXTERNAL_LIBS}/lib #export LIB_LIBPNG=${EXTERNAL_LIBS}/lib #export LIB_Z=${EXTERNAL_LIBS}/lib +#export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib +#export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib export MAKE_ARGS="-j 5" diff --git a/internal/scripts/installation/config/install_met_env.hera b/internal/scripts/installation/config/install_met_env.hera index cddaa00f90..2b0b054190 100755 --- a/internal/scripts/installation/config/install_met_env.hera +++ b/internal/scripts/installation/config/install_met_env.hera @@ -1,6 +1,6 @@ module load gnu/9.2.0 module load intel/2022.1.2 -module load cmake/3.26.4 +module load cmake/3.28.1 export FC=ifort export F77=ifort @@ -34,6 +34,8 @@ export COMPILE_ATLAS=1 #export LIB_JASPER=${EXTERNAL_LIBS}/lib #export LIB_LIBPNG=${EXTERNAL_LIBS}/lib #export LIB_Z=${EXTERNAL_LIBS}/lib +#export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib #export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include #export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib export MAKE_ARGS="-j 5" diff --git a/internal/scripts/installation/config/install_met_env.hercules b/internal/scripts/installation/config/install_met_env.hercules new file mode 100644 index 0000000000..dffb8fe186 --- /dev/null +++ b/internal/scripts/installation/config/install_met_env.hercules @@ -0,0 +1,39 @@ +module load intel-oneapi-compilers/2022.2.1 +module load cmake/3.26.3 + +export CC=icx +export CXX=icpx +export FC=ifx +export F77=ifx +export F90=ifx + +export TEST_BASE=/apps/contrib/MET/12.0.0-beta3 +export COMPILER=intel-oneapi-compilers_2022.2.1 +export MET_SUBDIR=${TEST_BASE}/ +export MET_TARBALL=v12.0.0-beta3.tar.gz +export USE_MODULES=TRUE +export MET_PYTHON=/work/noaa/ovp/miniconda/miniconda3/envs/metplus_v5.1_py3.10 +export MET_PYTHON_CC=-I${MET_PYTHON}/include/python3.10 +export MET_PYTHON_LD=-L${MET_PYTHON}/lib/python3.10/config-3.10-x86_64-linux-gnu\ -L${MET_PYTHON}/lib\ -lpython3.10\ -lcrypt\ -lpthread\ -ldl\ -lutil\ -lrt\ -lm\ -lm +export EXTERNAL_LIBS=${TEST_BASE}/external_libs +COMPILE_ATLAS=1 +COMPILE_ECKIT=1 +#export MET_PROJ=${EXTERNAL_LIBS} +#export MET_ATLAS=${EXTERNAL_LIBS} +#export MET_ECKIT=${EXTERNAL_LIBS} +#export MET_GSL=${EXTERNAL_LIBS} +#export MET_BUFRLIB=${EXTERNAL_LIBS} +#export BUFRLIB_NAME=-lbufr_4 +#export MET_HDF5=${EXTERNAL_LIBS} +#export MET_NETCDF=${EXTERNAL_LIBS} +#export MET_GRIB2CLIB=${EXTERNAL_LIBS}/lib +#export MET_GRIB2CINC=${EXTERNAL_LIBS}/include +#export GRIB2CLIB_NAME=-lg2c +#export LIB_JASPER=${EXTERNAL_LIBS}/lib +#export LIB_LIBPNG=${EXTERNAL_LIBS}/lib +#export LIB_Z=${EXTERNAL_LIBS}/lib +#export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib +#export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib +export MAKE_ARGS="-j 5" diff --git a/internal/scripts/installation/config/install_met_env.jet b/internal/scripts/installation/config/install_met_env.jet index b3be597853..15b5563ac2 100644 --- a/internal/scripts/installation/config/install_met_env.jet +++ b/internal/scripts/installation/config/install_met_env.jet @@ -1,5 +1,5 @@ module load intel/2022.1.2 -module load cmake/3.26.4 +module load cmake/3.28.1 export FC=ifort export F77=ifort @@ -14,13 +14,11 @@ export USE_MODULES=TRUE export MET_PYTHON=/mnt/lfs1/HFIP/dtc-hurr/METplus/miniconda/miniconda3/envs/metplus_v5.1_py3.10 export MET_PYTHON_CC=-I${MET_PYTHON}/include/python3.10 export MET_PYTHON_LD=-L${MET_PYTHON}/lib/python3.10/config-3.10-x86_64-linux-gnu\ -L${MET_PYTHON}/lib\ -lpython3.10\ -lcrypt\ -lpthread\ -ldl\ -lutil\ -lrt\ -lm\ -lm -export ADDTL_DIR=/usr/lib64 +#export ADDTL_DIR=/usr/lib64 export EXTERNAL_LIBS=${TEST_BASE}/external_libs/ COMPILE_ATLAS=1 COMPILE_ECKIT=1 #export MET_PROJ=${EXTERNAL_LIBS} -export TIFF_INCLUDE_DIR=/usr/include -export TIFF_LIB_DIR=/usr/lib64 #export MET_ATLAS=${EXTERNAL_LIBS} #export MET_ECKIT=${EXTERNAL_LIBS} #export MET_GSL=${EXTERNAL_LIBS} @@ -34,6 +32,8 @@ export TIFF_LIB_DIR=/usr/lib64 #export LIB_JASPER=${EXTERNAL_LIBS}/lib #export LIB_LIBPNG=${EXTERNAL_LIBS}/lib #export LIB_Z=${EXTERNAL_LIBS}/lib +#export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib #export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include #export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib export MAKE_ARGS="-j 5" diff --git a/internal/scripts/installation/config/install_met_env.orion b/internal/scripts/installation/config/install_met_env.orion index b951ee41f5..7ba320fe03 100644 --- a/internal/scripts/installation/config/install_met_env.orion +++ b/internal/scripts/installation/config/install_met_env.orion @@ -1,23 +1,19 @@ module load intel/2020.2 module load cmake/3.22.1 -export TEST_BASE=/apps/contrib/MET/12.0.0-beta2 +export TEST_BASE=/apps/contrib/MET/12.0.0 export COMPILER=intel_2020 export MET_SUBDIR=${TEST_BASE}/ -export MET_TARBALL=v12.0.0-beta2.tar.gz +export MET_TARBALL=v12.0.0.tar.gz export USE_MODULES=TRUE export MET_PYTHON=/work/noaa/ovp/miniconda/miniconda3/envs/metplus_v5.1_py3.10 export MET_PYTHON_CC=-I${MET_PYTHON}/include/python3.10 export MET_PYTHON_LD=-L${MET_PYTHON}/lib/python3.10/config-3.10-x86_64-linux-gnu\ -L${MET_PYTHON}/lib\ -lpython3.10\ -lcrypt\ -lpthread\ -ldl\ -lutil\ -lrt\ -lm\ -lm -export ADDTL_DIR=/usr/lib64 -#export TIFF_INCLUDE_DIR=${ADDTL_DIR} -#export LIB_TIFF=${ADDTL_DIR}/libtiff.so.5 +#export ADDTL_DIR=/usr/lib64 export EXTERNAL_LIBS=${TEST_BASE}/external_libs -#export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include -#export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib +COMPILE_ATLAS=1 +COMPILE_ECKIT=1 #export MET_PROJ=${EXTERNAL_LIBS} -#COMPILE_ATLAS=1 -#COMPILE_ECKIT=1 #export MET_ATLAS=${EXTERNAL_LIBS} #export MET_ECKIT=${EXTERNAL_LIBS} #export MET_GSL=${EXTERNAL_LIBS} @@ -31,4 +27,8 @@ export EXTERNAL_LIBS=${TEST_BASE}/external_libs #export LIB_JASPER=${EXTERNAL_LIBS}/lib #export LIB_LIBPNG=${EXTERNAL_LIBS}/lib #export LIB_Z=${EXTERNAL_LIBS}/lib +#export TIFF_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export TIFF_LIB_DIR=${EXTERNAL_LIBS}/lib +#export SQLITE_INCLUDE_DIR=${EXTERNAL_LIBS}/include +#export SQLITE_LIB_DIR=${EXTERNAL_LIBS}/lib export MAKE_ARGS="-j 5" diff --git a/internal/scripts/installation/config/install_met_env.wcoss2_py3.10 b/internal/scripts/installation/config/install_met_env.wcoss2 similarity index 98% rename from internal/scripts/installation/config/install_met_env.wcoss2_py3.10 rename to internal/scripts/installation/config/install_met_env.wcoss2 index f2f29e57df..86b73e0064 100644 --- a/internal/scripts/installation/config/install_met_env.wcoss2_py3.10 +++ b/internal/scripts/installation/config/install_met_env.wcoss2 @@ -21,13 +21,13 @@ export F77=ifort export F90=ifort export CC=icc export CXX=icpc -#export TEST_BASE=/apps/ops/para/libs/intel/19.1.3.304/met/12.0.0-beta1 +#export TEST_BASE=/apps/ops/para/libs/intel/19.1.3.304/met/12.0.0-beta3 export TEST_BASE=$(pwd) export LIB_DIR=${TEST_BASE}/external_libs export BIN_DIR_PATH=${TEST_BASE}/bin export COMPILER=intel_19.1.3.304 export MET_SUBDIR=${TEST_BASE} -export MET_TARBALL=v12.0.0-beta1.tar.gz +export MET_TARBALL=v12.0.0-beta3.tar.gz export USE_MODULES=TRUE export ADDTL_DIR=/apps/spack/gettext/0.21/intel/19.1.3.304/at2kdo4edvuhyzrt5g6zhwrdb7bdui4s/lib64 export PYTHON_MODULE=python_3.10.4 diff --git a/internal/scripts/installation/modulefiles/11.1.0_cheyenne b/internal/scripts/installation/modulefiles/11.1.0_cheyenne deleted file mode 100644 index 70032e4f5d..0000000000 --- a/internal/scripts/installation/modulefiles/11.1.0_cheyenne +++ /dev/null @@ -1,29 +0,0 @@ -#%Module###################################################################### -## -## Model Evaluation Tools -## -proc ModulesHelp { } { - puts stderr "Sets up the paths and environment variables to use the Model Evaluation Tools v11.1.0 - *** For help see the official MET webpage at http://www.dtcenter.org/met/users ***" -} - -# If they exist, remove ncdump and ncgen from /glade/p/ral/jntp/MET/MET_releases/11.1.0/external_libs/bin - -# The intel compiler is required to run MET -module load ncarenv/1.3 -module load intel/2021.2 -module load netcdf/4.8.0 - -set base /glade/p/ral/jntp/MET/MET_releases/11.1.0 -set ver 11.1.0 -set share $base/share/met - -prepend-path PATH $base/bin:/glade/p/ral/jntp/MET/MET_releases/11.1.0/external_libs/bin:/glade/p/ral/jntp/MET/METplus/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin - -setenv METversion V$ver - -# setenv MET_BUFRLIB /glade/p/ral/jntp/MET/MET_releases/11.1.0/external_libs/libs -# setenv MET_GRIB2C /glade/p/ral/jntp/MET/MET_releases/11.1.0/external_libs -# setenv MET_GSL /glade/p/ral/jntp/MET/MET_releases/11.1.0/external_libs - - diff --git a/internal/scripts/installation/modulefiles/12.0.0_acorn b/internal/scripts/installation/modulefiles/12.0.0_acorn index c97f4e92ed..5d7a98dcd7 100644 --- a/internal/scripts/installation/modulefiles/12.0.0_acorn +++ b/internal/scripts/installation/modulefiles/12.0.0_acorn @@ -22,6 +22,9 @@ module load libpng/1.6.37 module load gsl/2.7 module load g2c/1.6.4 module load proj/7.1.0 +module use /apps/dev/lmodules/intel/19.1.3.304/ +module load atlas/0.30.0 +module load eckit/1.20.2 set base /apps/sw_review/emc/MET/12.0.0 set ver 12.0.0 @@ -32,3 +35,4 @@ prepend-path PATH $base/bin setenv METversion V$ver setenv MET_ROOT $base +setenv MET_PYTHON_EXE /apps/dev/ve/evs/2.0/bin/python \ No newline at end of file diff --git a/internal/scripts/installation/modulefiles/12.0.0_casper b/internal/scripts/installation/modulefiles/12.0.0_casper new file mode 100644 index 0000000000..1c270efb3e --- /dev/null +++ b/internal/scripts/installation/modulefiles/12.0.0_casper @@ -0,0 +1,24 @@ +#%Module###################################################################### +## +## Model Evaluation Tools +## +proc ModulesHelp { } { + puts stderr "Sets up the paths and environment variables to use the Model Evaluation Tools v12.0.0 + *** For help see the official MET webpage at http://www.dtcenter.org/met/users ***" +} + + +# The intel compiler is required to run MET + +module load ncarenv/23.10 +module load intel-classic/2023.2.1 + +set base /glade/work/dtcrt/METplus/casper/components/MET/installations/12.0.0 +set ver 12.0.0 +set share $base/share/met + +prepend-path PATH $base/bin:/glade/work/dtcrt/METplus/casper/components/MET/installations/12.0.0/external_libs/bin:/glade/work/dtcrt/METplus/casper/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin + +setenv METversion V$ver + + diff --git a/internal/scripts/installation/modulefiles/12.0.0_derecho b/internal/scripts/installation/modulefiles/12.0.0_derecho new file mode 100644 index 0000000000..bfbe555e99 --- /dev/null +++ b/internal/scripts/installation/modulefiles/12.0.0_derecho @@ -0,0 +1,22 @@ +#%Module###################################################################### +## +## Model Evaluation Tools +## +proc ModulesHelp { } { + puts stderr "Sets up the paths and environment variables to use the Model Evaluation Tools v12.0.0 + *** For help see the official MET webpage at http://www.dtcenter.org/met/users ***" +} + +# The intel compiler is required to run MET + +module load ncarenv/23.09 +module load intel/2023.2.1 + +set base /glade/work/dtcrt/METplus/derecho/components/MET/installations/12.0.0 +set ver 12.0.0 +set share $base/share/met + +prepend-path PATH $base/bin:/glade/work/dtcrt/METplus/derecho/components/MET/installations/12.0.0/external_libs/bin:/glade/work/dtcrt/METplus/derecho/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin + +setenv METversion V$ver +setenv MET_PYTHON_EXE /glade/work/dtcrt/METplus/derecho/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin/python3 diff --git a/internal/scripts/installation/modulefiles/12.0.0_gaea b/internal/scripts/installation/modulefiles/12.0.0_gaea index 1ce4cd13c3..00b4625114 100644 --- a/internal/scripts/installation/modulefiles/12.0.0_gaea +++ b/internal/scripts/installation/modulefiles/12.0.0_gaea @@ -14,4 +14,6 @@ set ver 12.0.0 set share $base/$ver/share/met set lib_base $base/12.0.0 -prepend-path PATH $base/$ver/bin:$lib_base/external_libs/bin:/lustre/f2/dev/esrl/Julie.Prestopnik/projects/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin +prepend-path PATH $base/$ver/bin:$lib_base/external_libs/bin:/gpfs/f5/esrl/proj-shared/Julie.Prestopnik/projects/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin + +setenv MET_PYTHON_EXE /gpfs/f5/esrl/proj-shared/Julie.Prestopnik/projects/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin/python \ No newline at end of file diff --git a/internal/scripts/installation/modulefiles/12.0.0_hera b/internal/scripts/installation/modulefiles/12.0.0_hera index 2548513892..a97925d7e2 100644 --- a/internal/scripts/installation/modulefiles/12.0.0_hera +++ b/internal/scripts/installation/modulefiles/12.0.0_hera @@ -19,6 +19,8 @@ setenv MET_ROOT $base/$ver prepend-path PATH $base/$ver/bin:$lib_base/external_libs/bin:/scratch1/BMC/dtc/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin +setenv MET_PYTHON_EXE /scratch1/BMC/dtc/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin/python + #setenv METversion $ver #setenv MET_CONFIG $share/config #setenv MET_POLY $share/poly diff --git a/internal/scripts/installation/modulefiles/12.0.0_hercules b/internal/scripts/installation/modulefiles/12.0.0_hercules new file mode 100644 index 0000000000..deec9e17e9 --- /dev/null +++ b/internal/scripts/installation/modulefiles/12.0.0_hercules @@ -0,0 +1,20 @@ +#%Module###################################################################### +## +## Model Evaluation Tools +## +proc ModulesHelp { } { + puts stderr "Sets up the paths and environment variables to use the Model Evaluation Tools v12.0.0 + *** For help see the official MET webpage at http://www.dtcenter.org/met/users ***" +} + +prereq intel-oneapi-compilers/2022.2.1 + +set base /apps/contrib/MET +set ver 12.0.0 +set share $base/$ver/share/met +set lib_base $base/12.0.0 +setenv MET_ROOT $base/$ver/MET-12.0.0 + +prepend-path PATH $base/$ver/bin:$lib_base/external_libs/bin:/work/noaa/ovp/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin + +setenv MET_PYTHON_EXE /work/noaa/ovp/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin/python diff --git a/internal/scripts/installation/modulefiles/12.0.0_jet b/internal/scripts/installation/modulefiles/12.0.0_jet index 430bd27113..0ab7b873ce 100644 --- a/internal/scripts/installation/modulefiles/12.0.0_jet +++ b/internal/scripts/installation/modulefiles/12.0.0_jet @@ -15,3 +15,5 @@ set share $base/share/met setenv MET_ROOT $base/$ver/MET-12.0.0 prepend-path PATH $base/bin:$base/external_libs/bin:/mnt/lfs1/HFIP/dtc-hurr/METplus/miniconda/miniconda3/envs/metplus_v5.1_py3.10 + +setenv MET_PYTHON_EXE /mnt/lfs1/HFIP/dtc-hurr/METplus/miniconda/miniconda3/envs/metplus_v5.1_py3.10_intel/bin/python \ No newline at end of file diff --git a/internal/scripts/installation/modulefiles/12.0.0_orion b/internal/scripts/installation/modulefiles/12.0.0_orion index ed0dd56805..a78bfe25bb 100644 --- a/internal/scripts/installation/modulefiles/12.0.0_orion +++ b/internal/scripts/installation/modulefiles/12.0.0_orion @@ -10,10 +10,11 @@ proc ModulesHelp { } { prereq intel/2020.2 set base /apps/contrib/MET -set ver 12.0.0-beta2 +set ver 12.0.0 set share $base/$ver/share/met -set lib_base $base/12.0.0-beta2 -setenv MET_ROOT $base/$ver/MET-12.0.0-beta2 +set lib_base $base/12.0.0 +setenv MET_ROOT $base/$ver/MET-12.0.0 prepend-path PATH $base/$ver/bin:$lib_base/external_libs/bin:/work/noaa/ovp/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin +setenv MET_PYTHON_EXE /work/noaa/ovp/miniconda/miniconda3/envs/metplus_v5.1_py3.10/bin/python From d3ecc87e759a940ac04b5f27166f3a4c2c5b9251 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 30 Apr 2024 15:17:43 -0600 Subject: [PATCH 070/114] Feature #2795 level_mismatch_warning (#2873) * Per #2795, move the warning message about level mismatch from the config validation step to when the forecast files are being processed. Only check this when the number of forecast fields is greater than 1, but no longer limit the check to pressure levels only. * Per #2795, add comments * Whitespace * Per #2795, port level mismatch fix over to Ensemble-Stat. Check it for each verification task, but only print it once for each task, rather than once for each task * ensemble member. --- src/tools/core/ensemble_stat/ensemble_stat.cc | 34 +++++++++--- .../ensemble_stat/ensemble_stat_conf_info.cc | 19 ------- src/tools/core/point_stat/point_stat.cc | 52 ++++++++++++------- .../core/point_stat/point_stat_conf_info.cc | 19 ------- 4 files changed, 59 insertions(+), 65 deletions(-) diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 0ed6b71597..e81fc80039 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -70,8 +70,9 @@ // 038 09/06/22 Halley Gotway MET #1908 Remove ensemble processing logic. // 039 09/29/22 Halley Gotway MET #2286 Refine GRIB1 table lookup logic. // 040 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from -// header files +// header files. // 041 04/16/24 Halley Gotway MET #2786 Compute RPS from climo bin probs. +// 042 04/29/24 Halley Gotway MET #2795 Move level mismatch warning. // //////////////////////////////////////////////////////////////////////// @@ -839,6 +840,10 @@ void process_point_vx() { // Loop through each of the fields to be verified for(i=0; iget_var_info(); + VarInfo *obs_info = conf_info.vx_opt[i].vx_pd.obs_info; + bool print_level_mismatch_warning = true; + // Initialize emn_dpa.clear(); @@ -857,6 +862,23 @@ void process_point_vx() { continue; } + // MET #2795, for multiple individual forecast levels, print a + // warning if the observations levels are not fully covered. + if(print_level_mismatch_warning && + fcst_dpa.n_planes() > 1 && + !is_eq(fcst_info->level().lower(), fcst_info->level().upper()) && + (obs_info->level().lower() < fcst_info->level().lower() || + obs_info->level().upper() > fcst_info->level().upper())) { + mlog << Warning << "\nprocess_point_vx() -> " + << "The forecast level range (" << fcst_info->magic_str() + << ") does not fully contain the observation level range (" + << obs_info->magic_str() << "). No vertical interpolation " + << "will be performed for observations falling outside " + << "the range of forecast levels. Instead, they will be " + << "matched to the single nearest forecast level.\n\n"; + print_level_mismatch_warning = false; + } + // Store ensemble member data conf_info.vx_opt[i].vx_pd.set_fcst_dpa(fcst_dpa); @@ -875,20 +897,18 @@ void process_point_vx() { mlog << Debug(2) << "Processing ensemble mean file: " << ens_mean_file << "\n"; - VarInfo *info = conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info(); - // Read the gridded data from the ensemble mean file - if(!get_data_plane_array(ens_mean_file.c_str(), info->file_type(), info, - emn_dpa, true)) { + if(!get_data_plane_array(ens_mean_file.c_str(), fcst_info->file_type(), + fcst_info, emn_dpa, true)) { mlog << Error << "\nprocess_point_vx() -> " << "trouble reading the ensemble mean field \"" - << info->magic_str() << "\" from file \"" + << fcst_info->magic_str() << "\" from file \"" << ens_mean_file << "\"\n\n"; exit(1); } // Dump out the number of levels found - mlog << Debug(2) << "For " << info->magic_str() + mlog << Debug(2) << "For " << fcst_info->magic_str() << " found " << emn_dpa.n_planes() << " forecast levels.\n"; } diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 8306e3f41e..7987c742de 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -710,25 +710,6 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, vx_pd.obs_info->dump(cout); } - // Check the levels for the forecast and observation fields. If the - // forecast field is a range of pressure levels, check to see if the - // range of observation field pressure levels is wholly contained in the - // fcst levels. If not, print a warning message. - if(vx_pd.fcst_info->get_var_info()->level().type() == LevelType_Pres && - !is_eq(vx_pd.fcst_info->get_var_info()->level().lower(), vx_pd.fcst_info->get_var_info()->level().upper()) && - (vx_pd.obs_info->level().lower() < vx_pd.fcst_info->get_var_info()->level().lower() || - vx_pd.obs_info->level().upper() > vx_pd.fcst_info->get_var_info()->level().upper())) { - - mlog << Warning - << "\nEnsembleStatVxOpt::process_config() -> " - << "The range of requested observation pressure levels " - << "is not contained within the range of requested " - << "forecast pressure levels. No vertical interpolation " - << "will be performed for observations falling outside " - << "the range of forecast levels. Instead, they will be " - << "matched to the single nearest forecast level.\n\n"; - } - // No support for wind direction if(vx_pd.fcst_info->get_var_info()->is_wind_direction() || vx_pd.obs_info->is_wind_direction()) { diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 313db804b8..bbfb8774d5 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -102,7 +102,8 @@ // 050 02/11/22 Halley Gotway MET #2045 Fix HiRA output. // 051 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 052 09/29/22 Halley Gotway MET #2286 Refine GRIB1 table lookup logic. -// 053 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files +// 053 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files. +// 054 04/29/24 Halley Gotway MET #2795 Move level mismatch warning. // //////////////////////////////////////////////////////////////////////// @@ -606,25 +607,37 @@ void process_fcst_climo_files() { // the forecast and climatological fields for verification for(int i=0; idata_plane_array( - *conf_info.vx_opt[i].vx_pd.fcst_info, fcst_dpa); - mlog << Debug(2) - << "\n" << sep_str << "\n\n" - << "Reading data for " - << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() - << ".\n"; + n_fcst = fcst_mtddf->data_plane_array(*fcst_info, fcst_dpa); + mlog << Debug(2) << "\n" << sep_str << "\n\n" + << "Reading data for " << fcst_info->magic_str() << ".\n"; // Check for zero fields if(n_fcst == 0) { mlog << Warning << "\nprocess_fcst_climo_files() -> " - << "no fields matching " - << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() - << " found in file: " - << fcst_file << "\n\n"; + << "no fields matching " << fcst_info->magic_str() + << " found in file: " << fcst_file << "\n\n"; continue; } + // MET #2795, for multiple individual forecast levels, print a + // warning if the observations levels are not fully covered. + if(n_fcst > 1 && + !is_eq(fcst_info->level().lower(), fcst_info->level().upper()) && + (obs_info->level().lower() < fcst_info->level().lower() || + obs_info->level().upper() > fcst_info->level().upper())) { + mlog << Warning << "\nprocess_fcst_climo_files() -> " + << "The forecast level range (" << fcst_info->magic_str() + << ") does not fully contain the observation level range (" + << obs_info->magic_str() << "). No vertical interpolation " + << "will be performed for observations falling outside " + << "the range of forecast levels. Instead, they will be " + << "matched to the single nearest forecast level.\n\n"; + } + // Setup the first pass through the data if(is_first_pass) setup_first_pass(fcst_dpa[0], fcst_mtddf->grid()); @@ -632,19 +645,18 @@ void process_fcst_climo_files() { if(!(fcst_mtddf->grid() == grid)) { mlog << Debug(1) << "Regridding " << fcst_dpa.n_planes() - << " forecast field(s) for " - << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() + << " forecast field(s) for " << fcst_info->magic_str() << " to the verification grid.\n"; // Loop through the forecast fields for(j=0; jgrid(), grid, - conf_info.vx_opt[i].vx_pd.fcst_info->regrid()); + fcst_info->regrid()); } } // Rescale probabilities from [0, 100] to [0, 1] - if(conf_info.vx_opt[i].vx_pd.fcst_info->p_flag()) { + if(fcst_info->p_flag()) { for(j=0; jmagic_str() - << " found " << n_fcst << " forecast levels, " + << "For " << fcst_info->magic_str() << " found " + << n_fcst << " forecast levels, " << cmn_dpa.n_planes() << " climatology mean levels, and " << csd_dpa.n_planes() << " climatology standard deviation levels.\n"; @@ -1825,8 +1837,8 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { conf_info.vx_opt[i_vx].hira_info.width[i], grid.wrap_lon()); if (nullptr == gt) { - mlog << Warning - << "\nPdo_hira_ens() Fail to get GridTemplate for " << i << "-th width.\n\n"; + mlog << Warning << "\ndo_hira_ens() -> " + << "failed to get GridTemplate for " << i << "-th width.\n\n"; continue; } diff --git a/src/tools/core/point_stat/point_stat_conf_info.cc b/src/tools/core/point_stat/point_stat_conf_info.cc index e05157d5bc..1a416fbd5a 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.cc +++ b/src/tools/core/point_stat/point_stat_conf_info.cc @@ -851,25 +851,6 @@ void PointStatVxOpt::process_config(GrdFileType ftype, vx_pd.obs_info->dump(cout); } - // Check the levels for the forecast and observation fields. If the - // forecast field is a range of pressure levels, check to see if the - // range of observation field pressure levels is wholly contained in the - // fcst levels. If not, print a warning message. - if(vx_pd.fcst_info->level().type() == LevelType_Pres && - !is_eq(vx_pd.fcst_info->level().lower(), vx_pd.fcst_info->level().upper()) && - (vx_pd.obs_info->level().lower() < vx_pd.fcst_info->level().lower() || - vx_pd.obs_info->level().upper() > vx_pd.fcst_info->level().upper())) { - - mlog << Warning - << "\nPointStatVxOpt::process_config() -> " - << "The range of requested observation pressure levels " - << "is not contained within the range of requested " - << "forecast pressure levels. No vertical interpolation " - << "will be performed for observations falling outside " - << "the range of forecast levels. Instead, they will be " - << "matched to the single nearest forecast level.\n\n"; - } - // No support for wind direction if(vx_pd.fcst_info->is_wind_direction() || vx_pd.obs_info->is_wind_direction()) { From ccd1061f90cd79cad444424b7beba968b89cb431 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 1 May 2024 10:39:15 -0600 Subject: [PATCH 071/114] Feature #2870 removing_MISSING_warning (#2872) * Per #2870, define utility functions for parsing the file type from a file list and for logging missing files, checking for the MISSING keyword. Also, update Ensemble-Stat and Gen-Ens-Prod to call these functions. * Per #2870, update the gen_ens_prod tests to demonstrate the use of the MISSING keyword for missing files. METplus uses this keyword for Ensemble-Stat and Gen-Ens-Prod. --- internal/test_unit/xml/unit_gen_ens_prod.xml | 10 +-- .../vx_data2d_factory/parse_file_list.cc | 65 ++++++++++++++++ .../vx_data2d_factory/parse_file_list.h | 7 ++ src/tools/core/ensemble_stat/ensemble_stat.cc | 76 +++++-------------- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 41 +++++----- 5 files changed, 116 insertions(+), 83 deletions(-) diff --git a/internal/test_unit/xml/unit_gen_ens_prod.xml b/internal/test_unit/xml/unit_gen_ens_prod.xml index 771bf3e201..371a5c5283 100644 --- a/internal/test_unit/xml/unit_gen_ens_prod.xml +++ b/internal/test_unit/xml/unit_gen_ens_prod.xml @@ -26,7 +26,7 @@ echo "&DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-sch-gep2/arw-sch-gep2_2012040912_F024.grib \ - &DATA_DIR_MODEL;/grib1/arw-tom-gep3/arw-tom-gep3_2012040912_F024.grib \ + MISSING \ &DATA_DIR_MODEL;/grib1/nmm-fer-gep4/nmm-fer-gep4_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-fer-gep5/arw-fer-gep5_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-sch-gep6/arw-sch-gep6_2012040912_F024.grib \ @@ -42,7 +42,7 @@ -ens &OUTPUT_DIR;/gen_ens_prod/input_file_list \ -config &CONFIG_DIR;/GenEnsProdConfig \ -out &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_NO_CTRL_20120410_120000V.nc \ - -v 2 + -v 3 &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_NO_CTRL_20120410_120000V.nc @@ -52,7 +52,7 @@ echo "&DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-sch-gep2/arw-sch-gep2_2012040912_F024.grib \ - &DATA_DIR_MODEL;/grib1/arw-tom-gep3/arw-tom-gep3_2012040912_F024.grib \ + MISSING/&DATA_DIR_MODEL;/grib1/arw-tom-gep3/arw-tom-gep3_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/nmm-fer-gep4/nmm-fer-gep4_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-fer-gep5/arw-fer-gep5_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-sch-gep6/arw-sch-gep6_2012040912_F024.grib \ @@ -69,7 +69,7 @@ -ctrl &DATA_DIR_MODEL;/grib1/arw-tom-gep0/arw-tom-gep0_2012040912_F024.grib \ -config &CONFIG_DIR;/GenEnsProdConfig \ -out &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_WITH_CTRL_20120410_120000V.nc \ - -v 2 + -v 3 &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_WITH_CTRL_20120410_120000V.nc @@ -162,7 +162,7 @@ -ctrl &DATA_DIR_MODEL;/grib1/arw-tom-gep0/arw-tom-gep0_2012040912_F024.grib \ -config &CONFIG_DIR;/GenEnsProdConfig_normalize \ -out &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_NORMALIZE.nc \ - -v 2 + -v 3 &OUTPUT_DIR;/gen_ens_prod/gen_ens_prod_NORMALIZE.nc diff --git a/src/libcode/vx_data2d_factory/parse_file_list.cc b/src/libcode/vx_data2d_factory/parse_file_list.cc index 0363f0221f..2e2be2a632 100644 --- a/src/libcode/vx_data2d_factory/parse_file_list.cc +++ b/src/libcode/vx_data2d_factory/parse_file_list.cc @@ -37,6 +37,7 @@ using namespace std; static const char python_str [] = "python"; static const char file_list_str [] = "file_list"; +static const char missing_str [] = "MISSING"; //////////////////////////////////////////////////////////////////////// @@ -201,4 +202,68 @@ return a; } +//////////////////////////////////////////////////////////////////////// + + +GrdFileType parse_file_list_type(const StringArray& file_list) + +{ + +GrdFileType ftype = FileType_None; + +for ( int i=0; i filetype " - << grdfiletype_to_string(etype) << " from the configuration is not supported\n\n"; - exit(1); + // Get the ensemble file type from the files + if(etype == FileType_None) { + etype = parse_file_list_type(ens_file_list); } - // Read the first input ensemble file - if(!(ens_mtddf = mtddf_factory.new_met_2d_data_file(ens_file_list[0].c_str(), etype))) { + // UGrid not supported + if(etype == FileType_UGrid) { mlog << Error << "\n" << method_name - << "trouble reading ensemble file \"" - << ens_file_list[0] << "\"\n\n"; - exit(1); - } - - // Store the input ensemble file type - etype = ens_mtddf->file_type(); - if(FileType_UGrid == etype) { - mlog << Error << "\n" << program_name << " -> The filetype " - << grdfiletype_to_string(etype) << " (" << ens_file_list[0] - << ") is not supported\n\n"; - + << grdfiletype_to_string(etype) + << " ensemble files are not supported\n\n"; exit(1); } - // Observation files are required if(!grid_obs_flag && !point_obs_flag) { mlog << Error << "\n" << method_name @@ -406,28 +393,17 @@ void process_command_line(int argc, char **argv) { // Get the observation file type from config, if present otype = parse_conf_file_type(conf_info.conf.lookup_dictionary(conf_key_obs)); - if(FileType_UGrid == otype) { - mlog << Error << "\n" << program_name << " -> filetype " - << grdfiletype_to_string(otype) << " from the configuration is not supported\n\n"; - - exit(1); - } - // Read the first gridded observation file - if(!(obs_mtddf = mtddf_factory.new_met_2d_data_file(grid_obs_file_list[0].c_str(), otype))) { - mlog << Error << "\n" << method_name - << "trouble reading gridded observation file \"" - << grid_obs_file_list[0] << "\"\n\n"; - exit(1); + // Get the observation file type from the files + if(otype == FileType_None) { + otype = parse_file_list_type(grid_obs_file_list); } - // Store the gridded observation file type - otype = obs_mtddf->file_type(); - if(FileType_UGrid == otype) { - mlog << Error << "\n" << program_name << " -> The filetype " - << grdfiletype_to_string(etype) << " (" << grid_obs_file_list[0] - << ") is not supported\n\n"; - + // UGrid not supported + if(otype == FileType_UGrid) { + mlog << Error << "\n" << method_name + << grdfiletype_to_string(otype) + << " gridded observation files are not supported\n\n"; exit(1); } } @@ -476,9 +452,7 @@ void process_command_line(int argc, char **argv) { if(!file_exists(ens_file_list[i].c_str()) && !is_python_grdfiletype(etype)) { - mlog << Warning << "\n" << method_name - << "can't open input ensemble file: " - << ens_file_list[i] << "\n\n"; + log_missing_file(method_name, "input ensemble file", ens_file_list[i]); ens_file_vld.add(0); } else { @@ -489,9 +463,7 @@ void process_command_line(int argc, char **argv) { // User-specified ensemble mean file if(ens_mean_file.nonempty()) { if(!file_exists(ens_mean_file.c_str())) { - mlog << Warning << "\n" << method_name - << "can't open input ensemble mean file: " - << ens_mean_file << "\n\n"; + log_missing_file(method_name, "input ensemble mean file", ens_mean_file); ens_mean_file = ""; } } @@ -503,10 +475,6 @@ void process_command_line(int argc, char **argv) { << "control file is not provided with -ctrl argument\n\n"; } - // Deallocate memory for data files - if(ens_mtddf) { delete ens_mtddf; ens_mtddf = (Met2dDataFile *) nullptr; } - if(obs_mtddf) { delete obs_mtddf; obs_mtddf = (Met2dDataFile *) nullptr; } - return; } @@ -995,10 +963,8 @@ void process_point_obs(int i_nc) { #endif if(!nc_point_obs.open(point_obs_file_list[i_nc].c_str())) { nc_point_obs.close(); - - mlog << Warning << "\n" << method_name - << "can't open observation netCDF file: " - << point_obs_file_list[i_nc] << "\n\n"; + log_missing_file(method_name, "observation netCDF file", + point_obs_file_list[i_nc]); return; } diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index 4de6c2b2b8..46ad8b66df 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -20,10 +20,10 @@ // 003 02/17/22 Halley Gotway MET #1918 Add normalize config option. // 004 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 005 10/03/22 Prestopnik MET #2227 Remove using namespace std and netCDF from header files +// 006 04/29/24 Halley Gotway MET #2870 Ignore MISSING keyword. // //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -53,7 +53,6 @@ using namespace std; using namespace netCDF; - //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); @@ -111,19 +110,17 @@ int met_main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// - const string get_tool_name() { return "gen_ens_prod"; } - //////////////////////////////////////////////////////////////////////// void process_command_line(int argc, char **argv) { int i; CommandLine cline; ConcatString default_config_file; - Met2dDataFile *ens_mtddf = (Met2dDataFile *) nullptr; + const char *method_name = "process_command_line() -> "; // // Check for zero arguments @@ -159,19 +156,19 @@ void process_command_line(int argc, char **argv) { // Check that the required arguments have been set n_ens_files = ens_files.n(); if(n_ens_files == 0) { - mlog << Error << "\nprocess_command_line() -> " + mlog << Error << "\n" << method_name << "the ensemble file list must be set using the " << "\"-ens\" option.\n\n"; exit(1); } if(out_file.length() == 0) { - mlog << Error << "\nprocess_command_line() -> " + mlog << Error << "\n" << method_name << "the output file must be set using the " << "\"-out\" option.\n\n"; exit(1); } if(config_file.length() == 0) { - mlog << Error << "\nprocess_command_line() -> " + mlog << Error << "\n" << method_name << "the configuration file must be set using the " << "\"-config\" option.\n\n"; exit(1); @@ -191,15 +188,18 @@ void process_command_line(int argc, char **argv) { // Get the ensemble file type from config, if present etype = parse_conf_file_type(conf_info.conf.lookup_dictionary(conf_key_ens)); - // Read the first input ensemble file - if(!(ens_mtddf = mtddf_factory.new_met_2d_data_file(ens_files[0].c_str(), etype))) { - mlog << Error << "\nprocess_command_line() -> " - << "trouble reading ensemble file \"" << ens_files[0] << "\"\n\n"; - exit(1); + // Get the ensemble file type from the files + if(etype == FileType_None) { + etype = parse_file_list_type(ens_files); } - // Store the input ensemble file type - etype = ens_mtddf->file_type(); + // UGrid not supported + if(etype == FileType_UGrid) { + mlog << Error << "\n" << method_name + << grdfiletype_to_string(etype) + << " ensemble files are not supported\n\n"; + exit(1); + } // Process the configuration conf_info.process_config(etype, &ens_files, ctrl_file.nonempty()); @@ -225,7 +225,7 @@ void process_command_line(int argc, char **argv) { // Check for control in the list of ensemble files if(ctrl_file.nonempty() && ens_files.has(ctrl_file) && n_ens_files != 1) { - mlog << Error << "\nprocess_command_line() -> " + mlog << Error << "\n" << method_name << "the ensemble control file should not appear in the list " << "of ensemble member files:\n" << ctrl_file << "\n\n"; exit(1); @@ -235,9 +235,7 @@ void process_command_line(int argc, char **argv) { for(i=0; i " - << "cannot open input ensemble file: " - << ens_files[i] << "\n\n"; + log_missing_file(method_name, "input ensemble file", ens_files[i]); ens_file_vld.add(0); } else { @@ -246,14 +244,11 @@ void process_command_line(int argc, char **argv) { } if(conf_info.control_id.nonempty() && ctrl_file.empty()) { - mlog << Warning << "\nprocess_command_line() -> " + mlog << Warning << "\n" << method_name << "control_id is set in the config file but " << "control file is not provided with -ctrl argument\n\n"; } - // Deallocate memory for data files - if(ens_mtddf) { delete ens_mtddf; ens_mtddf = (Met2dDataFile *) nullptr; } - return; } From 7f9bf9c461ea83076f8e3b502e607b39399bca54 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 1 May 2024 10:44:44 -0600 Subject: [PATCH 072/114] Feature 2842 ugrid config (#2875) * #2842 Removed UGrid related setting * #2842 Corrected vertical level for data_plane_array * #2842 Do not allow the time range * #2842 The UGridConfig file can be passed as ugrid_dataset * #2842 Changed -config option to -ugrid_config * #2842 Deleted UGrid configurations * 2842 Fix a compile error when UGrid is disabled * #2842 Cleanup * #2842 Added an unittest point_stat_ugrid_mpas_config * #2842 Added a PointStatConfig without UGrid dataset. * #2842 Corrected ty[po at the variable name * Switched from time_centered to time_instant. I think time_centered is the center of the forecast lead window and time_instant is the time the forecast is valid (end of forecast window). * #2842 Removed ugrid_max_distance_km and unused metadata names * #2842 Restored time variable time_instant for LFric * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjusted lon to between -180 to 180 * #2842 Changed variable names * Per #2842, switch from degrees east to west right when the longitudes are read. * #2842, switch from degrees east to west right when the longitudes are read * #2842 Cleanup debug messages * #2842 Disabled output types except STAT for sl1l2 * #2842 Disabled output types except STAT for sl1l2 and MPR * #2842 Reduced output files for UGrid --------- Co-authored-by: Howard Soh Co-authored-by: Daniel Adriaansen Co-authored-by: John Halley Gotway --- .../config/GridStatConfig_ugrid_mpas | 10 +++--- .../config/GridStatConfig_ugrid_mpas_diag | 10 +++--- .../config/PointStatConfig_ugrid_mpas_diag | 16 +++++----- .../config/PointStatConfig_ugrid_mpas_out | 16 +++++----- .../config/PointStatConfig_ugrid_no_dataset | 16 +++++----- internal/test_unit/xml/unit_ugrid.xml | 32 ++++++++++++------- 6 files changed, 54 insertions(+), 46 deletions(-) diff --git a/internal/test_unit/config/GridStatConfig_ugrid_mpas b/internal/test_unit/config/GridStatConfig_ugrid_mpas index db40bb0798..d54b25de53 100644 --- a/internal/test_unit/config/GridStatConfig_ugrid_mpas +++ b/internal/test_unit/config/GridStatConfig_ugrid_mpas @@ -203,12 +203,12 @@ output_flag = { cts = NONE; mctc = NONE; mcts = NONE; - cnt = STAT; + cnt = NONE; sl1l2 = STAT; - sal1l2 = STAT; - vl1l2 = STAT; - val1l2 = STAT; - vcnt = STAT; + sal1l2 = NONE; + vl1l2 = NONE; + val1l2 = NONE; + vcnt = NONE; pct = NONE; pstd = NONE; pjc = NONE; diff --git a/internal/test_unit/config/GridStatConfig_ugrid_mpas_diag b/internal/test_unit/config/GridStatConfig_ugrid_mpas_diag index c893957e15..9e479d0302 100644 --- a/internal/test_unit/config/GridStatConfig_ugrid_mpas_diag +++ b/internal/test_unit/config/GridStatConfig_ugrid_mpas_diag @@ -203,12 +203,12 @@ output_flag = { cts = NONE; mctc = NONE; mcts = NONE; - cnt = STAT; + cnt = NONE; sl1l2 = STAT; - sal1l2 = STAT; - vl1l2 = STAT; - val1l2 = STAT; - vcnt = STAT; + sal1l2 = NONE; + vl1l2 = NONE; + val1l2 = NONE; + vcnt = NONE; pct = NONE; pstd = NONE; pjc = NONE; diff --git a/internal/test_unit/config/PointStatConfig_ugrid_mpas_diag b/internal/test_unit/config/PointStatConfig_ugrid_mpas_diag index ca0ef81ae7..886c6bb301 100644 --- a/internal/test_unit/config/PointStatConfig_ugrid_mpas_diag +++ b/internal/test_unit/config/PointStatConfig_ugrid_mpas_diag @@ -119,17 +119,17 @@ hira = { //////////////////////////////////////////////////////////////////////////////// output_flag = { - fho = BOTH; - ctc = BOTH; - cts = BOTH; + fho = STAT; + ctc = STAT; + cts = STAT; mctc = NONE; mcts = NONE; - cnt = BOTH; - sl1l2 = NONE; + cnt = NONE; + sl1l2 = STAT; sal1l2 = NONE; vl1l2 = NONE; val1l2 = NONE; - vcnt = BOTH; + vcnt = NONE; pct = NONE; pstd = NONE; pjc = NONE; @@ -137,8 +137,8 @@ output_flag = { ecnt = NONE; orank = NONE; rps = NONE; - eclv = BOTH; - mpr = BOTH; + eclv = NONE; + mpr = STAT; seeps = NONE; seeps_mpr = NONE; } diff --git a/internal/test_unit/config/PointStatConfig_ugrid_mpas_out b/internal/test_unit/config/PointStatConfig_ugrid_mpas_out index 1e1f9e4887..c16deb0f7d 100644 --- a/internal/test_unit/config/PointStatConfig_ugrid_mpas_out +++ b/internal/test_unit/config/PointStatConfig_ugrid_mpas_out @@ -119,17 +119,17 @@ hira = { //////////////////////////////////////////////////////////////////////////////// output_flag = { - fho = BOTH; - ctc = BOTH; - cts = BOTH; + fho = STAT; + ctc = STAT; + cts = STAT; mctc = NONE; mcts = NONE; - cnt = BOTH; - sl1l2 = NONE; + cnt = NONE; + sl1l2 = STAT; sal1l2 = NONE; vl1l2 = NONE; val1l2 = NONE; - vcnt = BOTH; + vcnt = NONE; pct = NONE; pstd = NONE; pjc = NONE; @@ -137,8 +137,8 @@ output_flag = { ecnt = NONE; orank = NONE; rps = NONE; - eclv = BOTH; - mpr = BOTH; + eclv = NONE; + mpr = STAT; seeps = NONE; seeps_mpr = NONE; } diff --git a/internal/test_unit/config/PointStatConfig_ugrid_no_dataset b/internal/test_unit/config/PointStatConfig_ugrid_no_dataset index e70a3af9ee..9c7c7f5b3a 100644 --- a/internal/test_unit/config/PointStatConfig_ugrid_no_dataset +++ b/internal/test_unit/config/PointStatConfig_ugrid_no_dataset @@ -119,17 +119,17 @@ hira = { //////////////////////////////////////////////////////////////////////////////// output_flag = { - fho = BOTH; - ctc = BOTH; - cts = BOTH; + fho = NONE; + ctc = NONE; + cts = NONE; mctc = NONE; mcts = NONE; - cnt = BOTH; - sl1l2 = NONE; + cnt = NONE; + sl1l2 = STAT; sal1l2 = NONE; vl1l2 = NONE; val1l2 = NONE; - vcnt = BOTH; + vcnt = NONE; pct = NONE; pstd = NONE; pjc = NONE; @@ -137,8 +137,8 @@ output_flag = { ecnt = NONE; orank = NONE; rps = NONE; - eclv = BOTH; - mpr = BOTH; + eclv = NONE; + mpr = STAT; seeps = NONE; seeps_mpr = NONE; } diff --git a/internal/test_unit/xml/unit_ugrid.xml b/internal/test_unit/xml/unit_ugrid.xml index 80211fdc2f..1122340a72 100644 --- a/internal/test_unit/xml/unit_ugrid.xml +++ b/internal/test_unit/xml/unit_ugrid.xml @@ -77,12 +77,6 @@ &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V.stat - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V_fho.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V_ctc.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V_cts.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V_cnt.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V_eclv.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_DIAG_TEMP_000000L_20120409_120000V_mpr.txt @@ -102,12 +96,26 @@ &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V.stat - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V_fho.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V_ctc.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V_cts.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V_cnt.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V_eclv.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_OUT_TEMP_000000L_20120409_120000V_mpr.txt + + + + + &MET_BIN;/point_stat + + BEG_DS -1800 + END_DS 1800 + OUTPUT_PREFIX UGRID_MPAS_CFG_OUT_TEMP + CONFIG_DIR &CONFIG_DIR; + + \ + &DATA_DIR_UGRID;/mpas/mpasout.2012-04-09_12.00.00_reduced.nc \ + &OUTPUT_DIR;/pb2nc/gdas1.20120409.t12z.prepbufr.nc \ + &CONFIG_DIR;/PointStatConfig_ugrid_no_dataset \ + -ugrid_config ${MET_BASE}/config/UGridConfig_mpas \ + -outdir &OUTPUT_DIR;/point_stat_ugrid -v 1 + + + &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V.stat From 566d4fb31e3000e94814ea2980ab1df9148fbf10 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 1 May 2024 19:31:46 +0000 Subject: [PATCH 073/114] Hotfix to develop branch to remove duplicate test named 'point_stat_ugrid_mpas_config'. That was causing unit_ugrid.xml to fail because it was still looking for .txt output files that are no longer being generated. --- internal/test_unit/xml/unit_ugrid.xml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/internal/test_unit/xml/unit_ugrid.xml b/internal/test_unit/xml/unit_ugrid.xml index 1122340a72..80a6a53360 100644 --- a/internal/test_unit/xml/unit_ugrid.xml +++ b/internal/test_unit/xml/unit_ugrid.xml @@ -119,30 +119,4 @@ - - &MET_BIN;/point_stat - - BEG_DS -1800 - END_DS 1800 - OUTPUT_PREFIX UGRID_MPAS_CFG_OUT_TEMP - CONFIG_DIR &CONFIG_DIR; - - \ - &DATA_DIR_UGRID;/mpas/mpasout.2012-04-09_12.00.00_reduced.nc \ - &OUTPUT_DIR;/pb2nc/gdas1.20120409.t12z.prepbufr.nc \ - &CONFIG_DIR;/PointStatConfig_ugrid_no_dataset \ - -ugrid_config ${MET_BASE}/config/UGridConfig_mpas \ - -outdir &OUTPUT_DIR;/point_stat_ugrid -v 1 - - - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V.stat - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_fho.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_ctc.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_cts.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_cnt.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_eclv.txt - &OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_mpr.txt - - - From 542b4ba9a1db69d445ecb3eb023d4c60cad291ea Mon Sep 17 00:00:00 2001 From: Dan Adriaansen Date: Tue, 7 May 2024 08:42:48 -0600 Subject: [PATCH 074/114] Feature 2748 document ugrid (#2869) * Initial documentation of the UGRID capability. * Fixes error in references, adds appendix to index, and adds sub-section for configuration entries and a table for metadata map items. * Corrects LFRic, rewords section on UGRID conventions, updates description of using GridStat, and removes mention of nodes. * Forgot one more mention of UGRID conventions. * Incorporates more suggestions from @willmayfield. * Switches to numerical table reference. --- docs/Users_Guide/appendixH.rst | 87 +++++++++++++++++++++++++++++ docs/Users_Guide/config_options.rst | 2 + docs/Users_Guide/grid-stat.rst | 11 ++-- docs/Users_Guide/index.rst | 1 + docs/Users_Guide/point-stat.rst | 15 +++-- docs/Users_Guide/refs.rst | 16 ++++++ 6 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 docs/Users_Guide/appendixH.rst diff --git a/docs/Users_Guide/appendixH.rst b/docs/Users_Guide/appendixH.rst new file mode 100644 index 0000000000..3fff53218a --- /dev/null +++ b/docs/Users_Guide/appendixH.rst @@ -0,0 +1,87 @@ +.. _appendixH: + +***************************** +Appendix H Unstructured Grids +***************************** + +Introduction +============ + +METv12.0.0+ includes limited support for using datasets on unstructured grids (UGRIDs) in the PointStat and GridStat tools. This support includes verifying UGRID forecasts against point observations (PointStat), and verifying UGRID forecasts regridded to a structured grid against gridded observations on a structured grid (GridStat). The implementation of UGRID support in METv12.0.0+ provides a mechanism for a user to describe the topology of their unstructured grid. Thus far, development to support datasets on unstructured grids has been driven by the LFRic (“elfrick”) NWP model (:ref:`Adams et al. 2019 `), and the Model for Prediction Across Scales (MPAS) NWP model (:ref:`Skamarock et al., 2012 `). However, the support for unstructured grids was implemented in such a way that additional unstructured grids can be utilized, with the appropriate mapping of the user's topology to the elements that MET requires. + +Unstructured Grid Files +======================= + +Support for UGRID files in NetCDF format is provided. MET will attempt to auto-detect UGRID files. If the file is CF-compliant and the “Conventions” global attribute is “UGRID” or “MPAS”, or if the global attribute “mesh_spec” is present, MET recognizes the file as a UGRID file. If the user is not using a supported UGRID, or a UGRID file that does not contain the required global attributes for autodetection, the user should set the **file_type** configuration entry to **NETCDF_UGRID**. In some cases, the UGRID topology is provided in an ancillary file separate from forecast variables. This is controlled via the **ugrid_coordinates_file** configuration entry. This file is checked first, and then the UGRID data file. If the same elements are found in both files, the information from the data file takes precedence, and thus it is recommended to leave **ugrid_coordinates_file** unset if all required elements are found in the data file. If both a data and coordinates file are provided, the shape of the latitude and longitude dimensions are cross-referenced as a limited enforcement measure that the coordinates file and data file belong to the same UGRID. + +Required Unstructured Grid Metadata +=================================== + +To correctly parse the UGRID topology, MET needs the following information that must be contained within the UGRID coordinates file or the UGRID data file. It is often the case that the variable names for these elements differ between UGRIDs. If the user is not using one of the supported UGRIDs, they will need to define the **ugrid_metadata_map** in a custom configuration file that they provide on the command line using the **-ugrid_config** command line argument, which tells MET the variable names that correspond to the following elements: + +.. _table_ugrid_metadata: + +.. list-table:: Required UGRID Metadata + :widths: auto + :header-rows: 1 + + * - Metadata Map Key + - Description + - Required + * - dim_face + - Dimension name for UGRID cells + - Required + * - lat_face + - Coordinate variable name for the latitude of each UGRID cell + - Required + * - lon_face + - Coordinate variable name for the longitude of each UGRID cell + - Required + * - dim_time + - Dimension name for the time coordinate + - Required + * - time + - Coordinate variable for time + - Required + * - dim_vert + - Dimension name for the vertical coordinate, if present + - Optional + * - vert_face + - Coordinate variable name for the vertical coordinate + - Optional + +Unstructured Grid Configuration Entries +======================================= + +In the PointStat and GridStat config files, a user can control aspects of the UGRID capability. Since the UGRID support in MET is optional, these items are not included in the default MET config files. If the user requires modification for any of the following, they must add them to their MET config file. + +ugrid_dataset +------------- + +If the UGRID dataset is supported by MET, then this item is set to the string identifying the UGRID. Currently supported ugrid_dataset options include “lfric”, and “mpas”. If this item is not set, the user must provide a separate UGRID configuration file on the command line using the **-ugrid_config** command line argument. + +ugrid_max_distance_km +--------------------- + +For PointStat, this is the distance from each UGRID cell center that PointStat will search outward to collect observations to use for verification. The default is 0 km, which by default will use the closest observation to the UGRID cell for verification. For GridStat, this is the distance from each forecast grid point to search for observation grid cells to include when interpolating to the forecast grid point locations. Currently, only the nearest point observation or gridded observation cell is used. See `Unstructured Grid Limitations`_ for additional details about interpolation when using GridStat. + +ugrid_coordinates_file +---------------------- + +The absolute path to the ancillary NetCDF file that describes the UGRID topology. This file is checked for the required UGRID metadata first, and the data file is checked second and takes precedence over this file if the same elements are found in both files. + +ugrid_metadata_map +------------------ + +The mapping dictionary which allows a user to specify the variable names of the required UGRID topology elements that are required by MET. For "lfric" and "mpas", **ugrid_metadata_map** comes pre-configured with MET and a user can simply set **ugrid_dataset**. Otherwise, the user must create a separate UGRID configuration file containing the **ugrid_metadata_map** containing the elements from :numref:`table_ugrid_metadata` and provide it on the command line using the **-ugrid_config** command line argument. + +Unstructured Grid Limitations +============================= + +We anticipate expanding the UGRID capabilities in MET in the near future. Until then, users are encouraged to be mindful of the following limitations: + +1. In GridStat, there is no support for verifying directly on a UGRID. The UGRID (either forecast, obs, or both) must be regridded to a structured verification grid prior to verification being performed. In most cases, gridded observations are on a structured grid and so the users are encouraged to regrid their UGRID forecast to the structured observation grid. If the user wishes to verify a UGRID observation against a UGRID forecast (for example, a UGRID model analysis), the user must define a custom verification grid tailored to their UGRID characteristics, being mindful that the regridding can be slow for large verification grids. The user is referred to :ref:`appendixB` for guidance on defining a structured verification grid. + +2. Data at cell edges are currently not supported, only those variables which have data at the cell centers are supported. Users should note in particular that wind components that are typically derived using data at cell edges are currently unsupported. + +3. No aggregation methods of point observations within the **ugrid_max_distance_km** are supported except NEAREST, and no aggregation methods of gridded observations within the **ugrid_max_distance_km** are supported except NEAREST. diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index ec76ecf7d5..fb6e4f47eb 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -1047,6 +1047,8 @@ to be verified. This dictionary may include the following entries: single model level. file_type = NETCDF_NCCF; NetCDF following the Climate Forecast (CF) convention. + file_type = NETCDF_UGRID; NetCDF containing data on an + unstructured grid. file_type = PYTHON_NUMPY; Run a Python script to load data into a NumPy array. file_type = PYTHON_XARRAY; Run a Python script to load data into diff --git a/docs/Users_Guide/grid-stat.rst b/docs/Users_Guide/grid-stat.rst index 22fe740a55..c09df58d54 100644 --- a/docs/Users_Guide/grid-stat.rst +++ b/docs/Users_Guide/grid-stat.rst @@ -172,6 +172,7 @@ The usage statement for the Grid-Stat tool is listed below: fcst_file obs_file config_file + [-ugrid_config config_file] [-outdir path] [-log file] [-v level] @@ -191,13 +192,15 @@ Required Arguments for grid_stat Optional Arguments for grid_stat ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4. The **-outdir path** indicates the directory where output files should be written. +4. The **-ugrid_config** option provides a way for a user to provide a separate config file with metadata about their UGRID. -5. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. +5. The **-outdir path** indicates the directory where output files should be written. -6. The **-v level** option indicates the desired level of verbosity. The contents of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. +6. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. -7. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. +7. The **-v level** option indicates the desired level of verbosity. The contents of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. + +8. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. An example of the grid_stat calling sequence is listed below: diff --git a/docs/Users_Guide/index.rst b/docs/Users_Guide/index.rst index ee3a5ff6dc..1df5c65e53 100644 --- a/docs/Users_Guide/index.rst +++ b/docs/Users_Guide/index.rst @@ -81,6 +81,7 @@ The National Center for Atmospheric Research (NCAR) is sponsored by NSF. The DTC appendixE appendixF appendixG + appendixH .. only:: html diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index d5f895a8aa..6c32537146 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -277,6 +277,7 @@ The usage statement for the Point-Stat tool is shown below: fcst_file obs_file config_file + [-ugrid_config config_file] [-point_obs file] [-obs_valid_beg time] [-obs_valid_end time] @@ -298,17 +299,19 @@ Required Arguments for point_stat Optional Arguments for point_stat ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4. The **-point_obs** file may be used to pass additional NetCDF point observation files to be used in the verification. Python embedding for point observations is also supported, as described in :numref:`pyembed-point-obs-data`. +5. The **-ugrid_config** option provides a way for a user to provide a separate config file with metadata about their UGRID. -5. The **-obs_valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the observation matching time window, overriding the configuration file setting. +5. The **-point_obs** file may be used to pass additional NetCDF point observation files to be used in the verification. Python embedding for point observations is also supported, as described in :numref:`pyembed-point-obs-data`. -6. The **-obs_valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the observation matching time window, overriding the configuration file setting. +6. The **-obs_valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the observation matching time window, overriding the configuration file setting. -7. The **-outdir path** indicates the directory where output files should be written. +7. The **-obs_valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the observation matching time window, overriding the configuration file setting. -8. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. +8. The **-outdir path** indicates the directory where output files should be written. -9. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity will increase the amount of logging. +9. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. + +10. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity will increase the amount of logging. An example of the point_stat calling sequence is shown below: diff --git a/docs/Users_Guide/refs.rst b/docs/Users_Guide/refs.rst index 1c328014cb..00e682abad 100644 --- a/docs/Users_Guide/refs.rst +++ b/docs/Users_Guide/refs.rst @@ -10,6 +10,14 @@ References | Atlantic Basin. *Weather and Forecasting*, 13, 1005-1015. | +.. _Adams-2019: + +| Adams, S. V., R. W. Ford, M. Hambley, J.M. Hobson, I. Kavčič, C. M. Maynard, +| T. Melvin, E. H. Müller, S. Mullerworth, A. R. Porter, M. Rezny, B. J. Shipway, +| and R. Wong, 2019: LFRic: Meeting the challenges of scalability and performance +| portability in Weather and Climate models. *Journal of Parallel and Distributed Computing*, +| **132**, 383-396, doi: https://doi.org/10.1016/j.jpdc.2019.02.007. + .. _Ahijevych-2009: | Ahijevych, D., E. Gilleland, B.G. Brown, and E.E. Ebert, 2009: Application of @@ -333,6 +341,14 @@ References | and Recommendations. *Monthly Weather Review*, 145, 3397-3418. | +.. _Skamarock-2012: + +| Skamarock, W. C., J. B. Klemp, M. G. Duda, L. D. Fowler, S. Park, and +| T. Ringler, 2012: A Multiscale Nonhydrostatic Atmospheric Model Using +| Centroidal Voronoi Tesselations and C-Grid Staggering. *Mon. Wea. Rev.*, +| **140**, 3090-3105, doi: https://doi.org/10.1175/MWR-D-11-00215.1. +| + .. _Stephenson-2000: | Stephenson, D.B., 2000: Use of the "Odds Ratio" for diagnosing From 79ac568ecc2570b27b388459e9600bfa418fddef Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 8 May 2024 16:54:39 -0600 Subject: [PATCH 075/114] Feature #2781 Convert MET NetCDF point obs to Pandas DataFrame (#2877) * Per #2781, added function to convert MET NetCDF point observation data to pandas so it can be read and modified in a python embedding script. Added example python embedding script * ignore python cache files * fixed function call * reduce cognitive complexity to satisfy SonarQube and add boolean return value to catch if function fails to read data * clean up script and add comments * replace call to object function that doesn't exist, handle exception when file passed to script cannot be read by the NetCDF library * rename example script * add new example script to makefiles * fix logic to build pandas DataFrame to properly get header information from observation header IDs * Per #2781, add unit test to demonstrate python embedding script that reads MET NetCDF point observation file and converts it to a pandas DataFrame * Per #2781, added init function for nc_point_obs to take an input filename. Also raise TypeError exception from nc_point_obs.read_data() if input file cannot be read * call parent class init function to properly initialize nc_point_obs --- .gitignore | 2 + internal/test_unit/xml/unit_python.xml | 14 ++ scripts/python/examples/Makefile.am | 3 +- scripts/python/examples/Makefile.in | 3 +- .../examples/read_met_point_obs_pandas.py | 52 +++++++ scripts/python/met/point.py | 2 +- scripts/python/met/point_nc.py | 136 +++++++++++------- 7 files changed, 154 insertions(+), 58 deletions(-) create mode 100644 scripts/python/examples/read_met_point_obs_pandas.py diff --git a/.gitignore b/.gitignore index d26e2e4a32..bbd21255b1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ make.log make_install.log .idea cmake-build-debug + +__pycache__ \ No newline at end of file diff --git a/internal/test_unit/xml/unit_python.xml b/internal/test_unit/xml/unit_python.xml index af782db022..0640aafd74 100644 --- a/internal/test_unit/xml/unit_python.xml +++ b/internal/test_unit/xml/unit_python.xml @@ -557,6 +557,20 @@ + + &MET_BIN;/plot_point_obs + \ + 'PYTHON_NUMPY=&MET_BASE;/python/examples/read_met_point_obs_pandas.py &OUTPUT_DIR;/pb2nc/ndas.20120409.t12z.prepbufr.tm00.nc' \ + &OUTPUT_DIR;/python/ndas.20120409.t12z.prepbufr.tm00.nr_met_nc_to_pandas.ps \ + -data_file &DATA_DIR_MODEL;/grib2/nam/nam_2012040900_F012.grib2 \ + -dotsize 2.0 \ + -v 1 + + + &OUTPUT_DIR;/python/ndas.20120409.t12z.prepbufr.tm00.nr_met_nc_to_pandas.ps + + + echo "&DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-fer-gep5/arw-fer-gep5_2012040912_F024.grib \ diff --git a/scripts/python/examples/Makefile.am b/scripts/python/examples/Makefile.am index e0461a3564..f1712318a6 100644 --- a/scripts/python/examples/Makefile.am +++ b/scripts/python/examples/Makefile.am @@ -32,7 +32,8 @@ pythonexamples_DATA = \ read_ascii_numpy.py \ read_ascii_point.py \ read_ascii_xarray.py \ - read_met_point_obs.py + read_met_point_obs.py \ + read_met_point_obs_pandas.py EXTRA_DIST = ${pythonexamples_DATA} diff --git a/scripts/python/examples/Makefile.in b/scripts/python/examples/Makefile.in index 1d4a58cadf..b994ccfd57 100644 --- a/scripts/python/examples/Makefile.in +++ b/scripts/python/examples/Makefile.in @@ -317,7 +317,8 @@ pythonexamples_DATA = \ read_ascii_numpy.py \ read_ascii_point.py \ read_ascii_xarray.py \ - read_met_point_obs.py + read_met_point_obs.py \ + read_met_point_obs_pandas.py EXTRA_DIST = ${pythonexamples_DATA} MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/python/examples/read_met_point_obs_pandas.py b/scripts/python/examples/read_met_point_obs_pandas.py new file mode 100644 index 0000000000..bf7bb5527b --- /dev/null +++ b/scripts/python/examples/read_met_point_obs_pandas.py @@ -0,0 +1,52 @@ +import os +import sys + +from met.point_nc import nc_point_obs + +# Description: Reads a point observation NetCDF file created by MET and passes +# the data to another MET tool via Python Embedding. This script can be copied +# to perform modifications to the data before it is passed to MET. +# Example: plot_point_obs "PYTHON_NUMPY=pyembed_met_point_nc.py in.nc" out.ps +# Contact: George McCabe + +# Read and format the input 11-column observations: +# (1) string: Message_Type +# (2) string: Station_ID +# (3) string: Valid_Time(YYYYMMDD_HHMMSS) +# (4) numeric: Lat(Deg North) +# (5) numeric: Lon(Deg East) +# (6) numeric: Elevation(msl) +# (7) string: Var_Name(or GRIB_Code) +# (8) numeric: Level +# (9) numeric: Height(msl or agl) +# (10) string: QC_String +# (11) numeric: Observation_Value + +print(f"Python Script:\t{sys.argv[0]}") + +if len(sys.argv) != 2: + print("ERROR: pyembed_met_point_nc.py -> Specify only 1 input file") + sys.exit(1) + +# Read the input file as the first argument +input_file = os.path.expandvars(sys.argv[1]) +print("Input File:\t" + repr(input_file)) + +# Read MET point observation NetCDF file +try: + point_obs = nc_point_obs(input_file) +except TypeError: + print(f"ERROR: Could not read MET point data file {input_file}") + sys.exit(1) + +# convert point observation data to a pandas DataFrame +df = point_obs.to_pandas() + +################################################## +# perform any modifications to the data here # +################################################## + +# convert pandas DataFrame to list format that is expected by MET +point_data = df.values.tolist() +print(f" point_data: Data Length:\t{len(point_data)}") +print(f" point_data: Data Type:\t{type(point_data)}") diff --git a/scripts/python/met/point.py b/scripts/python/met/point.py index eb85c3711d..05e3054ba3 100644 --- a/scripts/python/met/point.py +++ b/scripts/python/met/point.py @@ -185,7 +185,7 @@ def check_point_data(self): # return met_point_tools.convert_to_ndarray(value_list) def dump(self): - met_base_point.print_point_data(self.get_point_data()) + met_point_tools.print_point_data(self.get_point_data()) def get_count_string(self): return f' nobs={self.nobs} nhdr={self.nhdr} ntyp={self.nhdr_typ} nsid={self.nhdr_sid} nvld={self.nhdr_vld} nqty={self.nobs_qty} nvar={self.nobs_var}' diff --git a/scripts/python/met/point_nc.py b/scripts/python/met/point_nc.py index 37063bdb0d..db73d8fae4 100644 --- a/scripts/python/met/point_nc.py +++ b/scripts/python/met/point_nc.py @@ -8,10 +8,12 @@ ''' +import sys import os import numpy as np import netCDF4 as nc +import pandas as pd from met.point import met_point_obs, met_point_tools @@ -53,6 +55,11 @@ def get_string_array(nc_group, var_name): class nc_point_obs(met_point_obs): + def __init__(self, nc_filename=None): + super().__init__() + if nc_filename: + self.read_data(nc_filename) + # args should be string, list, or dictionary def get_nc_filename(self, args): nc_filename = None @@ -67,62 +74,65 @@ def get_nc_filename(self, args): def read_data(self, nc_filename): method_name = f"{self.__class__.__name__}.read_data()" - if nc_filename is None: - self.log_error_msg(f"{method_name} The input NetCDF filename is missing") - elif not os.path.exists(nc_filename): - self.log_error_msg(f"{method_name} input NetCDF file ({nc_filename}) does not exist") - else: + if not nc_filename: + raise TypeError(f"{method_name} The input NetCDF filename is missing") + if not os.path.exists(nc_filename): + raise TypeError(f"{method_name} input NetCDF file ({nc_filename}) does not exist") + + try: dataset = nc.Dataset(nc_filename, 'r') + except OSError: + raise TypeError(f"{method_name} Could not open NetCDF file ({nc_filename}") + + attr_name = 'use_var_id' + use_var_id_str = dataset.getncattr(attr_name) if attr_name in dataset.ncattrs() else "false" + self.use_var_id = use_var_id_str.lower() == 'true' + + # Header + self.hdr_typ = dataset['hdr_typ'][:] + self.hdr_sid = dataset['hdr_sid'][:] + self.hdr_vld = dataset['hdr_vld'][:] + self.hdr_lat = dataset['hdr_lat'][:] + self.hdr_lon = dataset['hdr_lon'][:] + self.hdr_elv = dataset['hdr_elv'][:] + self.hdr_typ_table = met_point_nc_tools.get_string_array(dataset, 'hdr_typ_table') + self.hdr_sid_table = met_point_nc_tools.get_string_array(dataset, 'hdr_sid_table') + self.hdr_vld_table = met_point_nc_tools.get_string_array(dataset, 'hdr_vld_table') + + nc_var = dataset.variables.get('obs_unit', None) + if nc_var: + self.obs_var_unit = nc_var[:] + nc_var = dataset.variables.get('obs_desc', None) + if nc_var: + self.obs_var_desc = nc_var[:] + + nc_var = dataset.variables.get('hdr_prpt_typ', None) + if nc_var: + self.hdr_prpt_typ = nc_var[:] + nc_var = dataset.variables.get('hdr_irpt_typ', None) + if nc_var: + self.hdr_irpt_typ = nc_var[:] + nc_var = dataset.variables.get('hdr_inst_typ', None) + if nc_var: + self.hdr_inst_typ =nc_var[:] + + #Observation data + self.hdr_sid = dataset['hdr_sid'][:] + self.obs_qty = np.array(dataset['obs_qty'][:]) + self.obs_hid = np.array(dataset['obs_hid'][:]) + self.obs_lvl = np.array(dataset['obs_lvl'][:]) + self.obs_hgt = np.array(dataset['obs_hgt'][:]) + self.obs_val = np.array(dataset['obs_val'][:]) + nc_var = dataset.variables.get('obs_vid', None) + if nc_var is None: + self.use_var_id = False + nc_var = dataset.variables.get('obs_gc', None) + else: + self.obs_var_table = met_point_nc_tools.get_string_array(dataset, 'obs_var') + if nc_var: + self.obs_vid = np.array(nc_var[:]) - attr_name = 'use_var_id' - use_var_id_str = dataset.getncattr(attr_name) if attr_name in dataset.ncattrs() else "false" - self.use_var_id = use_var_id_str.lower() == 'true' - - # Header - self.hdr_typ = dataset['hdr_typ'][:] - self.hdr_sid = dataset['hdr_sid'][:] - self.hdr_vld = dataset['hdr_vld'][:] - self.hdr_lat = dataset['hdr_lat'][:] - self.hdr_lon = dataset['hdr_lon'][:] - self.hdr_elv = dataset['hdr_elv'][:] - self.hdr_typ_table = met_point_nc_tools.get_string_array(dataset, 'hdr_typ_table') - self.hdr_sid_table = met_point_nc_tools.get_string_array(dataset, 'hdr_sid_table') - self.hdr_vld_table = met_point_nc_tools.get_string_array(dataset, 'hdr_vld_table') - - nc_var = dataset.variables.get('obs_unit', None) - if nc_var: - self.obs_var_unit = nc_var[:] - nc_var = dataset.variables.get('obs_desc', None) - if nc_var: - self.obs_var_desc = nc_var[:] - - nc_var = dataset.variables.get('hdr_prpt_typ', None) - if nc_var: - self.hdr_prpt_typ = nc_var[:] - nc_var = dataset.variables.get('hdr_irpt_typ', None) - if nc_var: - self.hdr_irpt_typ = nc_var[:] - nc_var = dataset.variables.get('hdr_inst_typ', None) - if nc_var: - self.hdr_inst_typ =nc_var[:] - - #Observation data - self.hdr_sid = dataset['hdr_sid'][:] - self.obs_qty = np.array(dataset['obs_qty'][:]) - self.obs_hid = np.array(dataset['obs_hid'][:]) - self.obs_lvl = np.array(dataset['obs_lvl'][:]) - self.obs_hgt = np.array(dataset['obs_hgt'][:]) - self.obs_val = np.array(dataset['obs_val'][:]) - nc_var = dataset.variables.get('obs_vid', None) - if nc_var is None: - self.use_var_id = False - nc_var = dataset.variables.get('obs_gc', None) - else: - self.obs_var_table = met_point_nc_tools.get_string_array(dataset, 'obs_var') - if nc_var: - self.obs_vid = np.array(nc_var[:]) - - self.obs_qty_table = met_point_nc_tools.get_string_array(dataset, 'obs_qty_table') + self.obs_qty_table = met_point_nc_tools.get_string_array(dataset, 'obs_qty_table') def save_ncfile(self, nc_filename): met_data = self.get_point_data() @@ -274,6 +284,22 @@ def write_nc_data(nc_dataset, point_obs): print(f' === ERROR at {method_name} type(nc_dataset)={type(nc_dataset)} type(point_obs)={type(point_obs)}') raise + def to_pandas(self): + return pd.DataFrame({ + 'typ': [self.hdr_typ_table[self.hdr_typ[i]] for i in self.obs_hid], + 'sid': [self.hdr_sid_table[self.hdr_sid[i]] for i in self.obs_hid], + 'vld': [self.hdr_vld_table[self.hdr_vld[i]] for i in self.obs_hid], + 'lat': [self.hdr_lat[i] for i in self.obs_hid], + 'lon': [self.hdr_lon[i] for i in self.obs_hid], + 'elv': [self.hdr_elv[i] for i in self.obs_hid], + 'var': [self.obs_var_table[i] if self.use_var_id else f'{i}' + for i in self.obs_vid], + 'lvl': self.obs_lvl, + 'hgt': self.obs_hgt, + 'qc': [np.nan if np.ma.is_masked(i) else self.obs_qty_table[i] + for i in self.obs_qty], + 'obs': self.obs_val, + }) def main(argv): if len(argv) != 1 and argv[1] != ARG_PRINT_DATA: @@ -289,5 +315,5 @@ def main(argv): point_obs_data.print_point_data(met_point_data) if __name__ == '__main__': - main() + main(sys.argv) print('Done python script') From a960cc6c2f6565ea53b0959d9cda348c33a1275c Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 15 May 2024 13:33:56 -0600 Subject: [PATCH 076/114] Feature #2833 pcp_combine_missing (#2886) * Per #2883, add -input_thresh command line option to configure allowable missing input files. * Per #2883, update pcp_combine usage statement. * Per #2883, update existing pcp_combine -derive unit test example by adding 3 new missing file inputs at the beginning, middle, and end of the file list. The first two are ignored since they include the MISSING keyword, but the third without that keyword triggers a warning message as desired. The -input_thresh option is added to only require 70% of the input files be present. This should produce the exact same output data. * Per #2883, update the pcp_combine logic for the sum command to allow missing data files based on the -input_thresh threshold. Add a test in unit_pcp_combine.xml to demonstrate. * Update docs/Users_Guide/reformat_grid.rst Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> * Per #2883, update pcp_combine usage statement in the code to be more simliar to the User's Guide. * Per #2883, switch to using derive_file_list_missing as the one containing missing files and recreate derive_file_list as it had existed for the test named pcp_combine_derive_VLD_THRESH. * Per #2883, move initialization inside the same loop to resolve SonarQube issues. * Per #2883, update sum_data_files() to switch from allocating memory to using STL vectors to satisfy SonarQube. * Per #2883, changes to declarations of variables to satisfy SonarQube. * Per #2883, address more SonarQube issues * Per #2883, backing out an unintended change I made to tcrmw_grid.cc. This change belongs on a different branch. * Per #2883, update logic of parse_file_list_type() function to handle python input strings. Also update pcp_combine to parse the type of input files being read and log non-missing python input files expected. --------- Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> --- docs/Users_Guide/reformat_grid.rst | 11 +- internal/test_unit/xml/unit_pcp_combine.xml | 36 +- .../vx_data2d_factory/parse_file_list.cc | 9 +- src/tools/core/pcp_combine/pcp_combine.cc | 389 +++++++++++------- 4 files changed, 284 insertions(+), 161 deletions(-) diff --git a/docs/Users_Guide/reformat_grid.rst b/docs/Users_Guide/reformat_grid.rst index afee78a7c6..d1bc065073 100644 --- a/docs/Users_Guide/reformat_grid.rst +++ b/docs/Users_Guide/reformat_grid.rst @@ -38,6 +38,7 @@ The usage statement for the Pcp-Combine tool is shown below: out_file [-field string] [-name list] + [-input_thresh n] [-vld_thresh n] [-log file] [-v level] @@ -79,13 +80,15 @@ Optional Arguments for pcp_combine 4. The **-name list** option is a comma-separated list of output variable names which override the default choices. If specified, the number of names must match the number of variables to be written to the output file. -5. The **-vld_thresh n** option overrides the default required ratio of valid data for at each grid point for an output value to be written. The default is 1.0. +5. The **-input_thresh n** option overrides the default required ratio of valid input files. This option does not apply to the -subtract command where exactly two valid inputs are required. The default is 1.0. -6. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. +6. The **-vld_thresh n** option overrides the default required ratio of valid data at each grid point for an output value to be written. The default is 1.0. -7. The **-v level** option indicates the desired level of verbosity. The contents of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. +7. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. -8. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. +8. The **-v level** option indicates the desired level of verbosity. The contents of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. + +9. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. Required Arguments for the pcp_combine Sum Command ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/internal/test_unit/xml/unit_pcp_combine.xml b/internal/test_unit/xml/unit_pcp_combine.xml index a49e220d79..8d9fb0f6c8 100644 --- a/internal/test_unit/xml/unit_pcp_combine.xml +++ b/internal/test_unit/xml/unit_pcp_combine.xml @@ -33,6 +33,19 @@ + + &MET_BIN;/pcp_combine + \ + 20120409_00 3 20120412_15 12 \ + &OUTPUT_DIR;/pcp_combine/nam_2012040900_F087_APCP12.nc \ + -pcpdir &DATA_DIR_MODEL;/grib1/nam \ + -input_thresh 0.75 + + + &OUTPUT_DIR;/pcp_combine/nam_2012040900_F087_APCP12.nc + + + &MET_BIN;/pcp_combine \ @@ -292,22 +305,26 @@ - echo "&DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \ + echo "MISSING \ + &DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-fer-gep5/arw-fer-gep5_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-sch-gep2/arw-sch-gep2_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-sch-gep6/arw-sch-gep6_2012040912_F024.grib \ + MISSING/optional/path/to/missing/file \ &DATA_DIR_MODEL;/grib1/arw-tom-gep0/arw-tom-gep0_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/arw-tom-gep7/arw-tom-gep7_2012040912_F024.grib \ &DATA_DIR_MODEL;/grib1/nmm-fer-gep4/nmm-fer-gep4_2012040912_F024.grib \ - &DATA_DIR_MODEL;/grib1/nmm-fer-gep8/nmm-fer-gep8_2012040912_F024.grib" \ - > &OUTPUT_DIR;/pcp_combine/derive_file_list; \ + &DATA_DIR_MODEL;/grib1/nmm-fer-gep8/nmm-fer-gep8_2012040912_F024.grib \ + &DATA_DIR_MODEL;/path/to/missing/file" \ + > &OUTPUT_DIR;/pcp_combine/derive_file_list_missing; \ &MET_BIN;/pcp_combine \ -derive mean,stdev,vld_count \ - &OUTPUT_DIR;/pcp_combine/derive_file_list \ + &OUTPUT_DIR;/pcp_combine/derive_file_list_missing \ -field 'name="TMP"; level="Z2";' \ -field 'name="UGRD"; level="Z10";' \ -field 'name="VGRD"; level="Z10";' \ + -input_thresh 0.7 \ &OUTPUT_DIR;/pcp_combine/derive_2012040912_F024_MULTIPLE_FIELDS.nc @@ -322,7 +339,16 @@ - &MET_BIN;/pcp_combine + echo "&DATA_DIR_MODEL;/grib1/arw-fer-gep1/arw-fer-gep1_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/arw-fer-gep5/arw-fer-gep5_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/arw-sch-gep2/arw-sch-gep2_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/arw-sch-gep6/arw-sch-gep6_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/arw-tom-gep0/arw-tom-gep0_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/arw-tom-gep7/arw-tom-gep7_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/nmm-fer-gep4/nmm-fer-gep4_2012040912_F024.grib \ + &DATA_DIR_MODEL;/grib1/nmm-fer-gep8/nmm-fer-gep8_2012040912_F024.grib" \ + > &OUTPUT_DIR;/pcp_combine/derive_file_list; \ + &MET_BIN;/pcp_combine \ -derive mean,stdev,vld_count \ &OUTPUT_DIR;/pcp_combine/derive_file_list \ diff --git a/src/libcode/vx_data2d_factory/parse_file_list.cc b/src/libcode/vx_data2d_factory/parse_file_list.cc index 2e2be2a632..dd31e1a213 100644 --- a/src/libcode/vx_data2d_factory/parse_file_list.cc +++ b/src/libcode/vx_data2d_factory/parse_file_list.cc @@ -213,11 +213,18 @@ GrdFileType ftype = FileType_None; for ( int i=0; i #include #include +#include #include @@ -135,6 +137,7 @@ static int i_out_var = 0; static int n_out_var; static MetConfig config; static VarInfo * var_info = (VarInfo *) nullptr; +static double input_thresh = 1.0; static double vld_thresh = 1.0; static int compress_level = -1; @@ -148,6 +151,7 @@ static ConcatString pcp_reg_exp = (string)default_reg_exp; // Variables for the derive command static StringArray file_list; +static GrdFileType file_list_type = FileType_None; static StringArray field_list; static StringArray derive_list; @@ -171,10 +175,11 @@ static void sum_data_files(Grid &, DataPlane &); static int search_pcp_dir(const char *, const unixtime, ConcatString &); -static void get_field(const char * filename, const char * cur_field, +static bool get_field(const char * filename, const char * cur_field, const unixtime get_init_ut, const unixtime get_valid_ut, - Grid & grid, DataPlane & plane); + Grid & grid, DataPlane & plane, + bool error_out); static void open_nc(const Grid &); static void write_nc_data(unixtime, unixtime, int, const DataPlane &, @@ -194,13 +199,13 @@ static void set_pcpdir(const StringArray &); static void set_pcprx(const StringArray &); static void set_field(const StringArray & a); static void set_name(const StringArray & a); +static void set_input_thresh(const StringArray & a); static void set_vld_thresh(const StringArray & a); static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// int met_main(int argc, char *argv[]) { - int i, j; program_name = get_short_name(argv[0]); @@ -212,7 +217,7 @@ int met_main(int argc, char *argv[]) { // // Process each requested field // - for(i=0; i " << "the output accumulation time (" << sec_to_hhmmss(out_accum) - << ") cannot be greater than the lead time (" + << ") can't be greater than the lead time (" << sec_to_hhmmss(lead_time) << ").\n\n"; exit(1); } @@ -535,7 +544,7 @@ void do_sum_command() { } // - // Check that the lead time is divisible by the the input. + // Check that the lead time is divisible by the input // accumulation time except when init_time = 0 for observations. // if(lead_time%in_accum != 0 && init_time != (unixtime) 0) { @@ -563,22 +572,18 @@ void do_sum_command() { //////////////////////////////////////////////////////////////////////// void sum_data_files(Grid & grid, DataPlane & plane) { - int i, j, x, y; + int n_vld = 0; DataPlane part; double v_sum, v_part; Grid cur_grid; - unixtime * pcp_times = (unixtime *) nullptr; - int * pcp_recs = (int *) nullptr; - ConcatString * pcp_files = (ConcatString *) nullptr; + vector pcp_times; + vector pcp_recs; + vector pcp_files; // - // Compute the number of forecast precipitation files to be found, - // and allocate memory to store their names and times. + // Compute the number of forecast precipitation files to be found. // - n_files = out_accum/in_accum; - pcp_times = new unixtime [n_files]; - pcp_recs = new int [n_files]; - pcp_files = new ConcatString [n_files]; + n_files = out_accum/in_accum; mlog << Debug(2) << "Searching for " << n_files << " files " @@ -586,25 +591,22 @@ void sum_data_files(Grid & grid, DataPlane & plane) { << " to sum to a total accumulation time of " << sec_to_hhmmss(out_accum) << ".\n"; - // - // Compute the valid times for the precipitation files - // to be found. - // - for(i=0; i " - << "cannot find a file with a valid time of " + if(pcp_recs[i] != -1) { + n_vld++; + } + else { + mlog << Warning << "\nsum_data_files() -> " + << "can't find a file with a valid time of " << unix_to_yyyymmdd_hhmmss(pcp_times[i]) << " and accumulation time of " << sec_to_hhmmss(in_accum) << " matching the regular " << "expression \"" << pcp_reg_exp << "\"\n\n"; - exit(1); } } // end for i + // Check for enough valid input files. + if((double) n_vld/n_files < input_thresh) { + mlog << Error << "\nsum_data_files() -> " + << n_vld << " of " << n_files << " (" << (double) n_vld/n_files + << ") valid inputs does not meet the required input threshold (" + << input_thresh << ").\n\n"; + exit(1); + } + // // Open each of the files found and parse the data. // - for(i=0; i " - << "cannot open search directory: " << cur_dir << "\n\n"; + << "can't open search directory: " << cur_dir << "\n\n"; exit(1); } // // Initialize the record index to not found. // - i_rec = -1; + int i_rec = -1; // // Process each file contained in the directory. @@ -807,8 +818,11 @@ int search_pcp_dir(const char *cur_dir, const unixtime cur_ut, if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } if(cur_var) { delete cur_var; cur_var = (VarInfo *) nullptr; } - // check for a valid match - if( -1 != i_rec ) { met_closedir(dp); break; } + // Check for a valid match + if(i_rec != -1) { + met_closedir(dp); + break; + } } // end if @@ -824,11 +838,9 @@ int search_pcp_dir(const char *cur_dir, const unixtime cur_ut, void do_sub_command() { DataPlane plus, minus, diff; Grid grid1, grid2; - unixtime nc_init_time, nc_valid_time; - int i, nxy, nc_accum; // - // Check for exactly two input files + // Check for exactly two input files. // if(n_files != 2) { mlog << Error << "\ndo_sub_command() -> " @@ -838,18 +850,21 @@ void do_sub_command() { } // - // Read the two specified data files + // Read the two specified data files. + // Error out for any problems reading the requested data. // mlog << Debug(1) << "Reading input file: " << file_list[0] << "\n"; - get_field(file_list[0].c_str(), field_list[0].c_str(), 0, 0, grid1, plus); + get_field(file_list[0].c_str(), field_list[0].c_str(), + 0, 0, grid1, plus, true); mlog << Debug(1) << "Reading input file: " << file_list[1] << "\n"; - get_field(file_list[1].c_str(), field_list[1].c_str(), 0, 0, grid2, minus); + get_field(file_list[1].c_str(), field_list[1].c_str(), + 0, 0, grid2, minus, true); // - // Check for the same grid dimensions + // Check for the same grid dimensions. // if(grid1 != grid2) { mlog << Error << "\ndo_sub_command() -> " @@ -867,10 +882,10 @@ void do_sub_command() { // // Output valid time // - nc_valid_time = plus.valid(); + unixtime nc_valid_time = plus.valid(); // - // Check that the initialization times match + // Check that the initialization times match. // if(plus.init() != minus.init()) { @@ -890,7 +905,7 @@ void do_sub_command() { mlog << Debug(3) << cs << "\n"; } } - nc_init_time = plus.init(); + unixtime nc_init_time = plus.init(); // // Output accumulation time @@ -902,7 +917,7 @@ void do_sub_command() { << "second (" << sec_to_hhmmss(plus.accum()) << " < " << sec_to_hhmmss(minus.accum()) << ") for subtraction.\n\n"; } - nc_accum = plus.accum() - minus.accum(); + int nc_accum = plus.accum() - minus.accum(); // // Initialize. @@ -912,7 +927,8 @@ void do_sub_command() { // // Update value for each grid point. // - for(i=0, nxy=grid1.nx()*grid1.ny(); i " @@ -1052,7 +1068,7 @@ void do_derive_command() { // // Update sums and counts. // - for(j=0; j " + << n_vld << " of " << n_files << " (" << (double) n_vld/n_files + << ") valid inputs does not meet the required input threshold (" + << input_thresh << ").\n\n"; + exit(1); } // - // Compute the valid data mask. + // Compute the valid data mask, relative the number of valid inputs. // mask.set_size(grid.nx(), grid.ny()); - for(j=0, n=0; j= vld_thresh; - if(!mask.data()[j]) n++; + int n_skip = 0; + for(int j=0; j= vld_thresh; + if(!mask.data()[j]) n_skip++; } mlog << Debug(2) - << "Skipping " << n << " of " << nxy << " grid points which " + << "Skipping " << n_skip << " of " << nxy << " grid points which " << "do not meet the valid data threshold (" << vld_thresh << ").\n"; @@ -1105,7 +1131,7 @@ void do_derive_command() { // // Loop through the derived fields. // - for(i=0; i " - << "can't open data file \"" << filename << "\"\n\n"; - exit(1); - } + if(ftype == FileType_None) ftype = file_list_type; - cur_var = var_fac.new_var_info(mtddf->file_type()); - if(!cur_var) { - mlog << Error << "\nget_field() -> " - << "unable to determine filetype of \"" << filename - << "\"\n\n"; - exit(1); + // + // Check for missing non-python input files. + // + if(!file_exists(filename) && + !is_python_grdfiletype(ftype)) { + log_missing_file(method_name, "input file", filename); + status = false; } // - // Initialize the VarInfo object with a config. + // Open the data file. // - cur_var->set_dict(config); + if(status) { + mtddf = factory.new_met_2d_data_file(filename, ftype); + if(!mtddf) { + mlog << Warning << "\n" << method_name + << "can't open data file \"" << filename << "\"\n\n"; + status = false; + } + } // - // Set the VarInfo timing object + // Build a VarInfo object. // - if(get_valid_ut != 0) cur_var->set_valid(get_valid_ut); - if(get_init_ut != 0) cur_var->set_init(get_init_ut); + if(status) { + cur_var = var_fac.new_var_info(mtddf->file_type()); + if(!cur_var) { + mlog << Warning << "\n" << method_name + << "unable to determine filetype of \"" << filename + << "\"\n\n"; + status = false; + } + } // - // Read the record of interest into a DataPlane object. + // Setup the VarInfo object and read the data. // - if(!mtddf->data_plane(*cur_var, plane)) { - mlog << Error << "\nget_field() -> " - << "can't get data plane from file \"" << filename - << "\"\n\n"; - exit(1); - } + if(status) { - grid = mtddf->grid(); + // + // Initialize the VarInfo object with a config. + // + cur_var->set_dict(config); + + // + // Set the VarInfo timing object. + // + if(get_valid_ut != 0) cur_var->set_valid(get_valid_ut); + if(get_init_ut != 0) cur_var->set_init(get_init_ut); + + // + // Read the record of interest into a DataPlane object. + // + if(!mtddf->data_plane(*cur_var, plane)) { + mlog << Warning << "\n" << method_name + << "can't get data plane from file \"" << filename + << "\"\n\n"; + status = false; + } + } // - // Set the global var_info, if needed. + // Store grid and global VarInfo, if needed. // - if(!var_info) { - var_info = var_fac.new_var_info(mtddf->file_type()); - *var_info = *cur_var; + if(status) { + + grid = mtddf->grid(); + + if(!var_info) { + var_info = var_fac.new_var_info(mtddf->file_type()); + *var_info = *cur_var; + } } // @@ -1265,9 +1327,17 @@ void get_field(const char *filename, const char *cur_field, if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) nullptr; } if(cur_var) { delete cur_var; cur_var = (VarInfo *) nullptr; } - // if ( var ) { delete var; var = nullptr; } + // + // Error out and exit, if requested. + // + if(!status && error_out) { + mlog << Error << "\n" << method_name + << "trouble reading data (" << config_str + << ") from required input file: " << filename << "\n\n"; + exit(1); + } - return; + return status; } @@ -1276,7 +1346,7 @@ void get_field(const char *filename, const char *cur_field, void open_nc(const Grid &grid) { ConcatString command_str; - // List the output file + // List the output file. mlog << Debug(1) << "Creating output file: " << out_filename << "\n"; @@ -1402,7 +1472,7 @@ void write_nc_data(unixtime nc_init, unixtime nc_valid, int nc_accum, int deflate_level = compress_level; if(deflate_level < 0) deflate_level = config.nc_compression(); - // Define Variable. + // Define variable. nc_var = add_var(nc_out, var_str.c_str(), ncFloat, lat_dim, lon_dim, deflate_level); @@ -1516,6 +1586,7 @@ void usage() { << "\tout_file\n" << "\t[-field string]\n" << "\t[-name list]\n" + << "\t[-input_thresh n]\n" << "\t[-vld_thresh n]\n" << "\t[-log file]\n" << "\t[-v level]\n" @@ -1546,8 +1617,12 @@ void usage() { << "variable names to be written to the \"out_file\" " << "(optional).\n" + << "\t\t\"-input_thresh\" overrides the default required ratio " + << "of valid input files (" << input_thresh << ") (optional).\n" + << "\t\t\"-vld_thresh\" overrides the default required ratio " - << "of valid data (" << vld_thresh << ") (optional).\n" + << "of valid data at each grid point (" << vld_thresh + << ") (optional).\n" << "\t\t\"-log file\" write log messages to the specified file " << "(optional).\n" @@ -1695,6 +1770,18 @@ void set_name(const StringArray & a) { //////////////////////////////////////////////////////////////////////// +void set_input_thresh(const StringArray & a) { + input_thresh = atof(a[0].c_str()); + if(input_thresh > 1 || input_thresh < 0) { + mlog << Error << "\nset_input_thresh() -> " + << "the \"-input_thresh\" command line option (" << input_thresh + << ") must be set between 0 and 1!\n\n"; + exit(1); + } +} + +//////////////////////////////////////////////////////////////////////// + void set_vld_thresh(const StringArray & a) { vld_thresh = atof(a[0].c_str()); if(vld_thresh > 1 || vld_thresh < 0) { From 27bff621c5748305f61daa51d0b5cebe3e2b914e Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 15 May 2024 21:56:54 -0600 Subject: [PATCH 077/114] Per #2888, update STATAnalysisJob::dump_stat_line() to support dumping stat line types VCNT, RPS, DMAP, and SSIDX. (#2891) --- src/libcode/vx_analysis_util/stat_job.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 573c0f43d6..dda0a08bd9 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -2176,6 +2176,7 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, if(line_type.n() == 1) { switch(string_to_statlinetype(line_type[0].c_str())) { + case STATLineType::fho: write_header_row(fho_columns, n_fho_columns, 1, dump_at, 0, 0); break; @@ -2200,6 +2201,10 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, write_header_row(sal1l2_columns, n_sal1l2_columns, 1, dump_at, 0, 0); break; + case STATLineType::vcnt: + write_header_row(vcnt_columns, n_vcnt_columns, 1, dump_at, 0, 0); + break; + case STATLineType::vl1l2: write_header_row(vl1l2_columns, n_vl1l2_columns, 1, dump_at, 0, 0); break; @@ -2232,6 +2237,10 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, write_header_row(ecnt_columns, n_ecnt_columns, 1, dump_at, 0, 0); break; + case STATLineType::rps: + write_header_row(rps_columns, n_rps_columns, 1, dump_at, 0, 0); + break; + case STATLineType::isc: write_header_row(isc_columns, n_isc_columns, 1, dump_at, 0, 0); break; @@ -2248,6 +2257,14 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, write_header_row(seeps_mpr_columns, n_seeps_mpr_columns, 1, dump_at, 0, 0); break; + case STATLineType::dmap: + write_header_row(dmap_columns, n_dmap_columns, 1, dump_at, 0, 0); + break; + + case STATLineType::ssidx: + write_header_row(ssidx_columns, n_ssidx_columns, 1, dump_at, 0, 0); + break; + // Just write a STAT header line for indeterminant line types case STATLineType::mctc: case STATLineType::mcts: From 32bd12d7c25adfe324611661f408550e54bbe3b0 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Tue, 21 May 2024 09:35:52 -0600 Subject: [PATCH 078/114] Per #2659, making updates as proposed at the 20240516 MET Eng. Mtg. (#2895) --- .github/ISSUE_TEMPLATE/enhancement_request.md | 4 ++-- .github/ISSUE_TEMPLATE/new_feature_request.md | 4 ++-- .github/ISSUE_TEMPLATE/sub-issue.md | 4 ++-- .github/ISSUE_TEMPLATE/task.md | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/enhancement_request.md b/.github/ISSUE_TEMPLATE/enhancement_request.md index e1134781cd..78cd208f15 100644 --- a/.github/ISSUE_TEMPLATE/enhancement_request.md +++ b/.github/ISSUE_TEMPLATE/enhancement_request.md @@ -39,8 +39,8 @@ Consider breaking the enhancement down into sub-issues. - [ ] Select **requestor(s)** ### Milestone and Projects ### -- [ ] Select **Milestone** as the next official version or **Backlog of Development Ideas** -- [ ] For the next official version, select the **MET-X.Y.Z Development** project +- [ ] Select **Milestone** as a **MET-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas** +- [ ] For a **MET-X.Y.Z** version, select the **MET-X.Y.Z Development** project ## Define Related Issue(s) ## Consider the impact to the other METplus components. diff --git a/.github/ISSUE_TEMPLATE/new_feature_request.md b/.github/ISSUE_TEMPLATE/new_feature_request.md index e4adb302c7..ea95d70c13 100644 --- a/.github/ISSUE_TEMPLATE/new_feature_request.md +++ b/.github/ISSUE_TEMPLATE/new_feature_request.md @@ -43,8 +43,8 @@ Consider breaking the new feature down into sub-issues. - [ ] Select **requestor(s)** ### Milestone and Projects ### -- [ ] Select **Milestone** as the next official version or **Backlog of Development Ideas** -- [ ] For the next official version, select the **MET-X.Y.Z Development** project +- [ ] Select **Milestone** as a **MET-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas** +- [ ] For a **MET-X.Y.Z** version, select the **MET-X.Y.Z Development** project ## Define Related Issue(s) ## Consider the impact to the other METplus components. diff --git a/.github/ISSUE_TEMPLATE/sub-issue.md b/.github/ISSUE_TEMPLATE/sub-issue.md index e02109e963..45ee00432d 100644 --- a/.github/ISSUE_TEMPLATE/sub-issue.md +++ b/.github/ISSUE_TEMPLATE/sub-issue.md @@ -29,5 +29,5 @@ This is a sub-issue of #*List the parent issue number here*. - [ ] Select **requestor(s)** ### Milestone and Projects ### -- [ ] Select **Milestone** as the next official version or **Backlog of Development Ideas** -- [ ] For the next official version, select the **MET-X.Y.Z Development** project +- [ ] Select **Milestone** as a **MET-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas** +- [ ] For a **MET-X.Y.Z** version, select the **MET-X.Y.Z Development** project diff --git a/.github/ISSUE_TEMPLATE/task.md b/.github/ISSUE_TEMPLATE/task.md index 05ad99baf8..33685adf25 100644 --- a/.github/ISSUE_TEMPLATE/task.md +++ b/.github/ISSUE_TEMPLATE/task.md @@ -39,8 +39,8 @@ Consider breaking the task down into sub-issues. - [ ] Select **requestor(s)** ### Milestone and Projects ### -- [ ] Select **Milestone** as the next official version or **Backlog of Development Ideas** -- [ ] For the next official version, select the **MET-X.Y.Z Development** project +- [ ] Select **Milestone** as a **MET-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas** +- [ ] For a **MET-X.Y.Z** version, select the **MET-X.Y.Z Development** project ## Define Related Issue(s) ## Consider the impact to the other METplus components. From 889f1b214665c68efd29f3f475e0bf280afaa1cb Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 22 May 2024 11:30:10 -0600 Subject: [PATCH 079/114] Feature #2395 TOTAL_DIR (#2892) * Per #2395, remove the n_dir_undef and n_dira_undef variables that are superceded by the new dcount and dacount VL1L2Info members to keep track of the number of valid wind direction vectors. * Per #2395, add TOTAL_DIR columns to the VL1L2, VAL1L2, and VCNT line types and update the header column tables. * Per #2395, update the User's Guide to list the new TOTAL_DIR columns in the VL1L2, VAL1L2, and VCNT line types. * Per #2395, update stat_analysis to parse the new TOTAL_DIR columns and use the values to aggregate results when needed. * Per #2395, for SonarQube change 'const char *' to 'const char * const' to satisfy the finding that 'Global variables should be const.' Should probably switch from 'char char *' to strings eventually. But for now, I'm just making up for some SonarQube technical debt. * Per #2395, fix typo in placement of the DIR_ME column name in the met_header_columns_V12.0.txt file * Per #2395, add 2 new Stat-Analysis jobs to demonstrate the processing of VL1L2 lines. * Per #2395, update logic of is_vector_dir_stat(). Instead of just checking 'DIR_', check 'DIR_ME', 'DIR_MAE', and 'DIR_MSE' to avoid an false positive match for the 'DIR_ERR' column which is computed from the vector partial sums rather than the individual direction differences. --- data/table_files/met_header_columns_V12.0.txt | 6 +- docs/Users_Guide/point-stat.rst | 25 ++++-- .../config/STATAnalysisConfig_point_stat | 6 +- internal/test_unit/hdr/met_12_0.hdr | 6 +- .../test_unit/xml/unit_stat_analysis_ps.xml | 2 + src/basic/vx_util/stat_column_defs.h | 87 ++++++++++--------- src/libcode/vx_stat_out/stat_columns.cc | 31 ++++--- src/libcode/vx_stat_out/stat_columns.h | 2 +- src/libcode/vx_statistics/met_stats.cc | 62 +++++-------- src/libcode/vx_statistics/met_stats.h | 10 +-- src/tools/core/ensemble_stat/ensemble_stat.h | 4 +- src/tools/core/grid_stat/grid_stat.h | 4 +- src/tools/core/point_stat/point_stat.h | 4 +- .../core/stat_analysis/aggr_stat_line.cc | 60 ++++++------- .../core/stat_analysis/parse_stat_line.cc | 2 + src/tools/tc_utils/tc_gen/tc_gen.h | 4 +- 16 files changed, 163 insertions(+), 152 deletions(-) diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index 299e6cb4d6..3d98f02206 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -27,9 +27,9 @@ V12.0 : STAT : RELP : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : SAL1L2 : 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 FABAR OABAR FOABAR FFABAR OOABAR MAE V12.0 : STAT : SL1L2 : 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 FBAR OBAR FOBAR FFBAR OOBAR MAE V12.0 : STAT : SSVAR : 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_BIN BIN_i BIN_N VAR_MIN VAR_MAX VAR_MEAN FBAR OBAR FOBAR FFBAR OOBAR FBAR_NCL FBAR_NCU FSTDEV FSTDEV_NCL FSTDEV_NCU OBAR_NCL OBAR_NCU OSTDEV OSTDEV_NCL OSTDEV_NCU PR_CORR PR_CORR_NCL PR_CORR_NCU ME ME_NCL ME_NCU ESTDEV ESTDEV_NCL ESTDEV_NCU MBIAS MSE BCMSE RMSE -V12.0 : STAT : VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR DIRA_ME DIRA_MAE DIRA_MSE -V12.0 : STAT : VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR DIR_ME DIR_MAE DIR_MSE -V12.0 : STAT : VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU DIR_ME DIR_ME_BCL DIR_ME_BCU DIR_MAE DIR_MAE_BCL DIR_MAE_BCU DIR_MSE DIR_MSE_BCL DIR_MSE_BCU DIR_RMSE DIR_RMSE_BCL DIR_RMSE_BCU +V12.0 : STAT : VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR TOTAL_DIR DIRA_ME DIRA_MAE DIRA_MSE +V12.0 : STAT : VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR TOTAL_DIR DIR_ME DIR_MAE DIR_MSE +V12.0 : STAT : VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU TOTAL_DIR DIR_ME DIR_ME_BCL DIR_ME_BCU DIR_MAE DIR_MAE_BCL DIR_MAE_BCU DIR_MSE DIR_MSE_BCL DIR_MSE_BCU DIR_RMSE DIR_RMSE_BCL DIR_RMSE_BCU V12.0 : STAT : GENMPR : 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 STORM_ID PROB_LEAD PROB_VAL AGEN_INIT AGEN_FHR AGEN_LAT AGEN_LON AGEN_DLAND BGEN_LAT BGEN_LON BGEN_DLAND GEN_DIST GEN_TDIFF INIT_TDIFF DEV_CAT OPS_CAT V12.0 : STAT : SSIDX : 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 FCST_MODEL REF_MODEL N_INIT N_TERM N_VLD SS_INDEX diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index 6c32537146..ec4e69178b 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -1289,12 +1289,15 @@ The first set of header columns are common to all of the output files generated - O_SPEED_BAR - Mean observed wind speed * - 35 + - TOTAL_DIR + - Total number of matched pairs for which both the forecast and observation wind directions are well-defined (i.e. non-zero vectors) + * - 36 - DIR_ME - Mean wind direction difference, from -180 to 180 degrees - * - 36 + * - 37 - DIR_MAE - Mean absolute wind direction difference - * - 37 + * - 38 - DIR_MSE - Mean squared wind direction difference @@ -1344,12 +1347,15 @@ The first set of header columns are common to all of the output files generated - OA_SPEED_BAR - Mean observed wind speed anomaly * - 35 + - TOTAL_DIR + - Total number of matched triplets for which the forecast, observation, and climatological wind directions are well-defined (i.e. non-zero vectors) + * - 36 - DIRA_ME - Mean wind direction anomaly difference, from -180 to 180 degrees - * - 36 + * - 37 - DIRA_MAE - Mean absolute wind direction anomaly difference - * - 37 + * - 38 - DIRA_MSE - Mean squared wind direction anomaly difference @@ -1431,16 +1437,19 @@ The first set of header columns are common to all of the output files generated * - 85-87 - ANOM_CORR_UNCNTR, :raw-html:`
` ANOM_CORR_UNCNTR_BCL, :raw-html:`
` ANOM_CORR_UNCNTR_BCU - Uncentered vector Anomaly Correlation excluding mean error including bootstrap upper and lower confidence limits - * - 88-90 + * - 88 + - TOTAL_DIR + - Total number of matched pairs for which both the forecast and observation wind directions are well-defined (i.e. non-zero vectors) + * - 89-91 - DIR_ME, :raw-html:`
` DIR_ME_BCL, :raw-html:`
` DIR_ME_BCU - Mean direction difference, from -180 to 180 degrees, including bootstrap upper and lower confidence limits - * - 91-93 + * - 92-94 - DIR_MAE, :raw-html:`
` DIR_MAE_BCL, :raw-html:`
` DIR_MAE_BCU - Mean absolute direction difference including bootstrap upper and lower confidence limits - * - 94-96 + * - 95-97 - DIR_MSE, :raw-html:`
` DIR_MSE_BCL, :raw-html:`
` DIR_MSE_BCU - Mean squared direction difference including bootstrap upper and lower confidence limits - * - 97-99 + * - 98-100 - DIR_RMSE, :raw-html:`
` DIR_RMSE_BCL, :raw-html:`
` DIR_RMSE_BCU - Root mean squared direction difference including bootstrap upper and lower confidence limits diff --git a/internal/test_unit/config/STATAnalysisConfig_point_stat b/internal/test_unit/config/STATAnalysisConfig_point_stat index 4f751b32dc..db7ab415a6 100644 --- a/internal/test_unit/config/STATAnalysisConfig_point_stat +++ b/internal/test_unit/config/STATAnalysisConfig_point_stat @@ -103,7 +103,11 @@ jobs = [ -dump_row ${OUTPUT_DIR}/CONFIG_POINT_STAT_filter_mpr_sid.stat", "-job filter -fcst_var TMP -fcst_lev Z2 \ -line_type MPR -column_thresh abs(fcst-obs) >5 \ - -dump_row ${OUTPUT_DIR}/CONFIG_POINT_STAT_filter_mpr_fcst_minus_obs.stat" + -dump_row ${OUTPUT_DIR}/CONFIG_POINT_STAT_filter_mpr_fcst_minus_obs.stat", + "-job aggregate -line_type VL1L2 -by FCST_LEV \ + -out_stat ${OUTPUT_DIR}/CONFIG_POINT_STAT_agg_vl1l2.stat", + "-job aggregate_stat -line_type VL1L2 -out_line_type VCNT -by FCST_LEV \ + -out_stat ${OUTPUT_DIR}/CONFIG_POINT_STAT_agg_stat_vl1l2_to_vcnt.stat" ]; //////////////////////////////////////////////////////////////////////////////// diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index a1113d5102..bf8575039a 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -27,9 +27,9 @@ RELP : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L SAL1L2 : 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 FABAR OABAR FOABAR FFABAR OOABAR MAE SL1L2 : 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 FBAR OBAR FOBAR FFBAR OOBAR MAE SSVAR : 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_BIN BIN_i BIN_N VAR_MIN VAR_MAX VAR_MEAN FBAR OBAR FOBAR FFBAR OOBAR FBAR_NCL FBAR_NCU FSTDEV FSTDEV_NCL FSTDEV_NCU OBAR_NCL OBAR_NCU OSTDEV OSTDEV_NCL OSTDEV_NCU PR_CORR PR_CORR_NCL PR_CORR_NCU ME ME_NCL ME_NCU ESTDEV ESTDEV_NCL ESTDEV_NCU MBIAS MSE BCMSE RMSE -VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR DIR_ME DIR_MAE DIR_MSE -VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR DIRA_ME DIRA_MAE DIRA_MSE -VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU DIR_ME DIR_ME_BCL DIR_ME_BCU DIR_MAE DIR_MAE_BCL DIR_MAE_BCU DIR_MSE DIR_MSE_BCL DIR_MSE_BCU DIR_RMSE DIR_RMSE_BCL DIR_RMSE_BCU +VL1L2 : 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 UFBAR VFBAR UOBAR VOBAR UVFOBAR UVFFBAR UVOOBAR F_SPEED_BAR O_SPEED_BAR TOTAL_DIR DIR_ME DIR_MAE DIR_MSE +VAL1L2 : 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 UFABAR VFABAR UOABAR VOABAR UVFOABAR UVFFABAR UVOOABAR FA_SPEED_BAR OA_SPEED_BAR TOTAL_DIR DIRA_ME DIRA_MAE DIRA_MSE +VCNT : 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 FBAR FBAR_BCL FBAR_BCU OBAR OBAR_BCL OBAR_BCU FS_RMS FS_RMS_BCL FS_RMS_BCU OS_RMS OS_RMS_BCL OS_RMS_BCU MSVE MSVE_BCL MSVE_BCU RMSVE RMSVE_BCL RMSVE_BCU FSTDEV FSTDEV_BCL FSTDEV_BCU OSTDEV OSTDEV_BCL OSTDEV_BCU FDIR FDIR_BCL FDIR_BCU ODIR ODIR_BCL ODIR_BCU FBAR_SPEED FBAR_SPEED_BCL FBAR_SPEED_BCU OBAR_SPEED OBAR_SPEED_BCL OBAR_SPEED_BCU VDIFF_SPEED VDIFF_SPEED_BCL VDIFF_SPEED_BCU VDIFF_DIR VDIFF_DIR_BCL VDIFF_DIR_BCU SPEED_ERR SPEED_ERR_BCL SPEED_ERR_BCU SPEED_ABSERR SPEED_ABSERR_BCL SPEED_ABSERR_BCU DIR_ERR DIR_ERR_BCL DIR_ERR_BCU DIR_ABSERR DIR_ABSERR_BCL DIR_ABSERR_BCU ANOM_CORR ANOM_CORR_NCL ANOM_CORR_NCU ANOM_CORR_BCL ANOM_CORR_BCU ANOM_CORR_UNCNTR ANOM_CORR_UNCNTR_BCL ANOM_CORR_UNCNTR_BCU TOTAL_DIR DIR_ME DIR_ME_BCL DIR_ME_BCU DIR_MAE DIR_MAE_BCL DIR_MAE_BCU DIR_MSE DIR_MSE_BCL DIR_MSE_BCU DIR_RMSE DIR_RMSE_BCL DIR_RMSE_BCU GENMPR : 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 STORM_ID PROB_LEAD PROB_VAL AGEN_INIT AGEN_FHR AGEN_LAT AGEN_LON AGEN_DLAND BGEN_LAT BGEN_LON BGEN_DLAND GEN_DIST GEN_TDIFF INIT_TDIFF DEV_CAT OPS_CAT SSIDX : 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 FCST_MODEL REF_MODEL N_INIT N_TERM N_VLD SS_INDEX MODE_SOA : 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 N_VALID GRID_RES OBJECT_ID OBJECT_CAT CENTROID_X CENTROID_Y CENTROID_LAT CENTROID_LON AXIS_ANG LENGTH WIDTH AREA AREA_THRESH CURVATURE CURVATURE_X CURVATURE_Y COMPLEXITY INTENSITY_10 INTENSITY_25 INTENSITY_50 INTENSITY_75 INTENSITY_90 INTENSITY_50 INTENSITY_SUM diff --git a/internal/test_unit/xml/unit_stat_analysis_ps.xml b/internal/test_unit/xml/unit_stat_analysis_ps.xml index 9fd50dcb2a..1ea5e2e19a 100644 --- a/internal/test_unit/xml/unit_stat_analysis_ps.xml +++ b/internal/test_unit/xml/unit_stat_analysis_ps.xml @@ -38,6 +38,8 @@ &OUTPUT_DIR;/stat_analysis_ps/CONFIG_POINT_STAT_agg_stat_mpr_to_wdir_dump.stat &OUTPUT_DIR;/stat_analysis_ps/CONFIG_POINT_STAT_filter_mpr_sid.stat &OUTPUT_DIR;/stat_analysis_ps/CONFIG_POINT_STAT_filter_mpr_fcst_minus_obs.stat + &OUTPUT_DIR;/stat_analysis_ps/CONFIG_POINT_STAT_agg_vl1l2.stat + &OUTPUT_DIR;/stat_analysis_ps/CONFIG_POINT_STAT_agg_stat_vl1l2_to_vcnt.stat
diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index 826d5101c9..9a92cf0970 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////////// -static const char * hdr_columns [] = { +static const char * const hdr_columns [] = { "VERSION", "MODEL", "DESC", "FCST_LEAD", "FCST_VALID_BEG", "FCST_VALID_END", @@ -29,17 +29,17 @@ static const char * hdr_columns [] = { "LINE_TYPE" }; -static const char * fho_columns [] = { +static const char * const fho_columns [] = { "TOTAL", "F_RATE", "H_RATE", "O_RATE" }; -static const char * ctc_columns [] = { +static const char * const ctc_columns [] = { "TOTAL", "FY_OY", "FY_ON", "FN_OY", "FN_ON", "EC_VALUE" }; -static const char * cts_columns [] = { +static const char * const cts_columns [] = { "TOTAL", "BASER", "BASER_NCL", "BASER_NCU", "BASER_BCL", "BASER_BCU", "FMEAN", "FMEAN_NCL", "FMEAN_NCU", "FMEAN_BCL", "FMEAN_BCU", @@ -64,11 +64,11 @@ static const char * cts_columns [] = { "HSS_EC", "HSS_EC_BCL", "HSS_EC_BCU", "EC_VALUE" }; -static const char * mctc_columns [] = { +static const char * const mctc_columns [] = { "TOTAL", "N_CAT", "Fi_Oj", "EC_VALUE" }; -static const char * mcts_columns [] = { +static const char * const mcts_columns [] = { "TOTAL", "N_CAT", "ACC", "ACC_NCL", "ACC_NCU", "ACC_BCL", "ACC_BCU", "HK", "HK_BCL", "HK_BCU", @@ -77,7 +77,7 @@ static const char * mcts_columns [] = { "HSS_EC", "HSS_EC_BCL", "HSS_EC_BCU", "EC_VALUE" }; -static const char * cnt_columns [] = { +static const char * const cnt_columns [] = { "TOTAL", "FBAR", "FBAR_NCL", "FBAR_NCU", "FBAR_BCL", "FBAR_BCU", "FSTDEV", "FSTDEV_NCL", "FSTDEV_NCU", "FSTDEV_BCL", "FSTDEV_BCU", @@ -108,36 +108,36 @@ static const char * cnt_columns [] = { "SI", "SI_BCL", "SI_BCU" }; -static const char * sl1l2_columns [] = { +static const char * const sl1l2_columns [] = { "TOTAL", "FBAR", "OBAR", "FOBAR", "FFBAR", "OOBAR", "MAE" }; -static const char * sal1l2_columns [] = { +static const char * const sal1l2_columns [] = { "TOTAL", "FABAR", "OABAR", "FOABAR", "FFABAR", "OOABAR", "MAE" }; -static const char * vl1l2_columns [] = { +static const char * const vl1l2_columns [] = { "TOTAL", "UFBAR", "VFBAR", "UOBAR", "VOBAR", "UVFOBAR", "UVFFBAR", "UVOOBAR", "F_SPEED_BAR", - "O_SPEED_BAR", "DIR_ME", "DIR_MAE", - "DIR_MSE" + "O_SPEED_BAR", "TOTAL_DIR", "DIR_ME", + "DIR_MAE", "DIR_MSE" }; -static const char * val1l2_columns [] = { +static const char * const val1l2_columns [] = { "TOTAL", "UFABAR", "VFABAR", "UOABAR", "VOABAR", "UVFOABAR", "UVFFABAR", "UVOOABAR", "FA_SPEED_BAR", - "OA_SPEED_BAR", "DIRA_ME", "DIRA_MAE", - "DIRA_MSE" + "OA_SPEED_BAR", "TOTAL_DIR", "DIRA_ME", + "DIRA_MAE", "DIRA_MSE" }; -static const char * vcnt_columns [] = { +static const char * const vcnt_columns [] = { "TOTAL", "FBAR", "FBAR_BCL", "FBAR_BCU", "OBAR", "OBAR_BCL", "OBAR_BCU", @@ -160,18 +160,19 @@ static const char * vcnt_columns [] = { "ANOM_CORR", "ANOM_CORR_NCL", "ANOM_CORR_NCU", "ANOM_CORR_BCL", "ANOM_CORR_BCU", "ANOM_CORR_UNCNTR", "ANOM_CORR_UNCNTR_BCL", "ANOM_CORR_UNCNTR_BCU", + "TOTAL_DIR", "DIR_ME", "DIR_ME_BCL", "DIR_ME_BCU", "DIR_MAE", "DIR_MAE_BCL", "DIR_MAE_BCU", "DIR_MSE", "DIR_MSE_BCL", "DIR_MSE_BCU", "DIR_RMSE", "DIR_RMSE_BCL", "DIR_RMSE_BCU" }; -static const char * pct_columns [] = { +static const char * const pct_columns [] = { "TOTAL", "N_THRESH", "THRESH_", "OY_", "ON_" }; -static const char * pstd_columns [] = { +static const char * const pstd_columns [] = { "TOTAL", "N_THRESH", "BASER", "BASER_NCL", "BASER_NCU", "RELIABILITY", "RESOLUTION", "UNCERTAINTY", "ROC_AUC", @@ -180,23 +181,23 @@ static const char * pstd_columns [] = { "BSS", "BSS_SMPL", "THRESH_", }; -static const char * pjc_columns [] = { +static const char * const pjc_columns [] = { "TOTAL", "N_THRESH", "THRESH_", "OY_TP_", "ON_TP_", "CALIBRATION_", "REFINEMENT_", "LIKELIHOOD_", "BASER_" }; -static const char * prc_columns [] = { +static const char * const prc_columns [] = { "TOTAL", "N_THRESH", "THRESH_", "PODY_", "POFD_" }; -static const char * eclv_columns [] = { +static const char * const eclv_columns [] = { "TOTAL", "BASER", "VALUE_BASER", "N_PNT", "CL_", "VALUE_" }; -static const char * mpr_columns [] = { +static const char * const mpr_columns [] = { "TOTAL", "INDEX", "OBS_SID", "OBS_LAT", "OBS_LON", "OBS_LVL", "OBS_ELV", "FCST", "OBS", @@ -204,12 +205,12 @@ static const char * mpr_columns [] = { "CLIMO_CDF" }; -static const char * nbrctc_columns [] = { +static const char * const nbrctc_columns [] = { "TOTAL", "FY_OY", "FY_ON", "FN_OY", "FN_ON" }; -static const char * nbrcts_columns [] = { +static const char * const nbrcts_columns [] = { "TOTAL", "BASER", "BASER_NCL", "BASER_NCU", "BASER_BCL", "BASER_BCU", "FMEAN", "FMEAN_NCL", "FMEAN_NCU", "FMEAN_BCL", "FMEAN_BCU", @@ -233,7 +234,7 @@ static const char * nbrcts_columns [] = { "BAGSS", "BAGSS_BCL", "BAGSS_BCU" }; -static const char * nbrcnt_columns [] = { +static const char * const nbrcnt_columns [] = { "TOTAL", "FBS", "FBS_BCL", "FBS_BCU", "FSS", "FSS_BCL", "FSS_BCU", @@ -243,14 +244,14 @@ static const char * nbrcnt_columns [] = { "O_RATE", "O_RATE_BCL", "O_RATE_BCU" }; -static const char * grad_columns [] = { +static const char * const grad_columns [] = { "TOTAL", "FGBAR", "OGBAR", "MGBAR", "EGBAR", "S1", "S1_OG", "FGOG_RATIO", "DX", "DY" }; -static const char * dmap_columns [] = { +static const char * const dmap_columns [] = { "TOTAL", "FY", "OY", "FBIAS", "BADDELEY", "HAUSDORFF", "MED_FO", "MED_OF", "MED_MIN", "MED_MAX", "MED_MEAN", @@ -259,7 +260,7 @@ static const char * dmap_columns [] = { "G", "GBETA", "BETA_VALUE" }; -static const char * isc_columns [] = { +static const char * const isc_columns [] = { "TOTAL", "TILE_DIM", "TILE_XLL", "TILE_YLL", "NSCALE", "ISCALE", "MSE", @@ -267,7 +268,7 @@ static const char * isc_columns [] = { "BASER", "FBIAS" }; -static const char * ecnt_columns [] = { +static const char * const ecnt_columns [] = { "TOTAL", "N_ENS", "CRPS", "CRPSS", "IGN", "ME", "RMSE", "SPREAD", "ME_OERR", @@ -279,22 +280,22 @@ static const char * ecnt_columns [] = { "ME_LT_OBS", "IGN_CONV_OERR", "IGN_CORR_OERR" }; -static const char * rps_columns [] = { +static const char * const rps_columns [] = { "TOTAL", "N_PROB", "RPS_REL", "RPS_RES", "RPS_UNC", "RPS", "RPSS", "RPSS_SMPL", "RPS_COMP" }; -static const char * rhist_columns [] = { +static const char * const rhist_columns [] = { "TOTAL", "N_RANK", "RANK_" }; -static const char * phist_columns [] = { +static const char * const phist_columns [] = { "TOTAL", "BIN_SIZE", "N_BIN", "BIN_" }; -static const char * orank_columns [] = { +static const char * const orank_columns [] = { "TOTAL", "INDEX", "OBS_SID", "OBS_LAT", "OBS_LON", "OBS_LVL", "OBS_ELV", "OBS", "PIT", @@ -304,7 +305,7 @@ static const char * orank_columns [] = { "SPREAD_OERR", "SPREAD_PLUS_OERR", "CLIMO_STDEV" }; -static const char * ssvar_columns [] = { +static const char * const ssvar_columns [] = { "TOTAL", "N_BIN", "BIN_i", "BIN_N", "VAR_MIN", "VAR_MAX", "VAR_MEAN", "FBAR", "OBAR", @@ -320,16 +321,16 @@ static const char * ssvar_columns [] = { "RMSE" }; -static const char * relp_columns [] = { +static const char * const relp_columns [] = { "TOTAL", "N_ENS", "RELP_" }; -static const char * ssidx_columns [] = { +static const char * const ssidx_columns [] = { "FCST_MODEL", "REF_MODEL", "N_INIT", "N_TERM", "N_VLD", "SS_INDEX" }; -static const char * genmpr_columns [] = { +static const char * const genmpr_columns [] = { "TOTAL", "INDEX", "STORM_ID", "PROB_LEAD", "PROB_VAL", "AGEN_INIT", "AGEN_FHR", @@ -339,7 +340,7 @@ static const char * genmpr_columns [] = { "DEV_CAT", "OPS_CAT" }; -static const char * job_summary_columns [] = { +static const char * const job_summary_columns [] = { "TOTAL", "MEAN", "MEAN_NCL", "MEAN_NCU", "MEAN_BCL", "MEAN_BCU", "STDEV", "STDEV_BCL", "STDEV_BCU", @@ -349,12 +350,12 @@ static const char * job_summary_columns [] = { "WMO_TYPE", "WMO_MEAN", "WMO_WEIGHTED_MEAN" }; -static const char * job_wdir_columns [] = { +static const char * const job_wdir_columns [] = { "TOTAL", "FBAR", "OBAR", "ME", "MAE" }; -static const char * job_ramp_columns [] = { +static const char * const job_ramp_columns [] = { "TYPE", "FCOLUMN", "OCOLUMN", "FTIME", "OTIME", @@ -363,7 +364,7 @@ static const char * job_ramp_columns [] = { "WINDOW_BEG", "WINDOW_END" }; -static const char * job_ramp_mpr_columns [] = { +static const char * const job_ramp_mpr_columns [] = { "TOTAL", "INDEX", "INIT", "LEAD", "VALID", "FPRV", "FCUR", "FDLT", "FRAMP", @@ -371,7 +372,7 @@ static const char * job_ramp_mpr_columns [] = { "CATEGORY" }; -static const char * seeps_mpr_columns [] = { +static const char * const seeps_mpr_columns [] = { "OBS_SID", "OBS_LAT", "OBS_LON", "FCST", "OBS", "OBS_QC", "FCST_CAT", "OBS_CAT", "P1", @@ -379,7 +380,7 @@ static const char * seeps_mpr_columns [] = { "SEEPS" }; -static const char * seeps_columns [] = { +static const char * const seeps_columns [] = { "TOTAL", "S12", "S13", "S21", "S23", "S31", "S32", "PF1", "PF2", diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 07c4df90d6..b2ef7bce7a 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -99,7 +99,7 @@ ConcatString append_climo_bin(const ConcatString &mask_name, //////////////////////////////////////////////////////////////////////// -void write_header_row(const char **cols, int n_cols, int hdr_flag, +void write_header_row(const char * const * cols, int n_cols, int hdr_flag, AsciiTable &at, int r, int c) { int i; @@ -2975,8 +2975,8 @@ void write_vl1l2_cols(const VL1L2Info &vl1l2_info, // TOTAL, UFBAR, VFBAR, // UOBAR, VOBAR, UVFOBAR, // UVFFBAR, UVOOBAR F_SPEED_BAR, - // O_SPEED_BAR, DIR_ME, DIR_MAE, - // DIR_MSE + // O_SPEED_BAR, TOTAL_DIR, DIR_ME, + // DIR_MAE, DIR_MSE // at.set_entry(r, c+0, // Total Count @@ -3009,13 +3009,16 @@ void write_vl1l2_cols(const VL1L2Info &vl1l2_info, at.set_entry(r, c+9, // O_SPEED_BAR vl1l2_info.o_speed_bar); - at.set_entry(r, c+10, // DIR_ME + at.set_entry(r, c+10, // TOTAL_DIR + vl1l2_info.dcount); + + at.set_entry(r, c+11, // DIR_ME vl1l2_info.dir_bar); - at.set_entry(r, c+11, // DIR_MAE + at.set_entry(r, c+12, // DIR_MAE vl1l2_info.absdir_bar); - at.set_entry(r, c+12, // DIR_MSE + at.set_entry(r, c+13, // DIR_MSE vl1l2_info.dir2_bar); return; @@ -3032,8 +3035,8 @@ void write_val1l2_cols(const VL1L2Info &vl1l2_info, // TOTAL, UFABAR, VFABAR, // UOABAR, VOABAR, UVFOABAR, // UVFFABAR, UVOOABAR, FA_SPEED_BAR, - // OA_SPEED_BAR, DIRA_ME, DIRA_MAE, - // DIRA_MSE + // OA_SPEED_BAR, TOTAL_DIR, DIRA_ME, + // DIRA_MAE, DIRA_MSE // at.set_entry(r, c+0, // Total Anomaly Count @@ -3066,13 +3069,16 @@ void write_val1l2_cols(const VL1L2Info &vl1l2_info, at.set_entry(r, c+9, // OA_SPEED_BAR vl1l2_info.oa_speed_bar); - at.set_entry(r, c+10, // DIRA_ME + at.set_entry(r, c+10, // TOTAL_DIR + vl1l2_info.dacount); + + at.set_entry(r, c+11, // DIRA_ME vl1l2_info.dira_bar); - at.set_entry(r, c+11, // DIRA_MAE + at.set_entry(r, c+12, // DIRA_MAE vl1l2_info.absdira_bar); - at.set_entry(r, c+12, // DIRA_MSE + at.set_entry(r, c+13, // DIRA_MSE vl1l2_info.dira2_bar); return; @@ -3108,6 +3114,7 @@ void write_vcnt_cols(const VL1L2Info &vcnt_info, int i, // ANOM_CORR, ANOM_CORR_NCL, ANOM_CORR_NCU, // ANOM_CORR_BCL, ANOM_CORR_BCU // ANOM_CORR_UNCNTR, ANOM_CORR_UNCNTR_BCL, ANOM_CORR_UNCNTR_BCU, + // TOTAL_DIR, // DIR_ME, DIR_ME_BCL, DIR_ME_BCU, // DIR_MAE, DIR_MAE_BCL, DIR_MAE_BCU, // DIR_MSE, DIR_MSE_BCL, DIR_MSE_BCU, @@ -3201,6 +3208,8 @@ void write_vcnt_cols(const VL1L2Info &vcnt_info, int i, at.set_entry(r, c++, (string)na_str); // ANOM_CORR_UNCNTR_BCL at.set_entry(r, c++, (string)na_str); // ANOM_CORR_UNCNTR_BCU + at.set_entry(r, c++, vcnt_info.dcount); // TOTAL_DIR + at.set_entry(r, c++, vcnt_info.DIR_ME.v); // DIR_ME at.set_entry(r, c++, (string)na_str); // DIR_ME_BCL at.set_entry(r, c++, (string)na_str); // DIR_ME_BCU diff --git a/src/libcode/vx_stat_out/stat_columns.h b/src/libcode/vx_stat_out/stat_columns.h index 923425dabc..8af99ad730 100644 --- a/src/libcode/vx_stat_out/stat_columns.h +++ b/src/libcode/vx_stat_out/stat_columns.h @@ -35,7 +35,7 @@ extern void close_txt_file(std::ofstream *&, const char *); extern ConcatString append_climo_bin(const ConcatString &, int, int); // Write out the header row for fixed length line types -extern void write_header_row(const char **, int, int, AsciiTable &, int, int); +extern void write_header_row(const char * const *, int, int, AsciiTable &, int, int); // Write out the header row for variable length line types extern void write_mctc_header_row (int, int, AsciiTable &, int, int); diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index 587c5552a7..7f2af8b534 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -1363,6 +1363,7 @@ VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { for(int i=0; i 0) { v_info.uf_bar = (uf_bar*vcount + c.uf_bar*c.vcount) /v_info.vcount; @@ -1374,12 +1375,15 @@ VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { v_info.uvoo_bar = (uvoo_bar*vcount + c.uvoo_bar*c.vcount) /v_info.vcount; v_info.f_speed_bar = (f_speed_bar*vcount + c.f_speed_bar*c.vcount)/v_info.vcount; v_info.o_speed_bar = (o_speed_bar*vcount + c.o_speed_bar*c.vcount)/v_info.vcount; - v_info.dir_bar = (dir_bar*vcount + c.dir_bar*c.vcount) /v_info.vcount; - v_info.absdir_bar = (absdir_bar*vcount + c.absdir_bar*c.vcount) /v_info.vcount; - v_info.dir2_bar = (dir2_bar*vcount + c.dir2_bar*c.vcount) /v_info.vcount; + } + if(v_info.dcount > 0) { + v_info.dir_bar = (dir_bar*dcount + c.dir_bar*c.dcount) /v_info.dcount; + v_info.absdir_bar = (absdir_bar*dcount + c.absdir_bar*c.dcount) /v_info.dcount; + v_info.dir2_bar = (dir2_bar*dcount + c.dir2_bar*c.dcount) /v_info.dcount; } v_info.vacount = vacount + c.vacount; + v_info.dacount = dacount + c.dacount; if(v_info.vacount > 0) { v_info.ufa_bar = (ufa_bar*vacount + c.ufa_bar*c.vacount) /v_info.vacount; @@ -1391,9 +1395,11 @@ VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { v_info.uvooa_bar = (uvooa_bar*vacount + c.uvooa_bar*c.vacount) /v_info.vacount; v_info.fa_speed_bar = (fa_speed_bar*vacount + c.fa_speed_bar*c.vacount)/v_info.vacount; v_info.oa_speed_bar = (oa_speed_bar*vacount + c.oa_speed_bar*c.vacount)/v_info.vacount; - v_info.dira_bar = (dira_bar*vacount + c.dira_bar*c.vacount) /v_info.vacount; - v_info.absdira_bar = (absdira_bar*vacount + c.absdira_bar*c.vacount) /v_info.vacount; - v_info.dira2_bar = (dira2_bar*vacount + c.dira2_bar*c.vacount) /v_info.vacount; + } + if(v_info.dacount > 0) { + v_info.dira_bar = (dira_bar*dacount + c.dira_bar*c.dacount) /v_info.dacount; + v_info.absdira_bar = (absdira_bar*dacount + c.absdira_bar*c.dacount) /v_info.dacount; + v_info.dira2_bar = (dira2_bar*dacount + c.dira2_bar*c.dacount) /v_info.dacount; } v_info.compute_stats(); @@ -1436,6 +1442,7 @@ void VL1L2Info::zero_out() { dir2_bar = 0.0; vcount = 0; + dcount = 0; // // VAL1L2 Quantities @@ -1455,6 +1462,7 @@ void VL1L2Info::zero_out() { dira2_bar = 0.0; vacount = 0; + dacount = 0; return; } @@ -1464,8 +1472,6 @@ void VL1L2Info::zero_out() { void VL1L2Info::clear() { n = 0; - n_dir_undef = 0; - n_dira_undef = 0; n_alpha = 0; if(alpha) { delete [] alpha; alpha = (double *) nullptr; } @@ -1515,8 +1521,6 @@ void VL1L2Info::assign(const VL1L2Info &c) { logic = c.logic; n = c.n; - n_dir_undef = c.n_dir_undef; - n_dira_undef = c.n_dira_undef; allocate_n_alpha(c.n_alpha); for(i=0; i 0) { - mlog << Warning << "\nVL1L2Info::compute_stats() -> " - << "Skipping " << n_dir_undef << " of " << vcount - << " vector pairs for which the direction difference is undefined.\n" - << "Set the \"wind_thresh\" and \"wind_logic\" configuration options " - << "to exclude zero vectors.\n\n"; - } - DIR_ME.v = dir_bar; DIR_MAE.v = absdir_bar; DIR_MSE.v = dir2_bar; @@ -1912,15 +1907,6 @@ void VL1L2Info::compute_stats() { } ANOM_CORR_UNCNTR.v = compute_anom_corr_uncntr(uvffa_bar, uvooa_bar, uvfoa_bar); - - // Print undefined wind direction warning message - if(n_dira_undef > 0) { - mlog << Warning << "\nVL1L2Info::compute_stats() -> " - << "Skipping " << n_dira_undef << " of " << vacount - << " anomaly vector pairs for which the direction difference is undefined.\n" - << "Set the \"wind_thresh\" and \"wind_logic\" configuration options " - << "to exclude zero vectors.\n\n"; - } } // Compute parametric confidence intervals diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index 1d5def71a7..36a9e2f01d 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -277,10 +277,6 @@ class VL1L2Info { // Number of points int n; - // Number of points for which the wind direction difference is undefined - int n_dir_undef; - int n_dira_undef; - // VL1L2 Quantities double uf_bar; @@ -336,7 +332,8 @@ class VL1L2Info { CIInfo DIR_MSE; CIInfo DIR_RMSE; - int vcount; + int vcount; // Vector count + int dcount; // Direction count // VAL1L2 Quantities double ufa_bar; @@ -355,7 +352,8 @@ class VL1L2Info { double absdira_bar; // Average anomalous absolute direction difference double dira2_bar; // Average anomalous squared direction difference - int vacount; + int vacount; // Vector anomaly count + int dacount; // Direction anomaly count // Compute sums void set(const PairDataPoint &, const PairDataPoint &); diff --git a/src/tools/core/ensemble_stat/ensemble_stat.h b/src/tools/core/ensemble_stat/ensemble_stat.h index 28d26a5585..3e14ebbaa1 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.h +++ b/src/tools/core/ensemble_stat/ensemble_stat.h @@ -49,14 +49,14 @@ static const char * default_config_filename = "MET_BASE/config/EnsembleStatConfig_default"; // Text file abbreviations -static const char *txt_file_abbr[n_txt] = { +static const char * const txt_file_abbr[n_txt] = { "ecnt", "rps", "rhist", "phist", "orank", "ssvar", "relp", "pct", "pstd", "pjc", "prc", "eclv" }; // Header columns -static const char **txt_columns[n_txt] = { +static const char * const * txt_columns[n_txt] = { ecnt_columns, rps_columns, rhist_columns, phist_columns, orank_columns, ssvar_columns, relp_columns, pct_columns, pstd_columns, diff --git a/src/tools/core/grid_stat/grid_stat.h b/src/tools/core/grid_stat/grid_stat.h index ccd85c82ac..9f170b5a9f 100644 --- a/src/tools/core/grid_stat/grid_stat.h +++ b/src/tools/core/grid_stat/grid_stat.h @@ -66,7 +66,7 @@ static const char * default_config_filename = static const char * default_out_dir = "."; // Header columns -static const char **txt_columns[n_txt] = { +static const char * const * txt_columns[n_txt] = { fho_columns, ctc_columns, cts_columns, mctc_columns, mcts_columns, cnt_columns, sl1l2_columns, sal1l2_columns, vl1l2_columns, @@ -90,7 +90,7 @@ static const int n_txt_columns[n_txt] = { }; // Text file abbreviations -static const char *txt_file_abbr[n_txt] = { +static const char * const txt_file_abbr[n_txt] = { "fho", "ctc", "cts", "mctc", "mcts", "cnt", "sl1l2", "sal1l2", "vl1l2", diff --git a/src/tools/core/point_stat/point_stat.h b/src/tools/core/point_stat/point_stat.h index 0804650b0a..abe34d25ac 100644 --- a/src/tools/core/point_stat/point_stat.h +++ b/src/tools/core/point_stat/point_stat.h @@ -61,7 +61,7 @@ static const char * default_config_filename = "MET_BASE/config/PointStatConfig_default"; // Header columns -static const char **txt_columns[n_txt] = { +static const char * const * txt_columns[n_txt] = { fho_columns, ctc_columns, cts_columns, mctc_columns, mcts_columns, cnt_columns, sl1l2_columns, sal1l2_columns, vl1l2_columns, @@ -85,7 +85,7 @@ static const int n_txt_columns[n_txt] = { }; // Text file abbreviations -static const char *txt_file_abbr[n_txt] = { +static const char * const txt_file_abbr[n_txt] = { "fho", "ctc", "cts", "mctc", "mcts", "cnt", "sl1l2", "sal1l2", "vl1l2", diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 7f3c16af10..c46c35c134 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -65,8 +65,9 @@ using namespace std; //////////////////////////////////////////////////////////////////////// -static bool is_precip_var_name(const ConcatString &s); -static const std::string case_str = "CASE"; +static bool is_precip_var_name(const ConcatString &s); +static const string case_str = "CASE"; +static bool is_vector_dir_stat(const STATLineType &t, const ConcatString &s); //////////////////////////////////////////////////////////////////////// // @@ -834,14 +835,18 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, } else if(line.type() == STATLineType::vl1l2 && lty == STATLineType::vcnt) { v = vl1l2_info.get_stat(req_col[i].c_str()); - w = vl1l2_info.vcount; + w = (is_vector_dir_stat(line.type(), req_col[i].c_str()) ? + vl1l2_info.dcount : + vl1l2_info.vcount); } else if(line.type() != lty) { continue; } else { v = job.get_column_double(line, req_col[i]); - w = atoi(line.get_item("TOTAL")); + w = (is_vector_dir_stat(line.type(), req_col[i].c_str()) ? + atoi(line.get_item("TOTAL_DIR")) : + atoi(line.get_item("TOTAL"))); } // @@ -2150,35 +2155,15 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, it->second.pd_u.f_na[i], it->second.pd_v.f_na[i], it->second.pd_u.o_na[i], it->second.pd_v.o_na[i]); - if(is_bad_data(d_diff)) { - v_info.n_dir_undef = 1; - } - else { - v_info.n_dir_undef = 0; - v_info.dir_bar = d_diff; - v_info.absdir_bar = abs(d_diff); - v_info.dir2_bar = d_diff*d_diff; + if(!is_bad_data(d_diff)) { + v_info.dcount = 1; + v_info.dir_bar = d_diff; + v_info.absdir_bar = abs(d_diff); + v_info.dir2_bar = d_diff*d_diff; } aggr.vl1l2_info += v_info; - // - // Check for vectors of length zero - // - if((is_eq(it->second.pd_u.f_na[i], 0.0) && - is_eq(it->second.pd_v.f_na[i], 0.0)) || - (is_eq(it->second.pd_u.o_na[i], 0.0) && - is_eq(it->second.pd_v.o_na[i], 0.0))) { - mlog << Debug(4) << "aggr_mpr_wind_lines() -> " - << "angle not defined for zero forecast (" - << it->second.pd_u.f_na[i] << ", " << it->second.pd_v.f_na[i] - << ") or observation (" - << it->second.pd_u.o_na[i] << ", " << it->second.pd_v.o_na[i] - << ") vector for header:\n" - << it->second.hdr_sa[i] << "\n"; - continue; - } - // // Convert to and append unit vectors // @@ -4229,7 +4214,7 @@ double compute_vif(NumArray &na) { //////////////////////////////////////////////////////////////////////// -bool is_precip_var_name(const ConcatString &s) { +static bool is_precip_var_name(const ConcatString &s) { bool match = has_prefix(pinterp_precipitation_names, n_pinterp_precipitation_names, s.c_str()) || @@ -4239,4 +4224,19 @@ bool is_precip_var_name(const ConcatString &s) { return match; } + +//////////////////////////////////////////////////////////////////////// + +static bool is_vector_dir_stat(const STATLineType &t, const ConcatString &s) { + + bool match = (t == STATLineType::vl1l2 || + t == STATLineType::val1l2 || + t == STATLineType::vcnt) && + (s.startswith("DIR_ME") || + s.startswith("DIR_MAE") || + s.startswith("DIR_MSE")); + + return match; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index ebdc9d9a0a..b3662a8eeb 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -238,6 +238,7 @@ void parse_vl1l2_line(STATLine &l, VL1L2Info &v_info) { v_info.uvoo_bar = atof(l.get_item("UVOOBAR")); v_info.f_speed_bar = atof(l.get_item("F_SPEED_BAR")); v_info.o_speed_bar = atof(l.get_item("O_SPEED_BAR")); + v_info.dcount = atoi(l.get_item("TOTAL_DIR")); v_info.dir_bar = atof(l.get_item("DIR_ME")); v_info.absdir_bar = atof(l.get_item("DIR_MAE")); v_info.dir2_bar = atof(l.get_item("DIR_MSE")); @@ -263,6 +264,7 @@ void parse_val1l2_line(STATLine &l, VL1L2Info &v_info) { v_info.uvooa_bar = atof(l.get_item("UVOOABAR")); v_info.fa_speed_bar = atof(l.get_item("FA_SPEED_BAR")); v_info.oa_speed_bar = atof(l.get_item("OA_SPEED_BAR")); + v_info.dacount = atoi(l.get_item("TOTAL_DIR")); v_info.dira_bar = atof(l.get_item("DIRA_ME")); v_info.absdira_bar = atof(l.get_item("DIRA_MAE")); v_info.dira2_bar = atof(l.get_item("DIRA_MSE")); diff --git a/src/tools/tc_utils/tc_gen/tc_gen.h b/src/tools/tc_utils/tc_gen/tc_gen.h index fa19075829..13c31a2ae9 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.h +++ b/src/tools/tc_utils/tc_gen/tc_gen.h @@ -59,7 +59,7 @@ static const char * default_config_filename = "MET_BASE/config/TCGenConfig_default"; // Header columns -static const char **txt_columns[n_txt] = { +static const char * const * txt_columns[n_txt] = { fho_columns, ctc_columns, cts_columns, pct_columns, pstd_columns, pjc_columns, prc_columns, genmpr_columns @@ -73,7 +73,7 @@ static const int n_txt_columns[n_txt] = { }; // Text file abbreviations -static const char *txt_file_abbr[n_txt] = { +static const char * const txt_file_abbr[n_txt] = { "fho", "ctc", "cts", "pct", "pstd", "pjc", "prc", "genmpr" }; From 663fda76d0663a22a9b721d4d7d8b2ebd516b002 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 22 May 2024 15:02:08 -0600 Subject: [PATCH 080/114] Bugfix #2897 develop python_valid_time (#2899) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Per #2897, fix typos in 2 log messages. Also fix the bug in storing the valid time strings. The time string in vld_array should exactly correspond to the numeric unixtime values in vld_num_array. Therefore they need to be updated inside the same if block. The bug is that we were storing only the unique unixtime values but storing ALL of the valid time string, not just the unique ones. * Per #2897, minor change to formatting of log message * MET #2897, don’t waste time searching, just set the index to n - 1 * Per #2897, remove unused add_prec_point_obs(...) function * Per #2897, update add_point_obs(...) logic for DEBUG(9) to print very detailed log messages about what obs are being rejected and which are being used for each verification task. * Per #2897, refine the 'using' log message to make the wording consistent with the summary rejection reason counts log message * Per #2897, update the User's Guide about -v 9 for Point-Stat --------- Co-authored-by: j-opatz Co-authored-by: MET Tools Test Account --- docs/Users_Guide/appendixA.rst | 5 + docs/Users_Guide/point-stat.rst | 2 +- .../vx_pointdata_python/python_pointdata.cc | 11 +- src/libcode/vx_statistics/pair_data_point.cc | 333 ++++++++++++++---- src/libcode/vx_statistics/pair_data_point.h | 4 - 5 files changed, 276 insertions(+), 79 deletions(-) diff --git a/docs/Users_Guide/appendixA.rst b/docs/Users_Guide/appendixA.rst index 83b10c2c32..4dbf571008 100644 --- a/docs/Users_Guide/appendixA.rst +++ b/docs/Users_Guide/appendixA.rst @@ -121,6 +121,11 @@ Q. How can I understand the number of matched pairs? in the configuration file. So all of the 1166 observations are rejected for the same reason. + In addition, running point_stat with at least verbosity level 9 (-v 9) + will result in a log message being printed to explain why each + observation is skipped or retained for each verification task. + This level of detail is intended only for debugging purposes. + Q. What types of NetCDF files can MET read? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index ec4e69178b..025b462f23 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -264,7 +264,7 @@ Practical Information The Point-Stat tool is used to perform verification of a gridded model field using point observations. The gridded model field to be verified must be in one of the supported file formats. The point observations must be formatted as the NetCDF output of the point reformatting tools described in :numref:`reformat_point`. The Point-Stat tool provides the capability of interpolating the gridded forecast data to the observation points using a variety of methods as described in :numref:`matching-methods`. The Point-Stat tool computes a number of continuous statistics on the matched pair data as well as discrete statistics once the matched pair data have been thresholded. -If no matched pairs are found for a particular verification task, a report listing counts for reasons why the observations were not used is written to the log output at the default verbosity level of 2. If matched pairs are found, this report is written at verbosity level 3. Inspecting these rejection reason counts is the first step in determining why Point-Stat found no matched pairs. The order of the log messages matches the order in which the processing logic is applied. Start from the last log message and work your way up, considering each of the non-zero rejection reason counts. +If no matched pairs are found for a particular verification task, a report listing counts for reasons why the observations were not used is written to the log output at the default verbosity level of 2. If matched pairs are found, this report is written at verbosity level 3. Inspecting these rejection reason counts is the first step in determining why Point-Stat found no matched pairs. The order of the log messages matches the order in which the processing logic is applied. Start from the last log message and work your way up, considering each of the non-zero rejection reason counts. Verbosity level 9 prints a very detailed explanation about why each observation is used or skipped for each verification task. point_stat Usage ---------------- diff --git a/src/libcode/vx_pointdata_python/python_pointdata.cc b/src/libcode/vx_pointdata_python/python_pointdata.cc index df27f81c9a..5eae0b7403 100644 --- a/src/libcode/vx_pointdata_python/python_pointdata.cc +++ b/src/libcode/vx_pointdata_python/python_pointdata.cc @@ -350,8 +350,10 @@ bool process_point_data_list(PyObject *python_point_data, MetPointDataPython &me // get valid time index vld_time = obs.getValidTime(); if ( !header_data->vld_num_array.has(vld_time, vld_idx) ) { + // MET #2897 keep vld_array and vld_num_array in sync + header_data->vld_array.add(obs.getValidTimeString()); header_data->vld_num_array.add(vld_time); - header_data->vld_num_array.has(vld_time, vld_idx); + vld_idx = header_data->vld_num_array.n() - 1; } if (!is_eq(prev_lat, lat) || !is_eq(prev_lon, lon) || !is_eq(prev_elv, elv) @@ -363,7 +365,6 @@ bool process_point_data_list(PyObject *python_point_data, MetPointDataPython &me header_data->sid_idx_array.add(sid); header_data->typ_idx_array.add(typ_idx); header_data->vld_idx_array.add(vld_idx); - header_data->vld_array.add(obs.getValidTimeString()); prev_lat = lat; prev_lon = lon; @@ -763,7 +764,7 @@ void print_met_data(MetPointObsData *obs_data, MetPointHeader *header_data, << header_data->vld_idx_array.n() << ", lat=" << header_data->lat_array.n() << ", lon=" << header_data->lon_array.n() << ", elv=" - << header_data->elv_array.n() << ", message_type=" + << header_data->elv_array.n() << ", message_type=" << header_data->typ_array.n() << ", station_id=" << header_data->sid_array.n() << ", valid_time=" << header_data->vld_array.n() << ", prpt=" @@ -774,7 +775,7 @@ void print_met_data(MetPointObsData *obs_data, MetPointHeader *header_data, log_count = (header_data->hdr_count > min_count) ? min_count : header_data->hdr_count; mlog << Debug(debug_level) << method_name - << "header_data: message_type,station_id,time_time,lat,lon.elv\n"; + << "header_data: message_type,station_id,time_time,lat,lon,elv\n"; for (int idx=0; idxmagic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation station id:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_sid++; return; } - + // Check whether the GRIB code for the observation matches // the specified code if((var_name != 0) && (0 < strlen(var_name))) { if(var_name != obs_info->name()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation variable name:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_var++; return; } } else if(obs_info->code() != nint(obs_arr[1])) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation variable GRIB code:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_var++; return; } - + // Check the observation quality include and exclude options if((obs_qty_inc_filt.n() > 0 && !obs_qty_inc_filt.has(obs_qty)) || (obs_qty_exc_filt.n() > 0 && obs_qty_exc_filt.has(obs_qty))) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation quality control string:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_qty++; return; } - + // Check whether the observation time falls within the valid time // window if(hdr_ut < beg_ut || hdr_ut > end_ut) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation valid time:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_vld++; return; } @@ -1043,13 +1100,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check whether the observation value contains valid data if(is_bad_data(obs_v)) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation with bad data value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation with bad data value:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_obs++; return; } @@ -1063,15 +1124,18 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, if(((x < 0 || x >= gr.nx()) && !gr.wrap_lon()) || y < 0 || y >= gr.ny()) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation off the grid where (x, y) = (" - << x << ", " << y << ") and grid (nx, ny) = (" << gr.nx() - << ", " << gr.ny() << "):\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation off the grid where (x, y) = (" + << x << ", " << y << ") and grid (nx, ny) = (" << gr.nx() + << ", " << gr.ny() << "):\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_grd++; return; } @@ -1088,32 +1152,40 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Skip bad topography values if(is_bad_data(hdr_elv) || is_bad_data(topo)) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to bad topography values " - << "where observation elevation = " << hdr_elv - << " and model topography = " << topo << ":\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation due to bad topography values " + << "where observation elevation = " << hdr_elv + << " and model topography = " << topo << ":\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_topo++; return; } // Check the topography difference threshold if(!sfc_info.topo_use_obs_thresh.check(topo - hdr_elv)) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to topography difference " - << "where observation elevation (" << hdr_elv - << ") minus model topography (" << topo << ") = " - << topo - hdr_elv << " is not " - << sfc_info.topo_use_obs_thresh.get_str() << ":\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation due to topography difference " + << "where observation elevation (" << hdr_elv + << ") minus model topography (" << topo << ") = " + << topo - hdr_elv << " is not " + << sfc_info.topo_use_obs_thresh.get_str() << ":\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_topo++; return; } @@ -1125,6 +1197,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, if(obs_lvl < obs_info->level().lower() || obs_lvl > obs_info->level().upper()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation pressure level value:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_lvl++; return; } @@ -1135,6 +1218,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, if(obs_lvl < obs_info->level().lower() || obs_lvl > obs_info->level().upper()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation accumulation interval:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_lvl++; return; } @@ -1147,6 +1241,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, if(!msg_typ_sfc.reg_exp_match(hdr_typ_str) && (obs_hgt < obs_info->level().lower() || obs_hgt > obs_info->level().upper())) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation level value:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + rej_lvl++; return; } @@ -1218,8 +1323,18 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // // Check for a matching PrepBufr message type // - if(!pd[i][0][0].msg_typ_vals.has(hdr_typ_str)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation message type:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_typ, i); continue; } @@ -1230,6 +1345,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check for the obs falling within the masking region if(pd[i][j][0].mask_area_ptr != (MaskPlane *) 0) { if(!pd[i][j][0].mask_area_ptr->s_is_on(x, y)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation based on spatial masking region:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_mask, i, j); continue; } @@ -1238,8 +1364,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // masking SID list else if(pd[i][j][0].mask_sid_ptr != (StringArray *) 0) { if(!pd[i][j][0].mask_sid_ptr->has(hdr_sid_str)) { - mlog << Debug(9) << "Checking for the obs station id in the masking SID list: rejected hdr_sid_str = " - << hdr_sid_str << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation based on masking station id list:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_mask, i, j); continue; } @@ -1248,6 +1383,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, else if(pd[i][j][0].mask_llpnt_ptr != (MaskLatLon *) 0) { if(!pd[i][j][0].mask_llpnt_ptr->lat_thresh.check(hdr_lat) || !pd[i][j][0].mask_llpnt_ptr->lon_thresh.check(hdr_lon)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation based on latitude/longitude thesholds:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_mask, i, j); continue; } @@ -1272,6 +1418,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check for bad data if(climo_mn_dpa.n_planes() > 0 && is_bad_data(cmn_v)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation based on bad climatological mean value:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_cmn, i, j, k); continue; } @@ -1300,6 +1457,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check for bad data if(climo_sd_dpa.n_planes() > 0 && is_bad_data(csd_v)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation based on bad climatological standard deviation value:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_csd, i, j, k); continue; } @@ -1336,16 +1504,20 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, } if(is_bad_data(fcst_v)) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to bad data in the " - << interpmthd_to_string(pd[0][0][k].interp_mthd) << "(" - << pd[0][0][k].interp_wdth * pd[0][0][k].interp_wdth - << ") interpolated forecast value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation based due to bad data in the " + << interpmthd_to_string(pd[0][0][k].interp_mthd) << "(" + << pd[0][0][k].interp_wdth * pd[0][0][k].interp_wdth + << ") interpolated forecast value:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_fcst, i, j, k); continue; } @@ -1353,14 +1525,18 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check matched pair filtering options if(!check_mpr_thresh(fcst_v, obs_v, cmn_v, csd_v, mpr_column, mpr_thresh, &reason_cs)) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to matched pair filter since " - << reason_cs << ":\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation due to matched pair filter since " + << reason_cs << ":\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_mpr, i, j, k); continue; } @@ -1375,13 +1551,17 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, hdr_lat, hdr_lon, obs_x, obs_y, hdr_ut, obs_lvl, obs_hgt, fcst_v, obs_v, obs_qty, cmn_v, csd_v, wgt_v)) { - mlog << Debug(4) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation since it is a duplicate:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() + << ", skipping observation since it is a duplicate:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + inc_count(rej_dup, i, j, k); } seeps = 0; @@ -1390,6 +1570,21 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, } pd[i][j][k].set_seeps_score(seeps); if (seeps) delete seeps; + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", for observation type " + << pd[i][0][0].msg_typ << ", over region " + << pd[0][j][0].mask_name << ", for interpolation method " + << interpmthd_to_string(pd[0][0][k].interp_mthd) << "(" + << pd[0][0][k].interp_wdth * pd[0][0][k].interp_wdth + << "), using observation:\n" + << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name) + << "\n"; + } + } // end for k } // end for j } // end for i @@ -1939,8 +2134,8 @@ ConcatString point_obs_to_string(float *hdr_arr, const char *hdr_typ_str, const char *var_name) { ConcatString obs_cs, name; - if((var_name != 0) && (0 < m_strlen(var_name))) name = var_name; - else name = obs_arr[1]; + if((var_name != 0) && (0 < m_strlen(var_name))) name << var_name; + else name << nint(obs_arr[1]); // // Write the 11-column MET point format: diff --git a/src/libcode/vx_statistics/pair_data_point.h b/src/libcode/vx_statistics/pair_data_point.h index a32e4dbe4e..c68ddf1f33 100644 --- a/src/libcode/vx_statistics/pair_data_point.h +++ b/src/libcode/vx_statistics/pair_data_point.h @@ -244,10 +244,6 @@ class VxPairDataPoint { const char *, float *, Grid &, const char * = 0, const DataPlane * = 0); - void add_prec_point_obs(float *, const char *, const char *, unixtime, - const char *, float *, Grid &, int month, int hour, - const char * = 0, const DataPlane * = 0); - int get_n_pair() const; void set_duplicate_flag(DuplicateType duplicate_flag); From cd2b42914febebbfc30395042059608303e559e6 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 22 May 2024 15:19:47 -0600 Subject: [PATCH 081/114] Bugfix 2867 point2grid qc flag (#2890) * #2867 Added compute_adp_qc_flag and adjusted ADP QC flags * #2867 Added point2grid_GOES_16_ADP_Enterprise_high. Changed AOD QC flags to 0,1,2 (was 1,2,3) * #2867 Added get_nc_att_values_ * #2867 Added get_nc_att_values. Added the argument allow_conversion to get_nc_data(netCDF::NcVar *, uchar *data) * #2867 Read the ADP QC flag values and meanings attributes from DQF variable and set the QC high, meduium, low values to support Enterprise algorithm. Adjusted the ADP QC values by using AOD qc values * #2867 Cleanup * #2867 Corrected indent * #2867 Changed log message * #2867 Removed unused argument * #2867 Removed unused argument * Cleanup * #2867 Fix SonarQube findings * #2867 Deleted protected section with no members * #2867 Cleanup * #2867 FIxed SonarQube findings; unused local variables, decalare as const, etc * #2867 MOved include directives to top * #2867 Changed some argumenmt with references to avoid copying objects * #2867 Do not filter by QC flag if -qc is not given * #2867 Use enumj class for GOES QC: HIGH, MEDIUM, and LOW * #2867 Added log message back which were deleted accidently * #2867 Chaned statci const to constexpr * #2867 Initial release. Separated from nc_utils.h * @2867 Added nc_utils_core.h * #2867 Moved some blocks to nc_utils_core.h * #2867 Include nc_utils_core.h * #2867 Added const references * Per #2867, fixing typo in comments. --------- Co-authored-by: Howard Soh Co-authored-by: j-opatz --- internal/test_unit/xml/unit_point2grid.xml | 29 +- src/libcode/vx_nc_util/Makefile.am | 2 +- src/libcode/vx_nc_util/Makefile.in | 2 +- src/libcode/vx_nc_util/nc_constants.h | 4 +- src/libcode/vx_nc_util/nc_utils.cc | 22 +- src/libcode/vx_nc_util/nc_utils.h | 62 +- src/libcode/vx_nc_util/nc_utils.hpp | 33 +- src/libcode/vx_nc_util/nc_utils_core.h | 80 + src/tools/other/point2grid/point2grid.cc | 1371 +++++++++-------- .../other/point2grid/point2grid_conf_info.cc | 17 +- .../other/point2grid/point2grid_conf_info.h | 6 +- 11 files changed, 912 insertions(+), 716 deletions(-) create mode 100644 src/libcode/vx_nc_util/nc_utils_core.h diff --git a/internal/test_unit/xml/unit_point2grid.xml b/internal/test_unit/xml/unit_point2grid.xml index dd1792ccf0..5221ea4460 100644 --- a/internal/test_unit/xml/unit_point2grid.xml +++ b/internal/test_unit/xml/unit_point2grid.xml @@ -137,7 +137,7 @@ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_compute.nc
- + &MET_BIN;/point2grid @@ -155,7 +155,7 @@ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_gaussian.nc - + &MET_BIN;/point2grid @@ -174,7 +174,7 @@ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_ADP.nc - + &MET_BIN;/point2grid @@ -185,7 +185,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_grid_map.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 1,2,3 -method MAX \ + -qc 0,1,2 -method MAX \ -v 1 @@ -205,7 +205,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 1,2,3 -method MAX \ + -qc 0,1,2 -method MAX \ -v 1 @@ -213,6 +213,25 @@ + + &MET_BIN;/point2grid + + MET_TMP_DIR &OUTPUT_DIR;/point2grid + + \ + &DATA_DIR_MODEL;/goes_16/OR_ABI-L2-AODC-M6_G16_s20241100001171_e20241100003544_c20241100006242.nc \ + G212 \ + &OUTPUT_DIR;/point2grid/point2grid_GOES_16_ADP_Enterprise_high.nc \ + -field 'name="AOD_Smoke"; level="(*,*)";' \ + -adp &DATA_DIR_MODEL;/goes_16/OR_ABI-L2-ADPC-M6_G16_s20241100001171_e20241100003544_c20241100006361.nc \ + -qc 0,1 -method MAX \ + -v 1 + + + &OUTPUT_DIR;/point2grid/point2grid_GOES_16_ADP_Enterprise_high.nc + + + &MET_BIN;/point2grid diff --git a/src/libcode/vx_nc_util/Makefile.am b/src/libcode/vx_nc_util/Makefile.am index a4e8499352..108ce97639 100644 --- a/src/libcode/vx_nc_util/Makefile.am +++ b/src/libcode/vx_nc_util/Makefile.am @@ -13,7 +13,7 @@ include ${top_srcdir}/Make-include noinst_LIBRARIES = libvx_nc_util.a libvx_nc_util_a_SOURCES = \ nc_var_info.cc nc_var_info.h \ - nc_utils.cc nc_utils.h nc_utils.hpp \ + nc_utils.cc nc_utils.h nc_utils_core.h nc_utils.hpp \ write_netcdf.cc write_netcdf.h \ grid_output.cc grid_output.h \ load_tc_data.cc load_tc_data.h \ diff --git a/src/libcode/vx_nc_util/Makefile.in b/src/libcode/vx_nc_util/Makefile.in index 9843b5647b..f2f564ff93 100644 --- a/src/libcode/vx_nc_util/Makefile.in +++ b/src/libcode/vx_nc_util/Makefile.in @@ -353,7 +353,7 @@ MAINTAINERCLEANFILES = Makefile.in noinst_LIBRARIES = libvx_nc_util.a libvx_nc_util_a_SOURCES = \ nc_var_info.cc nc_var_info.h \ - nc_utils.cc nc_utils.h nc_utils.hpp \ + nc_utils.cc nc_utils.h nc_utils_core.h nc_utils.hpp \ write_netcdf.cc write_netcdf.h \ grid_output.cc grid_output.h \ load_tc_data.cc load_tc_data.h \ diff --git a/src/libcode/vx_nc_util/nc_constants.h b/src/libcode/vx_nc_util/nc_constants.h index c308d0c484..28d8909321 100644 --- a/src/libcode/vx_nc_util/nc_constants.h +++ b/src/libcode/vx_nc_util/nc_constants.h @@ -29,10 +29,10 @@ // NetCDF keywords -static const char * const CONFIG_NetCDF_Dimension = "NetCDF_Dimension"; +constexpr char CONFIG_NetCDF_Dimension[] = "NetCDF_Dimension"; // Flag value used to indicate a range of values within a dimension -static const int range_flag = bad_data_int; +constexpr int range_flag = bad_data_int; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_util/nc_utils.cc b/src/libcode/vx_nc_util/nc_utils.cc index 87a46d9391..3698dbe41a 100644 --- a/src/libcode/vx_nc_util/nc_utils.cc +++ b/src/libcode/vx_nc_util/nc_utils.cc @@ -537,6 +537,16 @@ bool get_nc_att_value(const NcVar *var, const ConcatString &att_name, //////////////////////////////////////////////////////////////////////// +bool get_nc_att_values(const NcVar *var, const ConcatString &att_name, + unsigned short *att_val, bool exit_on_error) { + static const char *method_name = "get_nc_att_value(NcVar,float) -> "; + bool status = get_nc_att_values_(var, att_name, att_val, exit_on_error, + method_name); + return status; +} + +//////////////////////////////////////////////////////////////////////// + bool get_nc_att_value(const NcVarAtt *att, ConcatString &att_val) { bool status = false; @@ -1750,15 +1760,21 @@ bool get_nc_data(NcVar *var, char **data) { //////////////////////////////////////////////////////////////////////// -bool get_nc_data(NcVar *var, uchar *data) { +bool get_nc_data(NcVar *var, uchar *data, bool allow_conversion) { bool return_status = false; int cell_count = get_data_size(var); int data_type = GET_NC_TYPE_ID_P(var); static const char *method_name = "get_nc_data(NcVar *, uchar *) -> "; if (NC_UBYTE == data_type) return_status = get_nc_data_t(var, data); - else if (NC_BYTE == data_type && has_unsigned_attribute(var)) { + else if (NC_BYTE == data_type) { + if (!has_unsigned_attribute(var) && !allow_conversion) { + mlog << Debug(1) << "\n" << method_name + << "INFO: Unexpected conversion from 'ncbyte' for variable \"" + << GET_NC_NAME_P(var) << "\".\n\n"; + } ncbyte *signed_data = new ncbyte[cell_count]; - if (return_status = get_nc_data_t(var, signed_data)) { + return_status = get_nc_data_t(var, signed_data); + if (return_status) { for (int idx=0; idx -#ifndef ncbyte -typedef signed char ncbyte; // from ncvalues.h -#endif /* ncbyte */ -#ifndef uchar -typedef unsigned char uchar; -#endif /* uchar */ - #include "concat_string.h" #include "int_array.h" #include "long_array.h" #include "num_array.h" #include "nc_var_info.h" -//////////////////////////////////////////////////////////////////////// - -static const std::string C_unknown_str = std::string("unknown"); - -#define IS_VALID_NC(ncObj) (!ncObj.isNull()) -#define IS_VALID_NC_P(ncObjPtr) ((ncObjPtr != nullptr && !ncObjPtr->isNull())) - -#define IS_INVALID_NC(ncObj) ncObj.isNull() -#define IS_INVALID_NC_P(ncObjPtr) (ncObjPtr == nullptr || ncObjPtr->isNull()) - -#define GET_NC_NAME(ncObj) ncObj.getName() -#define GET_NC_NAME_P(ncObjPtr) ncObjPtr->getName() - -#define GET_NC_SIZE(ncObj) ncObj.getSize() -#define GET_NC_SIZE_P(ncObjPtr) ncObjPtr->getSize() - -#define GET_SAFE_NC_NAME(ncObj) (ncObj.isNull() ? C_unknown_str : ncObj.getName()) -#define GET_SAFE_NC_NAME_P(ncObjPtr) (IS_INVALID_NC_P(ncObjPtr) ? C_unknown_str : ncObjPtr->getName()) - -#define GET_NC_TYPE_ID(ncObj) ncObj.getType().getId() -#define GET_NC_TYPE_ID_P(ncObjPtr) ncObjPtr->getType().getId() -#define GET_NC_TYPE_NAME(ncObj) ncObj.getType().getName() -#define GET_NC_TYPE_NAME_P(ncObjPtr) ncObjPtr->getType().getName() - -#define GET_NC_DIM_COUNT(ncObj) ncObj.getDimCount() -#define GET_NC_DIM_COUNT_P(ncObjPtr) ncObjPtr->getDimCount() +#include "nc_utils.hpp" -#define GET_NC_VAR_COUNT(ncObj) ncObj.getVarCount() -#define GET_NC_VAR_COUNT_P(ncObjPtr) ncObjPtr->getVarCount() +//////////////////////////////////////////////////////////////////////// -#define GET_NC_VARS(ncObj) ncObj.getVars() -#define GET_NC_VARS_P(ncObjPtr) ncObjPtr->getVars() +#ifndef uchar +typedef unsigned char uchar; +#endif /* uchar */ //////////////////////////////////////////////////////////////////////// @@ -135,11 +103,9 @@ static const std::string coordinates_att_name = "coordinates"; static const std::string coordinate_axis_type_att_name = "_CoordinateAxisType"; static const std::string cf_att_name = "Conventions"; static const std::string description_att_name = "description"; -static const std::string fill_value_att_name = "_FillValue"; static const std::string grid_mapping_att_name = "grid_mapping"; static const std::string grid_mapping_name_att_name = "grid_mapping_name"; static const std::string long_name_att_name = "long_name"; -static const std::string missing_value_att_name = "missing_value"; static const std::string projection_att_name = "Projection"; static const std::string scale_factor_att_name = "scale_factor"; static const std::string standard_name_att_name = "standard_name"; @@ -183,9 +149,6 @@ extern bool get_att_no_leap_year(const netCDF::NcVar *); extern bool get_cf_conventions(const netCDF::NcFile *, ConcatString&); -extern netCDF::NcVarAtt *get_nc_att(const netCDF::NcVar *, const ConcatString &, bool exit_on_error = false); -extern netCDF::NcGroupAtt *get_nc_att(const netCDF::NcFile *, const ConcatString &, bool exit_on_error = false); - extern bool get_nc_att_value(const netCDF::NcVarAtt *, std::string &); extern bool get_nc_att_value(const netCDF::NcVarAtt *, int &, bool exit_on_error = true); extern bool get_nc_att_value(const netCDF::NcVarAtt *, float &, bool exit_on_error = true); @@ -195,6 +158,7 @@ extern bool get_nc_att_value(const netCDF::NcVar *, const ConcatString &, Concat extern bool get_nc_att_value(const netCDF::NcVar *, const ConcatString &, int &, bool exit_on_error = false); extern bool get_nc_att_value(const netCDF::NcVar *, const ConcatString &, float &, bool exit_on_error = false); extern bool get_nc_att_value(const netCDF::NcVar *, const ConcatString &, double &, bool exit_on_error = false); +extern bool get_nc_att_values(const netCDF::NcVar *, const ConcatString &, unsigned short *, bool exit_on_error = false); extern bool has_att(netCDF::NcFile *, const ConcatString name, bool exit_on_error=false); extern bool has_att(netCDF::NcVar *, const ConcatString name, bool do_log=false); @@ -257,11 +221,10 @@ extern ConcatString* get_string_val(netCDF::NcVar *var, const int index, const i extern bool get_nc_data(netCDF::NcVar *, int *data); extern bool get_nc_data(netCDF::NcVar *, char *data); extern bool get_nc_data(netCDF::NcVar *, char **data); -extern bool get_nc_data(netCDF::NcVar *, uchar *data); +extern bool get_nc_data(netCDF::NcVar *, uchar *data, bool allow_conversion=false); extern bool get_nc_data(netCDF::NcVar *, float *data); extern bool get_nc_data(netCDF::NcVar *, double *data); extern bool get_nc_data(netCDF::NcVar *, time_t *data); -extern bool get_nc_data(netCDF::NcVar *, ncbyte *data); extern bool get_nc_data(netCDF::NcVar *, unsigned short *data); extern bool get_nc_data(netCDF::NcVar *, int *data, const LongArray &curs); @@ -359,14 +322,8 @@ extern netCDF::NcDim add_dim(netCDF::NcFile *, const std::string &); extern netCDF::NcDim add_dim(netCDF::NcFile *, const std::string &, const size_t); extern bool has_dim(netCDF::NcFile *, const char *dim_name); extern bool get_dim(const netCDF::NcFile *, const ConcatString &, int &, bool error_out = false); -extern int get_dim_count(const netCDF::NcVar *); extern int get_dim_count(const netCDF::NcFile *); -extern int get_dim_size(const netCDF::NcDim *); -extern int get_dim_size(const netCDF::NcVar *, const int dim_offset); extern int get_dim_value(const netCDF::NcFile *, const std::string &, const bool error_out = false); -extern netCDF::NcDim get_nc_dim(const netCDF::NcFile *, const std::string &dim_name); -extern netCDF::NcDim get_nc_dim(const netCDF::NcVar *, const std::string &dim_name); -extern netCDF::NcDim get_nc_dim(const netCDF::NcVar *, const int dim_offset); extern bool get_dim_names(const netCDF::NcVar *var, StringArray *dimNames); extern bool get_dim_names(const netCDF::NcFile *nc, StringArray *dimNames); @@ -376,7 +333,6 @@ extern netCDF::NcVar get_nc_var_time(const netCDF::NcFile *nc); extern int get_index_at_nc_data(netCDF::NcVar *var, double value, const std::string dim_name, bool is_time=false); extern netCDF::NcFile* open_ncfile(const char * nc_name, bool write = false); -extern int get_data_size(netCDF::NcVar *); extern unixtime get_reference_unixtime(netCDF::NcVar *time_var, int &sec_per_unit, bool &no_leap_year); @@ -390,10 +346,6 @@ extern void parse_time_string(const char *str, unixtime &ut); //////////////////////////////////////////////////////////////////////// -#include "nc_utils.hpp" - -//////////////////////////////////////////////////////////////////////// - #endif /* __NC_UTILS_H__ */ //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_util/nc_utils.hpp b/src/libcode/vx_nc_util/nc_utils.hpp index 4a6c0a1a92..f86cb472e9 100644 --- a/src/libcode/vx_nc_util/nc_utils.hpp +++ b/src/libcode/vx_nc_util/nc_utils.hpp @@ -13,6 +13,10 @@ //////////////////////////////////////////////////////////////////////// +#include "nc_utils_core.h" + +//////////////////////////////////////////////////////////////////////// + extern bool get_att_value(const netCDF::NcAtt *att, int &att_val); extern bool get_att_value(const netCDF::NcAtt *att, ConcatString &value); extern bool get_att_value(const netCDF::NcAtt *att, ncbyte &att_val); @@ -93,12 +97,33 @@ bool get_nc_att_value_(const netCDF::NcVar *var, const ConcatString &att_name, if (!status) { mlog << Error << "\n" << caller_name << get_log_msg_for_att(att, GET_SAFE_NC_NAME_P(var), att_name); - if (exit_on_error) { - if (att) delete att; - exit(1); - } } if (att) delete att; + if (!status && exit_on_error) exit(1); + + return status; +} + +//////////////////////////////////////////////////////////////////////// + +template +bool get_nc_att_values_(const netCDF::NcVar *var, const ConcatString &att_name, + T *att_vals, bool exit_on_error, + const char *caller_name) { + // caller should initialize att_vals + + // + // Retrieve the NetCDF variable attribute. + // + netCDF::NcVarAtt *att = get_nc_att(var, att_name); + bool status = IS_VALID_NC_P(att); + if (status) att->getValues(att_vals); + else { + mlog << Error << "\n" << caller_name + << get_log_msg_for_att(att, GET_SAFE_NC_NAME_P(var), att_name); + } + if (att) delete att; + if (!status && exit_on_error) exit(1); return status; } diff --git a/src/libcode/vx_nc_util/nc_utils_core.h b/src/libcode/vx_nc_util/nc_utils_core.h new file mode 100644 index 0000000000..93838a2dbe --- /dev/null +++ b/src/libcode/vx_nc_util/nc_utils_core.h @@ -0,0 +1,80 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +//////////////////////////////////////////////////////////////////////// + +#ifndef __NC_UTILS_CORE_H__ +#define __NC_UTILS_CORE_H__ + +//////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////// + +#ifndef ncbyte +typedef signed char ncbyte; /* from ncvalues.h */ +#endif /* ncbyte */ + +//////////////////////////////////////////////////////////////////////// + +#define IS_VALID_NC(ncObj) (!ncObj.isNull()) +#define IS_VALID_NC_P(ncObjPtr) ((ncObjPtr != nullptr && !ncObjPtr->isNull())) + +#define IS_INVALID_NC(ncObj) ncObj.isNull() +#define IS_INVALID_NC_P(ncObjPtr) (ncObjPtr == nullptr || ncObjPtr->isNull()) + +#define GET_NC_NAME(ncObj) ncObj.getName() +#define GET_NC_NAME_P(ncObjPtr) ncObjPtr->getName() + +#define GET_NC_SIZE(ncObj) ncObj.getSize() +#define GET_NC_SIZE_P(ncObjPtr) ncObjPtr->getSize() + +#define GET_SAFE_NC_NAME(ncObj) (ncObj.isNull() ? C_unknown_str : ncObj.getName()) +#define GET_SAFE_NC_NAME_P(ncObjPtr) (IS_INVALID_NC_P(ncObjPtr) ? C_unknown_str : ncObjPtr->getName()) + +#define GET_NC_TYPE_ID(ncObj) ncObj.getType().getId() +#define GET_NC_TYPE_ID_P(ncObjPtr) ncObjPtr->getType().getId() +#define GET_NC_TYPE_NAME(ncObj) ncObj.getType().getName() +#define GET_NC_TYPE_NAME_P(ncObjPtr) ncObjPtr->getType().getName() + +#define GET_NC_DIM_COUNT(ncObj) ncObj.getDimCount() +#define GET_NC_DIM_COUNT_P(ncObjPtr) ncObjPtr->getDimCount() + +#define GET_NC_VAR_COUNT(ncObj) ncObj.getVarCount() +#define GET_NC_VAR_COUNT_P(ncObjPtr) ncObjPtr->getVarCount() + +#define GET_NC_VARS(ncObj) ncObj.getVars() +#define GET_NC_VARS_P(ncObjPtr) ncObjPtr->getVars() + +//////////////////////////////////////////////////////////////////////// + +static const std::string C_unknown_str = std::string("unknown"); + +static const std::string fill_value_att_name = "_FillValue"; +static const std::string missing_value_att_name = "missing_value"; + +//////////////////////////////////////////////////////////////////////// + + +extern int get_data_size(netCDF::NcVar *); +extern int get_dim_count(const netCDF::NcVar *); +extern int get_dim_size(const netCDF::NcDim *); +extern int get_dim_size(const netCDF::NcVar *, const int dim_offset); + +extern netCDF::NcVarAtt *get_nc_att(const netCDF::NcVar *, const ConcatString &, bool exit_on_error = false); +extern netCDF::NcGroupAtt *get_nc_att(const netCDF::NcFile *, const ConcatString &, bool exit_on_error = false); + +extern netCDF::NcDim get_nc_dim(const netCDF::NcFile *, const std::string &dim_name); +extern netCDF::NcDim get_nc_dim(const netCDF::NcVar *, const std::string &dim_name); +extern netCDF::NcDim get_nc_dim(const netCDF::NcVar *, const int dim_offset); + +//////////////////////////////////////////////////////////////////////// + +#endif /* __NC_UTILS_CORE_H__ */ + +//////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index d11044dc5f..2b067ffdf4 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -21,6 +21,7 @@ // 001 01-25-21 Halley Gotway MET #1630 Handle zero obs. // 002 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // 003 10-03-23 Prestopnik MET #2227 Remove namespace std and netCDF from header files +// 004 05-20-24 Howard Soh MET #2867 Fix -qc ADP bug. // //////////////////////////////////////////////////////////////////////// @@ -59,27 +60,24 @@ using namespace netCDF; static ConcatString program_name; // Constants -static const int TYPE_UNKNOWN = 0; // Can not process the input file -static const int TYPE_OBS = 1; // MET Point Obs NetCDF (from xxx2nc) -static const int TYPE_NCCF = 2; // CF NetCDF with time and lat/lon variables -static const int TYPE_GOES = 5; -static const int TYPE_GOES_ADP = 6; -static const int TYPE_PYTHON = 7; // MET Point Obs NetCDF from PYTHON +constexpr int TYPE_UNKNOWN = 0; // Can not process the input file +constexpr int TYPE_OBS = 1; // MET Point Obs NetCDF (from xxx2nc) +constexpr int TYPE_NCCF = 2; // CF NetCDF with time and lat/lon variables +constexpr int TYPE_GOES = 5; +constexpr int TYPE_GOES_ADP = 6; +constexpr int TYPE_PYTHON = 7; // MET Point Obs NetCDF from PYTHON -static const InterpMthd DefaultInterpMthd = InterpMthd::UW_Mean; -static const int DefaultInterpWdth = 2; -static const double DefaultVldThresh = 0.5; +constexpr InterpMthd DefaultInterpMthd = InterpMthd::UW_Mean; +constexpr int DefaultInterpWdth = 2; +constexpr double DefaultVldThresh = 0.5; -static const float MISSING_LATLON = -999.0; -static const int QC_NA_INDEX = -1; -static const int LEVEL_FOR_PERFORMANCE = 6; +constexpr float MISSING_LATLON = -999.0; +constexpr int QC_NA_INDEX = -1; +constexpr int LEVEL_FOR_PERFORMANCE = 6; -static const char * default_config_filename = "MET_BASE/config/Point2GridConfig_default"; +constexpr char default_config_filename[] = "MET_BASE/config/Point2GridConfig_default"; -static const string lat_dim_name_list = "x"; // "lat,latitude"; -static const string lon_dim_name_list = "y"; // "lon,longitude"; - -static const char * GOES_global_attr_names[] = { +static const vector GOES_global_attr_names = { "naming_authority", "project", "production_site", @@ -110,7 +108,7 @@ static IntArray message_type_list; // Variables for command line arguments static ConcatString InputFilename; static ConcatString OutputFilename; -static ConcatString AdpFilename; +static ConcatString adp_filename; static ConcatString config_filename; static PointToGridConfInfo conf_info; static StringArray FieldSA; @@ -126,6 +124,19 @@ static NcFile *nc_out = (NcFile *) nullptr; static NcDim lat_dim ; static NcDim lon_dim ; +static int adp_qc_high; /* 3 as baseline algorithm, 0 for enterprise algorithm */ +static int adp_qc_medium; /* 1 as baseline algorithm, 1 for enterprise algorithm */ +static int adp_qc_low; /* 0 as baseline algorithm, 2 for enterprise algorithm */ + +enum class GOES_QC { + HIGH = 0, + MEDIUM, + LOW, + NA +}; + +static const ConcatString att_name_values = "flag_values"; +static const ConcatString att_name_meanings = "flag_meanings"; //////////////////////////////////////////////////////////////////////// @@ -134,7 +145,7 @@ static void process_data_file(); static void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *, const Grid to_grid); #ifdef WITH_PYTHON -static void process_point_python(string python_command, MetConfig &config, +static void process_point_python(const string python_command, MetConfig &config, VarInfo *vinfo, const Grid to_grid, bool use_xarray); #endif static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, @@ -159,9 +170,9 @@ static void set_gaussian_dx(const StringArray &); static void set_gaussian_radius(const StringArray &); static unixtime compute_unixtime(NcVar *time_var, unixtime var_value); -static bool get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, +static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, NcVar var_lat, NcVar var_lon, bool *skip_times); -static bool get_grid_mapping(Grid to_grid, IntArray *cellMapping, +static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, const IntArray obs_index_array, const int *obs_hids, const float *hdr_lats, const float *hdr_lons); static int get_obs_type(NcFile *nc_in); @@ -171,17 +182,18 @@ static void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, static bool keep_message_type(const int mt_index); -static bool has_lat_lon_vars(NcFile *nc_in); +static bool has_lat_lon_vars(const NcFile *nc_in); +static void set_adp_gc_values(NcVar var_adp_qc); //////////////////////////////////////////////////////////////////////// // for GOES 16 // static const int factor_float_to_int = 1000000; -static const char *key_geostationary_data = "MET_GEOSTATIONARY_DATA"; -static const char *dim_name_lat = "lat"; -static const char *dim_name_lon = "lon"; -static const char *var_name_lat = "latitude"; -static const char *var_name_lon = "longitude"; +constexpr char key_geostationary_data[] = "MET_GEOSTATIONARY_DATA"; +constexpr char dim_name_lat[] = "lat"; +constexpr char dim_name_lon[] = "lon"; +constexpr char var_name_lat[] = "latitude"; +constexpr char var_name_lon[] = "longitude"; static const ConcatString vname_dust("Dust"); static const ConcatString vname_smoke("Smoke"); @@ -190,22 +202,21 @@ static IntArray qc_flags; static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *, const Grid fr_grid, const Grid to_grid); static unixtime find_valid_time(NcVar time_var); -static ConcatString get_goes_grid_input(MetConfig config, Grid fr_grid, Grid to_grid); -static void get_grid_mapping(Grid fr_grid, Grid to_grid, - IntArray *cellMapping, ConcatString geostationary_file); -static int get_lat_count(NcFile *); -static int get_lon_count(NcFile *); -static NcVar get_goes_nc_var(NcFile *nc, const ConcatString var_name, +static ConcatString get_goes_grid_input(MetConfig config, const Grid fr_grid); +static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, + IntArray *cellMapping, const ConcatString &geostationary_file); +static int get_lat_count(const NcFile *); +static int get_lon_count(const NcFile *); +static NcVar get_goes_nc_var(NcFile *nc, const ConcatString &var_name, bool exit_if_error=true); static bool is_time_mismatch(NcFile *nc_in, NcFile *nc_adp); -static ConcatString make_geostationary_filename(Grid fr_grid, Grid to_grid, - ConcatString regrid_name); -static void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, +static ConcatString make_geostationary_filename(Grid fr_grid); +static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, DataPlane &fr_dp, DataPlane &to_dp, Grid fr_grid, Grid to_grid, IntArray *cellMapping, NcFile *nc_adp); static void save_geostationary_data(const ConcatString geostationary_file, const float *latitudes, const float *longitudes, - const GoesImagerData grid_data); + const GoesImagerData &grid_data); static void set_qc_flags(const StringArray &); //////////////////////////////////////////////////////////////////////// @@ -226,13 +237,13 @@ int met_main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// -const string get_tool_name() { +string get_tool_name() { return "point2grid"; } //////////////////////////////////////////////////////////////////////// -void process_command_line(int argc, char **argv) { +static void process_command_line(int argc, char **argv) { CommandLine cline; static const char *method_name = "process_command_line() -> "; @@ -292,7 +303,7 @@ void process_command_line(int argc, char **argv) { // Check if the input file #ifdef WITH_PYTHON if (use_python) { - int offset = python_command.find("="); + auto offset = python_command.find("="); if (offset == std::string::npos) { mlog << Error << "\n" << method_name << "trouble parsing the python command " << python_command << ".\n\n"; @@ -318,12 +329,10 @@ void process_command_line(int argc, char **argv) { // Check that same variable is required multiple times without -name argument if(VarNameSA.n() == 0) { - VarInfo *vinfo; MetConfig config; - VarInfoFactory v_factory; ConcatString vname; StringArray var_names; - vinfo = v_factory.new_var_info(FileType_NcMet); + VarInfo *vinfo = VarInfoFactory::new_var_info(FileType_NcMet); for(int i=0; iclear(); // Populate the VarInfo object using the config string @@ -365,11 +374,11 @@ void process_command_line(int argc, char **argv) { //////////////////////////////////////////////////////////////////////// -void process_data_file() { - Grid fr_grid, to_grid; +static void process_data_file() { + Grid fr_grid; GrdFileType ftype; ConcatString run_cs; - NcFile *nc_in = (NcFile *) nullptr; + auto nc_in = (NcFile *) nullptr; static const char *method_name = "process_data_file() -> "; // Initialize configuration object @@ -388,14 +397,13 @@ void process_data_file() { bool goes_data = false; bool use_python = false; int obs_type; - Met2dDataFileFactory m_factory; - Met2dDataFile *fr_mtddf = (Met2dDataFile *) nullptr; + auto fr_mtddf = (Met2dDataFile *) nullptr; #ifdef WITH_PYTHON string python_command = InputFilename; bool use_xarray = (0 == python_command.find(conf_val_python_xarray)); use_python = use_xarray || (0 == python_command.find(conf_val_python_numpy)); if (use_python) { - int offset = python_command.find("="); + auto offset = python_command.find("="); if (offset == std::string::npos) { mlog << Error << "\n" << method_name << "trouble parsing the python command " << python_command << ".\n\n"; @@ -418,7 +426,7 @@ void process_data_file() { if (obs_type == TYPE_NCCF) setenv(nc_att_met_point_nccf, "yes", 1); // Read the input data file - fr_mtddf = m_factory.new_met_2d_data_file(InputFilename.c_str(), ftype); + fr_mtddf = Met2dDataFileFactory::new_met_2d_data_file(InputFilename.c_str(), ftype); } if(!fr_mtddf) { @@ -431,9 +439,7 @@ void process_data_file() { ftype = fr_mtddf->file_type(); // Setup the VarInfo request object - VarInfoFactory v_factory; - VarInfo *vinfo; - vinfo = v_factory.new_var_info(ftype); + VarInfo *vinfo = VarInfoFactory::new_var_info(ftype); if(!vinfo) { mlog << Error << "\n" << method_name @@ -452,7 +458,7 @@ void process_data_file() { #endif // Determine the "to" grid - to_grid = parse_vx_grid(RGInfo, &fr_grid, &fr_grid); + Grid to_grid = parse_vx_grid(RGInfo, &fr_grid, &fr_grid); mlog << Debug(2) << "Interpolation options: " << "method = " << interpmthd_to_string(RGInfo.method) @@ -460,11 +466,11 @@ void process_data_file() { // Build the run command string run_cs << "Point obs (" << fr_grid.serialize() << ") to " << to_grid.serialize(); - + if (goes_data) { mlog << Debug(2) << "Input grid: " << fr_grid.serialize() << "\n"; - ConcatString grid_string = get_goes_grid_input(config, fr_grid, to_grid); - if (grid_string.length() > 0) run_cs << " with " << grid_string; + ConcatString grid_string = get_goes_grid_input(config, fr_grid); + if (!grid_string.empty()) run_cs << " with " << grid_string; } mlog << Debug(2) << "Output grid: " << to_grid.serialize() << "\n"; @@ -497,7 +503,7 @@ void process_data_file() { close_nc(); // Clean up - if(nc_in) { delete nc_in; nc_in = 0; } + if(nc_in) { delete nc_in; nc_in = nullptr; } if(fr_mtddf) { delete fr_mtddf; fr_mtddf = (Met2dDataFile *) nullptr; } if(vinfo) { delete vinfo; vinfo = (VarInfo *) nullptr; } @@ -509,7 +515,7 @@ void process_data_file() { bool get_nc_data_int_array(NcFile *nc, char *var_name, int *data_array, bool stop=true) { bool status = false; - NcVar nc_var = get_nc_var(nc, (char *)var_name, stop); + NcVar nc_var = get_nc_var(nc, var_name, stop); if (IS_INVALID_NC(nc_var)) { if (stop) exit(1); } @@ -536,7 +542,7 @@ bool get_nc_data_int_array(NcFile *nc, const char *var_name, int *data_array, bo // returns true if no error bool get_nc_data_float_array(NcFile *nc, char *var_name, float *data_array) { - NcVar nc_var = get_nc_var(nc, (char *)var_name); + NcVar nc_var = get_nc_var(nc, var_name); if (IS_INVALID_NC(nc_var)) exit(1); bool status = get_nc_data(&nc_var, data_array); @@ -585,24 +591,24 @@ bool get_nc_data_string_array(NcFile *nc, const char *var_name, //////////////////////////////////////////////////////////////////////// -int get_obs_type(NcFile *nc) { +static int get_obs_type(NcFile *nc) { int obs_type = TYPE_UNKNOWN; ConcatString att_val_scene_id; ConcatString att_val_project; ConcatString input_type; static const char *method_name = "get_obs_type() -> "; - + bool has_project = get_global_att(nc, (string)"project", att_val_project); bool has_scene_id = get_global_att(nc, (string)"scene_id", att_val_scene_id); if( has_scene_id && has_project && att_val_project == "GOES" ) { obs_type = TYPE_GOES; input_type = "GOES"; - if (0 < AdpFilename.length()) { + if (!adp_filename.empty()) { obs_type = TYPE_GOES_ADP; input_type = "GOES_ADP"; - if (!file_exists(AdpFilename.c_str())) { + if (!file_exists(adp_filename.c_str())) { mlog << Error << "\n" << method_name - << "ADP input \"" << AdpFilename << "\" does not exist!\n\n"; + << "ADP input \"" << adp_filename << "\" does not exist!\n\n"; exit(1); } } @@ -624,7 +630,7 @@ int get_obs_type(NcFile *nc) { //////////////////////////////////////////////////////////////////////// // Check the message types -void prepare_message_types(const StringArray hdr_types) { +void prepare_message_types(const StringArray &hdr_types) { static const char *method_name = "prepare_message_types() -> "; message_type_list.clear(); if (0 < conf_info.message_type.n()) { @@ -653,10 +659,9 @@ void prepare_message_types(const StringArray hdr_types) { //////////////////////////////////////////////////////////////////////// -IntArray prepare_qc_array(const IntArray qc_flags, StringArray qc_tables) { +IntArray prepare_qc_array(const StringArray &qc_tables) { IntArray qc_idx_array; - bool has_qc_flags = (qc_flags.n() > 0); - if (has_qc_flags) { + if (qc_flags.n() > 0) { for(int idx=0; idx prepare_qoes_qc_array() { + std::set qc_flags_set; + for(int idx=0; idxget_header_data(); + const MetPointHeader *header_data = met_point_obs->get_header_data(); MetPointObsData *obs_data = met_point_obs->get_point_obs_data(); - nhdr = met_point_obs->get_hdr_cnt(); - nobs = met_point_obs->get_obs_cnt(); + int nhdr = met_point_obs->get_hdr_cnt(); + int nobs = met_point_obs->get_obs_cnt(); bool empty_input = (nhdr == 0 && nobs == 0); bool use_var_id = met_point_obs->is_using_var_id(); - float *hdr_lats = new float[nhdr]; - float *hdr_lons = new float[nhdr]; + auto hdr_lats = new float[nhdr]; + auto hdr_lons = new float[nhdr]; IntArray var_index_array; IntArray valid_time_array; StringArray qc_tables = met_point_obs->get_qty_data(); @@ -722,418 +735,411 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI prepare_message_types(header_data->typ_array); // Check and read obs_vid and obs_var if exists - bool success_to_read = true; - if (success_to_read) { - bool has_qc_flags = (qc_flags.n() > 0); - IntArray qc_idx_array = prepare_qc_array(qc_flags, qc_tables); + bool has_qc_flags = (qc_flags.n() > 0); + IntArray qc_idx_array = prepare_qc_array(qc_tables); - // Initialize size and values of output fields - nx = to_grid.nx(); - ny = to_grid.ny(); - to_dp.set_size(nx, ny); - to_dp.set_constant(bad_data_double); - cnt_dp.set_size(nx, ny); - cnt_dp.set_constant(0); - mask_dp.set_size(nx, ny); - mask_dp.set_constant(0); - if (has_prob_thresh || do_gaussian_filter) { - prob_dp.set_size(nx, ny); - prob_dp.set_constant(0); - prob_mask_dp.set_size(nx, ny); - prob_mask_dp.set_constant(0); - } - - // Loop through the requested fields - int obs_count_zero_to, obs_count_non_zero_to; - int obs_count_zero_from, obs_count_non_zero_from; - IntArray *cellMapping = (IntArray *) nullptr; + // Initialize size and values of output fields + int nx = to_grid.nx(); + int ny = to_grid.ny(); + to_dp.set_size(nx, ny); + to_dp.set_constant(bad_data_double); + cnt_dp.set_size(nx, ny); + cnt_dp.set_constant(0); + mask_dp.set_size(nx, ny); + mask_dp.set_constant(0); + if (has_prob_thresh || do_gaussian_filter) { + prob_dp.set_size(nx, ny); + prob_dp.set_constant(0); + prob_mask_dp.set_size(nx, ny); + prob_mask_dp.set_constant(0); + } - obs_count_zero_to = obs_count_non_zero_to = 0; - obs_count_zero_from = obs_count_non_zero_from = 0; - for(int i=0; iclear(); + var_idx_or_gc = -1; - // Populate the VarInfo object using the config string - config.read_string(FieldSA[i].c_str()); - vinfo->set_dict(config); + // Initialize + vinfo->clear(); - // Check the variable name - ConcatString error_msg; - vname = vinfo->name(); - bool exit_by_field_name_error = false; - if (vname == "obs_val" || vname == "obs_lvl" || vname == "obs_hgt") { - exit_by_field_name_error = true; - error_msg << "The variable \"" << vname - << "\" exists but is not a valid field name.\n"; + // Populate the VarInfo object using the config string + config.read_string(FieldSA[i].c_str()); + vinfo->set_dict(config); + + // Check the variable name + ConcatString error_msg; + vname = vinfo->name(); + bool exit_by_field_name_error = false; + if (vname == "obs_val" || vname == "obs_lvl" || vname == "obs_hgt") { + exit_by_field_name_error = true; + error_msg << "The variable \"" << vname + << "\" exists but is not a valid field name.\n"; + } + else { + if (use_var_id) { + if (!var_names.has(vname, var_idx_or_gc)) { + exit_by_field_name_error = true; + error_msg << "The variable \"" << vname << "\" is not available.\n"; + } } else { - if (use_var_id) { - if (!var_names.has(vname, var_idx_or_gc)) { + const int TMP_BUF_LEN = 128; + char grib_code[TMP_BUF_LEN + 1]; + var_idx_or_gc = atoi(vname.c_str()); + snprintf(grib_code, TMP_BUF_LEN, "%d", var_idx_or_gc); + if (vname != grib_code) { + ConcatString var_id = conf_info.get_var_id(vname); + if( var_id.nonempty() ) { + var_idx_or_gc = atoi(var_id.c_str()); + snprintf(grib_code, TMP_BUF_LEN, "%d", var_idx_or_gc); + } + else { exit_by_field_name_error = true; - error_msg << "The variable \"" << vname << "\" is not available.\n"; + error_msg << "Invalid GRIB code [" << vname << "]\n"; } } else { - const int TMP_BUF_LEN = 128; - char grib_code[TMP_BUF_LEN + 1]; - var_idx_or_gc = atoi(vname.c_str()); - snprintf(grib_code, TMP_BUF_LEN, "%d", var_idx_or_gc); - if (vname != grib_code) { - ConcatString var_id = conf_info.get_var_id(vname); - if( var_id.nonempty() ) { - var_idx_or_gc = atoi(var_id.c_str()); - snprintf(grib_code, TMP_BUF_LEN, "%d", var_idx_or_gc); - } - else { - exit_by_field_name_error = true; - error_msg << "Invalid GRIB code [" << vname << "]\n"; + bool not_found_grib_code = true; + for (idx=0; idxobs_ids[idx]) { + not_found_grib_code = false; + break; } } - else { - bool not_found_grib_code = true; - for (idx=0; idxobs_ids[idx]) { - not_found_grib_code = false; - break; - } - } - if (not_found_grib_code) { - exit_by_field_name_error = true; - error_msg << "No data for the GRIB code [" << vname << "]\n"; - } + if (not_found_grib_code) { + exit_by_field_name_error = true; + error_msg << "No data for the GRIB code [" << vname << "]\n"; } } } + } - if (exit_by_field_name_error) { - ConcatString log_msg; - if (use_var_id) { - for (idx=0; idxobs_ids[idx])) { - grib_codes.add(obs_data->obs_ids[idx]); - if (0 < idx) log_msg << ", "; - log_msg << obs_data->obs_ids[idx]; - } - } - } - if (empty_input) { - mlog << Warning << "\n" << method_name - << error_msg << "\tBut ignored because of empty input\n\n"; - } - else { - mlog << Error << "\n" << method_name - << error_msg - << "Try setting the \"name\" in the \"-field\" command line option to one of the available names:\n" - << "\t" << log_msg << "\n\n"; - exit(1); + if (exit_by_field_name_error) { + ConcatString log_msg; + if (use_var_id) { + for (idx=0; idxvalid(); - if (valid_time == 0) valid_time = conf_info.valid_time; - requested_valid_time = valid_time; - if (0 < valid_time) { - valid_beg_ut = valid_end_ut = valid_time; - if (!is_bad_data(conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; - if (!is_bad_data(conf_info.end_ds)) valid_end_ut += conf_info.end_ds; - for(idx=0; idxobs_ids[idx])) { + grib_codes.add(obs_data->obs_ids[idx]); + if (0 < idx) log_msg << ", "; + log_msg << obs_data->obs_ids[idx]; } } - valid_time_array.add(bad_data_int); // added dummy entry + } + if (empty_input) { + mlog << Warning << "\n" << method_name + << error_msg << "\tBut ignored because of empty input\n\n"; } else { - valid_time_from_config = false; - // Set the latest available valid time - valid_time = 0; - for(idx=0; idx valid_time) valid_time = obs_time; + mlog << Error << "\n" << method_name + << error_msg + << "Try setting the \"name\" in the \"-field\" command line option to one of the available names:\n" + << "\t" << log_msg << "\n\n"; + exit(1); + } + } + + // Check the time range. Apply the time window + bool valid_time_from_config = true; + unixtime valid_beg_ut, valid_end_ut, obs_time; + + valid_time_array.clear(); + valid_time = vinfo->valid(); + if (valid_time == 0) valid_time = conf_info.valid_time; + requested_valid_time = valid_time; + if (0 < valid_time) { + valid_beg_ut = valid_end_ut = valid_time; + if (!is_bad_data(conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; + if (!is_bad_data(conf_info.end_ds)) valid_end_ut += conf_info.end_ds; + for(idx=0; idx valid_time) valid_time = obs_time; } + } + mlog << Debug(3) << method_name << "valid_time from " + << (valid_time_from_config ? "config" : "input data") << ": " + << unix_to_yyyymmdd_hhmmss(valid_time) << "\n"; - var_index_array.clear(); - // Select output variable name - vname = (VarNameSA.n() == 0) - ? conf_info.get_var_name(vinfo->name()) - : conf_info.get_var_name(VarNameSA[i]); - mlog << Debug(4) << method_name - << "var: " << vname << ", index: " << var_idx_or_gc << ".\n"; - - var_count = var_count2 = to_count = 0; - filtered_by_time = filtered_by_msg_type = filtered_by_qc = 0; - for (idx=0; idx < nobs; idx++) { - if (var_idx_or_gc == obs_data->obs_ids[idx]) { - var_count2++; - hdr_idx = obs_data->obs_hids[idx]; - if (0 < valid_time_array.n() && - !valid_time_array.has(header_data->vld_idx_array[hdr_idx])) { - filtered_by_time++; - continue; - } + to_dp.set_init(valid_time); + to_dp.set_valid(valid_time); + cnt_dp.set_init(valid_time); + cnt_dp.set_valid(valid_time); + mask_dp.set_init(valid_time); + mask_dp.set_valid(valid_time); + if (has_prob_thresh || do_gaussian_filter) { + prob_dp.set_init(valid_time); + prob_dp.set_valid(valid_time); + prob_mask_dp.set_init(valid_time); + prob_mask_dp.set_valid(valid_time); + } - if(!keep_message_type(header_data->typ_idx_array[hdr_idx])) { - filtered_by_msg_type++; - continue; - } + var_index_array.clear(); + // Select output variable name + vname = (VarNameSA.n() == 0) + ? conf_info.get_var_name(vinfo->name()) + : conf_info.get_var_name(VarNameSA[i]); + mlog << Debug(4) << method_name + << "var: " << vname << ", index: " << var_idx_or_gc << ".\n"; + + int var_count = 0; + int var_count2 = 0; + int to_count = 0; + int filtered_by_time = 0; + int filtered_by_msg_type = 0; + int filtered_by_qc = 0; + for (idx=0; idx < nobs; idx++) { + if (var_idx_or_gc == obs_data->obs_ids[idx]) { + var_count2++; + hdr_idx = obs_data->obs_hids[idx]; + if (0 < valid_time_array.n() && + !valid_time_array.has(header_data->vld_idx_array[hdr_idx])) { + filtered_by_time++; + continue; + } - // Filter by QC flag - if (has_qc_flags && !qc_idx_array.has(obs_data->obs_qids[idx])) { - filtered_by_qc++; - continue; - } + if(!keep_message_type(header_data->typ_idx_array[hdr_idx])) { + filtered_by_msg_type++; + continue; + } - var_index_array.add(idx); - var_count++; - if (is_eq(obs_data->obs_vals[idx], 0.)) obs_count_zero_from++; - else obs_count_non_zero_from++; + // Filter by QC flag + if (has_qc_flags && !qc_idx_array.has(obs_data->obs_qids[idx])) { + filtered_by_qc++; + continue; } + + var_index_array.add(idx); + var_count++; + if (is_eq(obs_data->obs_vals[idx], 0.)) obs_count_zero_from++; + else obs_count_non_zero_from++; } + } - if (cellMapping) { - for (idx=0; idx<(nx*ny); idx++) cellMapping[idx].clear(); - delete [] cellMapping; + if (cellMapping) { + for (idx=0; idx<(nx*ny); idx++) cellMapping[idx].clear(); + delete [] cellMapping; + } + cellMapping = new IntArray[nx * ny]; + if( get_grid_mapping(to_grid, cellMapping, var_index_array, + obs_data->obs_hids, hdr_lats, hdr_lons) ) { + int from_index; + IntArray cellArray; + NumArray dataArray; + int offset = 0; + int valid_count = 0; + int censored_count = 0; + double data_value; + double from_min_value = 10e10; + double from_max_value = -10e10; + + // Initialize counter and output fields + to_dp.set_constant(bad_data_double); + cnt_dp.set_constant(0); + mask_dp.set_constant(0); + if (has_prob_thresh || do_gaussian_filter) { + prob_dp.set_constant(0); + prob_mask_dp.set_constant(0); } - cellMapping = new IntArray[nx * ny]; - if( get_grid_mapping(to_grid, cellMapping, var_index_array, - obs_data->obs_hids, hdr_lats, hdr_lons) ) { - int from_index; - IntArray cellArray; - NumArray dataArray; - int offset = 0; - int valid_count = 0; - int absent_count = 0; - int censored_count = 0; - int qc_filtered_count = 0; - int adp_qc_filtered_count = 0; - float data_value; - float from_min_value = 10e10; - float from_max_value = -10e10; - - // Initialize counter and output fields - to_count = 0; - to_dp.set_constant(bad_data_double); - cnt_dp.set_constant(0); - mask_dp.set_constant(0); - if (has_prob_thresh || do_gaussian_filter) { - prob_dp.set_constant(0); - prob_mask_dp.set_constant(0); - } - for (int x_idx = 0; x_idxget_obs_val(from_index); - if (is_bad_data(data_value)) continue; - - if(mlog.verbosity_level() >= 4) { - if (from_min_value > data_value) from_min_value = data_value; - if (from_max_value < data_value) from_max_value = data_value; - } + for (int x_idx = 0; x_idxget_obs_val(from_index); + if (is_bad_data(data_value)) continue; + + if(mlog.verbosity_level() >= 4) { + if (from_min_value > data_value) from_min_value = data_value; + if (from_max_value < data_value) from_max_value = data_value; + } - for(int ic=0; iccensor_thresh().n(); ic++) { - // Break out after the first match. - if(vinfo->censor_thresh()[ic].check(data_value)) { - data_value = vinfo->censor_val()[ic]; - censored_count++; - break; - } + for(int ic=0; iccensor_thresh().n(); ic++) { + // Break out after the first match. + if(vinfo->censor_thresh()[ic].check(data_value)) { + data_value = vinfo->censor_val()[ic]; + censored_count++; + break; } + } - dataArray.add(data_value); - valid_count++; + dataArray.add(data_value); + valid_count++; + } + if (0 < valid_count) to_count++; + + int data_count = dataArray.n(); + if (0 < data_count) { + double to_value; + if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { + dataArray.sort_array(); + to_value = dataArray[data_count/2]; + if (0 == data_count % 2) + to_value = (float)(to_value + dataArray[(data_count/2)+1])/2; + } + else to_value = dataArray.sum() / data_count; + + if (is_eq(to_value, 0.)) obs_count_zero_to++; + else obs_count_non_zero_to++; + + cnt_dp.set(data_count, x_idx, y_idx); + mask_dp.set(1, x_idx, y_idx); + to_dp.set(to_value, x_idx, y_idx); + if ((has_prob_thresh && prob_cat_thresh.check(to_value)) + || (do_gaussian_filter && !has_prob_thresh)) { + prob_dp.set(1, x_idx, y_idx); + prob_mask_dp.set(1, x_idx, y_idx); } - if (0 < valid_count) to_count++; - - int data_count = dataArray.n(); - if (0 < data_count) { - float to_value; - if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd::Median) { - dataArray.sort_array(); - to_value = dataArray[data_count/2]; - if (0 == data_count % 2) - to_value = (to_value + dataArray[(data_count/2)+1])/2; - } - else to_value = dataArray.sum() / data_count; - - if (is_eq(to_value, 0.)) obs_count_zero_to++; - else obs_count_non_zero_to++; - - cnt_dp.set(data_count, x_idx, y_idx); - mask_dp.set(1, x_idx, y_idx); - to_dp.set(to_value, x_idx, y_idx); - if ((has_prob_thresh && prob_cat_thresh.check(to_value)) - || (do_gaussian_filter && !has_prob_thresh)) { - prob_dp.set(1, x_idx, y_idx); - prob_mask_dp.set(1, x_idx, y_idx); - } - if (1 < data_count) { - mlog << Debug(9) << method_name - << " to_value:" << to_value - << " at " << x_idx << "," << y_idx - << ", max: " << dataArray.max() - << ", min: " << dataArray.min() - << ", mean: " << dataArray.sum()/data_count - << " from " << data_count << " data values.\n"; - } - mlog << Debug(8) << method_name << "data at " << x_idx << "," << y_idx - << ", value: " << to_value << "\n"; + if (1 < data_count) { + mlog << Debug(9) << method_name + << " to_value:" << to_value + << " at " << x_idx << "," << y_idx + << ", max: " << dataArray.max() + << ", min: " << dataArray.min() + << ", mean: " << dataArray.sum()/data_count + << " from " << data_count << " data values.\n"; } + mlog << Debug(8) << method_name << "data at " << x_idx << "," << y_idx + << ", value: " << to_value << "\n"; } } } } + } - // Write the regridded data - write_nc(to_dp, to_grid, vinfo, vname.c_str()); + // Write the regridded data + write_nc(to_dp, to_grid, vinfo, vname.c_str()); - vname_cnt = vname; - vname_cnt << "_cnt"; - vname_mask = vname; - vname_mask << "_mask"; + ConcatString vname_cnt = vname; + vname_cnt << "_cnt"; + ConcatString vname_mask = vname; + vname_mask << "_mask"; - ConcatString tmp_long_name; - ConcatString var_long_name = vinfo->long_name(); - ConcatString dim_string = "(*,*)"; + ConcatString var_long_name = vinfo->long_name(); + ConcatString dim_string = "(*,*)"; - tmp_long_name = vname_cnt; - tmp_long_name << dim_string; - vinfo->set_long_name(tmp_long_name.c_str()); - write_nc_int(cnt_dp, to_grid, vinfo, vname_cnt.c_str()); + ConcatString tmp_long_name = vname_cnt; + tmp_long_name << dim_string; + vinfo->set_long_name(tmp_long_name.c_str()); + write_nc_int(cnt_dp, to_grid, vinfo, vname_cnt.c_str()); - tmp_long_name = vname_mask; - tmp_long_name << dim_string; - vinfo->set_long_name(tmp_long_name.c_str()); - write_nc_int(mask_dp, to_grid, vinfo, vname_mask.c_str()); + tmp_long_name = vname_mask; + tmp_long_name << dim_string; + vinfo->set_long_name(tmp_long_name.c_str()); + write_nc_int(mask_dp, to_grid, vinfo, vname_mask.c_str()); - if (has_prob_thresh || do_gaussian_filter) { - ConcatString vname_prob = vname; - vname_prob << "_prob_" << prob_cat_thresh.get_abbr_str(); - ConcatString vname_prob_mask = vname_prob; - vname_prob_mask << "_mask"; + if (has_prob_thresh || do_gaussian_filter) { + ConcatString vname_prob = vname; + vname_prob << "_prob_" << prob_cat_thresh.get_abbr_str(); + ConcatString vname_prob_mask = vname_prob; + vname_prob_mask << "_mask"; - if (do_gaussian_filter) interp_gaussian_dp(prob_dp, RGInfo.gaussian, RGInfo.vld_thresh); + if (do_gaussian_filter) interp_gaussian_dp(prob_dp, RGInfo.gaussian, RGInfo.vld_thresh); - tmp_long_name = vname_prob; - tmp_long_name << dim_string; - vinfo->set_long_name(tmp_long_name.c_str()); - write_nc(prob_dp, to_grid, vinfo, vname_prob.c_str()); - if (do_gaussian_filter) { - NcVar prob_var = get_var(nc_out, vname_prob.c_str()); - if (IS_VALID_NC(prob_var)) { - add_att(&prob_var, "gaussian_radius", RGInfo.gaussian.radius); - add_att(&prob_var, "gaussian_dx", RGInfo.gaussian.dx); - add_att(&prob_var, "trunc_factor", RGInfo.gaussian.trunc_factor); - } + tmp_long_name = vname_prob; + tmp_long_name << dim_string; + vinfo->set_long_name(tmp_long_name.c_str()); + write_nc(prob_dp, to_grid, vinfo, vname_prob.c_str()); + if (do_gaussian_filter) { + NcVar prob_var = get_var(nc_out, vname_prob.c_str()); + if (IS_VALID_NC(prob_var)) { + add_att(&prob_var, "gaussian_radius", RGInfo.gaussian.radius); + add_att(&prob_var, "gaussian_dx", RGInfo.gaussian.dx); + add_att(&prob_var, "trunc_factor", RGInfo.gaussian.trunc_factor); } - - tmp_long_name = vname_prob_mask; - tmp_long_name << dim_string; - vinfo->set_long_name(tmp_long_name.c_str()); - write_nc_int(prob_mask_dp, to_grid, vinfo, vname_prob_mask.c_str()); } - vinfo->set_long_name(var_long_name.c_str()); - mlog << Debug(7) << method_name << "obs_count_zero_to: " << obs_count_zero_to - << ", obs_count_non_zero_to: " << obs_count_non_zero_to << "\n"; + tmp_long_name = vname_prob_mask; + tmp_long_name << dim_string; + vinfo->set_long_name(tmp_long_name.c_str()); + write_nc_int(prob_mask_dp, to_grid, vinfo, vname_prob_mask.c_str()); + } + vinfo->set_long_name(var_long_name.c_str()); + + mlog << Debug(7) << method_name << "obs_count_zero_to: " << obs_count_zero_to + << ", obs_count_non_zero_to: " << obs_count_non_zero_to << "\n"; - ConcatString log_msg; - log_msg << "Filtered by time: " << filtered_by_time; - if (0 < requested_valid_time) { - log_msg << " [" << unix_to_yyyymmdd_hhmmss(requested_valid_time) << "]"; - } - log_msg << ", by msg_type: " << filtered_by_msg_type; - if (0 < filtered_by_msg_type) { - log_msg << " ["; - for(idx=0; idx 0) log_msg << ","; - log_msg << conf_info.message_type[idx]; - } - log_msg << "]"; + ConcatString log_msg; + log_msg << "Filtered by time: " << filtered_by_time; + if (0 < requested_valid_time) { + log_msg << " [" << unix_to_yyyymmdd_hhmmss(requested_valid_time) << "]"; + } + log_msg << ", by msg_type: " << filtered_by_msg_type; + if (0 < filtered_by_msg_type) { + log_msg << " ["; + for(idx=0; idx 0) log_msg << ","; + log_msg << conf_info.message_type[idx]; } - log_msg << ", by QC: " << filtered_by_qc; - if (0 < filtered_by_qc) { - log_msg << " ["; - for(idx=0; idx 0) log_msg << ","; - log_msg << qc_flags[idx]; - } - log_msg << "]"; + log_msg << "]"; + } + log_msg << ", by QC: " << filtered_by_qc; + if (0 < filtered_by_qc) { + log_msg << " ["; + for(idx=0; idx 0) log_msg << ","; + log_msg << qc_flags[idx]; } - log_msg << ", out of " << var_count2; - int filtered_count = filtered_by_msg_type + filtered_by_qc + requested_valid_time; - if (0 == var_count) { - if (0 == filtered_count) { - mlog << Warning << "\n" << method_name - << "No valid data for the variable [" - << vinfo->name() << "]\n\n"; - } - else { - mlog << Warning << "\n" << method_name - << "No valid data after filtering.\n\t" - << log_msg << ".\n\n"; - } + log_msg << "]"; + } + log_msg << ", out of " << var_count2; + int filtered_count = filtered_by_msg_type + filtered_by_qc + (int)requested_valid_time; + if (0 == var_count) { + if (0 == filtered_count) { + mlog << Warning << "\n" << method_name + << "No valid data for the variable [" + << vinfo->name() << "]\n\n"; } else { - mlog << Debug(2) << method_name << "var_count=" << var_count - << ", grid: " << to_count << " out of " << (nx * ny) << " " - << (0 < filtered_count ? log_msg.c_str() : " ") << "\n"; + mlog << Warning << "\n" << method_name + << "No valid data after filtering.\n\t" + << log_msg << ".\n\n"; } - } // end for i - - if (cellMapping) { - delete [] cellMapping; cellMapping = (IntArray *) nullptr; } + else { + mlog << Debug(2) << method_name << "var_count=" << var_count + << ", grid: " << to_count << " out of " << (nx * ny) << " " + << (0 < filtered_count ? log_msg.c_str() : " ") << "\n"; + } + } // end for i + + if (cellMapping) { + delete [] cellMapping; cellMapping = (IntArray *) nullptr; } delete [] hdr_lats; @@ -1144,17 +1150,10 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI //////////////////////////////////////////////////////////////////////// -void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, - const Grid to_grid) { - ConcatString vname, vname_cnt, vname_mask; - DataPlane fr_dp, to_dp; - DataPlane cnt_dp, mask_dp; - DataPlane prob_dp, prob_mask_dp; - NcVar var_obs_gc, var_obs_var; - +static void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, + const Grid to_grid) { + ConcatString vname; clock_t start_clock = clock(); - - unixtime requested_valid_time, valid_time; static const char *method_name = "process_point_file() -> "; static const char *method_name_s = "process_point_file()"; @@ -1185,21 +1184,10 @@ void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, #ifdef WITH_PYTHON -void process_point_python(string python_command, MetConfig &config, VarInfo *vinfo, - const Grid to_grid, bool use_xarray) { - int idx, hdr_idx; - ConcatString vname, vname_cnt, vname_mask; - DataPlane fr_dp, to_dp; - DataPlane cnt_dp, mask_dp; - DataPlane prob_dp, prob_mask_dp; - NcVar var_obs_gc, var_obs_var; - +static void process_point_python(const string python_command, MetConfig &config, + VarInfo *vinfo, const Grid to_grid, bool use_xarray) { clock_t start_clock = clock(); - bool has_prob_thresh = !prob_cat_thresh.check(bad_data_double); - - unixtime requested_valid_time, valid_time; static const char *method_name = "process_point_python() -> "; - static const char *method_name_s = "process_point_python()"; // Check for at least one configuration string if(FieldSA.n() < 1) { @@ -1233,15 +1221,15 @@ void process_point_python(string python_command, MetConfig &config, VarInfo *vin //////////////////////////////////////////////////////////////////////// -void process_point_nccf_file(NcFile *nc_in, MetConfig &config, - VarInfo *vinfo, Met2dDataFile *fr_mtddf, - const Grid to_grid) { - ConcatString vname, vname_cnt, vname_mask; +static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, + VarInfo *vinfo, Met2dDataFile *fr_mtddf, + const Grid to_grid) { + ConcatString vname; DataPlane fr_dp, to_dp; DataPlane cnt_dp, mask_dp; unixtime valid_beg_ut, valid_end_ut; - bool *skip_times = 0; - double *valid_times = 0; + bool *skip_times = nullptr; + double *valid_times = nullptr; int filtered_by_time = 0; clock_t start_clock = clock(); bool opt_all_attrs = false; @@ -1261,7 +1249,7 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, << "can not find the longitude variable.\n\n"; exit(1); } - + // Check for at least one configuration string if(FieldSA.n() < 1) { mlog << Error << "\n" << method_name @@ -1271,7 +1259,7 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, unixtime valid_time = bad_data_int; valid_beg_ut = valid_end_ut = conf_info.valid_time; - + NcVar time_var = get_nc_var_time(nc_in); if( IS_VALID_NC(time_var) ) { if( 1 < get_dim_count(&time_var) ) { @@ -1281,7 +1269,7 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, if (get_nc_data(&time_var, valid_times)) { int sec_per_unit = 0; bool no_leap_year = false; - unixtime ref_ut = (unixtime) 0; + auto ref_ut = (unixtime) 0; unixtime tmp_time; if( conf_info.valid_time > 0 ) { if (!is_bad_data(conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; @@ -1304,7 +1292,7 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, else valid_time = find_valid_time(time_var); } to_dp.set_size(to_grid.nx(), to_grid.ny()); - IntArray *cellMapping = new IntArray[to_grid.nx() * to_grid.ny()]; + auto cellMapping = new IntArray[to_grid.nx() * to_grid.ny()]; get_grid_mapping(fr_grid, to_grid, cellMapping, var_lat, var_lon, skip_times); if( skip_times ) delete [] skip_times; if( valid_times ) delete [] valid_times; @@ -1361,7 +1349,7 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, prob_dp.set_constant(0); for (int x=0; x= 4) { @@ -1483,7 +1470,7 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, } if (0 < dataArray.n()) { - float to_value; + double to_value; int data_cnt = dataArray.n(); if (1 == data_cnt) to_value = dataArray[0]; else if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); @@ -1495,7 +1482,7 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, to_value = (to_value + dataArray[(data_cnt/2)+1])/2; } else to_value = dataArray.sum() / data_cnt; // UW_Mean - + to_dp.set(to_value, xIdx, yIdx); to_cell_cnt++; if(mlog.verbosity_level() >= 9) { @@ -1522,9 +1509,9 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, } } } - + delete [] from_data; - + mlog << Debug(4) << method_name << "[Count] data cells: " << to_cell_cnt << ", missing: " << missing_cnt << ", non_missing: " << non_missing_cnt << ", non mapped cells: " << no_map_cnt @@ -1534,7 +1521,7 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, } if (to_cell_cnt == 0) { - mlog << Warning << "\n" << method_name + mlog << Warning << "\n" << method_name << " There are no matching cells between input and the target grid.\n\n"; } @@ -1544,7 +1531,7 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, //////////////////////////////////////////////////////////////////////// -void open_nc(const Grid &grid, ConcatString run_cs) { +static void open_nc(const Grid &grid, ConcatString run_cs) { // Create output file nc_out = open_ncfile(OutputFilename.c_str(), true); @@ -1576,7 +1563,7 @@ void open_nc(const Grid &grid, ConcatString run_cs) { void write_nc_data(const DataPlane &dp, const Grid &grid, NcVar *data_var) { // Allocate memory to store data values for each grid point - float *data = new float [grid.nx()*grid.ny()]; + auto data = new float [grid.nx()*grid.ny()]; // Store the data int grid_nx = grid.nx(); @@ -1584,7 +1571,7 @@ void write_nc_data(const DataPlane &dp, const Grid &grid, NcVar *data_var) { for(int x=0; xname()); if(IS_VALID_NC(var_data)) { - for (int idx=0; idx mapVar = GET_NC_VARS_P(nc_in); - for (multimap::iterator itVar = mapVar.begin(); - itVar != mapVar.end(); ++itVar) { - if ((*itVar).first == "t" - || string::npos != (*itVar).first.find("time")) { - NcVar from_var = (*itVar).second; + for (const auto &kv : mapVar) { + if (kv.first == "t" || string::npos != kv.first.find("time")) { + NcVar from_var = kv.second; copy_nc_var(nc_out, &from_var); } } - //copy_nc_atts(_nc_in, nc_out, opt_all_attrs); - delete nc_adp; nc_adp = 0; + delete nc_adp; nc_adp = nullptr; delete [] cellMapping; cellMapping = (IntArray *) nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; @@ -1865,6 +1848,24 @@ void check_lat_lon(int data_size, float *latitudes, float *longitudes) { << method_name << "LONG: " << min_lon << " to " << max_lon << "\n"; } +//////////////////////////////////////////////////////////////////////// +// QC flags: 0=high, 1=medium, 2=low +// Enterpise algorithm: 0=high, 1=medium, 2=low +// Baseline algorithm: 3=high, 1=medium, 0=low (high=12/48, medium=4/16) +// returns bad_data_int if it does not belong to high, mediuam, or low. + +GOES_QC compute_adp_qc_flag(int adp_qc, int shift_bits) { + GOES_QC adp_qc_flag; + int particle_qc = ((adp_qc >> shift_bits) & 0x03); + if (particle_qc == adp_qc_high) adp_qc_flag = GOES_QC::HIGH; + else if (particle_qc == adp_qc_medium) adp_qc_flag = GOES_QC::MEDIUM; + else if (particle_qc == adp_qc_low) adp_qc_flag = GOES_QC::LOW; + else adp_qc_flag = GOES_QC::NA; + + return adp_qc_flag; +} + + //////////////////////////////////////////////////////////////////////// static unixtime compute_unixtime(NcVar *time_var, unixtime var_value) { @@ -1885,7 +1886,19 @@ static unixtime compute_unixtime(NcVar *time_var, unixtime var_value) { //////////////////////////////////////////////////////////////////////// -static bool get_grid_mapping(Grid to_grid, IntArray *cellMapping, +GOES_QC convert_aod_qc_flag(int aod_qc) { + GOES_QC aod_qc_flag; + if (0 == aod_qc) aod_qc_flag = GOES_QC::HIGH; + else if (1 == aod_qc) aod_qc_flag = GOES_QC::MEDIUM; + else if (2 == aod_qc) aod_qc_flag = GOES_QC::LOW; + else aod_qc_flag = GOES_QC::NA; + + return aod_qc_flag; +} + +//////////////////////////////////////////////////////////////////////// + +static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, const IntArray obs_index_array, const int *obs_hids, const float *hdr_lats, const float *hdr_lons) { bool status = false; @@ -1899,28 +1912,23 @@ static bool get_grid_mapping(Grid to_grid, IntArray *cellMapping, return status; } - int hdr_idx, obs_idx; - int count_in_grid; double x, y; - float lat, lon; DataPlane to_dp; - int to_offset, idx_x, idx_y; int to_lat_count = to_grid.ny(); int to_lon_count = to_grid.nx(); - - count_in_grid = 0; + int count_in_grid = 0; to_dp.set_size(to_lon_count, to_lat_count); for (int idx=0; idx 0 ) { @@ -2022,7 +2028,7 @@ static void get_grid_mapping_latlon( // Build cell mapping for (int xIdx=0; xIdx= to_size ) { mlog << Error << "\n" << method_name @@ -2043,7 +2049,7 @@ static void get_grid_mapping_latlon( //////////////////////////////////////////////////////////////////////// -static bool get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, +static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, NcVar var_lat, NcVar var_lon, bool *skip_times) { bool status = false; DataPlane from_dp, to_dp; @@ -2078,8 +2084,8 @@ static bool get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, } else if (data_size > 0) { int last_idx = data_size - 1; - float *latitudes = new float[data_size]; - float *longitudes = new float[data_size]; + auto latitudes = new float[data_size]; + auto longitudes = new float[data_size]; status = get_nc_data(&var_lat, latitudes); if( status ) status = get_nc_data(&var_lon, longitudes); if( status ) { @@ -2112,7 +2118,7 @@ static unixtime find_valid_time(NcVar time_var) { if( IS_VALID_NC(time_var) || get_dim_count(&time_var) < 2) { int time_count = get_dim_size(&time_var, 0); - + double time_values [time_count + 1]; if (get_nc_data(&time_var, time_values)) { valid_time = compute_unixtime(&time_var, time_values[0]); @@ -2136,13 +2142,13 @@ static unixtime find_valid_time(NcVar time_var) { //////////////////////////////////////////////////////////////////////// -ConcatString get_goes_grid_input(MetConfig config, Grid fr_grid, Grid to_grid) { +static ConcatString get_goes_grid_input(MetConfig config, const Grid fr_grid) { ConcatString run_string; ConcatString env_coord_name; ConcatString tmp_dir = config.get_tmp_dir(); ConcatString geostationary_file(tmp_dir); geostationary_file.add("/"); - geostationary_file.add(make_geostationary_filename(fr_grid, to_grid, RGInfo.name)); + geostationary_file.add(make_geostationary_filename(fr_grid)); if (get_env(key_geostationary_data, env_coord_name) && env_coord_name.nonempty() && file_exists(env_coord_name.c_str())) { @@ -2157,8 +2163,8 @@ ConcatString get_goes_grid_input(MetConfig config, Grid fr_grid, Grid to_grid) { //////////////////////////////////////////////////////////////////////// -void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, - ConcatString geostationary_file) { +static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, + const ConcatString &geostationary_file) { static const char *method_name = "get_grid_mapping() -> "; DataPlane from_dp, to_dp; ConcatString cur_coord_name; @@ -2186,7 +2192,7 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, } // Override the from nx & ny from NetCDF if exists - NcFile *coord_nc_in = (NcFile *) nullptr; + auto coord_nc_in = (NcFile *) nullptr; if (has_coord_input) { mlog << Debug(2) << method_name << "Reading coord file: " << cur_coord_name << "\n"; coord_nc_in = open_ncfile(cur_coord_name.c_str()); @@ -2205,10 +2211,10 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, to_dp.set_size(to_lon_count, to_lat_count); if (data_size > 0) { - float *latitudes = (float *)nullptr; - float *longitudes = (float *)nullptr; - float *latitudes_buf = (float *)nullptr; - float *longitudes_buf = (float *)nullptr; + auto latitudes = (float *)nullptr; + auto longitudes = (float *)nullptr; + auto latitudes_buf = (float *)nullptr; + auto longitudes_buf = (float *)nullptr; int buff_size = data_size*sizeof(float); GoesImagerData grid_data; grid_data.reset(); @@ -2246,8 +2252,8 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, int lat_mis_matching_count = 0; int lon_matching_count = 0; int lon_mis_matching_count = 0; - float *tmp_lats = grid_data.lat_values; - float *tmp_lons = grid_data.lon_values; + const float *tmp_lats = grid_data.lat_values; + const float *tmp_lons = grid_data.lon_values; for (int idx=0; idx MISSING_LATLON) && (tmp_lats[idx] > MISSING_LATLON)) { @@ -2294,18 +2300,18 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, } } } - if (0 == latitudes) { + if (nullptr == latitudes) { mlog << Error << "\n" << method_name << "Fail to get latitudes!\n\n"; } - else if (0 == longitudes) { + else if (nullptr == longitudes) { mlog << Error << "\n" << method_name << "Fail to get longitudes!\n\n"; } else { check_lat_lon(data_size, latitudes, longitudes); get_grid_mapping_latlon(from_dp, to_dp, to_grid, cellMapping, latitudes, - longitudes, from_lat_count, from_lon_count, 0, + longitudes, from_lat_count, from_lon_count, nullptr, !fr_grid.get_swap_to_north()); } @@ -2324,7 +2330,7 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, //////////////////////////////////////////////////////////////////////// -int get_lat_count(NcFile *_nc) { +static int get_lat_count(const NcFile *_nc) { int lat_count = 0; NcDim dim_lat = get_nc_dim(_nc, dim_name_lat); if(IS_INVALID_NC(dim_lat)) dim_lat = get_nc_dim(_nc, "y"); @@ -2332,7 +2338,9 @@ int get_lat_count(NcFile *_nc) { return lat_count; } -int get_lon_count(NcFile *_nc) { +//////////////////////////////////////////////////////////////////////// + +static int get_lon_count(const NcFile *_nc) { int lon_count = 0; NcDim dim_lon = get_nc_dim(_nc, dim_name_lon); if(IS_INVALID_NC(dim_lon)) dim_lon = get_nc_dim(_nc, "x"); @@ -2342,14 +2350,19 @@ int get_lon_count(NcFile *_nc) { //////////////////////////////////////////////////////////////////////// -static NcVar get_goes_nc_var(NcFile *nc, const ConcatString var_name, +static NcVar get_goes_nc_var(NcFile *nc, const ConcatString &var_name, bool exit_if_error) { - NcVar var_data = get_nc_var(nc, var_name.c_str(), false); + NcVar var_data; + static const char *method_name = "get_goes_nc_var() -> "; + if (has_var(nc, var_name.c_str())) var_data = get_nc_var(nc, var_name.c_str(), false); if (IS_INVALID_NC(var_data)) { - var_data = get_nc_var(nc, var_name.split("_")[0].c_str()); + mlog << Debug(4) << method_name + << "The variable \"" << var_name << "\" does not exist. Find \"" + << var_name.split("_")[0] << "\" variable\n"; + var_data = get_nc_var(nc, var_name.split("_")[0].c_str()); } if (IS_INVALID_NC(var_data)) { - mlog << Error << "\nget_goes_nc_var() -> " + mlog << Error << "\n" << method_name << "The variable \"" << var_name << "\" does not exist\n\n"; if (exit_if_error) exit(1); } @@ -2359,8 +2372,7 @@ static NcVar get_goes_nc_var(NcFile *nc, const ConcatString var_name, //////////////////////////////////////////////////////////////////////// -static ConcatString make_geostationary_filename(Grid fr_grid, Grid to_grid, - ConcatString regrid_name) { +static ConcatString make_geostationary_filename(Grid fr_grid) { ConcatString geo_data_filename; GridInfo info = fr_grid.info(); @@ -2420,12 +2432,13 @@ static bool is_time_mismatch(NcFile *nc_in, NcFile *nc_adp) { //////////////////////////////////////////////////////////////////////// -void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, +static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, DataPlane &fr_dp, DataPlane &to_dp, Grid fr_grid, Grid to_grid, IntArray *cellMapping, NcFile *nc_adp) { bool has_qc_var = false; bool has_adp_qc_var = false; + const int log_debug_level = 4; clock_t start_clock = clock(); int to_lat_count = to_grid.ny(); int to_lon_count = to_grid.nx(); @@ -2436,15 +2449,19 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, ConcatString goes_var_sub_name; ConcatString qc_var_name; uchar qc_value; - uchar *qc_data = new uchar[from_data_size]; - uchar *adp_data = new uchar[from_data_size]; - float *from_data = new float[from_data_size]; - unsigned short *adp_qc_data = new unsigned short[from_data_size]; + auto qc_data = new uchar[from_data_size]; + auto adp_data = new uchar[from_data_size]; + auto from_data = new float[from_data_size]; + auto adp_qc_data = new unsigned short[from_data_size]; static const char *method_name = "regrid_goes_variable() -> "; // -99 is arbitrary number as invalid QC value memset(qc_data, -99, from_data_size*sizeof(uchar)); + adp_qc_high = 3; /* 3 as baseline algorithm, 0 for enterprise algorithm */ + adp_qc_medium = 1; /* 1 as baseline algorithm, 1 for enterprise algorithm */ + adp_qc_low = 0; /* 0 as baseline algorithm, 2 for enterprise algorithm */ + NcVar var_qc; NcVar var_adp; NcVar var_adp_qc; @@ -2452,7 +2469,7 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, bool is_dust_only = false; bool is_smoke_only = false; string actual_var_name = GET_NC_NAME(var_data); - int actual_var_len = actual_var_name.length(); + auto actual_var_len = actual_var_name.length(); bool is_adp_variable = (0 != actual_var_name.compare(vinfo->name().c_str())); memset(adp_data, 1, from_data_size*sizeof(uchar)); // Default: 1 = data present @@ -2467,13 +2484,14 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, else if (is_smoke_only) var_adp = get_goes_nc_var(nc_adp, vname_smoke); if (IS_VALID_NC(var_adp)) { - get_nc_data(&var_adp, adp_data); + get_nc_data(&var_adp, adp_data, true); - //Smoke:ancillary_variables = "DQF" ; ubyte DQF(y, x) ; + //ADP Smoke:ancillary_variables: ubyte DQF(y, x) if (get_att_value_string(&var_adp, (string)"ancillary_variables", qc_var_name)) { var_adp_qc = get_nc_var(nc_adp, qc_var_name.c_str()); if (IS_VALID_NC(var_adp_qc)) { get_nc_data(&var_adp_qc, adp_qc_data); + set_adp_gc_values(var_adp_qc); has_adp_qc_var = true; mlog << Debug(5) << method_name << "found QC var: " << qc_var_name << " for " << GET_NC_NAME(var_adp) << ".\n"; @@ -2490,7 +2508,7 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, mlog << Debug(5) << method_name << "is_dust: " << is_dust_only << ", is_smoke: " << is_smoke_only << "\n"; - //AOD:ancillary_variables = "DQF" ; byte DQF(y, x) ; + //AOD ancillary_variables: byte DQF(y, x) if (get_att_value_string(&var_data, (string)"ancillary_variables", qc_var_name)) { var_qc = get_nc_var(nc_in, qc_var_name.c_str()); if (IS_VALID_NC(var_qc)) { @@ -2505,7 +2523,7 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, } } - get_nc_data(&var_data, (float *)from_data); + get_nc_data(&var_data, from_data); fr_dp.set_size(from_lon_count, from_lat_count); for (int xIdx=0; xIdx 0); + std::set aod_qc_flags = prepare_qoes_qc_array(); missing_count = non_missing_count = 0; to_dp.set_constant(bad_data_double); + int shift_bits = 2; + if (is_dust_only) shift_bits += 2; + + int cnt_aod_qc_low = 0; + int cnt_aod_qc_high = 0; + int cnt_aod_qc_medium = 0; + int cnt_aod_qc_nr = 0; // no_retrieval_qf + int cnt_adp_qc_low = 0; + int cnt_adp_qc_high = 0; + int cnt_adp_qc_medium = 0; + int cnt_adp_qc_nr = 0; // no_retrieval_qf + int cnt_adp_qc_high_to_low = 0; + int cnt_adp_qc_high_to_medium = 0; + int cnt_adp_qc_medium_to_low = 0; for (int xIdx=0; xIdx= 4) { if (from_min_value > data_value) from_min_value = data_value; if (from_max_value < data_value) from_max_value = data_value; } + // Apply censor threshold + for(int i=0; icensor_thresh().n(); i++) { + // Break out after the first match. + if(vinfo->censor_thresh()[i].check(data_value)) { + data_value = vinfo->censor_val()[i]; + censored_count++; + break; + } + } + + // Check the data existance (always 1 if ADP variable does not exist) + if (0 == adp_data[from_index]) { + absent_count++; + continue; + } + // Filter by QC flag - qc_value = qc_data[from_index]; - if (!has_qc_var || !has_qc_flags || qc_flags.has(qc_value)) { - for(int i=0; icensor_thresh().n(); i++) { - // Break out after the first match. - if(vinfo->censor_thresh()[i].check(data_value)) { - data_value = vinfo->censor_val()[i]; - censored_count++; - break; + if (has_qc_flags && (has_qc_var || has_adp_qc_var)) { + qc_value = qc_data[from_index]; + GOES_QC aod_qc_flag = convert_aod_qc_flag(qc_value); + if (mlog.verbosity_level() >= log_debug_level) { + if (qc_min_value > qc_value) qc_min_value = qc_value; + if (qc_max_value < qc_value) qc_max_value = qc_value; + switch (aod_qc_flag) { + case GOES_QC::HIGH: cnt_aod_qc_high++; break; + case GOES_QC::MEDIUM: cnt_aod_qc_medium++; break; + case GOES_QC::LOW: cnt_aod_qc_low++; break; + default: cnt_aod_qc_nr++; break; } } - if (0 == adp_data[from_index]) { - absent_count++; - continue; - } + if (has_adp_qc_var) { + GOES_QC adp_qc_flag = compute_adp_qc_flag(adp_qc_data[from_index], shift_bits); + if (mlog.verbosity_level() >= log_debug_level) { + switch (adp_qc_flag) { + case GOES_QC::HIGH: cnt_adp_qc_high++; break; + case GOES_QC::MEDIUM: cnt_adp_qc_medium++; break; + case GOES_QC::LOW: cnt_adp_qc_low++; break; + default: cnt_adp_qc_nr++; break; + } + } - if (has_adp_qc_var && has_qc_flags) { - int shift_bits = 2; - if (is_dust_only) shift_bits += 2; - particle_qc = ((adp_qc_data[from_index] >> shift_bits) & 0x03); - int qc_for_flag = 3 - particle_qc; // high = 3, qc_flag for high = 0 - if (!qc_flags.has(qc_for_flag)) { + bool filter_out = GOES_QC::NA == adp_qc_flag; + if (!filter_out) { + /* Adjust the quality by AOD data QC */ + if (GOES_QC::LOW == aod_qc_flag) { + if (GOES_QC::LOW != adp_qc_flag) { + if (GOES_QC::HIGH == adp_qc_flag) cnt_adp_qc_high_to_low++; + else if (GOES_QC::MEDIUM == adp_qc_flag) cnt_adp_qc_medium_to_low++; + adp_qc_flag = GOES_QC::LOW; /* high/medium to low quality */ + } + } + else if (GOES_QC::MEDIUM == aod_qc_flag && GOES_QC::HIGH == adp_qc_flag) { + adp_qc_flag = GOES_QC::MEDIUM; /* high to medium quality */ + cnt_adp_qc_high_to_medium++; + } + if (0 == aod_qc_flags.count(adp_qc_flag)) filter_out = true; + } + if (filter_out) { adp_qc_filtered_count++; continue; } } - - dataArray.add(data_value); - if (mlog.verbosity_level() >= 4) { - if (qc_min_value > qc_value) qc_min_value = qc_value; - if (qc_max_value < qc_value) qc_max_value = qc_value; + else if (has_qc_var && 0 == aod_qc_flags.count(aod_qc_flag)) { + qc_filtered_count++; + continue; } } - else { - qc_filtered_count++; - } + dataArray.add(data_value); valid_count++; } if (0 < dataArray.n()) { int data_count = dataArray.n(); - float to_value; + double to_value; if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); else if (RGInfo.method == InterpMthd::Median) { @@ -2620,7 +2682,6 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, << data_count << " data values.\n"; } } - else {} } } @@ -2629,14 +2690,34 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, delete [] from_data; delete [] adp_qc_data; - mlog << Debug(4) << method_name << "Count: actual: " << to_cell_count + int cnt_adjused_low = cnt_adp_qc_low + cnt_adp_qc_high_to_low + cnt_adp_qc_medium_to_low; + int cnt_adjused_high = cnt_adp_qc_high - cnt_adp_qc_high_to_medium - cnt_adp_qc_high_to_low; + int cnt_adjused_medium = cnt_adp_qc_medium + cnt_adp_qc_high_to_medium - cnt_adp_qc_medium_to_low; + int cnt_adjused_total = cnt_adp_qc_high_to_medium + cnt_adp_qc_high_to_low + cnt_adp_qc_medium_to_low; + + mlog << Debug(log_debug_level) << method_name << "Count: actual: " << to_cell_count << ", missing: " << missing_count << ", non_missing: " << non_missing_count - << "\n\tFiltered: by QC: " << qc_filtered_count + << "\n Filtered: by QC: " << qc_filtered_count << ", by adp QC: " << adp_qc_filtered_count << ", by absent: " << absent_count << ", total: " << (qc_filtered_count + adp_qc_filtered_count + absent_count) - << "\n\tRange: data: [" << from_min_value << " - " << from_max_value + << "\n Range: data: [" << from_min_value << " - " << from_max_value << "] QC: [" << qc_min_value << " - " << qc_max_value << "]\n"; + if (has_qc_flags) { + mlog << Debug(log_debug_level) + << " AOD QC: high=" << cnt_aod_qc_high + << " medium=" << cnt_aod_qc_medium << ", low=" << cnt_aod_qc_low + << ", no_retrieval=" << cnt_aod_qc_nr + << "\n ADP QC: high=" << cnt_adjused_high << " (" << cnt_adp_qc_high + << "), medium=" << cnt_adjused_medium << " (" << cnt_adp_qc_medium + << "), low=" << cnt_adjused_low << " (" << cnt_adp_qc_low + << "), no_retrieval=" << cnt_adp_qc_nr + << "\n adjusted: high to medium=" << cnt_adp_qc_high_to_medium + << ", high to low=" << cnt_adp_qc_high_to_low + << ", medium to low=" << cnt_adp_qc_medium_to_low + << ", total=" << cnt_adjused_total + << "\n"; + } if (to_cell_count == 0) { mlog << Warning << "\n" << method_name @@ -2651,7 +2732,7 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, static void save_geostationary_data(const ConcatString geostationary_file, const float *latitudes, const float *longitudes, - const GoesImagerData grid_data) { + const GoesImagerData &grid_data) { bool has_error = false; int deflate_level = 0; clock_t start_clock = clock(); @@ -2674,7 +2755,7 @@ static void save_geostationary_data(const ConcatString geostationary_file, add_att(&lat_var, "units","degrees_south"); } add_att(&lat_var, "dy_rad", grid_data.dy_rad); - if(!put_nc_data((NcVar *)&lat_var, latitudes)) { + if(!put_nc_data(&lat_var, latitudes)) { has_error = true; mlog << Warning << "\nsave_geostationary_data() -> " << "Cannot save latitudes!\n\n"; @@ -2690,7 +2771,7 @@ static void save_geostationary_data(const ConcatString geostationary_file, add_att(&lon_var, "units","degrees_west"); } add_att(&lon_var, "dx_rad", grid_data.dx_rad); - if(!put_nc_data((NcVar *)&lon_var, longitudes)) { + if(!put_nc_data(&lon_var, longitudes)) { has_error = true; mlog << Warning << "\nsave_geostationary_data() -> " << "Cannot save longitudes!\n\n"; @@ -2710,7 +2791,7 @@ static void save_geostationary_data(const ConcatString geostationary_file, << geostationary_file << ") was saved\n"; } - delete nc_file; nc_file = 0; + delete nc_file; nc_file = nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; @@ -2718,7 +2799,7 @@ static void save_geostationary_data(const ConcatString geostationary_file, //////////////////////////////////////////////////////////////////////// -void close_nc() { +static void close_nc() { // Clean up if(nc_out) { @@ -2734,8 +2815,7 @@ void close_nc() { //////////////////////////////////////////////////////////////////////// -//bool keep_message_type(const char *mt_str) { -bool keep_message_type(const int mt_index) { +static bool keep_message_type(const int mt_index) { bool keep = false; @@ -2747,7 +2827,7 @@ bool keep_message_type(const int mt_index) { //////////////////////////////////////////////////////////////////////// -bool has_lat_lon_vars(NcFile *nc) { +static bool has_lat_lon_vars(const NcFile *nc) { bool has_lat_var = IS_VALID_NC(get_nc_var_lat(nc)); bool has_lon_var = IS_VALID_NC(get_nc_var_lon(nc)); @@ -2763,7 +2843,7 @@ bool has_lat_lon_vars(NcFile *nc) { //////////////////////////////////////////////////////////////////////// -void usage() { +__attribute__((noreturn)) static void usage() { cout << "\n*** Model Evaluation Tools (MET" << met_version << ") ***\n\n" @@ -2839,13 +2919,42 @@ void usage() { //////////////////////////////////////////////////////////////////////// -void set_field(const StringArray &a) { +static void set_adp_gc_values(NcVar var_adp_qc) { + ConcatString att_flag_meanings; + + if (get_nc_att_value(&var_adp_qc, (ConcatString)"flag_meanings", att_flag_meanings)) { + StringArray flag_meanings = to_lower(att_flag_meanings).split(" "); + unsigned short flag_values[flag_meanings.n()+128]; /* reserve enough storage */ + for (int i=0; i> 2) & 0x03; + } + if (flag_meanings.has("medium_confidence_smoke_detection_qf", idx)) { + adp_qc_medium = (flag_values[idx] >> 2) & 0x03; + } + if (flag_meanings.has("high_confidence_smoke_detection_qf", idx)) { + adp_qc_high = (flag_values[idx] >> 2) & 0x03; + } + } + mlog << Debug(4) << "set_adp_gc_values() " + << " high_confidence = " << adp_qc_high + << ", medium_confidence = " << adp_qc_medium + << ", low_confidence = " << adp_qc_low << "\n"; + } +} + +//////////////////////////////////////////////////////////////////////// + +static void set_field(const StringArray &a) { FieldSA.add(a[0]); } //////////////////////////////////////////////////////////////////////// -void set_method(const StringArray &a) { +static void set_method(const StringArray &a) { InterpMthd method_id = string_to_interpmthd(a[0].c_str()); if (method_id == InterpMthd::Gaussian || method_id == InterpMthd::MaxGauss ) { do_gaussian_filter = true; @@ -2857,13 +2966,13 @@ void set_method(const StringArray &a) { //////////////////////////////////////////////////////////////////////// -void set_prob_cat_thresh(const StringArray &a) { +static void set_prob_cat_thresh(const StringArray &a) { prob_cat_thresh.set(a[0].c_str()); } //////////////////////////////////////////////////////////////////////// -void set_vld_thresh(const StringArray &a) { +static void set_vld_thresh(const StringArray &a) { RGInfo.vld_thresh = atof(a[0].c_str()); if(RGInfo.vld_thresh > 1 || RGInfo.vld_thresh < 0) { mlog << Error << "\nset_vld_thresh() -> " @@ -2875,25 +2984,25 @@ void set_vld_thresh(const StringArray &a) { //////////////////////////////////////////////////////////////////////// -void set_name(const StringArray & a) { +static void set_name(const StringArray & a) { VarNameSA.add_css(a[0]); } //////////////////////////////////////////////////////////////////////// -void set_config(const StringArray & a) { +static void set_config(const StringArray & a) { config_filename = a[0]; } //////////////////////////////////////////////////////////////////////// -void set_compress(const StringArray & a) { +static void set_compress(const StringArray & a) { compress_level = atoi(a[0].c_str()); } //////////////////////////////////////////////////////////////////////// -void set_qc_flags(const StringArray & a) { +static void set_qc_flags(const StringArray & a) { int qc_flag; StringArray sa; @@ -2906,24 +3015,24 @@ void set_qc_flags(const StringArray & a) { //////////////////////////////////////////////////////////////////////// -void set_adp(const StringArray & a) { - AdpFilename = a[0]; - if (!file_exists(AdpFilename.c_str())) { +static void set_adp(const StringArray & a) { + adp_filename = a[0]; + if (!file_exists(adp_filename.c_str())) { mlog << Error << "\nset_adp() -> " - << "\"" << AdpFilename << "\" does not exist\n\n"; + << "\"" << adp_filename << "\" does not exist\n\n"; exit(1); } } //////////////////////////////////////////////////////////////////////// -void set_gaussian_dx(const StringArray &a) { +static void set_gaussian_dx(const StringArray &a) { RGInfo.gaussian.dx = atof(a[0].c_str()); } //////////////////////////////////////////////////////////////////////// -void set_gaussian_radius(const StringArray &a) { +static void set_gaussian_radius(const StringArray &a) { RGInfo.gaussian.radius = atof(a[0].c_str()); } diff --git a/src/tools/other/point2grid/point2grid_conf_info.cc b/src/tools/other/point2grid/point2grid_conf_info.cc index ba2989212f..ad661ebfe8 100644 --- a/src/tools/other/point2grid/point2grid_conf_info.cc +++ b/src/tools/other/point2grid/point2grid_conf_info.cc @@ -85,7 +85,7 @@ void PointToGridConfInfo::read_config(const char *default_file_name, void PointToGridConfInfo::process_config() { ConcatString s; StringArray sa; - Dictionary *dict = (Dictionary *) nullptr; + auto dict = (Dictionary *) nullptr; // Dump the contents of the config file if(mlog.verbosity_level() >= 5) conf.dump(cout); @@ -126,7 +126,7 @@ void PointToGridConfInfo::process_config() { //////////////////////////////////////////////////////////////////////// -ConcatString PointToGridConfInfo::get_var_id(const ConcatString var_name) { +ConcatString PointToGridConfInfo::get_var_id(const ConcatString &var_name) { ConcatString var_id; map::iterator ptr; @@ -136,7 +136,7 @@ ConcatString PointToGridConfInfo::get_var_id(const ConcatString var_name) { break; } } - + if( var_id.empty() ) { for (ptr=def_var_name_map.begin(); ptr != def_var_name_map.end(); ptr++) { if( ptr->second == var_name ) { @@ -151,17 +151,14 @@ ConcatString PointToGridConfInfo::get_var_id(const ConcatString var_name) { //////////////////////////////////////////////////////////////////////// -ConcatString PointToGridConfInfo::get_var_name(const ConcatString var_name) { +ConcatString PointToGridConfInfo::get_var_name(const ConcatString &var_name) { ConcatString out_var; - ConcatString t_name; - - t_name = var_name_map[var_name]; + ConcatString t_name = var_name_map[var_name]; if (t_name.empty()) t_name = def_var_name_map[var_name]; if (t_name.empty()) { - ConcatString tmp_key, tmp_value; - tmp_key = "grib_code_"; + ConcatString tmp_key = "grib_code_"; tmp_key << atoi(var_name.c_str()); - tmp_value = var_name_map[tmp_key]; + ConcatString tmp_value = var_name_map[tmp_key]; if (tmp_value.empty()) tmp_value = def_var_name_map[tmp_key]; if (!tmp_value.empty()) t_name = tmp_value; } diff --git a/src/tools/other/point2grid/point2grid_conf_info.h b/src/tools/other/point2grid/point2grid_conf_info.h index f6dff25b55..5b12b6166e 100644 --- a/src/tools/other/point2grid/point2grid_conf_info.h +++ b/src/tools/other/point2grid/point2grid_conf_info.h @@ -29,8 +29,6 @@ class PointToGridConfInfo { private: void init_from_scratch(); - - protected: std::map var_name_map; std::map def_var_name_map; @@ -54,8 +52,8 @@ class PointToGridConfInfo { void process_config(); void read_config(const char *, const char *); - ConcatString get_var_name(const ConcatString); - ConcatString get_var_id(const ConcatString); + ConcatString get_var_name(const ConcatString &); + ConcatString get_var_id(const ConcatString &); }; //////////////////////////////////////////////////////////////////////// From 66dca0d6493955c0a9fae4534c2b4f7b12eb96fe Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 23 May 2024 10:03:31 -0600 Subject: [PATCH 082/114] Hotfix to develop to fix the update_truth.yml workflow logic. This testing workflow run failed (https://github.com/dtcenter/MET/actions/runs/9209471209). Here we switch to a unique update truth branch name to avoid conflicts. --- .github/workflows/update_truth.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/update_truth.yml b/.github/workflows/update_truth.yml index adb67ecacc..fe57a9aa83 100644 --- a/.github/workflows/update_truth.yml +++ b/.github/workflows/update_truth.yml @@ -32,6 +32,7 @@ jobs: fetch-depth: 0 token: ${{ secrets.METPLUS_BOT_TOKEN }} - name: Resolve conflicts between branch and branch-ref + id: resolve_conflicts run: | branch_name=${{ env.branch_name }} cd ${GITHUB_WORKSPACE} @@ -39,23 +40,38 @@ jobs: echo ERROR: ${branch_name}-ref does not exist exit 1 fi - + echo ${branch_name}-ref does exist -- update it git config --global user.name "metplus-bot" git config --global user.email "97135045+metplus-bot@users.noreply.github.com" + + # checkout branch (develop or main_vX.Y) echo git checkout ${branch_name} git checkout ${branch_name} - echo git checkout -b update_truth_for_${branch_name} - git checkout -b update_truth_for_${branch_name} + + # merge -ref branch into branch (favoring branch changes) echo git merge -s ours origin/${branch_name}-ref git merge -s ours origin/${branch_name}-ref - echo git push origin update_truth_for_${branch_name} - git push origin update_truth_for_${branch_name} + + # push changes to branch (develop or main_vX.Y) + echo git push origin ${branch_name} + git push origin ${branch_name} + + # create unique branch name to update *-ref branch + update_branch=update_${branch_name}_$(uuidgen | cut -d "-" -f1) + echo "update_branch=${update_branch}" >> $GITHUB_OUTPUT + + # create update branch from branch (develop or main_vX.Y) + echo git checkout -b ${update_branch} + git checkout -b ${update_branch} + echo git push origin ${update_branch} + git push origin ${update_branch} - name: Create Pull Request - run: gh pr create --base $BASE --body "$BODY" --title "$TITLE" + run: gh pr create --head $HEAD --base $BASE --body "$BODY" --title "$TITLE" env: GH_TOKEN: ${{ github.token }} + HEAD: ${{ steps.resolve_conflicts.outputs.update_branch }} BASE: ${{ env.branch_name }}-ref - BODY: ${{ github.event.inputs.change_summary }}
Created by @${{ github.actor}} + BODY: ${{ github.event.inputs.change_summary }}
Created by @${{ github.actor }} TITLE: Update ${{ env.branch_name }}-ref after ${{ github.event.inputs.pull_requests }} From 942959e13d8353ac5ebb06497e2d54118e21b834 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 23 May 2024 10:28:59 -0600 Subject: [PATCH 083/114] Avoid pushing directly to the develop or main_vX.Y branches since that is not necessary for the automation logic in MET. --- .github/workflows/update_truth.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/update_truth.yml b/.github/workflows/update_truth.yml index fe57a9aa83..a5ce785489 100644 --- a/.github/workflows/update_truth.yml +++ b/.github/workflows/update_truth.yml @@ -12,7 +12,7 @@ on: jobs: update_truth: - name: "Update or create truth reference branch" + name: "Update reference branch truth data" runs-on: ubuntu-latest steps: - name: Check if branch is develop or main_vX.Y @@ -31,7 +31,7 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.METPLUS_BOT_TOKEN }} - - name: Resolve conflicts between branch and branch-ref + - name: Resolve conflicts with an update branch id: resolve_conflicts run: | branch_name=${{ env.branch_name }} @@ -49,21 +49,17 @@ jobs: echo git checkout ${branch_name} git checkout ${branch_name} - # merge -ref branch into branch (favoring branch changes) - echo git merge -s ours origin/${branch_name}-ref - git merge -s ours origin/${branch_name}-ref - - # push changes to branch (develop or main_vX.Y) - echo git push origin ${branch_name} - git push origin ${branch_name} - # create unique branch name to update *-ref branch update_branch=update_${branch_name}_$(uuidgen | cut -d "-" -f1) echo "update_branch=${update_branch}" >> $GITHUB_OUTPUT - - # create update branch from branch (develop or main_vX.Y) echo git checkout -b ${update_branch} git checkout -b ${update_branch} + + # merge -ref branch into the update branch (favoring update branch changes) + echo git merge -s ours origin/${branch_name}-ref + git merge -s ours origin/${branch_name}-ref + + # push update branch to origin echo git push origin ${update_branch} git push origin ${update_branch} From f368db937da671970c696afb15cace5a6c99cfcd Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 7 Jun 2024 13:41:05 -0600 Subject: [PATCH 084/114] #2904 Changed R path to R-4.4.0 (#2905) Co-authored-by: Howard Soh --- internal/scripts/environment/development.seneca | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scripts/environment/development.seneca b/internal/scripts/environment/development.seneca index 7007241362..4f15f6ff73 100644 --- a/internal/scripts/environment/development.seneca +++ b/internal/scripts/environment/development.seneca @@ -46,7 +46,7 @@ export MET_TEST_INPUT=${MET_PROJ_DIR}/MET_test_data/unit_test export MET_FONT_DIR=${MET_TEST_INPUT}/fonts # Define Rscript to use a version with the ncdf4 package 1.17 or later -export MET_TEST_RSCRIPT=/nrit/ral/R-4.3.1/bin/Rscript +export MET_TEST_RSCRIPT=/nrit/ral/R-4.4.0/bin/Rscript # Define runtime Python version export MET_TEST_MET_PYTHON_EXE=${MET_PYTHON_BIN_EXE} From bdcfcf852543643212baf98a564996eed172ae1f Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 12 Jun 2024 11:07:07 -0600 Subject: [PATCH 085/114] Feature #2912 pb2nc error (#2914) --- src/tools/other/pb2nc/pb2nc.cc | 59 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index 2561288484..e393a17f57 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -386,6 +386,7 @@ static bool insert_pbl(float *obs_arr, const float pbl_value, const int pbl_co static int interpolate_by_pressure(int length, float *pres_data, float *var_data); static void interpolate_pqtzuv(float*, float*, float*); static bool is_valid_pb_data(float pb_value); +static void check_fortran_file_id(const int unit, const char *method_name); static void log_merged_tqz_uv(map pqtzuv_map_tq, map pqtzuv_map_uv, map &pqtzuv_map_merged, @@ -431,10 +432,7 @@ void dump_pb_data( msg_typ_ret[i] = keep_message_type(vld_msg_typ_list[i]); } - if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { - mlog << Error << "\n" << method_name - << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; - } + check_fortran_file_id(unit, method_name); dumppb_(blk_file.c_str(), &unit, dump_dir.c_str(), &len1, prefix.c_str(), &len2, msg_typ_ret); } @@ -661,14 +659,12 @@ ConcatString save_bufr_table_to_file(const char *blk_file, int _file_id) { int len; ConcatString tbl_filename; ConcatString tbl_prefix; + const char *method_name = "save_bufr_table_to_file() "; tbl_prefix << conf_info.tmp_dir << "/" << tmp_pb2nc_base; tbl_filename = make_temp_file_name(tbl_prefix.c_str(), "tbl"); len = tbl_filename.length(); - if (_file_id > MAX_FORTRAN_FILE_ID || _file_id < MIN_FORTRAN_FILE_ID) { - mlog << Error << "\nsave_bufr_table_to_file() -> " - << "Invalid file ID [" << _file_id << "] between 1 and 99.\n\n"; - } + check_fortran_file_id(_file_id, method_name); openpb_(blk_file, &_file_id); dump_tbl_(blk_file, &_file_id, tbl_filename.c_str(), &len); closepb_(&_file_id); @@ -822,6 +818,7 @@ void get_variable_info(ConcatString blk_file, int unit) { } remove_temp_file(tbl_filename); + return; } @@ -946,16 +943,12 @@ void process_pbfile(int i_pb) { unit = dump_unit+i_pb; prefix = get_short_name(pbfile[i_pb].c_str()); - dump_pb_data((dump_unit+i_pb), prefix, blk_file, method_name); + dump_pb_data((dump_unit+i_pb), prefix, blk_file, method_name_s); } - // Open the blocked temp PrepBufr file for reading unit = file_unit + i_pb; - if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { - mlog << Error << "\n" << method_name - << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; - } + check_fortran_file_id(unit, method_name_s); openpb_(blk_file.c_str(), &unit); // Compute the number of PrepBufr records in the current file. @@ -2143,18 +2136,12 @@ void process_pbfile_metadata(int i_pb) { pblock(file_name.c_str(), blk_file.c_str(), Action::block); unit = dump_unit + i_pb + file_unit; - if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { - mlog << Error << "\n" << method_name << " -> " - << "Invalid file ID [" << unit << "] between 1 and 99 for BUFR table.\n\n"; - } + check_fortran_file_id(unit, method_name); get_variable_info(blk_file, unit); // The input PrepBufr file is blocked already. unit = dump_unit + i_pb; - if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { - mlog << Error << "\n" << method_name << " -> " - << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; - } + check_fortran_file_id(unit, method_name); // Compute the number of PrepBufr records in the current file. numpbmsg_new_(blk_file.c_str(), &unit, &npbmsg); @@ -2511,11 +2498,13 @@ void write_netcdf_hdr_data() { // Check for no messages retained if(dim_count <= 0) { - mlog << Error << "\n" << method_name << "-> " - << "No PrepBufr messages retained. Nothing to write.\n\n"; + mlog << Warning << "\n" << method_name << "-> " + << "No PrepBufr messages retained. No output file written.\n\n"; + // Delete the NetCDF file remove_temp_file(ncfile); - exit(1); + + return; } nc_point_obs.get_obs_vars()->attr_pb2nc = true; @@ -3130,8 +3119,10 @@ float compute_pbl(map pqtzuv_map_tq, selected_levels.add(nint(pqtzuv[0])); } if (start_offset > 0) { - // Replace the interpolated records with common records. - mlog << Error << "\n" << method_name << "Excluded " << start_offset << " records\n"; + + // Replace the interpolated records with common records + mlog << Debug(5) << method_name << "Excluded " << start_offset << " records\n"; + // Find vertical levels with both data float highest_pressure = bad_data_float; for (it = pqtzuv_map_tq.begin(); it!=pqtzuv_map_tq.end(); ++it) { @@ -3318,8 +3309,8 @@ void interpolate_pqtzuv(float *prev_pqtzuv, float *cur_pqtzuv, float *next_pqtzu if ((nint(prev_pqtzuv[0]) == nint(cur_pqtzuv[0])) || (nint(next_pqtzuv[0]) == nint(cur_pqtzuv[0])) || (nint(prev_pqtzuv[0]) == nint(next_pqtzuv[0]))) { - mlog << Error << "\n" << method_name - << " Can't interpolate because of same pressure levels. prev: " + mlog << Debug(9) << method_name + << " can't interpolate because of same pressure levels. prev: " << prev_pqtzuv[0] << ", cur: " << cur_pqtzuv[0] << ", next: " << prev_pqtzuv[0] << "\n\n"; } @@ -3359,6 +3350,16 @@ static bool is_valid_pb_data(float pb_value) { //////////////////////////////////////////////////////////////////////// +void check_fortran_file_id(const int unit, const char *method_name) { + if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { + mlog << Error << "\n" << method_name << " -> " + << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; + exit(1); + } +} + +//////////////////////////////////////////////////////////////////////// + void merge_records(float *first_pqtzuv, map pqtzuv_map_pivot, map pqtzuv_map_aux, map &pqtzuv_map_merged) { From 6f75e5adb7c25e23bd95dd7caa602c58e376db24 Mon Sep 17 00:00:00 2001 From: natalieb-noaa <146213121+natalieb-noaa@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:44:33 -0400 Subject: [PATCH 086/114] Feature 2717 convert unit.pl to unit.py (#2871) * created unit.py module in new internal/test_unit/python directory * added xml parsing to unit.py * added repl_env function * added reading of the remaining xml tags in build_tests function * progress on main function (putting together test commands) * a few more lines in the main function * minor updates * fixed how the test command was being run * added if name/main and command line parsing * fixed handling of no 'env' in cmd_only mode * handle params from xml that have \ after filename without space in between * added logging * added some more pieces to unit * more updates to unit.py, including running checks on output files * bug fixes, improved handling of output file names, improved handling of env vars, improved logging output * fixed how shell commands are run, and other minor fixes * added last bits from the perl script, fixed some bugs * created unit.py module in new internal/test_unit/python directory * added xml parsing to unit.py * added repl_env function * added reading of the remaining xml tags in build_tests function * progress on main function (putting together test commands) * a few more lines in the main function * minor updates * update scripts to call python unit test script instead of the old perl script * fix she-bang line to allow script to be run without python3 before it * add missing test_dir and exit_on_fail tags that are found in the rest of the unit test xml files * fix call to logger.warning * change tags named 'exists' to 'exist' to match the rest of the xml files * added logger to function * removed tab at end of line that was causing output file path to be excluded from the command * fix broken checks for output files * incorporated george's recommended changes * changed default to overwrite logs; allow for more than one xml file to be passed in command --------- Co-authored-by: Natalie babij Co-authored-by: Natalie babij Co-authored-by: Natalie babij Co-authored-by: Natalie Babij Co-authored-by: John Halley Gotway Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> Co-authored-by: j-opatz --- .github/jobs/run_unit_tests.sh | 2 +- internal/test_unit/bin/unit_test.sh | 14 +- internal/test_unit/python/unit.py | 389 ++++++++++++++++++ internal/test_unit/xml/unit_point_stat.xml | 2 + internal/test_unit/xml/unit_python.xml | 23 +- .../test_unit/xml/unit_ref_config_lead_12.xml | 2 +- internal/test_unit/xml/unit_tc_diag.xml | 6 +- internal/test_unit/xml/unit_ugrid.xml | 7 +- 8 files changed, 419 insertions(+), 26 deletions(-) create mode 100755 internal/test_unit/python/unit.py diff --git a/.github/jobs/run_unit_tests.sh b/.github/jobs/run_unit_tests.sh index e866b2cc61..b85bac84fe 100755 --- a/.github/jobs/run_unit_tests.sh +++ b/.github/jobs/run_unit_tests.sh @@ -15,7 +15,7 @@ source ${MET_REPO_DIR}/.github/jobs/test_env_vars.sh echo "Running MET unit tests..." for testname in $TESTS_TO_RUN; do CMD_LOGFILE=/met/logs/unit_${testname}.log - time_command ${MET_TEST_BASE}/perl/unit.pl ${MET_TEST_BASE}/xml/unit_${testname}.xml + time_command ${MET_TEST_BASE}/python/unit.py ${MET_TEST_BASE}/xml/unit_${testname}.xml if [ $? != 0 ]; then echo "ERROR: Unit test ${testname} failed" cat /met/logs/unit_${testname}.log diff --git a/internal/test_unit/bin/unit_test.sh b/internal/test_unit/bin/unit_test.sh index 0f0493720f..0e2579464d 100755 --- a/internal/test_unit/bin/unit_test.sh +++ b/internal/test_unit/bin/unit_test.sh @@ -24,14 +24,14 @@ if [[ -z "${MET_TEST_MET_PYTHON_EXE}" ]] ; then export MET_TEST_MET_PYTHON_EXE=/usr/local/python3/bin/python3 fi -PERL_UNIT_OPTS="" +UNIT_OPTS="" for arg in $@; do - [ $arg == "-memchk" -o $arg == "memchk" ] && PERL_UNIT_OPTS="$PERL_UNIT_OPTS -memchk" - [ $arg == "-callchk" -o $arg == "callchk" ] && PERL_UNIT_OPTS="$PERL_UNIT_OPTS -callchk" + [ $arg == "-memchk" -o $arg == "memchk" ] && UNIT_OPTS="$UNIT_OPTS -memchk" + [ $arg == "-callchk" -o $arg == "callchk" ] && UNIT_OPTS="$UNIT_OPTS -callchk" done # Unit test script -PERL_UNIT=${MET_TEST_BASE}/perl/unit.pl +UNIT=${MET_TEST_BASE}/python/unit.py # Unit test XML UNIT_XML="unit_ascii2nc.xml \ @@ -107,15 +107,15 @@ UNIT_XML="${UNIT_XML} unit_ugrid.xml" for CUR_XML in ${UNIT_XML}; do echo - echo "CALLING: ${PERL_UNIT} $PERL_UNIT_OPTS ${MET_TEST_BASE}/xml/${CUR_XML}" + echo "CALLING: ${UNIT} $UNIT_OPTS ${MET_TEST_BASE}/xml/${CUR_XML}" echo - ${PERL_UNIT} $PERL_UNIT_OPTS ${MET_TEST_BASE}/xml/${CUR_XML} + ${UNIT} $UNIT_OPTS ${MET_TEST_BASE}/xml/${CUR_XML} RET_VAL=$? # Fail on non-zero return status if [ ${RET_VAL} != 0 ]; then echo - echo "ERROR: ${PERL_UNIT} ${CUR_XML} failed." + echo "ERROR: ${UNIT} ${CUR_XML} failed." echo echo "*** UNIT TESTS FAILED ***" echo diff --git a/internal/test_unit/python/unit.py b/internal/test_unit/python/unit.py new file mode 100755 index 0000000000..831a540b32 --- /dev/null +++ b/internal/test_unit/python/unit.py @@ -0,0 +1,389 @@ +#! /usr/bin/env python3 + +from datetime import datetime as dt +import logging +import os +from pathlib import Path +import re +import subprocess +import sys +import xml.etree.ElementTree as ET + +def unit(test_xml, file_log=None, cmd_only=False, noexit=False, memchk=False, callchk=False, log_overwrite=True): + """ + Parse a unit test xml file, run the associated tests, and display test results. + + Parameters + ----------- + test_xml : pathlike + path to file containing the unit test(s) to perform + file_log : pathlike, default None + if present, write output from each test to the specified file + cmd_only : bool, default False + if true, print the test commands but do not run them (overrides file_log) + noexit : bool, default False + if true, the unit tester will continue executing subsequent + tests when a test fails + memchk : bool, default False + if true, activate valgrind with memcheck + callchk : bool, default False + if true, activate valgrind with callcheck + log_overwrite : bool, default True + when true, if file_log points to an existing file, that file will be overwritten. + when false, new log records will be appended to the existing file. + """ + + # initialize logger + logger = logging.getLogger(__name__) + logger.setLevel(logging.DEBUG) + + # create/add console handler + ch = logging.StreamHandler() + ch.setLevel(logging.INFO) + logger.addHandler(ch) + + # create/add file handler + if file_log and not cmd_only: + if log_overwrite: + file_mode = 'w' + else: + file_mode = 'a' + fh = logging.FileHandler(file_log, mode=file_mode) + fh.setLevel(logging.DEBUG) + logger.addHandler(fh) + + # parse xml file + try: + test_root = ET.parse(test_xml) + except Exception as e: + logger.exception(f"ERROR: Unable to parse xml from {test_xml}") + raise + + # parse the children of the met_test element + if test_root.getroot().tag != 'met_test': + logger.error(f"ERROR: unexpected top-level element. Expected 'met_test', got '{test_root.tag}'") + sys.exit(1) + # read test_dir + try: + test_dir = test_root.find('test_dir').text + mgnc = repl_env(test_dir + '/bin/mgnc.sh') + mpnc = repl_env(test_dir + '/bin/mpnc.sh') + except Exception as e: + logger.warning(f"WARNING: unable to read test_dir from {test_xml}") + pass + + tests = build_tests(test_root) + + # determine the max length of the test names + # not used, unless format of test result display is changed + name_wid = max([len(test['name']) for test in tests]) + + VALGRIND_OPT_MEM ="--leak-check=full --show-leak-kinds=all --error-limit=no -v" + VALGRIND_OPT_CALL ="--tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes" + + # run each test + for test in tests: + # # print the test name ... may want to change this to only if cmd_only=False + logger.debug("\n") + logger.info(f"TEST: {test['name']}") + + # # prepare the output space + output_keys = [key for key in test.keys() if key.startswith('out_')] + outputs = [output for key in output_keys for output in test[key]] + for output in outputs: + try: + Path(output).unlink() + except FileNotFoundError: + pass + except Exception as e: + logger.exception() + raise + output_dir = Path(output).parent + output_dir.mkdir(parents=True, exist_ok=True) #should error/warning be raised if dir already exists? + + # # set the test environment variables + set_envs = [] + if 'env' in test.keys(): + for key, val in sorted(test['env'].items()): + os.environ[key] = val + set_cmd = f"export {key}={val}" + logger.debug(set_cmd) + set_envs.append(set_cmd) + + # # build the text command + cmd = (test['exec'] + test['param']).strip() + + if memchk: + cmd = f"valgrind {VALGRIND_OPT_MEM} {cmd}" + elif callchk: + cmd = f"valgrind {VALGRIND_OPT_CALL} {cmd}" + + + # # if writing a command file, print the environment and command, then loop + # consider tying this into logging... + if cmd_only: + if 'env' in test.keys(): + for key, val in sorted(test['env'].items()): + print(f"export {key}={val}") + print(f"{cmd}") + if 'env' in test.keys(): + for key, val in sorted(test['env'].items()): + print(f"unset {key}") + print("\n") + + # # run and time the test command + else: + logger.debug(f"{cmd}") + t_start = dt.now() + cmd_return = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True) + t_elaps = dt.now() - t_start + + cmd_outs = cmd_return.stdout + logger.debug(f"{cmd_outs}") + logger.debug(f"Return code: {cmd_return.returncode}") + + # # check the return status and output files + ret_ok = not cmd_return.returncode + if ret_ok: + out_ok = True + + for filepath in test['out_pnc']: + result = subprocess.run([mpnc, '-v', filepath], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + cmd_outs += ("\n"+result.stdout) + logger.debug(result.stdout) + if result.returncode: + out_ok = False + + for filepath in test['out_gnc']: + result = subprocess.run([mgnc, '-v', filepath], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + cmd_outs += ("\n"+result.stdout) + logger.debug(result.stdout) + if result.returncode: + out_ok = False + + for filepath in test['out_stat']: + # check stat file exists and is nonzero size + try: + filesize = os.stat(filepath).st_size + if filesize==0: + cmd_outs += (f"\nERROR: stat file empty {filepath}\n") + out_ok = False + break + except FileNotFoundError: + cmd_outs += (f"\nERROR: stat file missing {filepath}\n") + logger.debug(result.stdout) + out_ok = False + break + # check stat file has non-header lines + with open(filepath) as f: + numlines = len([l for l in f.readlines() if not l.startswith('VERSION')]) + if numlines==0: + cmd_outs += (f"\nERROR: stat data missing from file {filepath}\n") + out_ok = False + + for filepath in test['out_ps']: + # check postscript file exists and is nonzero size + try: + filesize = os.stat(filepath).st_size + if filesize==0: + cmd_outs += (f"\nERROR: postscript file empty {filepath}\n") + out_ok = False + break + except FileNotFoundError: + cmd_outs += (f"\nERROR: postscript file missing {filepath}\n") + out_ok = False + break + # check for ghostscript errors + result = subprocess.run(['gs', '-sDEVICE=nullpage', '-dQUIET', '-dNOPAUSE', '-dBATCH', filepath]) + if result.returncode: + cmd_outs += (f"\nERROR: ghostscript error for postscript file {filepath}") + out_ok = False + + for filepath in test['out_exist']: + # check output file exists and is nonzero size + try: + filesize = os.stat(filepath).st_size + if filesize==0: + cmd_outs += (f"\nERROR: file empty {filepath}\n") + out_ok = False + break + except FileNotFoundError: + cmd_outs += (f"\nERROR: file missing when it should exist {filepath}\n") + out_ok = False + + for filepath in test['out_not_exist']: + # check output file doesn't exist + if os.path.isfile(filepath): + cmd_outs += (f"\nERROR: file exists when it should be missing {filepath}\n") + out_ok = False + + # # unset the test environment variables + unset_envs = [] + if 'env' in test.keys(): + for key, val in sorted(test['env'].items()): + del os.environ[key] + unset_cmd = f"unset {key}" + logger.debug(unset_cmd) + unset_envs.append(unset_cmd) + + # # print the test result + test_result = "pass" if (ret_ok and out_ok) else "FAIL" + logger.info(f"\t- {test_result} - \t{round(t_elaps.total_seconds(),3)} sec") + + # # on failure, print the problematic test and exit, if requested + if not (ret_ok and out_ok): + logger.info("\n".join(set_envs) + cmd + cmd_outs + "\n".join(unset_envs) + "\n") + if not noexit: + sys.exit(1) + + # clean up logger/handlers (to avoid duplicate logging when this function is looped) + logger.removeHandler(ch) + try: + logger.removeHandler(fh) + except NameError: + pass + + +def build_tests(test_root): + """ + Parse the test components. + + Take an ElementTree element extracted from a unit test xml file. + Return a list of all tests, where each test is represented as a dictionary, + with its keys representing each test component. + + Parameters + ---------- + test_root : ElementTree element + parsed from XML file containing the unit test(s) to perform + + Returns + ------- + test_list: + list of test dicts, containing test attributes parsed from xml object + + """ + + # define logger + logger = logging.getLogger(__name__) + + # find all tests in test_xml, and create a dictionary of attributes for each test + test_list = [] + for test_el in test_root.iter('test'): + test = {} + try: + test['name'] = test_el.attrib['name'] + except KeyError: + logger.error("ERROR: name attribute not found for test") + raise + + for el in test_el: + if (el.tag=='exec' or el.tag=='param'): + test[el.tag] = repl_env(el.text) + elif el.tag=='output': + test['out_pnc'] = [] + test['out_gnc'] = [] + test['out_stat'] = [] + test['out_ps'] = [] + test['out_exist'] = [] + test['out_not_exist'] = [] + output_names = { + 'point_nc' : 'out_pnc', + 'grid_nc' : 'out_gnc', + 'stat' : 'out_stat', + 'ps' : 'out_ps', + 'exist' : 'out_exist', + 'not_exist' : 'out_not_exist', + } + for output_el in el: + test[output_names[output_el.tag]].append(repl_env(output_el.text)) + + elif el.tag=='env': + env_dict = {} + for env_el in el: + try: + env_name = env_el.find('name').text + env_dict[env_name] = env_el.find('value').text + if not env_dict[env_name]: + env_dict[env_name] = '' + except AttributeError: + logger.error(f"ERROR: env pair in test \\{test['name']}\\ missing name or value") + raise + + test['env'] = env_dict + + # validate test format/details + expected_keys = ['exec', 'param', 'out_pnc', 'out_gnc', 'out_stat', 'out_ps', + 'out_exist', 'out_not_exist'] + for key in expected_keys: + if key not in test.keys(): + logger.error(f"ERROR: test {test['name']} missing {key} element") + sys.exit(1) + + test_list.append(test) + + return test_list + + +def repl_env(string_with_ref): + """ + Take a string with a placeholder for environment variable with syntax + ${ENV_NAME} and replace placeholder with corresponding value of environment + variable. + + Parameters + ---------- + string_with_ref : str + A string, generally path-like, that includes substring ${ENV_NAME} + + Returns + ------- + string_with_ref : str + The provided string with ${ENV_NAME} replaced by corresponding environment variable + """ + # define logger + logger = logging.getLogger(__name__) + + envar_ref_list = re.findall('\$\{\w+}', string_with_ref) + envar_ref_unique = [ + envar_ref_list[i] for i in list(range(len(envar_ref_list))) if ( + envar_ref_list[i] not in envar_ref_list[:i])] + + if len(envar_ref_unique)>0: + for envar_ref in envar_ref_unique: + envar_name = envar_ref[2:-1] + envar = os.getenv(envar_name) + if not envar: + logger.error(f"ERROR: environment variable {envar_name} not found") + string_with_ref = string_with_ref.replace(envar_ref, envar) + + return string_with_ref + +if __name__ == "__main__": + import argparse + + parser = argparse.ArgumentParser(description="Run a unit test.") + parser.add_argument('test_xml', nargs='+') + parser.add_argument('-log', metavar='log_file', + help='if present, write output from each test to log_file') + parser.add_argument('-cmd', action='store_true', + help='if present, print the test commands but do not run them, overrides -log') + parser.add_argument('-memchk', action='store_true', + help='if present, activate valgrind with memcheck') + parser.add_argument('-callchk', action='store_true', + help='if present, activate valgrind with callcheck') + parser.add_argument('-noexit', action='store_true', + help='if present, the unit tester will continue executing subsequent tests when a test fails') + args = parser.parse_args() + + for i, xml in enumerate(args.test_xml): + if i==0: + new_log = True + else: + new_log = False + unit(test_xml=xml, file_log=args.log, cmd_only=args.cmd, noexit=args.noexit, memchk=args.memchk, callchk=args.callchk, + log_overwrite=new_log) + + diff --git a/internal/test_unit/xml/unit_point_stat.xml b/internal/test_unit/xml/unit_point_stat.xml index b57d756a14..aea2b8e042 100644 --- a/internal/test_unit/xml/unit_point_stat.xml +++ b/internal/test_unit/xml/unit_point_stat.xml @@ -18,6 +18,8 @@ + &TEST_DIR; + true &MET_BIN;/point_stat diff --git a/internal/test_unit/xml/unit_python.xml b/internal/test_unit/xml/unit_python.xml index 0640aafd74..3bf4c6521f 100644 --- a/internal/test_unit/xml/unit_python.xml +++ b/internal/test_unit/xml/unit_python.xml @@ -162,9 +162,9 @@ &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A.ps - &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A_cts.txt - &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A_obj.txt - &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A_obj.nc + &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A_cts.txt + &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A_obj.txt + &OUTPUT_DIR;/python/mode_python_mixed_300000L_20120410_180000V_060000A_obj.nc @@ -182,9 +182,9 @@ &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A.ps - &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A_obj.txt - &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A_cts.txt - &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A_obj.nc + &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A_obj.txt + &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A_cts.txt + &OUTPUT_DIR;/python/mode_python_120000L_20050807_120000V_120000A_obj.nc
@@ -200,8 +200,7 @@ -outdir &OUTPUT_DIR;/python -v 1 - &OUTPUT_DIR;/python/grid_stat_python_mixed_120000L_20120409_120000V.stat - &OUTPUT_DIR;/python/grid_stat_python_mixed_120000L_20120409_120000V_pairs.nc + &OUTPUT_DIR;/python/grid_stat_python_mixed_120000L_20120409_120000V_pairs.nc @@ -218,7 +217,7 @@ -outdir &OUTPUT_DIR;/python -v 1 - &OUTPUT_DIR;/python/grid_stat_python_120000L_20050807_120000V_pairs.nc + &OUTPUT_DIR;/python/grid_stat_python_120000L_20050807_120000V_pairs.nc @@ -237,7 +236,7 @@ -outdir &OUTPUT_DIR;/python -v 1 - &OUTPUT_DIR;/python/point_stat_python_120000L_20120409_120000V.stat + &OUTPUT_DIR;/python/point_stat_120000L_20050807_120000V.stat @@ -255,7 +254,7 @@ &OUTPUT_DIR;/python/wavelet_stat_python_120000L_20050807_120000V.stat - &OUTPUT_DIR;/python/wavelet_stat_python_120000L_20050807_120000V_isc.txt + &OUTPUT_DIR;/python/wavelet_stat_python_120000L_20050807_120000V_isc.txt &OUTPUT_DIR;/python/wavelet_stat_python_120000L_20050807_120000V.nc &OUTPUT_DIR;/python/wavelet_stat_python_120000L_20050807_120000V.ps @@ -274,7 +273,7 @@ &OUTPUT_DIR;/python/wavelet_stat_python_mixed_120000L_20050807_120000V.stat - &OUTPUT_DIR;/python/wavelet_stat_python_mixed_120000L_20050807_120000V_isc.txt + &OUTPUT_DIR;/python/wavelet_stat_python_mixed_120000L_20050807_120000V_isc.txt &OUTPUT_DIR;/python/wavelet_stat_python_mixed_120000L_20050807_120000V.nc &OUTPUT_DIR;/python/wavelet_stat_python_mixed_120000L_20050807_120000V.ps diff --git a/internal/test_unit/xml/unit_ref_config_lead_12.xml b/internal/test_unit/xml/unit_ref_config_lead_12.xml index 989e548da5..5945ff2fdc 100644 --- a/internal/test_unit/xml/unit_ref_config_lead_12.xml +++ b/internal/test_unit/xml/unit_ref_config_lead_12.xml @@ -79,7 +79,7 @@ \ -subtract \ &DATA_DIR_MODEL;/grib1/ref_config/2011090200/AFWAv3.4_Noahv3.3/postprd/wrfprs_012.tm00 12 \ - &DATA_DIR_MODEL;/grib1/ref_config/2011090200/AFWAv3.4_Noahv3.3/postprd/wrfprs_009.tm00 9 \ + &DATA_DIR_MODEL;/grib1/ref_config/2011090200/AFWAv3.4_Noahv3.3/postprd/wrfprs_009.tm00 9 \ &OUTPUT_DIR;/ref_config_lead_12/pcp_combine/wrf/wrfpcp03_012.nc diff --git a/internal/test_unit/xml/unit_tc_diag.xml b/internal/test_unit/xml/unit_tc_diag.xml index e0e1686718..1f75454ac0 100644 --- a/internal/test_unit/xml/unit_tc_diag.xml +++ b/internal/test_unit/xml/unit_tc_diag.xml @@ -33,9 +33,9 @@ -v 2 - &OUTPUT_DIR;/tc_diag/sal092022_gfso_doper_2022092400_cyl_grid_parent.nc - &OUTPUT_DIR;/tc_diag/sal092022_gfso_doper_2022092400_diag.nc - &OUTPUT_DIR;/tc_diag/sal092022_gfso_doper_2022092400_diag.dat + &OUTPUT_DIR;/tc_diag/sal092022_gfso_doper_2022092400_cyl_grid_parent.nc + &OUTPUT_DIR;/tc_diag/sal092022_gfso_doper_2022092400_diag.nc + &OUTPUT_DIR;/tc_diag/sal092022_gfso_doper_2022092400_diag.dat diff --git a/internal/test_unit/xml/unit_ugrid.xml b/internal/test_unit/xml/unit_ugrid.xml index 80a6a53360..5f6e517a7c 100644 --- a/internal/test_unit/xml/unit_ugrid.xml +++ b/internal/test_unit/xml/unit_ugrid.xml @@ -20,6 +20,9 @@ + &TEST_DIR; + true + &MET_BIN;/grid_stat @@ -33,7 +36,7 @@ &OUTPUT_DIR;/grid_stat_ugrid/grid_stat_UGRID_MPAS_OUT_TO_GRID_000000L_20120409_120000V.stat - &OUTPUT_DIR;/grid_stat_ugrid/grid_stat_UGRID_MPAS_OUT_TO_GRID_000000L_20120409_120000V_pairs.nc + &OUTPUT_DIR;/grid_stat_ugrid/grid_stat_UGRID_MPAS_OUT_TO_GRID_000000L_20120409_120000V_pairs.nc @@ -51,7 +54,7 @@ &OUTPUT_DIR;/grid_stat_ugrid/grid_stat_UGRID_MPAS_DIAG_000000L_20120409_120000V.stat - &OUTPUT_DIR;/grid_stat_ugrid/grid_stat_UGRID_MPAS_DIAG_000000L_20120409_120000V_pairs.nc + &OUTPUT_DIR;/grid_stat_ugrid/grid_stat_UGRID_MPAS_DIAG_000000L_20120409_120000V_pairs.nc From 4179f55c5b6fd24e83d9e62277f4caee4d50babe Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Fri, 14 Jun 2024 09:09:55 -0600 Subject: [PATCH 087/114] Bugfix 2867 point2grid qc unittest (#2913) * #2867 Added compute_adp_qc_flag and adjusted ADP QC flags * #2867 Added point2grid_GOES_16_ADP_Enterprise_high. Changed AOD QC flags to 0,1,2 (was 1,2,3) * #2867 Added get_nc_att_values_ * #2867 Added get_nc_att_values. Added the argument allow_conversion to get_nc_data(netCDF::NcVar *, uchar *data) * #2867 Read the ADP QC flag values and meanings attributes from DQF variable and set the QC high, meduium, low values to support Enterprise algorithm. Adjusted the ADP QC values by using AOD qc values * #2867 Cleanup * #2867 Corrected indent * #2867 Changed log message * #2867 Removed unused argument * #2867 Removed unused argument * Cleanup * #2867 Fix SonarQube findings * #2867 Deleted protected section with no members * #2867 Cleanup * #2867 FIxed SonarQube findings; unused local variables, decalare as const, etc * #2867 MOved include directives to top * #2867 Changed some argumenmt with references to avoid copying objects * #2867 Do not filter by QC flag if -qc is not given * #2867 Use enumj class for GOES QC: HIGH, MEDIUM, and LOW * #2867 Added log message back which were deleted accidently * #2867 Chaned statci const to constexpr * #2867 Initial release. Separated from nc_utils.h * @2867 Added nc_utils_core.h * #2867 Moved some blocks to nc_utils_core.h * #2867 Include nc_utils_core.h * #2867 Added const references * #2867 Some 'static const' were chnaged to constexpr * #2867 Changed -qc options (1,2,3 to 0,1 - high & medium) for AOD * #2867 Merged develop branch * #2867 Corrected the unit test name --------- Co-authored-by: Howard Soh --- internal/test_unit/xml/unit_point2grid.xml | 8 +- src/libcode/vx_nc_util/nc_utils.h | 104 ++++++++++----------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/internal/test_unit/xml/unit_point2grid.xml b/internal/test_unit/xml/unit_point2grid.xml index 5221ea4460..213ffcf756 100644 --- a/internal/test_unit/xml/unit_point2grid.xml +++ b/internal/test_unit/xml/unit_point2grid.xml @@ -130,7 +130,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_compute.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 1,2,3 -method MAX \ + -qc 0,1 -method MAX \ -v 1 @@ -167,7 +167,7 @@ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_ADP.nc \ -field 'name="AOD_Smoke"; level="(*,*)";' \ -adp &DATA_DIR_MODEL;/goes_16/OR_ABI-L2-ADPC-M6_G16_s20192662141196_e20192662143569_c20192662144526.nc \ - -qc 1,2 -method MAX \ + -qc 0,1 -method MAX \ -v 1 @@ -213,7 +213,7 @@ - + &MET_BIN;/point2grid MET_TMP_DIR &OUTPUT_DIR;/point2grid @@ -259,7 +259,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_unsigned.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 1,2,3 -method MAX \ + -qc 0,1,2 -method MAX \ -v 1 diff --git a/src/libcode/vx_nc_util/nc_utils.h b/src/libcode/vx_nc_util/nc_utils.h index c879ba3c1d..671b3bf609 100644 --- a/src/libcode/vx_nc_util/nc_utils.h +++ b/src/libcode/vx_nc_util/nc_utils.h @@ -52,49 +52,49 @@ typedef unsigned char uchar; #define OBS_BUFFER_SIZE (128 * 1024) -static const char nc_dim_nhdr[] = "nhdr"; -static const char nc_dim_nhdr_typ[] = "nhdr_typ"; -static const char nc_dim_nhdr_sid[] = "nhdr_sid"; -static const char nc_dim_nhdr_vld[] = "nhdr_vld"; -static const char nc_dim_npbhdr[] = "npbhdr"; -static const char nc_dim_nobs[] = "nobs"; -static const char nc_dim_nqty[] = "nobs_qty"; -static const char nc_dim_hdr_arr[] = "hdr_arr_len"; -static const char nc_dim_obs_arr[] = "obs_arr_len"; -static const char nc_dim_mxstr[] = "mxstr"; -static const char nc_dim_mxstr2[] = "mxstr2"; -static const char nc_dim_mxstr3[] = "mxstr3"; -static const char nc_dim_nvar[] = "obs_var_num"; -static const char nc_dim_unit[] = "unit_len"; -static const char nc_dim_desc[] = "desc_len"; -static const char nc_var_desc[] = "obs_desc"; -static const char nc_var_hdr_arr[] = "hdr_arr"; -static const char nc_var_hdr_lat[] = "hdr_lat"; -static const char nc_var_hdr_lon[] = "hdr_lon"; -static const char nc_var_hdr_elv[] = "hdr_elv"; -static const char nc_var_hdr_typ[] = "hdr_typ"; -static const char nc_var_hdr_sid[] = "hdr_sid"; -static const char nc_var_hdr_vld[] = "hdr_vld"; -static const char nc_var_hdr_prpt_typ[] = "hdr_prpt_typ"; -static const char nc_var_hdr_irpt_typ[] = "hdr_irpt_typ"; -static const char nc_var_hdr_inst_typ[] = "hdr_inst_typ"; -static const char nc_var_hdr_typ_tbl[] = "hdr_typ_table"; -static const char nc_var_hdr_sid_tbl[] = "hdr_sid_table"; -static const char nc_var_hdr_vld_tbl[] = "hdr_vld_table"; -static const char nc_var_obs_arr[] = "obs_arr"; -static const char nc_var_obs_hid[] = "obs_hid"; -static const char nc_var_obs_gc[] = "obs_gc"; -static const char nc_var_obs_vid[] = "obs_vid"; -static const char nc_var_obs_lvl[] = "obs_lvl"; -static const char nc_var_obs_hgt[] = "obs_hgt"; -static const char nc_var_obs_val[] = "obs_val"; -static const char nc_var_obs_qty[] = "obs_qty"; -static const char nc_var_obs_qty_tbl[] = "obs_qty_table"; -static const char nc_var_obs_var[] = "obs_var"; -static const char nc_var_unit[] = "obs_unit"; -static const std::string nc_att_use_var_id = "use_var_id"; -static const char nc_att_obs_version[] = "MET_Obs_version"; -static const char nc_att_met_point_nccf[] = "MET_point_NCCF"; +constexpr char nc_dim_nhdr[] = "nhdr"; +constexpr char nc_dim_nhdr_typ[] = "nhdr_typ"; +constexpr char nc_dim_nhdr_sid[] = "nhdr_sid"; +constexpr char nc_dim_nhdr_vld[] = "nhdr_vld"; +constexpr char nc_dim_npbhdr[] = "npbhdr"; +constexpr char nc_dim_nobs[] = "nobs"; +constexpr char nc_dim_nqty[] = "nobs_qty"; +constexpr char nc_dim_hdr_arr[] = "hdr_arr_len"; +constexpr char nc_dim_obs_arr[] = "obs_arr_len"; +constexpr char nc_dim_mxstr[] = "mxstr"; +constexpr char nc_dim_mxstr2[] = "mxstr2"; +constexpr char nc_dim_mxstr3[] = "mxstr3"; +constexpr char nc_dim_nvar[] = "obs_var_num"; +constexpr char nc_dim_unit[] = "unit_len"; +constexpr char nc_dim_desc[] = "desc_len"; +constexpr char nc_var_desc[] = "obs_desc"; +constexpr char nc_var_hdr_arr[] = "hdr_arr"; +constexpr char nc_var_hdr_lat[] = "hdr_lat"; +constexpr char nc_var_hdr_lon[] = "hdr_lon"; +constexpr char nc_var_hdr_elv[] = "hdr_elv"; +constexpr char nc_var_hdr_typ[] = "hdr_typ"; +constexpr char nc_var_hdr_sid[] = "hdr_sid"; +constexpr char nc_var_hdr_vld[] = "hdr_vld"; +constexpr char nc_var_hdr_prpt_typ[] = "hdr_prpt_typ"; +constexpr char nc_var_hdr_irpt_typ[] = "hdr_irpt_typ"; +constexpr char nc_var_hdr_inst_typ[] = "hdr_inst_typ"; +constexpr char nc_var_hdr_typ_tbl[] = "hdr_typ_table"; +constexpr char nc_var_hdr_sid_tbl[] = "hdr_sid_table"; +constexpr char nc_var_hdr_vld_tbl[] = "hdr_vld_table"; +constexpr char nc_var_obs_arr[] = "obs_arr"; +constexpr char nc_var_obs_hid[] = "obs_hid"; +constexpr char nc_var_obs_gc[] = "obs_gc"; +constexpr char nc_var_obs_vid[] = "obs_vid"; +constexpr char nc_var_obs_lvl[] = "obs_lvl"; +constexpr char nc_var_obs_hgt[] = "obs_hgt"; +constexpr char nc_var_obs_val[] = "obs_val"; +constexpr char nc_var_obs_qty[] = "obs_qty"; +constexpr char nc_var_obs_qty_tbl[] = "obs_qty_table"; +constexpr char nc_var_obs_var[] = "obs_var"; +constexpr char nc_var_unit[] = "obs_unit"; +constexpr char nc_att_use_var_id[] = "use_var_id"; +constexpr char nc_att_obs_version[] = "MET_Obs_version"; +constexpr char nc_att_met_point_nccf[] = "MET_point_NCCF"; static const std::string add_offset_att_name = "add_offset"; static const std::string axis_att_name = "axis"; @@ -111,17 +111,17 @@ static const std::string scale_factor_att_name = "scale_factor"; static const std::string standard_name_att_name = "standard_name"; static const std::string units_att_name = "units"; -static const char nc_time_unit_exp[] = "^[a-z|A-Z]* *since *[0-9]\\{1,4\\}-[0-9]\\{1,2\\}-[0-9]\\{1,2\\}"; -static const char nc_time_unit_ymd_exp[] = "[0-9]\\{1,4\\}-[0-9]\\{1,2\\}-[0-9]\\{1,2\\}"; +constexpr char nc_time_unit_exp[] = "^[a-z|A-Z]* *since *[0-9]\\{1,4\\}-[0-9]\\{1,2\\}-[0-9]\\{1,2\\}"; +constexpr char nc_time_unit_ymd_exp[] = "[0-9]\\{1,4\\}-[0-9]\\{1,2\\}-[0-9]\\{1,2\\}"; -static const char MET_NC_Obs_ver_1_2[] = "1.02"; -static const char MET_NC_Obs_version[] = "1.02"; +constexpr char MET_NC_Obs_ver_1_2[] = "1.02"; +constexpr char MET_NC_Obs_version[] = "1.02"; -static const int exit_code_no_error = 0; -static const int exit_code_no_dim = 1; -static const int exit_code_no_hdr_vars = 2; -static const int exit_code_no_loc_vars = 3; -static const int exit_code_no_obs_vars = 4; +constexpr int exit_code_no_error = 0; +constexpr int exit_code_no_dim = 1; +constexpr int exit_code_no_hdr_vars = 2; +constexpr int exit_code_no_loc_vars = 3; +constexpr int exit_code_no_obs_vars = 4; //////////////////////////////////////////////////////////////////////// From 95ad048b51080747e953e7f086a68b94bce622cf Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 18 Jun 2024 12:06:32 -0600 Subject: [PATCH 088/114] Feature #2911 tc_stat_set_hdr (#2916) * Per #2911, no real changes for Stat-Analysis. Just changing order of variables for consistency. * Per #2911, add StatHdrColumns::apply_set_hdr_opts(...) function to be used by TC-Stat. * Per #2911, move ByColumn to the TCStatJob base class and add HdrName and HdrValue to support the -set_hdr job command. * Per #2911, update GSI tools to call the newly added StatHdrColumns::apply_set_hdr_opts(...) function. * Per #2911, update logic of Stat-Analysis for consistency to make use of common apply_set_hdr_opts() function. * Per #2911, add DataLine::set_item() function to support -set_hdr options. * Per #2911, just update contents of error message * Per #2911, add TCStatLine member functions for has() and get_offset(). * Per #2911, update tc_stat to support applying -set_hdr to TC-Stat filter jobs. * Per #2911, revise TC-Stat config files to exercise the -set_hdr job command option * Per #2911, update TC-Stat documentation to mention the -set_hdr job command option * Per #2911, add note * Per #2911, as recommended by SonarQube, make some of these member functions const. --- docs/Users_Guide/tc-stat.rst | 14 ++ .../test_unit/config/TCStatConfig_ALAL2010 | 6 +- .../test_unit/config/TCStatConfig_PROBRIRW | 2 +- src/basic/vx_util/data_line.cc | 27 +++ src/basic/vx_util/data_line.h | 6 + src/libcode/vx_analysis_util/stat_job.cc | 14 +- src/libcode/vx_analysis_util/stat_job.h | 9 +- src/libcode/vx_stat_out/stat_hdr_columns.cc | 214 ++++++++++++++++++ src/libcode/vx_stat_out/stat_hdr_columns.h | 8 + src/libcode/vx_tc_util/tc_columns.cc | 19 +- src/libcode/vx_tc_util/tc_columns.h | 2 + src/libcode/vx_tc_util/tc_hdr_columns.cc | 86 +++++++ src/libcode/vx_tc_util/tc_hdr_columns.h | 3 + src/libcode/vx_tc_util/tc_stat_line.cc | 30 +++ src/libcode/vx_tc_util/tc_stat_line.h | 2 + .../core/stat_analysis/aggr_stat_line.cc | 153 +++---------- src/tools/core/stat_analysis/aggr_stat_line.h | 8 +- src/tools/other/gsi_tools/gsi_util.cc | 167 ++------------ src/tools/other/gsi_tools/gsi_util.h | 28 +-- src/tools/other/gsi_tools/gsid2mpr.cc | 27 ++- src/tools/tc_utils/tc_stat/tc_stat.cc | 1 + src/tools/tc_utils/tc_stat/tc_stat_job.cc | 103 +++++---- src/tools/tc_utils/tc_stat/tc_stat_job.h | 22 +- 23 files changed, 577 insertions(+), 374 deletions(-) diff --git a/docs/Users_Guide/tc-stat.rst b/docs/Users_Guide/tc-stat.rst index bdcbc35327..3cddda63f2 100644 --- a/docs/Users_Guide/tc-stat.rst +++ b/docs/Users_Guide/tc-stat.rst @@ -400,6 +400,8 @@ The output generated from the TC-Stat tool contains statistics produced by the a This job command finds and filters TCST lines down to those meeting the criteria selected by the filter's options. The filtered TCST lines are written to a file specified by the **-dump_row** option. The TCST output from this job follows the TCST output description in :numref:`tc-dland` and :numref:`tc-pairs`. + The "-set_hdr" job command option can be used to override any of the output header strings (e.g. "-set_hdr DESC EVENT_EQUAL" sets the output DESC column to "EVENT_EQUAL"). + **Job: Summary** This job produces summary statistics for the column name specified by the **-column** option. The output of the summary job consists of three rows: @@ -475,6 +477,18 @@ Users may also specify the **-out_alpha** option to define the alpha value for t Users may also specify the **-out_stat** option to write the contingency table counts and statistics (for the CTC and CTS output line types) to an output STAT file. Information about the RIRW timing information and filtering criteria are written to the STAT header columns while the contingency table counts and/or statistics are written to the CTC and/or CTS output columns. +When using the "-out_stat" option to create a .stat output file and stratifying results using one or more "-by" job command options, those columns may be referenced in the "-set_hdr" option. + +.. code-block:: none + + -job rirw -line_type TCMPR -by CYCLONE -out_stat ctc.stat -set_hdr DESC CYCLONE + +When using multiple "-by" options, use "CASE" to reference the full case information string. + +.. code-block:: none + + -job rirw -line_type TCMPR -by CYCLONE,LEAD -out_stat ctc.stat -set_hdr DESC CASE + **Job: PROBRIRW** The PROBRIRW job produces probabilistic contingency table counts and statistics defined by placing forecast probabilities and BEST track rapid intensification events into an Nx2 contingency table. Users may specify several job command options to configure the behavior of this job: diff --git a/internal/test_unit/config/TCStatConfig_ALAL2010 b/internal/test_unit/config/TCStatConfig_ALAL2010 index dd0de6084d..b46d0f72c3 100644 --- a/internal/test_unit/config/TCStatConfig_ALAL2010 +++ b/internal/test_unit/config/TCStatConfig_ALAL2010 @@ -208,11 +208,11 @@ jobs = [ "-job summary -column TRACK -by AMODEL -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_vs_BCLP.tcst", "-job summary -column TRACK -by AMODEL,INIT -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_vs_BCLP_by_INIT.tcst", "-job summary -column WIND -by AMODEL -column_union true", - "-job filter -amodel AHWI -rirw_track BDECK -rirw_thresh >=30 -rirw_exact FALSE -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_ri.tcst", - "-job filter -amodel AHWI -rirw_track BDECK -rirw_thresh <=-30 -rirw_exact TRUE -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_rw.tcst", + "-job filter -amodel AHWI -rirw_track BDECK -rirw_thresh >=30 -rirw_exact FALSE -set_hdr DESC RI -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_ri.tcst", + "-job filter -amodel AHWI -rirw_track BDECK -rirw_thresh <=-30 -rirw_exact TRUE -set_hdr DESC RW -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_rw.tcst", "-job rirw -rirw_window 00 -rirw_thresh <=-15 -out_line_type CTC,CTS,MPR", "-job rirw -rirw_window 12 -rirw_thresh <=-15 -out_line_type CTC,CTS,MPR", - "-job rirw -rirw_window 12 -rirw_thresh <=-15 -out_line_type CTC,CTS -by amodel -out_stat ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_rirw.stat" + "-job rirw -rirw_window 12 -rirw_thresh <=-15 -out_line_type CTC,CTS -by amodel -set_hdr DESC AMODEL -out_stat ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_rirw.stat" ]; // diff --git a/internal/test_unit/config/TCStatConfig_PROBRIRW b/internal/test_unit/config/TCStatConfig_PROBRIRW index f8645a1e1e..679b681e59 100644 --- a/internal/test_unit/config/TCStatConfig_PROBRIRW +++ b/internal/test_unit/config/TCStatConfig_PROBRIRW @@ -205,7 +205,7 @@ out_valid_mask = ""; // Array of TCStat analysis jobs to be performed on the filtered data // jobs = [ - "-job filter -dump_row ${MET_TEST_OUTPUT}/tc_stat/PROBRIRW_filter_ee.tcst", + "-job filter -set_hdr DESC EVENT_EQUAL -dump_row ${MET_TEST_OUTPUT}/tc_stat/PROBRIRW_filter_ee.tcst", "-job summary -column TK_ERR -by AMODEL -probrirw_thresh 30 -column_thresh PROBRIRW_PROB >0 -dump_row ${MET_TEST_OUTPUT}/tc_stat/PROBRIRW_summary_tk_err.tcst", "-job probrirw -column_thresh RIRW_WINDOW ==24 -by AMODEL -probrirw_thresh 30 -probrirw_bdelta_thresh >=30 -out_line_type PCT,PSTD,PRC,PJC -dump_row ${MET_TEST_OUTPUT}/tc_stat/PROBRIRW_probrirw.tcst", "-job summary -column TK_ERR -by AMODEL,LEAD -amodel GPMI,GPMN -event_equal TRUE", diff --git a/src/basic/vx_util/data_line.cc b/src/basic/vx_util/data_line.cc index 62b7e0c923..5c283e258d 100644 --- a/src/basic/vx_util/data_line.cc +++ b/src/basic/vx_util/data_line.cc @@ -232,6 +232,33 @@ return; //////////////////////////////////////////////////////////////////////// +void DataLine::set_item(int k, const ConcatString &item_cs) + +{ + +if ( (k < 0) || (k >= N_items) ) { + + ConcatString cs = (File ? File->filename() : ""); + + mlog << Error << "\nDataLine::set_item(int) -> " + << "range check error setting line number " << LineNumber + << ", item number " << k+1 << " of " << N_items + << " from file \"" << cs << "\"\n\n"; + + exit ( 1 ); + +} + +Items[k] = item_cs; + +return; + +} + + +//////////////////////////////////////////////////////////////////////// + + const char * DataLine::get_item(int k) const { diff --git a/src/basic/vx_util/data_line.h b/src/basic/vx_util/data_line.h index bb9de49c8e..b3ef288b5e 100644 --- a/src/basic/vx_util/data_line.h +++ b/src/basic/vx_util/data_line.h @@ -98,6 +98,12 @@ class DataLine { void dump(std::ostream &, int depth = 0) const; + // + // set stuff + // + + void set_item(int, const ConcatString &); + // // retrieve stuff // diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index dda0a08bd9..ced4361068 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -1174,13 +1174,13 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { else if(jc_array[i] == "-column_str_exc" ) { column_str_exc_map.clear(); } + else if(jc_array[i] == "-by" ) { + by_column.clear(); + } else if(jc_array[i] == "-set_hdr" ) { hdr_name.clear(); hdr_value.clear(); } - else if(jc_array[i] == "-by" ) { - by_column.clear(); - } else if(jc_array[i] == "-out_line_type" ) { out_line_type.clear(); } @@ -1450,15 +1450,15 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { } i+=2; } + else if(jc_array[i] == "-by") { + by_column.add_css(to_upper(jc_array[i+1])); + i+=1; + } else if(jc_array[i] == "-set_hdr") { hdr_name.add_css(to_upper(jc_array[i+1])); hdr_value.add_css(jc_array[i+2]); i+=2; } - else if(jc_array[i] == "-by") { - by_column.add_css(to_upper(jc_array[i+1])); - i+=1; - } else if(jc_array[i] == "-dump_row") { set_dump_row(jc_array[i+1].c_str()); i++; diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 208c6d4894..88b709adf7 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -234,14 +234,17 @@ class STATAnalysisJob { std::map column_str_inc_map; std::map column_str_exc_map; - StringArray hdr_name; - StringArray hdr_value; - // // Store the case information for the -by option // StringArray by_column; + // + // Options for -set_hdr output + // + StringArray hdr_name; + StringArray hdr_value; + // // Variables used to the store the analysis job specification // diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.cc b/src/libcode/vx_stat_out/stat_hdr_columns.cc index 005499d8ed..3c3560b587 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.cc +++ b/src/libcode/vx_stat_out/stat_hdr_columns.cc @@ -15,6 +15,9 @@ using namespace std; +//////////////////////////////////////////////////////////////////////// + +static const string case_str = "CASE"; //////////////////////////////////////////////////////////////////////// // @@ -337,6 +340,217 @@ void StatHdrColumns::set_alpha(const double a) { //////////////////////////////////////////////////////////////////////// +void StatHdrColumns::apply_set_hdr_opts( + const StringArray &hdr_cols, const StringArray &hdr_vals) { + StringArray case_cols; + StringArray case_vals; + + // Call other implementation without case information + apply_set_hdr_opts(hdr_cols, hdr_vals, case_cols, case_vals); + + return; +} + +//////////////////////////////////////////////////////////////////////// +// +// Use the current -set_hdr options to populate the STAT header columns, +// substituting in case-specific values, as needed. +// +//////////////////////////////////////////////////////////////////////// + +void StatHdrColumns::apply_set_hdr_opts( + const StringArray &hdr_cols, const StringArray &hdr_vals, + const StringArray &case_cols, const StringArray &case_vals) { + + // No updates needed + if(hdr_cols.n() == 0) return; + + // Sanity check lengths + if(hdr_cols.n() != hdr_vals.n()) { + mlog << Error << "\nStatHdrColumns::apply_set_hdr_opts() -> " + << "the number of -set_hdr columns names (" << hdr_cols.n() + << " and values (" << hdr_vals.n() << " must match!\n\n"; + exit(1); + } + if(case_cols.n() != case_vals.n()) { + mlog << Error << "\nStatHdrColumns::apply_set_hdr_opts() -> " + << "the number of case columns names (" << case_cols.n() + << " and values (" << case_vals.n() << " must match!\n\n"; + exit(1); + } + + int index; + ConcatString cs; + SingleThresh st; + + // MODEL + if(hdr_cols.has("MODEL", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_model(cs.c_str()); + } + + // DESC + if(hdr_cols.has("DESC", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_desc(cs.c_str()); + } + + // FCST_LEAD + if(hdr_cols.has("FCST_LEAD", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_fcst_lead_sec(timestring_to_sec(cs.c_str())); + } + + // FCST_VALID_BEG, FCST_VALID_END + if(hdr_cols.has("FCST_VALID_BEG", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_fcst_valid_beg(timestring_to_unix(cs.c_str())); + } + if(hdr_cols.has("FCST_VALID_END", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_fcst_valid_end(timestring_to_unix(cs.c_str())); + } + + // OBS_LEAD + if(hdr_cols.has("OBS_LEAD", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obs_lead_sec(timestring_to_sec(cs.c_str())); + } + + // OBS_VALID_BEG, OBS_VALID_END + if(hdr_cols.has("OBS_VALID_BEG", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obs_valid_beg(timestring_to_unix(cs.c_str())); + } + if(hdr_cols.has("OBS_VALID_END", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obs_valid_end(timestring_to_unix(cs.c_str())); + } + + // FCST_VAR + if(hdr_cols.has("FCST_VAR", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_fcst_var(cs.c_str()); + } + + // FCST_UNITS + if(hdr_cols.has("FCST_UNITS", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_fcst_units(cs.c_str()); + } + + // FCST_LEV + if(hdr_cols.has("FCST_LEV", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_fcst_lev(cs.c_str()); + } + + // OBS_VAR + if(hdr_cols.has("OBS_VAR", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obs_var(cs.c_str()); + } + + // OBS_UNITS + if(hdr_cols.has("OBS_UNITS", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obs_units(cs.c_str()); + } + + // OBS_LEV + if(hdr_cols.has("OBS_LEV", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obs_lev(cs.c_str()); + } + + // OBTYPE + if(hdr_cols.has("OBTYPE", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_obtype(cs.c_str()); + } + + // VX_MASK + if(hdr_cols.has("VX_MASK", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_mask(cs.c_str()); + } + + // INTERP_MTHD + if(hdr_cols.has("INTERP_MTHD", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_interp_mthd(cs.c_str()); + } + + // INTERP_PNTS + if(hdr_cols.has("INTERP_PNTS", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_interp_wdth(nint(sqrt(atof(cs.c_str())))); + } + + // FCST_THRESH + if(hdr_cols.has("FCST_THRESH", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + st.set(cs.c_str()); + set_fcst_thresh(st); + } + + // OBS_THRESH + if(hdr_cols.has("OBS_THRESH", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + st.set(cs.c_str()); + set_obs_thresh(st); + } + + // COV_THRESH + if(hdr_cols.has("COV_THRESH", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + st.set(cs.c_str()); + set_cov_thresh(st); + } + + // ALPHA + if(hdr_cols.has("ALPHA", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_alpha(atof(cs.c_str())); + } + + // LINE_TYPE + if(hdr_cols.has("LINE_TYPE", index)) { + cs = get_set_hdr_str(hdr_vals[index], case_cols, case_vals); + set_line_type(cs.c_str()); + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +ConcatString StatHdrColumns::get_set_hdr_str(const std::string &hdr_val, + const StringArray &case_cols, const StringArray &case_vals) const { + ConcatString cs; + int index; + + // Check for the full CASE string + if(case_str.compare(hdr_val) == 0) { + cs = case_vals.serialize(":"); + } + // Check for one of the case columns + else if(case_cols.has(hdr_val, index)) { + cs = case_vals[index]; + } + // Otherwise, use the current header value + else { + cs = hdr_val; + } + + // Sanity check for empty strings + if(cs.empty()) cs = na_str; + + return cs; +} + +//////////////////////////////////////////////////////////////////////// + ConcatString StatHdrColumns::get_fcst_thresh_str() const { ConcatString cs; diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.h b/src/libcode/vx_stat_out/stat_hdr_columns.h index 6a1c5da0fb..8fb9e4f564 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.h +++ b/src/libcode/vx_stat_out/stat_hdr_columns.h @@ -151,6 +151,14 @@ class StatHdrColumns { void set_cov_thresh (const ThreshArray); void set_alpha (const double); + // Apply -set_hdr overrides + void apply_set_hdr_opts(const StringArray &, const StringArray &); + void apply_set_hdr_opts(const StringArray &, const StringArray &, + const StringArray &, const StringArray &); + + ConcatString get_set_hdr_str(const std::string &, + const StringArray &, const StringArray &) const; + // Get functions ConcatString get_model () const; ConcatString get_desc () const; diff --git a/src/libcode/vx_tc_util/tc_columns.cc b/src/libcode/vx_tc_util/tc_columns.cc index 6f7e7f2d6c..f91431718f 100644 --- a/src/libcode/vx_tc_util/tc_columns.cc +++ b/src/libcode/vx_tc_util/tc_columns.cc @@ -170,7 +170,8 @@ void write_prob_rirw_header_row(int hdr_flag, int n_thresh, AsciiTable &at, //////////////////////////////////////////////////////////////////////// void write_track_pair_info(TcHdrColumns &hdr, const TrackPairInfo &p, - AsciiTable &at, int &i_row) { + AsciiTable &at, int &i_row, + const StringArray &hdr_name, const StringArray &hdr_value) { // Loop through the TrackPairInfo points for(int i=0; iget_item("DESC", false)); } + // Apply -set_hdr options + if(hdr_name.n() > 0) hdr.apply_set_hdr_opts(hdr_name, hdr_value); + // Write the header columns write_tc_header_cols(hdr, at, i_row); @@ -221,6 +225,19 @@ void write_track_pair_info(TcHdrColumns &hdr, const TrackPairInfo &p, //////////////////////////////////////////////////////////////////////// +void write_track_pair_info(TcHdrColumns &hdr, const TrackPairInfo &p, + AsciiTable &at, int &i_row) { + + StringArray hdr_name; + StringArray hdr_value; + + write_track_pair_info(hdr, p, at, i_row, hdr_name, hdr_value); + + return; +} + +//////////////////////////////////////////////////////////////////////// + void write_prob_rirw_pair_info(TcHdrColumns &hdr, const ProbRIRWPairInfo &p, AsciiTable &at, int &i_row) { diff --git a/src/libcode/vx_tc_util/tc_columns.h b/src/libcode/vx_tc_util/tc_columns.h index 9a5aee0181..0d3a83e0a8 100644 --- a/src/libcode/vx_tc_util/tc_columns.h +++ b/src/libcode/vx_tc_util/tc_columns.h @@ -166,6 +166,8 @@ extern void write_prob_rirw_header_row(int, int, AsciiTable &, int, int); // Write out the data lines extern void write_track_pair_info (TcHdrColumns &, const TrackPairInfo &, AsciiTable &, int &); +extern void write_track_pair_info (TcHdrColumns &, const TrackPairInfo &, AsciiTable &, int &, + const StringArray &, const StringArray &); extern void write_prob_rirw_pair_info(TcHdrColumns &, const ProbRIRWPairInfo &, AsciiTable &, int &); // Write out the header entries diff --git a/src/libcode/vx_tc_util/tc_hdr_columns.cc b/src/libcode/vx_tc_util/tc_hdr_columns.cc index 3708417560..9cb4c1a77b 100644 --- a/src/libcode/vx_tc_util/tc_hdr_columns.cc +++ b/src/libcode/vx_tc_util/tc_hdr_columns.cc @@ -64,3 +64,89 @@ void TcHdrColumns::clear() { } //////////////////////////////////////////////////////////////////////// + +void TcHdrColumns::apply_set_hdr_opts( + const StringArray &hdr_cols, const StringArray &hdr_vals) { + + // No updates needed + if(hdr_cols.n() == 0) return; + + int index; + + // Sanity check lengths + if(hdr_cols.n() != hdr_vals.n()) { + mlog << Error << "\nTcHdrColumns::apply_set_hdr_opts() -> " + << "the number of -set_hdr columns names (" << hdr_cols.n() + << " and values (" << hdr_vals.n() << " must match!\n\n"; + exit(1); + } + + // AMODEL + if(hdr_cols.has("AMODEL", index)) { + set_adeck_model(hdr_vals[index]); + } + + // BMODEL + if(hdr_cols.has("BMODEL", index)) { + set_bdeck_model(hdr_vals[index]); + } + + // DESC + if(hdr_cols.has("DESC", index)) { + set_desc(hdr_vals[index]); + } + + // STORM_ID + if(hdr_cols.has("STORM_ID", index)) { + set_storm_id(hdr_vals[index]); + } + + // BASIN + if(hdr_cols.has("BASIN", index)) { + set_basin(hdr_vals[index]); + } + + // CYCLONE + if(hdr_cols.has("CYCLONE", index)) { + set_cyclone(hdr_vals[index]); + } + + // STORM_NAME + if(hdr_cols.has("STORM_NAME", index)) { + set_storm_name(hdr_vals[index]); + } + + // INIT + if(hdr_cols.has("INIT", index)) { + set_init(timestring_to_sec(hdr_vals[index].c_str())); + } + + // LEAD + if(hdr_cols.has("LEAD", index)) { + set_lead(timestring_to_sec(hdr_vals[index].c_str())); + } + + // VALID + if(hdr_cols.has("VALID", index)) { + set_valid(timestring_to_sec(hdr_vals[index].c_str())); + } + + // INIT_MASK + if(hdr_cols.has("INIT_MASK", index)) { + set_init_mask(hdr_vals[index]); + } + + // VALID_MASK + if(hdr_cols.has("VALID_MASK", index)) { + set_valid_mask(hdr_vals[index]); + } + + // LINE_TYPE + if(hdr_cols.has("LINE_TYPE", index)) { + set_line_type(hdr_vals[index]); + } + + return; +} + +//////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/tc_hdr_columns.h b/src/libcode/vx_tc_util/tc_hdr_columns.h index f632dfaf56..60ecf39260 100644 --- a/src/libcode/vx_tc_util/tc_hdr_columns.h +++ b/src/libcode/vx_tc_util/tc_hdr_columns.h @@ -70,6 +70,9 @@ class TcHdrColumns { void set_valid_mask (const ConcatString &); void set_line_type (const ConcatString &); + // Apply -set_hdr overrides + void apply_set_hdr_opts(const StringArray &, const StringArray &); + // Get functions ConcatString adeck_model () const; ConcatString bdeck_model () const; diff --git a/src/libcode/vx_tc_util/tc_stat_line.cc b/src/libcode/vx_tc_util/tc_stat_line.cc index a8556a7dd2..d46dc41c77 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.cc +++ b/src/libcode/vx_tc_util/tc_stat_line.cc @@ -164,6 +164,36 @@ bool TCStatLine::is_header() const { //////////////////////////////////////////////////////////////////////// +bool TCStatLine::has(const char *col_str) const { + return !is_bad_data(get_offset(col_str)); +} + +//////////////////////////////////////////////////////////////////////// + +int TCStatLine::get_offset(const char *col_str) const { + int offset = bad_data_int; + + // + // Search for matching header column + // + offset = HdrLine->col_offset(col_str); + + // + // If not found, check extra header columns + // + if(is_bad_data(offset)) { + if(!get_file()->header().has(col_str, offset)) offset = bad_data_int; + } + + // + // Return the offset value + // + + return offset; +} + +//////////////////////////////////////////////////////////////////////// + ConcatString TCStatLine::get(const char *col_str, bool check_na) const { ConcatString cs = (string)get_item(col_str, check_na); diff --git a/src/libcode/vx_tc_util/tc_stat_line.h b/src/libcode/vx_tc_util/tc_stat_line.h index 276fad1638..e39dcf7f70 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.h +++ b/src/libcode/vx_tc_util/tc_stat_line.h @@ -75,6 +75,8 @@ class TCStatLine : public DataLine { // Retrieve values of the header columns // + bool has (const char *) const; + int get_offset (const char *) const; ConcatString get (const char *, bool check_na = true) const; const char * get_item (const char *, bool check_na = true) const; const char * get_item (int, bool check_na = true) const; diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index c46c35c134..c40fb0eb64 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -41,6 +41,7 @@ // to VL1L2, VAL1L2, and VCNT. // 019 02/21/24 Halley Gotway MET #2583 Add observation error // ECNT statistics. +// 020 06/14/24 Halley Gotway MET #2911 Call apply_set_hdr_opts(). // //////////////////////////////////////////////////////////////////////// @@ -62,7 +63,6 @@ using namespace std; - //////////////////////////////////////////////////////////////////////// static bool is_precip_var_name(const ConcatString &s); @@ -350,25 +350,17 @@ StatHdrColumns StatHdrInfo::get_shc(const ConcatString &cur_case, const StringArray &hdr_cols, const StringArray &hdr_vals, const STATLineType lt) { - ConcatString css; - StringArray case_vals; ThreshArray ta; + ConcatString css; double out_alpha; - int index, wdth; + int wdth; StatHdrColumns shc; - // Split up the current case into values - case_vals = cur_case.split(":"); - // MODEL - shc.set_model( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "MODEL", model, false).c_str()); + shc.set_model(get_col_css(cur_case, "MODEL", model, false).c_str()); // DESC - shc.set_desc( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "DESC", desc, false).c_str()); + shc.set_desc(get_col_css(cur_case, "DESC", desc, false).c_str()); // FCST_LEAD css = write_css_hhmmss(fcst_lead); @@ -378,26 +370,11 @@ StatHdrColumns StatHdrInfo::get_shc(const ConcatString &cur_case, << fcst_lead.n() << " unique FCST_LEAD values: " << css << "\n"; } - if(hdr_cols.has("FCST_LEAD", index)) { - shc.set_fcst_lead_sec(timestring_to_sec(hdr_vals[index].c_str())); - } - else { - shc.set_fcst_lead_sec(fcst_lead.max()); - } + shc.set_fcst_lead_sec(fcst_lead.max()); // FCST_VALID_BEG, FCST_VALID_END - if(hdr_cols.has("FCST_VALID_BEG", index)) { - shc.set_fcst_valid_beg(timestring_to_unix(hdr_vals[index].c_str())); - } - else { - shc.set_fcst_valid_beg(fcst_valid_beg); - } - if(hdr_cols.has("FCST_VALID_END", index)) { - shc.set_fcst_valid_end(timestring_to_unix(hdr_vals[index].c_str())); - } - else { - shc.set_fcst_valid_end(fcst_valid_end); - } + shc.set_fcst_valid_beg(fcst_valid_beg); + shc.set_fcst_valid_end(fcst_valid_end); // OBS_LEAD css = write_css_hhmmss(obs_lead); @@ -407,71 +384,38 @@ StatHdrColumns StatHdrInfo::get_shc(const ConcatString &cur_case, << obs_lead.n() << " unique OBS_LEAD values: " << css << "\n"; } - if(hdr_cols.has("OBS_LEAD", index)) { - shc.set_obs_lead_sec(timestring_to_sec(hdr_vals[index].c_str())); - } - else { - shc.set_obs_lead_sec(obs_lead.max()); - } + shc.set_obs_lead_sec(obs_lead.max()); // OBS_VALID_BEG, OBS_VALID_END - if(hdr_cols.has("OBS_VALID_BEG", index)) { - shc.set_obs_valid_beg(timestring_to_unix(hdr_vals[index].c_str())); - } - else { - shc.set_obs_valid_beg(obs_valid_beg); - } - if(hdr_cols.has("OBS_VALID_END", index)) { - shc.set_obs_valid_end(timestring_to_unix(hdr_vals[index].c_str())); - } - else { - shc.set_obs_valid_end(obs_valid_end); - } + shc.set_obs_valid_beg(obs_valid_beg); + shc.set_obs_valid_end(obs_valid_end); // FCST_VAR - shc.set_fcst_var( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "FCST_VAR", fcst_var, false)); + shc.set_fcst_var(get_col_css(cur_case, "FCST_VAR", fcst_var, false)); // FCST_UNITS - shc.set_fcst_units( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "FCST_UNITS", fcst_units, false)); + shc.set_fcst_units(get_col_css(cur_case, "FCST_UNITS", fcst_units, false)); // FCST_LEV - shc.set_fcst_lev( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "FCST_LEV", fcst_lev, false).c_str()); + shc.set_fcst_lev(get_col_css(cur_case, "FCST_LEV", fcst_lev, false).c_str()); // OBS_VAR - shc.set_obs_var( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "OBS_VAR", obs_var, false)); + shc.set_obs_var(get_col_css(cur_case, "OBS_VAR", obs_var, false)); // OBS_UNITS - shc.set_obs_units( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "OBS_UNITS", obs_units, false)); + shc.set_obs_units(get_col_css(cur_case, "OBS_UNITS", obs_units, false)); // OBS_LEV - shc.set_obs_lev( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "OBS_LEV", obs_lev, false).c_str()); + shc.set_obs_lev(get_col_css(cur_case, "OBS_LEV", obs_lev, false).c_str()); // OBTYPE - shc.set_obtype( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "OBTYPE", obtype, false).c_str()); + shc.set_obtype(get_col_css(cur_case, "OBTYPE", obtype, false).c_str()); // VX_MASK - shc.set_mask( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "VX_MASK", vx_mask, false).c_str()); + shc.set_mask(get_col_css(cur_case, "VX_MASK", vx_mask, false).c_str()); // INTERP_MTHD - shc.set_interp_mthd( - get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "INTERP_MTHD", interp_mthd, true)); + shc.set_interp_mthd(get_col_css(cur_case, "INTERP_MTHD", interp_mthd, true)); // INTERP_PNTS css = write_css(interp_pnts); @@ -485,28 +429,21 @@ StatHdrColumns StatHdrInfo::get_shc(const ConcatString &cur_case, else { wdth = nint(sqrt(interp_pnts[0])); } - - if(hdr_cols.has("INTERP_PNTS", index)) { - wdth = nint(sqrt(atof(hdr_vals[index].c_str()))); - } shc.set_interp_wdth(wdth); // FCST_THRESH ta.clear(); - ta.add_css(get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "FCST_THRESH", fcst_thresh, true).c_str()); + ta.add_css(get_col_css(cur_case, "FCST_THRESH", fcst_thresh, true).c_str()); shc.set_fcst_thresh(ta); // OBS_THRESH ta.clear(); - ta.add_css(get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "OBS_THRESH", obs_thresh, true).c_str()); + ta.add_css(get_col_css(cur_case, "OBS_THRESH", obs_thresh, true).c_str()); shc.set_obs_thresh(ta); // COV_THRESH ta.clear(); - ta.add_css(get_shc_str(cur_case, case_cols, case_vals, hdr_cols, hdr_vals, - "COV_THRESH", cov_thresh, true).c_str()); + ta.add_css(get_col_css(cur_case, "COV_THRESH", cov_thresh, true).c_str()); shc.set_cov_thresh(ta); // ALPHA @@ -521,34 +458,27 @@ StatHdrColumns StatHdrInfo::get_shc(const ConcatString &cur_case, else { out_alpha = alpha[0]; } - - if(hdr_cols.has("ALPHA", index)) { - out_alpha = atof(hdr_vals[index].c_str()); - } shc.set_alpha(out_alpha); // LINE_TYPE shc.set_line_type(statlinetype_to_string(lt)); + // Apply the -set_hdr options + StringArray case_vals = cur_case.split(":"); + shc.apply_set_hdr_opts(hdr_cols, hdr_vals, case_cols, case_vals); + return shc; } //////////////////////////////////////////////////////////////////////// -ConcatString StatHdrInfo::get_shc_str(const ConcatString &cur_case, - const StringArray &case_cols, - const StringArray &case_vals, - const StringArray &hdr_cols, - const StringArray &hdr_vals, +ConcatString StatHdrInfo::get_col_css(const ConcatString &cur_case, const char *col_name, const StringArray &col_vals, - bool warning) { - ConcatString css, shc_str; - int hdr_index, case_index; - + bool warning) const { // Build comma-separated list of column values - css = write_css(col_vals); + ConcatString css(write_css(col_vals)); // Check for multiple entries if(col_vals.n() > 1) { @@ -560,28 +490,7 @@ ConcatString StatHdrInfo::get_shc_str(const ConcatString &cur_case, else mlog << Debug(2) << msg; } - // Check the header options. - if(hdr_cols.has(col_name, hdr_index)) { - - // Check for the full CASE string. - if(case_str.compare(hdr_vals[hdr_index]) == 0) { - shc_str = cur_case; - } - // Check for one of the case columns. - else if(case_cols.has(hdr_vals[hdr_index], case_index)) { - shc_str = case_vals[case_index]; - } - // Otherwise, use the constant header string. - else { - shc_str = hdr_vals[hdr_index]; - } - } - // Otherwise, use the comma-separated list of values. - else { - shc_str = css; - } - - return shc_str; + return css; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/stat_analysis/aggr_stat_line.h b/src/tools/core/stat_analysis/aggr_stat_line.h index a934491a1f..e79c0155eb 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.h +++ b/src/tools/core/stat_analysis/aggr_stat_line.h @@ -80,14 +80,10 @@ struct StatHdrInfo { const StringArray &hdr_cols, const StringArray &hdr_vals, const STATLineType lt); - ConcatString get_shc_str(const ConcatString &cur_case, - const StringArray &case_cols, - const StringArray &case_vals, - const StringArray &hdr_cols, - const StringArray &hdr_vals, + ConcatString get_col_css(const ConcatString &cur_case, const char *col_name, const StringArray &col_vals, - bool warning); + bool warning) const; }; struct AggrSummaryInfo { diff --git a/src/tools/other/gsi_tools/gsi_util.cc b/src/tools/other/gsi_tools/gsi_util.cc index 5381ebe2d1..82b4000ae9 100644 --- a/src/tools/other/gsi_tools/gsi_util.cc +++ b/src/tools/other/gsi_tools/gsi_util.cc @@ -301,152 +301,35 @@ bool is_retr(const char *s) { void setup_header(StatHdrColumns &shc, const StringArray &name, const StringArray &value, const char *default_line_type) { - int index; - SingleThresh st; - - // MODEL - if(name.has("MODEL", index)) { - shc.set_model(value[index].c_str()); - } - else { - shc.set_model(default_model); - } - - // DESC - if(name.has("DESC", index)) { - shc.set_desc(value[index].c_str()); - } - else { - shc.set_desc(default_desc); - } - - // FCST_LEAD - if(name.has("FCST_LEAD", index)) { - shc.set_fcst_lead_sec(timestring_to_sec(value[index].c_str())); - } - else { - shc.set_fcst_lead_sec(default_lead); - } - - // FCST_VALID_BEG, FCST_VALID_END - if(name.has("FCST_VALID_BEG", index)) { - shc.set_fcst_valid_beg(timestring_to_unix(value[index].c_str())); - not_has_FCST_VALID_BEG = false; - } - if(name.has("FCST_VALID_END", index)) { - shc.set_fcst_valid_end(timestring_to_unix(value[index].c_str())); - not_has_FCST_VALID_END = false; - } - - // OBS_LEAD - if(name.has("OBS_LEAD", index)) { - shc.set_obs_lead_sec(timestring_to_sec(value[index].c_str())); - } - else { - shc.set_obs_lead_sec(default_lead); - } - - // OBS_VALID_BEG, OBS_VALID_END - if(name.has("OBS_VALID_BEG", index)) { - shc.set_obs_valid_beg(timestring_to_unix(value[index].c_str())); - not_has_OBS_VALID_BEG = false; - } - if(name.has("OBS_VALID_END", index)) { - shc.set_obs_valid_end(timestring_to_unix(value[index].c_str())); - not_has_OBS_VALID_END = false; - } - - // FCST_VAR - if(name.has("FCST_VAR", index)) { - shc.set_fcst_var(value[index]); - not_has_FCST_VAR = false; - } - - // FCST_LEV - if(name.has("FCST_LEV", index)) { - shc.set_fcst_lev(value[index].c_str()); - } - else { - shc.set_fcst_lev(default_lev); - } - - // OBS_VAR - if(name.has("OBS_VAR", index)) { - shc.set_obs_var(value[index]); - not_has_OBS_VAR = false; - } - - // OBS_LEV - if(name.has("OBS_LEV", index)) { - shc.set_obs_lev(value[index].c_str()); - } - else { - shc.set_obs_lev(default_lev); - } - - // OBTYPE - if(name.has("OBTYPE", index)) { - shc.set_obtype(value[index].c_str()); - not_has_OBTYPE = false; - } - else { - shc.set_obtype(default_obtype); - } - - // VX_MASK - if(name.has("VX_MASK", index)) { - shc.set_mask(value[index].c_str()); - } - else { - shc.set_mask(default_vx_mask); - } - - // INTERP_MTHD - if(name.has("INTERP_MTHD", index)) { - shc.set_interp_mthd(value[index]); - } - else { - shc.set_interp_mthd((string)default_interp_mthd); - } - - // INTERP_PNTS - if(name.has("INTERP_PNTS", index)) { - shc.set_interp_wdth(nint(sqrt(atof(value[index].c_str())))); - } - else { - shc.set_interp_wdth(default_interp_wdth); - } - - // FCST_THRESH - if(name.has("FCST_THRESH", index)) st.set(value[index].c_str()); - else st.set(default_thresh); + SingleThresh st(na_str); + + // Initialize the header + shc.set_model("GSI"); + shc.set_desc(na_str); + shc.set_fcst_lead_sec(0); + shc.set_fcst_valid_beg(0); + shc.set_fcst_valid_end(0); + shc.set_obs_lead_sec(0); + shc.set_obs_valid_beg(0); + shc.set_obs_valid_end(0); + shc.set_fcst_var(na_str); + shc.set_fcst_units(na_str); + shc.set_fcst_lev(na_str); + shc.set_obs_var(na_str); + shc.set_obs_units(na_str); + shc.set_obs_lev(na_str); + shc.set_obtype(na_str); + shc.set_mask(na_str); + shc.set_interp_mthd(na_str); + shc.set_interp_wdth(0); shc.set_fcst_thresh(st); - - // OBS_THRESH - if(name.has("OBS_THRESH", index)) st.set(value[index].c_str()); - else st.set(default_thresh); shc.set_obs_thresh(st); - - // COV_THRESH - if(name.has("COV_THRESH", index)) st.set(value[index].c_str()); - else st.set(default_thresh); shc.set_cov_thresh(st); + shc.set_alpha(bad_data_double); + shc.set_line_type(default_line_type); - // ALPHA - if(name.has("ALPHA", index)) { - shc.set_alpha(atof(value[index].c_str())); - } - else { - shc.set_alpha(default_alpha); - } - - // LINE_TYPE - if(name.has("LINE_TYPE", index)) { - shc.set_line_type(value[index].c_str()); - } - else { - shc.set_line_type(default_line_type); - } + // Apply the -set_hdr options + shc.apply_set_hdr_opts(name, value); return; } diff --git a/src/tools/other/gsi_tools/gsi_util.h b/src/tools/other/gsi_tools/gsi_util.h index b635884ed2..dfd4390247 100644 --- a/src/tools/other/gsi_tools/gsi_util.h +++ b/src/tools/other/gsi_tools/gsi_util.h @@ -18,21 +18,9 @@ //////////////////////////////////////////////////////////////////////// // Constants -static const char default_model[] = "GSI"; -static const char default_desc[] = "NA"; -static const int default_lead = 0; -static const char default_lev[] = "NA"; -static const char default_obtype[] = "NA"; -static const char default_vx_mask[] = "NA"; -static const char default_interp_mthd[] = "NA"; -static const int default_interp_wdth = 0; -static const char default_thresh[] = "NA"; -static const double default_alpha = bad_data_double; - -static const int bad_setup_qc = -999; -static const char key_sep[] = ":"; - -static const char conv_id_str[] = "conv"; +static const int bad_setup_qc = -999; +static const char key_sep[] = ":"; +static const char conv_id_str[] = "conv"; static const char *micro_id_str [] = { "amsua", "amsub", "mhs", @@ -83,16 +71,6 @@ struct RadData { //////////////////////////////////////////////////////////////////////// -static bool not_has_FCST_VALID_BEG = true; -static bool not_has_FCST_VALID_END = true; -static bool not_has_OBS_VALID_BEG = true; -static bool not_has_OBS_VALID_END = true; -static bool not_has_FCST_VAR = true; -static bool not_has_OBS_VAR = true; -static bool not_has_OBTYPE = true; - -//////////////////////////////////////////////////////////////////////// - ConvData parse_conv_data(const ConvRecord &r, const int i); RadData parse_rad_data (const RadRecord &r, const int i, const int chval, const int use); diff --git a/src/tools/other/gsi_tools/gsid2mpr.cc b/src/tools/other/gsi_tools/gsid2mpr.cc index 8915b73ce6..579d41bd19 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.cc +++ b/src/tools/other/gsi_tools/gsid2mpr.cc @@ -47,7 +47,6 @@ using namespace std; - //////////////////////////////////////////////////////////////////////// static void process_conv(const char *conv_filename, const char *output_filename); @@ -365,13 +364,13 @@ void write_mpr_row_conv(AsciiTable &at, int row, const ConvData &d) { int col; // Update header for current data - if(not_has_FCST_VALID_BEG) shc.set_fcst_valid_beg(d.fcst_ut); - if(not_has_FCST_VALID_END) shc.set_fcst_valid_end(d.fcst_ut); - if(not_has_OBS_VALID_BEG) shc.set_obs_valid_beg(d.obs_ut); - if(not_has_OBS_VALID_END) shc.set_obs_valid_end(d.obs_ut); - if(not_has_FCST_VAR) shc.set_fcst_var(d.var); - if(not_has_OBS_VAR) shc.set_obs_var(d.var); - if(not_has_OBTYPE) shc.set_obtype(d.obtype.c_str()); + if(!hdr_name.has("FCST_VALID_BEG")) shc.set_fcst_valid_beg(d.fcst_ut); + if(!hdr_name.has("FCST_VALID_END")) shc.set_fcst_valid_end(d.fcst_ut); + if(!hdr_name.has("OBS_VALID_BEG")) shc.set_obs_valid_beg(d.obs_ut); + if(!hdr_name.has("OBS_VALID_END")) shc.set_obs_valid_end(d.obs_ut); + if(!hdr_name.has("FCST_VAR")) shc.set_fcst_var(d.var); + if(!hdr_name.has("OBS_VAR")) shc.set_obs_var(d.var); + if(!hdr_name.has("OBTYPE")) shc.set_obtype(d.obtype.c_str()); // Write header columns write_header_cols(shc, at, row); @@ -420,12 +419,12 @@ void write_mpr_row_rad(AsciiTable &at, int row, const RadData & d) { int col; // Update header for current data - if(not_has_FCST_VALID_BEG) shc.set_fcst_valid_beg(d.fcst_ut); - if(not_has_FCST_VALID_END) shc.set_fcst_valid_end(d.fcst_ut); - if(not_has_OBS_VALID_BEG) shc.set_obs_valid_beg(d.obs_ut); - if(not_has_OBS_VALID_END) shc.set_obs_valid_end(d.obs_ut); - if(not_has_FCST_VAR) shc.set_fcst_var(d.var); - if(not_has_OBS_VAR) shc.set_obs_var(d.var); + if(!hdr_name.has("FCST_VALID_BEG")) shc.set_fcst_valid_beg(d.fcst_ut); + if(!hdr_name.has("FCST_VALID_END")) shc.set_fcst_valid_end(d.fcst_ut); + if(!hdr_name.has("OBS_VALID_BEG")) shc.set_obs_valid_beg(d.obs_ut); + if(!hdr_name.has("OBS_VALID_END")) shc.set_obs_valid_end(d.obs_ut); + if(!hdr_name.has("FCST_VAR")) shc.set_fcst_var(d.var); + if(!hdr_name.has("OBS_VAR")) shc.set_obs_var(d.var); // Write header columns write_header_cols(shc, at, row); diff --git a/src/tools/tc_utils/tc_stat/tc_stat.cc b/src/tools/tc_utils/tc_stat/tc_stat.cc index 28025107aa..a5592c7b15 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat.cc @@ -22,6 +22,7 @@ // 004 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 005 09/28/22 Prestopnik MET #2227 Remove namespace std from header files // 006 10/06/22 Halley Gotway MET #392 Incorporate diagnostics +// 007 06/14/24 Halley Gotway MET #2911 Support -set_hdr job command option // //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index ec8172776c..2bfca419fd 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -184,6 +184,8 @@ void TCStatJob::init_from_scratch() { ValidMask.set_ignore_case(1); LineType.set_ignore_case(1); TrackWatchWarn.set_ignore_case(1); + ByColumn.set_ignore_case(1); + HdrName.set_ignore_case(1); clear(); @@ -230,6 +232,10 @@ void TCStatJob::clear() { EventEqualLead.clear(); EventEqualCases.clear(); + ByColumn.clear(); + HdrName.clear(); + HdrValue.clear(); + DumpFile.clear(); close_dump_file(); JobOut = (ofstream *) nullptr; @@ -315,6 +321,11 @@ void TCStatJob::assign(const TCStatJob & j) { InitDiagThreshMap = j.InitDiagThreshMap; PrintDiagWarning = j.PrintDiagWarning; + ByColumn = j.ByColumn; + + HdrName = j.HdrName; + HdrValue = j.HdrValue; + DumpFile = j.DumpFile; open_dump_file(); @@ -514,6 +525,15 @@ void TCStatJob::dump(ostream & out, int depth) const { out << prefix << "OutValidMask = " << (OutValidMaskName.nonempty() ? OutValidMaskName.text() : na_str) << "\n"; + out << prefix << "ByColumn ...\n"; + ByColumn.dump(out, depth + 1); + + out << prefix << "HdrName ...\n"; + HdrName.dump(out, depth + 1); + + out << prefix << "HdrValue ...\n"; + HdrValue.dump(out, depth + 1); + out << prefix << "DumpFile = " << (DumpFile.nonempty() ? DumpFile.text() : na_str) << "\n"; out << prefix << "StatFile = " << (StatFile.nonempty() ? StatFile.text() : na_str) << "\n"; @@ -1086,6 +1106,9 @@ StringArray TCStatJob::parse_job_command(const char *jobstring) { else if(c.compare("-event_equal_lead" ) == 0) { EventEqualLead.add_css_sec(a[i+1].c_str()); a.shift_down(i, 1); } else if(c.compare("-out_init_mask" ) == 0) { set_out_init_mask(a[i+1].c_str()); a.shift_down(i, 1); } else if(c.compare("-out_valid_mask" ) == 0) { set_out_valid_mask(a[i+1].c_str()); a.shift_down(i, 1); } + else if(c.compare("-by" ) == 0) { ByColumn.add_css(to_upper(a[i+1])); a.shift_down(i, 1); } + else if(c.compare("-set_hdr" ) == 0) { HdrName.add(to_upper(a[i+1])); + HdrValue.add(a[i+2]); a.shift_down(i, 2); } else if(c.compare("-dump_row" ) == 0) { DumpFile = a[i+1]; open_dump_file(); a.shift_down(i, 1); } else if(c.compare("-out_stat" ) == 0) { StatFile = a[i+1]; open_stat_file(); a.shift_down(i, 1); } else { b.add(a[i]); } @@ -1206,7 +1229,8 @@ void TCStatJob::close_stat_file() { //////////////////////////////////////////////////////////////////////// -void TCStatJob::dump_pair(const TrackPairInfo &pair, ofstream *out) { +void TCStatJob::dump_pair(const TrackPairInfo &pair, ofstream *out, + bool do_set_hdr) const { if(!out || pair.n_points() == 0) return; @@ -1258,7 +1282,8 @@ void TCStatJob::dump_pair(const TrackPairInfo &pair, ofstream *out) { // Write the TrackPairInfo object i_row = hdr_row; - write_track_pair_info(tchc, pair, out_at, i_row); + if(do_set_hdr) write_track_pair_info(tchc, pair, out_at, i_row, HdrName, HdrValue); + else write_track_pair_info(tchc, pair, out_at, i_row); // Write the AsciiTable to the file *out << out_at; @@ -1268,11 +1293,23 @@ void TCStatJob::dump_pair(const TrackPairInfo &pair, ofstream *out) { //////////////////////////////////////////////////////////////////////// -void TCStatJob::dump_line(const TCStatLine &line, ofstream *out) { +void TCStatJob::dump_line(const TCStatLine &line, ofstream *out, + bool do_set_hdr) const { if(!out) return; - *out << line; + // Apply -set_hdr options, if requested + if(do_set_hdr) { + TCStatLine line_set_hdr = line; + for(int i=0; i 0) s << "-dump_row " << DumpFile << " "; if(StatFile.length() > 0) @@ -1851,7 +1892,7 @@ void TCStatJobFilter::filter_tracks(TCPointCounts &n) { mlog << Debug(4) << "Processing track pair: " << pair.case_info() << "\n"; - if(DumpOut) dump_pair(pair, DumpOut); + if(DumpOut) dump_pair(pair, DumpOut, true); } } // end while } // end else @@ -1888,7 +1929,7 @@ void TCStatJobFilter::filter_lines(TCPointCounts &n) { // Check if this line should be kept if(!is_keeper_line(line, n)) continue; - if(DumpOut) dump_line(line, DumpOut); + if(DumpOut) dump_line(line, DumpOut, true); } // end while } // end else @@ -1955,7 +1996,6 @@ void TCStatJobSummary::init_from_scratch() { // Ignore case when performing comparisons ReqColumn.set_ignore_case(1); Column.set_ignore_case(1); - ByColumn.set_ignore_case(1); clear(); @@ -1972,7 +2012,6 @@ void TCStatJobSummary::clear() { ReqColumn.clear(); Column.clear(); - ByColumn.clear(); SummaryMap.clear(); // Set to default value @@ -1992,7 +2031,6 @@ void TCStatJobSummary::assign(const TCStatJobSummary & j) { ReqColumn = j.ReqColumn; Column = j.Column; ColumnUnion = j.ColumnUnion; - ByColumn = j.ByColumn; SummaryMap = j.SummaryMap; OutAlpha = j.OutAlpha; FSPThresh = j.FSPThresh; @@ -2026,7 +2064,6 @@ StringArray TCStatJobSummary::parse_job_command(const char *jobstring) { if(c.compare("-column" ) == 0) { ReqColumn.add_css(to_upper(a[i+1])); add_column(a[i+1].c_str()); a.shift_down(i, 1); } else if(c.compare("-column_union") == 0) { ColumnUnion = string_to_bool(a[i+1].c_str()); a.shift_down(i, 1); } - else if(c.compare("-by" ) == 0) { ByColumn.add_css(to_upper(a[i+1])); a.shift_down(i, 1); } else if(c.compare("-out_alpha" ) == 0) { OutAlpha = atof(a[i+1].c_str()); a.shift_down(i, 1); } else if(c.compare("-fsp_thresh" ) == 0) { FSPThresh.set(a[i+1].c_str()); a.shift_down(i, 1); } else { b.add(a[i]); } @@ -2090,8 +2127,6 @@ ConcatString TCStatJobSummary::serialize() const { s << "-column " << ReqColumn[i] << " "; if(ColumnUnion != default_column_union) s << "-column_union " << bool_to_string(ColumnUnion) << " "; - for(i=0; isecond.InitMask); sa.add_uniq(it->second.ValidMask); - + // Use the basin names instead if(sa.n() == 1 && sa[0] == na_str) { sa.clear(); @@ -3889,16 +3917,21 @@ void TCStatJobRIRW::do_stat_output(ostream &out) { // c = 0; + // Split the current map key, eliminating the job name in the first entry + StringArray ByValue = it->first.split(":"); + ByValue.shift_down(0, 1); + // // CTC output line // if(OutLineType.has(stat_ctc_str)) { shc.set_alpha(bad_data_double); shc.set_line_type(stat_ctc_str); + shc.apply_set_hdr_opts(HdrName, HdrValue, ByColumn, ByValue); write_header_cols(shc, stat_at, stat_row); write_ctc_cols(it->second.Info, stat_at, stat_row++, n_header_columns); } - + // // CTS output line // @@ -3910,12 +3943,12 @@ void TCStatJobRIRW::do_stat_output(ostream &out) { it->second.Info.allocate_n_alpha(1); it->second.Info.alpha[0] = OutAlpha; shc.set_alpha(OutAlpha); - + // // Compute the stats and confidence intervals for this // CTSInfo object // - + it->second.Info.compute_stats(); it->second.Info.compute_ci(); @@ -3923,14 +3956,15 @@ void TCStatJobRIRW::do_stat_output(ostream &out) { // Write the data line // shc.set_line_type(stat_cts_str); + shc.apply_set_hdr_opts(HdrName, HdrValue, ByColumn, ByValue); write_header_cols(shc, stat_at, stat_row); write_cts_cols(it->second.Info, 0, stat_at, stat_row++, n_header_columns); } } // end for it - + // Write the table out << stat_at << "\n" << flush; - + return; } @@ -3981,9 +4015,6 @@ void TCStatJobProbRIRW::init_from_scratch() { TCStatJob::init_from_scratch(); - // Ignore case when performing comparisons - ByColumn.set_ignore_case(1); - clear(); return; @@ -3997,7 +4028,6 @@ void TCStatJobProbRIRW::clear() { JobType = TCStatJobType::ProbRIRW; - ByColumn.clear(); ProbRIRWMap.clear(); // Set to default values @@ -4023,7 +4053,6 @@ void TCStatJobProbRIRW::assign(const TCStatJobProbRIRW & j) { ProbRIRWExact = j.ProbRIRWExact; ProbRIRWBDeltaThresh = j.ProbRIRWBDeltaThresh; ProbRIRWProbThresh = j.ProbRIRWProbThresh; - ByColumn = j.ByColumn; MaxNThresh = j.MaxNThresh; NDumpLines = j.NDumpLines; OutAlpha = j.OutAlpha; @@ -4060,8 +4089,7 @@ StringArray TCStatJobProbRIRW::parse_job_command(const char *jobstring) { } // Check job command options - if(c.compare("-by" ) == 0) { ByColumn.add_css(to_upper(a[i+1])); a.shift_down(i, 1); } - else if(c.compare("-out_alpha" ) == 0) { OutAlpha = atof(a[i+1].c_str()); a.shift_down(i, 1); } + if(c.compare("-out_alpha" ) == 0) { OutAlpha = atof(a[i+1].c_str()); a.shift_down(i, 1); } else if(c.compare("-out_line_type" ) == 0) { OutLineType.add_css(to_upper(a[i+1])); a.shift_down(i, 1); } else if(c.compare("-probrirw_exact" ) == 0) { ProbRIRWExact = string_to_bool(a[i+1].c_str()); a.shift_down(i, 1); } else if(c.compare("-probrirw_bdelta_thresh") == 0) { ProbRIRWBDeltaThresh.set(a[i+1].c_str()); a.shift_down(i, 1); } @@ -4157,9 +4185,6 @@ ConcatString TCStatJobProbRIRW::serialize() const { s << "-probrirw_prob_thresh " << prob_thresh_to_string(ProbRIRWProbThresh) << " "; // Add ProbRIRW job-specific options - for(i=0; i InitDiagThreshMap; StringArray PrintDiagWarning; + // Store the case information + StringArray ByColumn; + + // Options for -set_hdr output + StringArray HdrName; + StringArray HdrValue; + // Variables to the store the analysis job specification ConcatString DumpFile; // Dump TrackPairInfo used to a file std::ofstream *DumpOut; // Dump output file stream @@ -448,9 +457,6 @@ class TCStatJobSummary : public TCStatJob { StringArray Column; bool ColumnUnion; - // Store the case information - StringArray ByColumn; - // Confidence interval alpha value double OutAlpha; @@ -504,9 +510,6 @@ class TCStatJobRIRW : public TCStatJob { void do_cts_output (std::ostream &); void do_mpr_output (std::ostream &); void do_stat_output(std::ostream &); - - // Store the case information - StringArray ByColumn; // Confidence interval alpha value double OutAlpha; @@ -555,9 +558,6 @@ class TCStatJobProbRIRW : public TCStatJob { SingleThresh ProbRIRWBDeltaThresh; // Threshold the BEST track change ThreshArray ProbRIRWProbThresh; // Array of probabilities for PCT bins - // Store the case information - StringArray ByColumn; - // Maximum number of thresholds encountered int MaxNThresh; int NDumpLines; From 5f20f550f7c3f8012ef7627eb7ed76e8a8cbe8d0 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 20 Jun 2024 16:16:17 -0600 Subject: [PATCH 089/114] Bugfix #2856 develop ens_climo (#2918) * Per #2856, port over fixes from main_v11.1 to develop. * Per #2856, correct conditionals in set_job_controls.sh and tweak existing Ensemble-Stat configuration file to exercise the logic that's being impacted here. --- .github/jobs/set_job_controls.sh | 21 ++++++++++++++++++- .../test_unit/config/EnsembleStatConfig_climo | 1 + src/libcode/vx_stat_out/stat_columns.cc | 8 ++++--- src/libcode/vx_statistics/contable_nx2.cc | 9 ++++++-- src/libcode/vx_statistics/contable_stats.cc | 2 ++ src/tools/core/ensemble_stat/ensemble_stat.cc | 3 +++ .../ensemble_stat/ensemble_stat_conf_info.cc | 18 ++++++++-------- 7 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.github/jobs/set_job_controls.sh b/.github/jobs/set_job_controls.sh index 9c39a50716..10f3b4c21e 100755 --- a/.github/jobs/set_job_controls.sh +++ b/.github/jobs/set_job_controls.sh @@ -57,6 +57,12 @@ elif [ "${GITHUB_EVENT_NAME}" == "push" ]; then input_data_version=${branch_name:6} fi + # check for main_vX.Y in the branch name + elif [[ "${branch_name}" =~ .*(main_v)([0-9]+\.[0-9]+).* ]]; then + + truth_data_version=${BASH_REMATCH[1]}${BASH_REMATCH[2]} + input_data_version=${BASH_REMATCH[2]} + fi # check commit messages for skip or force keywords @@ -87,14 +93,27 @@ elif [ "${GITHUB_EVENT_NAME}" == "push" ]; then elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then + branch_name=`cut -d "/" -f3 <<< "${GITHUB_REF}"` + + # check for main_vX.Y in the branch name + if [[ "${branch_name}" =~ .*(main_v)([0-9]+\.[0-9]+).* ]]; then + + truth_data_version=${BASH_REMATCH[1]}${BASH_REMATCH[2]} + input_data_version=${BASH_REMATCH[2]} + + fi + if [ "${force_tests}" == "true" ]; then + run_diff=true + fi fi # if updating truth or running diff, run unit tests -if [ "$run_update_truth" == "true" ] || [ "$run_diff" == "true" ]; then +if [ "$run_update_truth" == "true" ] || + [ "$run_diff" == "true" ]; then run_unit_tests=true diff --git a/internal/test_unit/config/EnsembleStatConfig_climo b/internal/test_unit/config/EnsembleStatConfig_climo index 633ab775f9..06699abf0a 100644 --- a/internal/test_unit/config/EnsembleStatConfig_climo +++ b/internal/test_unit/config/EnsembleStatConfig_climo @@ -71,6 +71,7 @@ fcst = { field = [ { name = "TMP"; level = "Z2"; message_type = [ "ADPSFC" ]; }, + { name = "TMP"; level = "Z2"; message_type = [ "ADPSFC" ]; prob_cat_thresh = [ >275, >280, >285 ]; }, { name = "TMP"; level = "P850"; message_type = [ "ADPUPA" ]; } ]; } diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index b2ef7bce7a..c6c6244f67 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -3388,11 +3388,13 @@ void write_pjc_cols(const PCTInfo &pct_info, col++; at.set_entry(r, col, // OY_TP - pct_info.pct.event_count_by_row(i)/(double) n); + (n == 0 ? bad_data_double : + pct_info.pct.event_count_by_row(i)/(double) n)); col++; at.set_entry(r, col, // ON_TP - pct_info.pct.nonevent_count_by_row(i)/(double) n); + (n == 0 ? bad_data_double : + pct_info.pct.nonevent_count_by_row(i)/(double) n)); col++; at.set_entry(r, col, // CALIBRATION @@ -3483,7 +3485,7 @@ void write_eclv_cols(const TTContingencyTable &ct, // // Economic Cost/Loss Value // Dump out the ECLV line: - // TOTAL, BASER, BASER_VALUE, + // TOTAL, BASER, VALUE_BASER, // N_PNT, [CL_], [VALUE_] (for each point) // at.set_entry(r, c+0, // Total Number of pairs diff --git a/src/libcode/vx_statistics/contable_nx2.cc b/src/libcode/vx_statistics/contable_nx2.cc index e94cf60dc4..e9964a3b28 100644 --- a/src/libcode/vx_statistics/contable_nx2.cc +++ b/src/libcode/vx_statistics/contable_nx2.cc @@ -467,7 +467,12 @@ return x; double Nx2ContingencyTable::baser() const { - return (double) event_col_total()/n(); + double v; + + if( n() == 0 ) v = bad_data_double; + else v = (double) event_col_total()/n(); + + return ( v ); } @@ -475,7 +480,7 @@ double Nx2ContingencyTable::baser() const { double Nx2ContingencyTable::baser_ci(double alpha, - double &cl, double &cu) const { + double &cl, double &cu) const { double v; v = baser(); diff --git a/src/libcode/vx_statistics/contable_stats.cc b/src/libcode/vx_statistics/contable_stats.cc index b2a9b2bfbd..d0c795f2a2 100644 --- a/src/libcode/vx_statistics/contable_stats.cc +++ b/src/libcode/vx_statistics/contable_stats.cc @@ -737,6 +737,8 @@ double TTContingencyTable::sedi_ci(double alpha, double TTContingencyTable::cost_loss(double r) const { double num, den, h, m, f, b, v; + if(n() == 0) return(bad_data_double); + // Total proportion of hits, misses, false alarms, and observations h = (double) fy_oy() / n(); m = (double) fn_oy() / n(); diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index b15f0fd728..b0fadc0c3a 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -74,6 +74,7 @@ // 041 04/16/24 Halley Gotway MET #2786 Compute RPS from climo bin probs. // 042 04/29/24 Halley Gotway MET #2870 Ignore MISSING keyword. // 043 04/29/24 Halley Gotway MET #2795 Move level mismatch warning. +// 044 06/17/24 Halley Gotway MET #2856 Reinitialize climo_cdf pointer // //////////////////////////////////////////////////////////////////////// @@ -2257,6 +2258,7 @@ void do_pct_cat_thresh(const EnsembleStatVxOpt &vx_opt, // Re-initialize pd_pnt.erase(); + pd_pnt.set_climo_cdf_info_ptr(&vx_opt.cdf_info); // Process the observations for(i_obs=0; i_obs Date: Mon, 24 Jun 2024 13:23:01 -0600 Subject: [PATCH 090/114] Bugfix #2841 develop tang_rad_winds (#2921) * Per #2841, port over fixes from bugfix_2841_main_v11.1_tang_rad_winds for the develop branch * Per #2841, clarify in the docs that azimuths are defined in degrees counter-clockwise from due east. * Per #2841, just updating with output from enum_to_string. * Per #2841, tweak the documentation. * Per #2841, correct the location of using namespace lines. * Per #2841, update compute_tc_diag.py to no longer skip writing the radial and tangential wind diagnostics. * Per #2841, update compute_tc_diag.py to no longer skip writing radial and tangential wind diagnostics. * Revert "Per #2841, update compute_tc_diag.py to no longer skip writing radial and tangential wind diagnostics." This reverts commit f097345bedcfcca663e8fb4322eed5b5e00e19fd. * Revert "Per #2841, update compute_tc_diag.py to no longer skip writing the radial and tangential wind diagnostics." This reverts commit c0402151b038c59efab99c060cc5c390edf002f6. * Per #2841, update comp_dir.sh logic to include .dat in the files that are diffed * Replace tab with spaces * Per #2841, correct the units for the azimuth netcdf output variable * Per #2841, reverse the x dimension of the rotated latlon grid to effectively switch from counterclockwise rotation to clockwise. --------- Co-authored-by: MET Tools Test Account --- docs/Users_Guide/tc-diag.rst | 2 +- docs/Users_Guide/tc-rmw.rst | 2 +- internal/test_unit/R_test/comp_dir.R | 9 +- src/basic/vx_util/main.cc | 2 +- src/libcode/vx_gis/shapetype_to_string.cc | 1 - src/libcode/vx_grid/earth_rotation.cc | 8 +- src/libcode/vx_grid/tcrmw_grid.cc | 99 ++++-------- src/libcode/vx_grid/tcrmw_grid.h | 23 +-- src/libcode/vx_tc_util/vx_tc_nc_util.cc | 26 +++- src/libcode/vx_tc_util/vx_tc_nc_util.h | 2 + src/tools/tc_utils/tc_diag/tc_diag.cc | 2 +- src/tools/tc_utils/tc_rmw/tc_rmw.cc | 96 ++++++------ src/tools/tc_utils/tc_rmw/tc_rmw.h | 8 +- .../tc_utils/tc_rmw/tc_rmw_wind_converter.cc | 146 +++++++++--------- .../tc_utils/tc_rmw/tc_rmw_wind_converter.h | 27 ++-- 15 files changed, 207 insertions(+), 246 deletions(-) diff --git a/docs/Users_Guide/tc-diag.rst b/docs/Users_Guide/tc-diag.rst index 4f1d4630ee..edcafa62dd 100644 --- a/docs/Users_Guide/tc-diag.rst +++ b/docs/Users_Guide/tc-diag.rst @@ -15,7 +15,7 @@ Originally developed for the Statistical Hurricane Intensity Prediction Scheme ( TC-Diag is run once for each initialization time to produce diagnostics for each user-specified combination of TC tracks and model fields. The user provides track data (such as one or more ATCF a-deck track files), along with track filtering criteria as needed, to select one or more tracks to be processed. The user also provides gridded model data from which diagnostics should be computed. Gridded data can be provided for multiple concurrent storms, multiple models, and/or multiple domains (i.e. parent and nest) in a single run. -TC-Diag first determines the list of valid times that appear in any one of the tracks. For each valid time, it processes all track points for that time. For each track point, it reads the gridded model fields requested in the configuration file and transforms the gridded data to a range-azimuth cylindrical coordinates grid. For each domain, it writes the range-azimuth data to a temporary NetCDF file, as described in :numref:`Contributor's Guide Section %s `. +TC-Diag first determines the list of valid times that appear in any one of the tracks. For each valid time, it processes all track points for that time. For each track point, it reads the gridded model fields requested in the configuration file and transforms the gridded data to a range-azimuth cylindrical coordinates grid, as described for the TC-RMW tool in :numref:`tc-rmw`. For each domain, it writes the range-azimuth data to a temporary NetCDF file, as described in :numref:`Contributor's Guide Section %s `. Once the input data have been processed into the temporary NetCDF files, TC-Diag then calls one or more Python diagnostics scripts, as specified in the configuration file, to compute tropical cyclone diagnostic values. The computed diagnostics values are retrieved from the Python script and stored in memory. diff --git a/docs/Users_Guide/tc-rmw.rst b/docs/Users_Guide/tc-rmw.rst index 82628c087c..5f226cc76a 100644 --- a/docs/Users_Guide/tc-rmw.rst +++ b/docs/Users_Guide/tc-rmw.rst @@ -7,7 +7,7 @@ TC-RMW Tool Introduction ============ -The TC-RMW tool regrids tropical cyclone model data onto a moving range-azimuth grid centered on points along the storm track provided in ATCF format, most likely the adeck generated from the file. The radial grid spacing may be set as a factor of the radius of maximum winds (RMW). If wind fields are specified in the configuration file the radial and tangential wind components will be computed. Any regridding method available in MET can be used to interpolate data on the model output grid to the specified range-azimuth grid. The regridding will be done separately on each vertical level. The model data files must coincide with track points in a user provided ATCF formatted track file. +The TC-RMW tool regrids tropical cyclone model data onto a moving range-azimuth grid centered on points along the storm track provided in ATCF format, most likely the adeck generated from the file. The radial grid spacing can be defined in kilometers or as a factor of the radius of maximum winds (RMW). The azimuthal grid spacing is defined in degrees clockwise from due east. If wind vector fields are specified in the configuration file, the radial and tangential wind components will be computed. Any regridding method available in MET can be used to interpolate data on the model output grid to the specified range-azimuth grid. The regridding will be done separately on each vertical level. The model data files must coincide with track points in a user provided ATCF formatted track file. Practical Information ===================== diff --git a/internal/test_unit/R_test/comp_dir.R b/internal/test_unit/R_test/comp_dir.R index a4453459c3..c94d8bae38 100644 --- a/internal/test_unit/R_test/comp_dir.R +++ b/internal/test_unit/R_test/comp_dir.R @@ -51,9 +51,9 @@ strDir1 = gsub("/$", "", listArgs[1]); strDir2 = gsub("/$", "", listArgs[2]); # build a list of files in each stat folder -listTest1 = system(paste("find", strDir1, "| egrep '\\.stat$|\\.txt$|\\.tcst|\\.nc$|\\.out$|\\.ps$|\\.png$' | sort"), intern=T); +listTest1 = system(paste("find", strDir1, "| egrep '\\.stat$|\\.txt$|\\.tcst|\\.nc$|\\.out$|\\.ps$|\\.png$|\\.dat$' | sort"), intern=T); listTest1Files = gsub(paste(strDir1, "/", sep=""), "", listTest1); -listTest2 = system(paste("find", strDir2, "| egrep '\\.stat$|\\.txt$|\\.tcst|\\.nc$|\\.out$|\\.ps$|\\.png$' | sort"), intern=T); +listTest2 = system(paste("find", strDir2, "| egrep '\\.stat$|\\.txt$|\\.tcst|\\.nc$|\\.out$|\\.ps$|\\.png$|\\.dat$' | sort"), intern=T); listTest2Files = gsub(paste(strDir2, "/", sep=""), "", listTest2); if( 1 <= verb ){ cat("dir1:", strDir1, "contains", length(listTest1Files), "files\n"); @@ -103,10 +103,11 @@ for(strFile in listTest1Files[ listTest1Files %in% listTest2Files ]){ compareNc(strFile1, strFile2, verb, strict, file_size_delta, compare_nc_var); } - # if the files are PostScript, PNG, or end in .out, compare accordingly + # if the files are PostScript, PNG, or end in .out or .dat, compare accordingly else if( TRUE == grepl("\\.out$", strFile1, perl=T) || TRUE == grepl("\\.ps$", strFile1, perl=T) || - TRUE == grepl("\\.png$", strFile1, perl=T) ){ + TRUE == grepl("\\.png$", strFile1, perl=T) || + TRUE == grepl("\\.dat$", strFile1, perl=T) ){ if( 1 <= verb ){ cat("file1: ", strFile1, "\nfile2: ", strFile2, "\n", sep=""); } compareDiff(strFile1, strFile2, verb); } diff --git a/src/basic/vx_util/main.cc b/src/basic/vx_util/main.cc index f75b648e3f..f9b55fa203 100644 --- a/src/basic/vx_util/main.cc +++ b/src/basic/vx_util/main.cc @@ -1,5 +1,5 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 2022 - 2023 +// ** Copyright UCAR (c) 2022 - 2024 // ** University Corporation for Atmospheric Research (UCAR) // ** National Center for Atmospheric Research (NCAR) // ** Research Applications Lab (RAL) diff --git a/src/libcode/vx_gis/shapetype_to_string.cc b/src/libcode/vx_gis/shapetype_to_string.cc index 55e8f318c4..e292ffe878 100644 --- a/src/libcode/vx_gis/shapetype_to_string.cc +++ b/src/libcode/vx_gis/shapetype_to_string.cc @@ -28,7 +28,6 @@ #include "shapetype_to_string.h" - using namespace std; diff --git a/src/libcode/vx_grid/earth_rotation.cc b/src/libcode/vx_grid/earth_rotation.cc index 3da1347f23..a904fb9615 100644 --- a/src/libcode/vx_grid/earth_rotation.cc +++ b/src/libcode/vx_grid/earth_rotation.cc @@ -179,7 +179,13 @@ M23 = clat*clon; M33 = slat; */ -set_np(lat_center, lon_center, lon_center - 180.0); + // + // MET #2841 define the rotation by subtracting 90 degrees + // instead of 180 to define TCRMW grids as pointing east + // instead of north. + // + +set_np(lat_center, lon_center, lon_center - 90.0); // // diff --git a/src/libcode/vx_grid/tcrmw_grid.cc b/src/libcode/vx_grid/tcrmw_grid.cc index a2e1738e1b..e695e1c49d 100644 --- a/src/libcode/vx_grid/tcrmw_grid.cc +++ b/src/libcode/vx_grid/tcrmw_grid.cc @@ -136,7 +136,7 @@ Ir.set_xyz(1.0, 0.0, 0.0); Jr.set_xyz(0.0, 1.0, 0.0); Kr.set_xyz(0.0, 0.0, 1.0); -Range_n = 0; +Range_n = 0; Azimuth_n = 0; Range_max_km = 0.0; @@ -288,6 +288,7 @@ y = (lat_rot - RData.rot_lat_ll)/(RData.delta_rot_lat); x = lon_rot/(RData.delta_rot_lon); +x = Nx - x; // MET #2841 switch from counterclockwise to clockwise RotatedLatLonGrid::xy_to_latlon(x, y, lat, lon); @@ -310,6 +311,8 @@ const double range_max_deg = deg_per_km*Range_max_km; RotatedLatLonGrid::latlon_to_xy(lat, lon, x, y); +x = Nx - x; // MET #2841 switch from counterclockwise to clockwise + azi_deg = x*(RData.delta_rot_lon); range_deg = range_max_deg - y*(RData.delta_rot_lat); @@ -324,54 +327,23 @@ return; //////////////////////////////////////////////////////////////////////// -void TcrmwGrid::wind_ne_to_ra (const double lat, const double lon, - const double east_component, const double north_component, - double & radial_component, double & azimuthal_component) const +void TcrmwGrid::wind_ne_to_rt (const double azi_deg, + const double u_wind, const double v_wind, + double & radial_wind, double & tangential_wind) const { -Vector E, N, V; -Vector B_range, B_azi; -double azi_deg, range_deg, range_km; - - -latlon_to_range_azi(lat, lon, range_km, azi_deg); - -range_deg = deg_per_km*range_km; - -E = latlon_to_east (lat, lon); -N = latlon_to_north (lat, lon); - -V = east_component*E + north_component*N; - - -range_azi_to_basis(range_deg, azi_deg, B_range, B_azi); - - - - radial_component = dot(V, B_range); - -azimuthal_component = dot(V, B_azi); - - - - - -return; +double rcos = cosd(azi_deg); +double rsin = sind(azi_deg); +if (is_bad_data(u_wind) || is_bad_data(v_wind)) { + radial_wind = bad_data_double; + tangential_wind = bad_data_double; +} +else { + radial_wind = rcos*u_wind + rsin*v_wind; + tangential_wind = -1.0*rsin*u_wind + rcos*v_wind; } - - -//////////////////////////////////////////////////////////////////////// - - -void TcrmwGrid::wind_ne_to_ra_conventional (const double lat, const double lon, - const double east_component, const double north_component, - double & radial_component, double & azimuthal_component) const - -{ - -wind_ne_to_ra(lat, lon, east_component, north_component, radial_component, azimuthal_component); return; @@ -381,33 +353,17 @@ return; //////////////////////////////////////////////////////////////////////// -void TcrmwGrid::range_azi_to_basis(const double range_deg, const double azi_deg, Vector & B_range, Vector & B_azi) const +void TcrmwGrid::wind_ne_to_rt (const double lat, const double lon, + const double u_wind, const double v_wind, + double & radial_wind, double & tangential_wind) const { -double u, v, w; - - -u = cosd(range_deg)*sind(azi_deg); - -v = cosd(range_deg)*cosd(azi_deg); - -w = -sind(range_deg); - - - -B_range = u*Ir + v*Jr + w*Kr; - +double range_km, azi_deg; -u = cosd(azi_deg); - -v = -sind(azi_deg); - -w = 0.0; - - -B_azi = u*Ir + v*Jr + w*Kr; +latlon_to_range_azi(lat, lon, range_km, azi_deg); +wind_ne_to_rt(azi_deg, u_wind, v_wind, radial_wind, tangential_wind); return; @@ -425,8 +381,9 @@ RotatedLatLonGrid::latlon_to_xy(true_lat, true_lon, x, y); x -= Nx*floor(x/Nx); -x -= Nx*floor(x/Nx); +x = Nx - x; // MET #2841 switch from counterclockwise to clockwise +y -= Ny*floor(y/Ny); return; @@ -442,7 +399,9 @@ void TcrmwGrid::xy_to_latlon(double x, double y, double & true_lat, double & tru x -= Nx*floor(x/Nx); -x -= Nx*floor(x/Nx); +x = Nx - x; // MET #2841 switch from counterclockwise to clockwise + +y -= Ny*floor(y/Ny); RotatedLatLonGrid::xy_to_latlon(x, y, true_lat, true_lon); @@ -500,7 +459,3 @@ return; //////////////////////////////////////////////////////////////////////// - - - - diff --git a/src/libcode/vx_grid/tcrmw_grid.h b/src/libcode/vx_grid/tcrmw_grid.h index 8af34d9261..b7304b614e 100644 --- a/src/libcode/vx_grid/tcrmw_grid.h +++ b/src/libcode/vx_grid/tcrmw_grid.h @@ -35,11 +35,8 @@ class TcrmwGrid : public RotatedLatLonGrid { void calc_ijk(); // calculate rotated basis vectors - void range_azi_to_basis(const double range_deg, const double azi_deg, Vector & B_range, Vector & B_azi) const; - TcrmwData TData; - Vector Ir, Jr, Kr; int Range_n, Azimuth_n; // # of points in the radial and azimuthal directions @@ -89,23 +86,15 @@ class TcrmwGrid : public RotatedLatLonGrid { void xy_to_latlon(double x, double y, double & true_lat, double & true_lon) const; + void wind_ne_to_rt(const double azi_deg, + const double u_wind, const double v_wind, + double & radial_wind, double & tangential_wind) const; + void wind_ne_to_rt(const double lat, const double lon, + const double u_wind, const double v_wind, + double & radial_wind, double & tangential_wind) const; - void wind_ne_to_ra(const double lat, const double lon, - const double east_component, const double north_component, - double & radial_component, double & azimuthal_component) const; - - - // - // possibly toggles the signs of the radial and/or azimuthal components - // - // to align with the conventions used in the TC community - // - void wind_ne_to_ra_conventional (const double lat, const double lon, - const double east_component, const double north_component, - double & radial_component, double & azimuthal_component) const; - }; diff --git a/src/libcode/vx_tc_util/vx_tc_nc_util.cc b/src/libcode/vx_tc_util/vx_tc_nc_util.cc index d601d48caa..bc835eb4e2 100644 --- a/src/libcode/vx_tc_util/vx_tc_nc_util.cc +++ b/src/libcode/vx_tc_util/vx_tc_nc_util.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// - #include #include "vx_tc_nc_util.h" @@ -159,6 +158,21 @@ void write_tc_rmw(NcFile* nc_out, //////////////////////////////////////////////////////////////////////// +bool has_pressure_level(vector levels) { + + bool status = false; + + for (int j = 0; j < levels.size(); j++) { + if (levels[j].substr(0, 1) == "P") { + status = true; + break; + } + } + + return status; +} + +//////////////////////////////////////////////////////////////////////// set get_pressure_level_strings( map > variable_levels) { @@ -289,7 +303,7 @@ void def_tc_pressure(NcFile* nc_out, put_nc_data(&pressure_var, &pressure_data[0]); // Cleanup - if(pressure_data) { delete [] pressure_data; pressure_data = (double *) nullptr; } + if(pressure_data) { delete [] pressure_data; pressure_data = (double *) 0; } return; } @@ -324,7 +338,7 @@ void def_tc_range_azimuth(NcFile* nc_out, add_att(&range_var, "_FillValue", bad_data_double); add_att(&azimuth_var, "long_name", "azimuth"); - add_att(&azimuth_var, "units", "degrees_clockwise_from_north"); + add_att(&azimuth_var, "units", "degrees_clockwise_from_east"); add_att(&azimuth_var, "standard_name", "azimuth"); add_att(&azimuth_var, "_FillValue", bad_data_double); @@ -342,8 +356,8 @@ void def_tc_range_azimuth(NcFile* nc_out, put_nc_data(&azimuth_var, &azimuth_data[0]); // Cleanup - if(range_data) { delete [] range_data; range_data = (double *) nullptr; } - if(azimuth_data) { delete [] azimuth_data; azimuth_data = (double *) nullptr; } + if(range_data) { delete [] range_data; range_data = (double *) 0; } + if(azimuth_data) { delete [] azimuth_data; azimuth_data = (double *) 0; } return; } @@ -539,7 +553,7 @@ void def_tc_variables(NcFile* nc_out, string long_name = variable_long_names[i->first]; string units = variable_units[i->first]; - if (levels.size() > 1) { + if (has_pressure_level(levels)) { data_var = nc_out->addVar( var_name, ncDouble, dims_3d); add_att(&data_var, "long_name", long_name); diff --git a/src/libcode/vx_tc_util/vx_tc_nc_util.h b/src/libcode/vx_tc_util/vx_tc_nc_util.h index bd9911e4d0..174319888c 100644 --- a/src/libcode/vx_tc_util/vx_tc_nc_util.h +++ b/src/libcode/vx_tc_util/vx_tc_nc_util.h @@ -35,6 +35,8 @@ extern void write_tc_track_point(netCDF::NcFile*, extern void write_tc_rmw(netCDF::NcFile*, const netCDF::NcDim&, const TrackInfo&); +extern bool has_pressure_level(std::vector); + extern std::set get_pressure_level_strings( std::map >); diff --git a/src/tools/tc_utils/tc_diag/tc_diag.cc b/src/tools/tc_utils/tc_diag/tc_diag.cc index e5815d30cb..0b551fd1f2 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag.cc @@ -867,7 +867,7 @@ void compute_lat_lon(TcrmwGrid& grid, ia * grid.azimuth_delta_deg(), lat, lon); lat_arr[i] = lat; - lon_arr[i] = -lon; // degrees east to west + lon_arr[i] = -lon; // degrees west to east } } diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index d32bc62d81..2dfe8afd6e 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -23,7 +23,6 @@ // //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -57,7 +56,6 @@ using namespace std; using namespace netCDF; - //////////////////////////////////////////////////////////////////////// static void usage(); @@ -69,22 +67,21 @@ static bool file_is_ok(const ConcatString &, const GrdFileType); static void process_rmw(); static void process_tracks(TrackInfoArray&); static void get_atcf_files(const StringArray&, - const StringArray&, StringArray&, StringArray&); + const StringArray&, StringArray&, StringArray&); static void process_track_files(const StringArray&, - const StringArray&, TrackInfoArray&); + const StringArray&, TrackInfoArray&); static bool is_keeper(const ATCFLineBase *); static void set_deck(const StringArray&); static void set_atcf_source(const StringArray&, - StringArray&, StringArray&); + StringArray&, StringArray&); static void set_data_files(const StringArray&); static void set_config(const StringArray&); static void set_out(const StringArray&); static void setup_grid(); static void setup_nc_file(); static void build_outfile_name(const ConcatString&, - const char*, ConcatString&); -static void compute_lat_lon(TcrmwGrid&, - double*, double*); + const char*, ConcatString&); +static void compute_lat_lon(TcrmwGrid&, double*, double*); static void process_fields(const TrackInfoArray&); //////////////////////////////////////////////////////////////////////// @@ -552,19 +549,19 @@ void set_out(const StringArray& a) { void setup_grid() { - grid_data.name = "TCRMW"; - grid_data.range_n = conf_info.n_range; - grid_data.azimuth_n = conf_info.n_azimuth; + tcrmw_data.name = "TCRMW"; + tcrmw_data.range_n = conf_info.n_range; + tcrmw_data.azimuth_n = conf_info.n_azimuth; // Define the maximum range in km based on the fixed increment if(is_bad_data(conf_info.rmw_scale)) { - grid_data.range_max_km = + tcrmw_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); + tcrmw_grid.set_from_data(tcrmw_data); + grid_out.set(tcrmw_data); } //////////////////////////////////////////////////////////////////////// @@ -651,8 +648,8 @@ void compute_lat_lon(TcrmwGrid& tcrmw_grid, ir * tcrmw_grid.range_delta_km(), ia * tcrmw_grid.azimuth_delta_deg(), lat, lon); - lat_arr[i] = lat; - lon_arr[i] = -lon; + lat_arr[i] = lat; + lon_arr[i] = -lon; // degrees west to east } } } @@ -693,12 +690,12 @@ void process_fields(const TrackInfoArray& tracks) { << point.lon() << ").\n"; // Set grid center - grid_data.lat_center = point.lat(); - grid_data.lon_center = -1.0*point.lon(); // internal sign change + tcrmw_data.lat_center = point.lat(); + tcrmw_data.lon_center = -1.0*point.lon(); // internal sign change // 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 = + tcrmw_data.range_max_km = conf_info.rmw_scale * point.mrd() * tc_km_per_nautical_miles * (conf_info.n_range - 1); @@ -706,9 +703,9 @@ void process_fields(const TrackInfoArray& tracks) { // Re-define the range/azimuth grid tcrmw_grid.clear(); - tcrmw_grid.set_from_data(grid_data); - grid.clear(); - grid.set(grid_data); + tcrmw_grid.set_from_data(tcrmw_data); + grid_out.clear(); + grid_out.set(tcrmw_data); // Compute lat and lon coordinate arrays compute_lat_lon(tcrmw_grid, lat_arr, lon_arr); @@ -727,7 +724,7 @@ void process_fields(const TrackInfoArray& tracks) { for(int i_var = 0; i_var < conf_info.get_n_data(); i_var++) { - // Update with the valid time of the track point + // Update the variable info with the valid time of the track point data_info = conf_info.data_info[i_var]; string sname = data_info->name_attr().string(); @@ -736,38 +733,33 @@ void process_fields(const TrackInfoArray& tracks) { data_info->set_valid(valid_time); // Find data for this track point - get_series_entry(i_point, data_info, data_files, ftype, data_dp, latlon_arr); - - // Check data range - double data_min, data_max; - data_dp.data_range(data_min, data_max); - mlog << Debug(4) << "data_min:" << data_min << "\n"; - mlog << Debug(4) << "data_max:" << data_max << "\n"; - - // Regrid data - data_dp = met_regrid(data_dp, latlon_arr, grid, - data_info->regrid()); - data_dp.data_range(data_min, data_max); - mlog << Debug(4) << "data_min:" << data_min << "\n"; - mlog << Debug(4) << "data_max:" << data_max << "\n"; - - // If this is "U", setup everything for matching "V" - // and compute the radial/tangential winds - if(wind_converter.compute_winds_if_input_is_u( - i_point, sname, slevel, valid_time, data_files, ftype, - latlon_arr, lat_arr, lon_arr, grid, data_dp, tcrmw_grid)) { - write_tc_pressure_level_data(nc_out, tcrmw_grid, - pressure_level_indices, data_info->level_attr(), i_point, - data_3d_vars[conf_info.radial_velocity_field_name.string()], - wind_converter.get_wind_r_arr()); - write_tc_pressure_level_data(nc_out, tcrmw_grid, - pressure_level_indices, data_info->level_attr(), i_point, - data_3d_vars[conf_info.tangential_velocity_field_name.string()], - wind_converter.get_wind_t_arr()); + get_series_entry(i_point, data_info, data_files, ftype, data_dp, grid_in); + + // Regrid data and log the range of values before and after + double dmin, dmax, dmin_rgd, dmax_rgd; + data_dp.data_range(dmin, dmax); + data_dp = met_regrid(data_dp, grid_in, grid_out, data_info->regrid()); + data_dp.data_range(dmin_rgd, dmax_rgd); + + mlog << Debug(4) << data_info->magic_str() + << " input range (" << dmin << ", " << dmax + << "), regrid range (" << dmin_rgd << ", " << dmax_rgd << ")\n"; + + // if this is "U", setup everything for matching "V" and compute the radial/tangential + if(wind_converter.compute_winds_if_input_is_u(i_point, sname, slevel, valid_time, data_files, ftype, + grid_in, grid_out, data_dp, tcrmw_grid)) { + write_tc_pressure_level_data(nc_out, tcrmw_grid, + pressure_level_indices, data_info->level_attr(), i_point, + data_3d_vars[conf_info.radial_velocity_field_name.string()], + wind_converter.get_wind_r_arr()); + write_tc_pressure_level_data(nc_out, tcrmw_grid, + pressure_level_indices, data_info->level_attr(), i_point, + data_3d_vars[conf_info.tangential_velocity_field_name.string()], + wind_converter.get_wind_t_arr()); } // Write data - if(variable_levels[data_info->name_attr()].size() > 1) { + if(has_pressure_level(variable_levels[data_info->name_attr()])) { write_tc_pressure_level_data(nc_out, tcrmw_grid, pressure_level_indices, data_info->level_attr(), i_point, data_3d_vars[data_info->name_attr()], data_dp.data()); diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.h b/src/tools/tc_utils/tc_rmw/tc_rmw.h index 7691a2c012..3bd0bfae40 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.h @@ -84,7 +84,6 @@ static TCRMWConfInfo conf_info; static GrdFileType ftype; static TCRMW_WindConverter wind_converter; - // Optional arguments static ConcatString out_dir; static ConcatString out_prefix; @@ -136,11 +135,10 @@ static std::map pressure_level_indices; // //////////////////////////////////////////////////////////////////////// -static DataPlane dp; -static Grid latlon_arr; -static TcrmwData grid_data; +static Grid grid_in; +static TcrmwData tcrmw_data; static TcrmwGrid tcrmw_grid; -static Grid grid; +static Grid grid_out; // Grid coordinate arrays static double* lat_arr; diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc b/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc index b82f8e30da..58e4b9ea48 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.cc @@ -17,27 +17,25 @@ // ---- ---- ---- ----------- // 000 05/11/22 Albo Pulled the wind conversion into a class // 001 09/28/22 Prestopnik MET #2227 Remove namespace std from header files +// 002 05/03/24 Halley Gotway MET #2841 Fix radial and tangential winds // //////////////////////////////////////////////////////////////////////// - #include "tc_rmw_wind_converter.h" #include "series_data.h" #include "vx_regrid.h" using namespace std; - //////////////////////////////////////////////////////////////////////// -static void wind_ne_to_ra(const TcrmwGrid&, +static void wind_ne_to_rt(const TcrmwGrid&, const DataPlane&, const DataPlane&, - const double*, const double*, double*, double*); + double*, double*); //////////////////////////////////////////////////////////////////////// -void TCRMW_WindConverter::_free_winds_arrays(void) -{ +void TCRMW_WindConverter::_free_winds_arrays(void) { if (_windR != nullptr) { delete [] _windR; _windR = nullptr; @@ -96,6 +94,7 @@ void TCRMW_WindConverter::init(const TCRMWConfInfo *conf) { _vIndexMap[varlevel] = i_var; } } + // test for consistency if (_uIndexMap.size() != _vIndexMap.size()) { mlog << Warning << "Uneven number of u/v wind inputs, no wind conversion will be done:\n" @@ -103,12 +102,16 @@ void TCRMW_WindConverter::init(const TCRMWConfInfo *conf) { << _conf->v_wind_field_name.string() << " has " << _vIndexMap.size() << " inputs\n"; _computeWinds = false; } - map::const_iterator iu, iv; - for (iu=_uIndexMap.begin(), iv=_vIndexMap.begin(); iu!=_uIndexMap.end(); ++iu, ++iv) { - if (iu->first != iv->first) { - mlog << Warning << "Ordering of u/v wind input levels not the same, not implemented, no wind conversions will be done:\n" - << " " << iu->first << " " << iv->first << "\n"; - _computeWinds = false; + if (_computeWinds) { + map::const_iterator iu, iv; + for (iu=_uIndexMap.begin(), iv=_vIndexMap.begin(); iu!=_uIndexMap.end(); ++iu, ++iv) { + if (iu->first != iv->first) { + mlog << Warning << "Ordering of u/v wind input levels not the same, " + << "not implemented, no wind conversions will be done:\n" + << " " << iu->first << " " << iv->first << "\n"; + _computeWinds = false; + break; + } } } } @@ -132,9 +135,7 @@ void TCRMW_WindConverter::update_input(const string &variableName, const string void TCRMW_WindConverter::append_nc_output_vars(map > &variable_levels, map &variable_long_names, map &variable_units) { - if (!_computeWinds) { - return; - } + if (!_computeWinds) return; if (_foundUInInput && _foundVInInput) { variable_levels[_conf->tangential_velocity_field_name] = variable_levels[_conf->u_wind_field_name.string()]; @@ -146,14 +147,15 @@ void TCRMW_WindConverter::append_nc_output_vars(map > &va } else { if (!_foundUInInput) { - mlog << Warning << "\nTCWRMW_WindConverter::checkInputs() -> " + mlog << Warning << "\nTCWRMW_WindConverter::append_nc_output_vars() -> " << "field not found in input \"" << _conf->u_wind_field_name << "\"\n\n"; } if (!_foundVInInput) { - mlog << Warning << "\nTCWRMW_WindConverter::checkInputs() -> " + mlog << Warning << "\nTCWRMW_WindConverter::append_nc_output_vars() -> " << "field not found in input \"" << _conf->v_wind_field_name << "\"\n\n"; } - mlog << Warning << "\nNot computing radial and tangential winds\n\n"; + mlog << Warning << "\nTCWRMW_WindConverter::append_nc_output_vars() -> " + << "Not computing radial and tangential winds\n\n"; _computeWinds = false; } } @@ -166,11 +168,9 @@ bool TCRMW_WindConverter::compute_winds_if_input_is_u(int i_point, unixtime valid_time, const StringArray &data_files, const GrdFileType &ftype, - const Grid &latlon_arr, - const double *lat_arr, - const double *lon_arr, - const Grid &grid, - const DataPlane &data_dp, + const Grid &grid_in, + const Grid &grid_out, + const DataPlane &u_wind_dp, const TcrmwGrid &tcrmw_grid) { if (!_computeWinds) { return false; @@ -178,67 +178,75 @@ bool TCRMW_WindConverter::compute_winds_if_input_is_u(int i_point, int uIndex = -1; int vIndex = -1; - VarInfo *data_infoV = (VarInfo *) nullptr; + VarInfo *v_wind_info = (VarInfo *) nullptr; if (varName == _conf->u_wind_field_name.string()) { uIndex = _uIndexMap[varLevel]; vIndex = _vIndexMap[varLevel]; - data_infoV = _conf->data_info[vIndex]; - data_infoV->set_valid(valid_time); + v_wind_info = _conf->data_info[vIndex]; + v_wind_info->set_valid(valid_time); } else { // not the U input return false; } - DataPlane data_dpV; - Grid latlon_arrV; - get_series_entry(i_point, data_infoV, data_files, ftype, data_dpV, - latlon_arrV); - double data_min, data_max; - data_dpV.data_range(data_min, data_max); - mlog << Debug(4) << "V data_min:" << data_min << "\n"; - mlog << Debug(4) << "V data_max:" << data_max << "\n"; - data_dpV = met_regrid(data_dpV, latlon_arr, grid, data_infoV->regrid()); - data_dpV.data_range(data_min, data_max); - mlog << Debug(4) << "V data_min:" << data_min << "\n"; - mlog << Debug(4) << "V data_max:" << data_max << "\n"; - - // here's the conversion, at last - wind_ne_to_ra(tcrmw_grid, data_dp, data_dpV, lat_arr, lon_arr, - _windR, _windT); - // _windR and _windT now set + DataPlane v_wind_dp; + Grid v_wind_grid; + get_series_entry(i_point, v_wind_info, data_files, ftype, + v_wind_dp, v_wind_grid); + double dmin, dmax, dmin_rgd, dmax_rgd; + v_wind_dp.data_range(dmin, dmax); + v_wind_dp = met_regrid(v_wind_dp, v_wind_grid, grid_out, v_wind_info->regrid()); + v_wind_dp.data_range(dmin_rgd, dmax_rgd); + + mlog << Debug(4) << v_wind_info->magic_str() + << " input range (" << dmin << ", " << dmax + << "), regrid range (" << dmin_rgd << ", " << dmax_rgd << ")\n"; + + // Compute the radial and tangential winds and store in _windR and _windT + wind_ne_to_rt(tcrmw_grid, u_wind_dp, v_wind_dp, _windR, _windT); + return true; } - //////////////////////////////////////////////////////////////////////// -void wind_ne_to_ra(const TcrmwGrid& tcrmw_grid, +void wind_ne_to_rt(const TcrmwGrid& tcrmw_grid, const DataPlane& u_dp, const DataPlane& v_dp, - const double* lat_arr, const double* lon_arr, double* wind_r_arr, double* wind_t_arr) { - // Transform (u, v) to (radial, azimuthal) - for(int ir = 0; ir < tcrmw_grid.range_n(); ir++) { - for(int ia = 0; ia < tcrmw_grid.azimuth_n(); ia++) { - int i = ir * tcrmw_grid.azimuth_n() + ia; - double lat = lat_arr[i]; - double lon = - lon_arr[i]; - double u = u_dp.data()[i]; - double v = v_dp.data()[i]; - double wind_r; - double wind_t; - if(is_bad_data(u) || is_bad_data(v)) { - mlog << Debug(4) << "wind_ne_to_ra: latlon:" << lat << "," << lon << " winds are missing\n"; - wind_r = bad_data_double; - wind_t = bad_data_double; - } else { - tcrmw_grid.wind_ne_to_ra(lat, lon, u, v, wind_r, wind_t); - mlog << Debug(4) << "wind_ne_to_ra: latlon:" << lat << "," << lon << " uv:" << u << "," - << v << ", rt:" << wind_r << "," << wind_t <<"\n"; - } - wind_r_arr[i] = wind_r; - wind_t_arr[i] = wind_t; - } - } + + int n_rng = tcrmw_grid.range_n(); + int n_azi = tcrmw_grid.azimuth_n(); + + // Transform (u, v) to (radial, tangential) winds + for(int ir = 0; ir < n_rng; ir++) { + for(int ia = 0; ia < n_azi; ia++) { + + // Store data in reverse order + int i_rev = (n_rng - ir - 1) * n_azi + ia; + + double azi_deg = ia * tcrmw_grid.azimuth_delta_deg(); + double range_km = ir * tcrmw_grid.range_delta_km(); + + double lat, lon; + tcrmw_grid.range_azi_to_latlon(range_km, azi_deg, lat, lon); + + tcrmw_grid.wind_ne_to_rt(azi_deg, u_dp.data()[i_rev], v_dp.data()[i_rev], + wind_r_arr[i_rev], wind_t_arr[i_rev]); + + mlog << Debug(4) << "wind_ne_to_rt() -> " + << "center lat/lon (" << tcrmw_grid.lat_center_deg() + << ", " << tcrmw_grid.lon_center_deg() + << "), range (km): " << range_km + << ", azimuth (deg): " << azi_deg + << ", point lat/lon (" << lat << ", " << lon + << "), uv (" << u_dp.data()[i_rev] << ", " << v_dp.data()[i_rev] + << "), radial wind: " << wind_r_arr[i_rev] + << ", tangential wind: " << wind_t_arr[i_rev] << "\n"; + } // end for ia + } // end for ir + + return; } +//////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.h b/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.h index 86dbc0d802..819dcb999a 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_wind_converter.h @@ -15,7 +15,7 @@ // // Mod# Date Name Description // ---- ---- ---- ----------- -// 000 05/11/22 DaveAlbo New +// 000 05/11/22 Albo New // //////////////////////////////////////////////////////////////////////// @@ -32,7 +32,6 @@ using std::map; using std::string; - //////////////////////////////////////////////////////////////////////// // // Constants @@ -98,8 +97,8 @@ class TCRMW_WindConverter { // if configured to compute winds, but didn't find U or V, turn off // the wind computations and report an error void append_nc_output_vars(std::map > &variable_levels, - std::map &variable_long_names, - std::map &variable_units); + std::map &variable_long_names, + std::map &variable_units); // Check input varName against U, and if it's a match, lookup V using the // map members, and then compute tangential and radial winds if it is so @@ -109,17 +108,15 @@ class TCRMW_WindConverter { // If true if returned, the winds can be accessed by calls to // get_wind_t_arr() and get_wind_r_arr() bool compute_winds_if_input_is_u(int i_point, - const string &varName, - const string &varLevel, - unixtime valid_time, - const StringArray &data_files, - const GrdFileType &ftype, - const Grid &latlon_arr, - const double *lat_arr, - const double *lon_arr, - const Grid &grid, - const DataPlane &data_dp, - const TcrmwGrid &tcrmw_grid); + const string &varName, + const string &varLevel, + unixtime valid_time, + const StringArray &data_files, + const GrdFileType &ftype, + const Grid &grid_in, + const Grid &grid_out, + const DataPlane &u_wind_dp, + const TcrmwGrid &tcrmw_grid); }; From 1a40ca6eedc738900494630651f24afcfc906ce2 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 27 Jun 2024 10:52:50 -0600 Subject: [PATCH 091/114] Feature #2601 seeps climo config (#2927) * #2601 Added seeps_grid_climo_name and seeps_point_climo_name * #2601 Added seeps_grid_climo_name * #2601 Removed SEEPS settings * #2601 Initial release * #2601 Changed to set the SEEPS climo by using the configuration * #2601 Removed SEESP settings at PointStatConfig_APCP and use PointStatConfig_SEEPS for SEEPSm testing * #2601 Updated descryption for seeps_grid_climo_name * #2601 Added a argument for the SEEPS clomo file * #2601 Added conf_key_seeps_grid_climo_name and conf_key_seeps_point_climo_name * #2601 Support the climo filename from the configuration * #2601 Corrected key for climo name * Removing duplicate word --------- Co-authored-by: Howard Soh Co-authored-by: Julie Prestopnik --- docs/Users_Guide/config_options.rst | 20 ++ docs/Users_Guide/grid-stat.rst | 2 +- docs/Users_Guide/point-stat.rst | 2 +- .../test_unit/config/GridStatConfig_SEEPS | 1 + .../test_unit/config/PointStatConfig_APCP | 9 +- .../test_unit/config/PointStatConfig_SEEPS | 149 +++++++++++++++ internal/test_unit/xml/unit_grid_stat.xml | 2 +- internal/test_unit/xml/unit_point_stat.xml | 10 +- src/basic/vx_config/config_constants.h | 4 +- src/libcode/vx_seeps/seeps.cc | 176 +++++++----------- src/libcode/vx_seeps/seeps.h | 119 +++++++----- src/libcode/vx_statistics/compute_stats.cc | 5 +- src/libcode/vx_statistics/compute_stats.h | 3 +- src/libcode/vx_statistics/pair_data_point.cc | 8 +- src/libcode/vx_statistics/pair_data_point.h | 4 +- src/tools/core/grid_stat/grid_stat.cc | 2 +- .../core/grid_stat/grid_stat_conf_info.cc | 14 +- .../core/grid_stat/grid_stat_conf_info.h | 6 +- .../core/point_stat/point_stat_conf_info.cc | 18 +- .../core/point_stat/point_stat_conf_info.h | 5 +- 20 files changed, 361 insertions(+), 198 deletions(-) create mode 100644 internal/test_unit/config/PointStatConfig_SEEPS diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index fb6e4f47eb..5a92571886 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -1626,6 +1626,26 @@ The default setting is >=0.1&&<=0.85. seeps_p1_thresh = >=0.1&&<=0.85; +seeps_grid_climo_name +--------------------- + +The "seeps_grid_climo_name" option sets the location and the filename of the SEEPS climo file for the gridded data. +The default setting is the empty string. It should be configured by the user. It can be overridden by the environment variable, MET_SEEPS_GRID_CLIMO_NAME. + +.. code-block:: none + + seeps_grid_climo_name = ""; + +seeps_point_climo_name +---------------------- + +The "seeps_point_climo_name" option controls the location and the filename of the SEEPS climo file for the point data. +The default setting is the empty string which does not override the default location and name. It can be overridden by the environment variable, MET_SEEPS_POINT_CLIMO_NAME. + +.. code-block:: none + + seeps_point_climo_name = ""; + mask_missing_flag ----------------- diff --git a/docs/Users_Guide/grid-stat.rst b/docs/Users_Guide/grid-stat.rst index c09df58d54..051178cfb1 100644 --- a/docs/Users_Guide/grid-stat.rst +++ b/docs/Users_Guide/grid-stat.rst @@ -428,7 +428,7 @@ The **output_flag** array controls the type of output that the Grid-Stat tool ge Note that the first two line types are easily derived from one another. The user is free to choose which measure is most desired. The output line types are described in more detail in :numref:`grid_stat-output`. -The SEEPS climo file is not distributed with MET tools because of the file size. It should be configured by using the environment variable, MET_SEEPS_GRID_CLIMO_NAME. +The SEEPS climo file is not distributed with MET tools because of the file size. It should be configured by using the configuration file (seeps_grid_climo_name). It can be overridden by the environment variable, MET_SEEPS_GRID_CLIMO_NAME. _____________________ diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index 025b462f23..0f42d54129 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -501,7 +501,7 @@ Note that writing out matched pair data (MPR lines) for a large number of cases If all line types corresponding to a particular verification method are set to NONE, the computation of those statistics will be skipped in the code and thus make the Point-Stat tool run more efficiently. For example, if FHO, CTC, and CTS are all set to NONE, the Point-Stat tool will skip the categorical verification step. -The default SEEPS climo file exists at MET_BASE/climo/seeps/PPT24_seepsweights.nc. It can be overridden by using the environment variable, MET_SEEPS_POINT_CLIMO_NAME. +The default SEEPS climo file exists at MET_BASE/climo/seeps/PPT24_seepsweights.nc. It is configurable by using the configuration file (seeps_point_climo_name). It can be overridden by the environment variable, MET_SEEPS_POINT_CLIMO_NAME. .. _point_stat-output: diff --git a/internal/test_unit/config/GridStatConfig_SEEPS b/internal/test_unit/config/GridStatConfig_SEEPS index 8a23c76c45..51bc14e2d6 100644 --- a/internal/test_unit/config/GridStatConfig_SEEPS +++ b/internal/test_unit/config/GridStatConfig_SEEPS @@ -210,6 +210,7 @@ nc_pairs_flag = { // Threshold for SEEPS p1 (Probability of being dry) seeps_p1_thresh = ${SEEPS_P1_THRESH}; +seeps_grid_climo_name = "${SEEPS_GRID_CLIMO_NAME}"; //////////////////////////////////////////////////////////////////////////////// diff --git a/internal/test_unit/config/PointStatConfig_APCP b/internal/test_unit/config/PointStatConfig_APCP index a6a6f06d64..b1df56e94b 100644 --- a/internal/test_unit/config/PointStatConfig_APCP +++ b/internal/test_unit/config/PointStatConfig_APCP @@ -127,15 +127,10 @@ output_flag = { rps = NONE; eclv = BOTH; mpr = NONE; - seeps = ${SEEPS_FLAG}; - seeps_mpr = ${SEEPS_FLAG}; + seeps = NONE; + seeps_mpr = NONE; } -//////////////////////////////////////////////////////////////////////////////// -// Threshold for SEEPS p1 (Probability of being dry) - -seeps_p1_thresh = ${SEEPS_P1_THRESH}; - //////////////////////////////////////////////////////////////////////////////// duplicate_flag = NONE; diff --git a/internal/test_unit/config/PointStatConfig_SEEPS b/internal/test_unit/config/PointStatConfig_SEEPS new file mode 100644 index 0000000000..20ffa18cfb --- /dev/null +++ b/internal/test_unit/config/PointStatConfig_SEEPS @@ -0,0 +1,149 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Point-Stat configuration file. +// +// For additional information, please see the MET User's Guide. +// Copied from PointStatConfig_APCP +// +//////////////////////////////////////////////////////////////////////////////// + +model = "FCST"; + +// +// Output description to be written +// May be set separately in each "obs.field" entry +// +desc = "NA"; + +//////////////////////////////////////////////////////////////////////////////// + +regrid = { + to_grid = NONE; + method = NEAREST; + width = 1; +} + +//////////////////////////////////////////////////////////////////////////////// + +obs_window = { + beg = ${BEG_DS}; + end = ${END_DS}; +} + +//////////////////////////////////////////////////////////////////////////////// + +mpr_column = []; +mpr_thresh = []; +cnt_thresh = [ NA ]; +cnt_logic = UNION; +wind_thresh = [ NA ]; +wind_logic = UNION; +eclv_points = 0.05; + +cat_thresh = [ >0.254, >0.635, >1.270, >2.540 ]; +message_type = "ADPSFC"; + +fcst = { + sid_inc = []; + sid_exc = []; + obs_quality_inc = []; + obs_quality_exc = []; + + field = [ + { + name = "${FCST_FIELD_NAME}"; + level = "${FCST_FIELD_LEVEL}"; + } + ]; + +} +obs = ${OBS_DICT}; + +//////////////////////////////////////////////////////////////////////////////// + +mask = { + grid = [ "FULL" ]; + poly = []; + sid = []; + llpnt = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +ci_alpha = [ 0.05 ]; + +boot = { + interval = PCTILE; + rep_prop = 1.0; + n_rep = 0; + rng = "mt19937"; + seed = "1"; +} + +//////////////////////////////////////////////////////////////////////////////// + +interp = { + vld_thresh = 1.0; + + type = [ + { method = MEDIAN; width = 3; }, + { method = NEAREST; width = 1; }, + { method = DW_MEAN; width = [ 3, 5 ]; }, + { method = LS_FIT; width = [ 3, 5 ]; }, + { method = BILIN; width = 2; } + ]; +} + +//////////////////////////////////////////////////////////////////////////////// + +hira = { + flag = FALSE; + width = [ 2, 3, 4, 5 ]; + vld_thresh = 1.0; + cov_thresh = [ ==0.25 ]; + shape = SQUARE; + prob_cat_thresh = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +output_flag = { + fho = BOTH; + ctc = BOTH; + cts = BOTH; + mctc = NONE; + mcts = NONE; + cnt = BOTH; + sl1l2 = BOTH; + sal1l2 = NONE; + vl1l2 = NONE; + val1l2 = NONE; + vcnt = NONE; + pct = NONE; + pstd = NONE; + pjc = NONE; + prc = NONE; + ecnt = NONE; + orank = NONE; + rps = NONE; + eclv = BOTH; + mpr = NONE; + seeps = BOTH; + seeps_mpr = BOTH; +} + +//////////////////////////////////////////////////////////////////////////////// +// Threshold for SEEPS p1 (Probability of being dry) + +seeps_p1_thresh = ${SEEPS_P1_THRESH}; +seeps_point_climo_name = "${SEEPS_POINT_CLIMO_NAME}"; + +//////////////////////////////////////////////////////////////////////////////// + +duplicate_flag = NONE; +rank_corr_flag = FALSE; +tmp_dir = "/tmp"; +output_prefix = "${OUTPUT_PREFIX}"; +version = "V12.0.0"; + +//////////////////////////////////////////////////////////////////////////////// diff --git a/internal/test_unit/xml/unit_grid_stat.xml b/internal/test_unit/xml/unit_grid_stat.xml index cc24ad21d3..ad070dff60 100644 --- a/internal/test_unit/xml/unit_grid_stat.xml +++ b/internal/test_unit/xml/unit_grid_stat.xml @@ -296,7 +296,7 @@ SEEPS_FLAG BOTH SEEPS_P1_THRESH NA OUTPUT_PREFIX SEEPS - MET_SEEPS_GRID_CLIMO_NAME&DATA_DIR_CLIMO;/seeps/PPT24_seepsweights_grid.nc + SEEPS_GRID_CLIMO_NAME&DATA_DIR_CLIMO;/seeps/PPT24_seepsweights_grid.nc \ &DATA_DIR_MODEL;/seeps/gpm_2021120100_2021120200_trmmgrid.nc \ diff --git a/internal/test_unit/xml/unit_point_stat.xml b/internal/test_unit/xml/unit_point_stat.xml index aea2b8e042..2c90567c80 100644 --- a/internal/test_unit/xml/unit_point_stat.xml +++ b/internal/test_unit/xml/unit_point_stat.xml @@ -168,8 +168,6 @@ FCST_FIELD_NAME APCP FCST_FIELD_LEVEL A3 OBS_DICT fcst - SEEPS_FLAG NONE - SEEPS_P1_THRESH NA OUTPUT_PREFIX GRIB1_NAM_TRMM \ @@ -196,8 +194,6 @@ FCST_FIELD_NAME APCP FCST_FIELD_LEVEL A3 OBS_DICT fcst - SEEPS_FLAG NONE - SEEPS_P1_THRESH NA OUTPUT_PREFIX GRIB2_SREF_TRMM \ @@ -224,8 +220,6 @@ FCST_FIELD_NAME APCP_24 FCST_FIELD_LEVEL (*,*) OBS_DICT { field = [ { name = "APCP"; level = "A24"; } ]; } - SEEPS_FLAG NONE - SEEPS_P1_THRESH NA OUTPUT_PREFIX NCMET_NAM_HMTGAGE \ @@ -252,14 +246,14 @@ FCST_FIELD_NAME APCP_24 FCST_FIELD_LEVEL (*,*) OBS_DICT { field = [ { name = "TP24"; level = "L0"; is_precipitation = TRUE; } ]; } - SEEPS_FLAG BOTH SEEPS_P1_THRESH ge0.1&&le0.85 + SEEPS_POINT_CLIMO_NAME OUTPUT_PREFIX NCMET_NAM_NDAS_SEEPS \ &DATA_DIR_MODEL;/met_nc/nam/nam_2012040900_F036_APCP24.nc \ &OUTPUT_DIR;/pb2nc/ndas.20120410.t12z.prepbufr.tm00.nc \ - &CONFIG_DIR;/PointStatConfig_APCP \ + &CONFIG_DIR;/PointStatConfig_SEEPS \ -outdir &OUTPUT_DIR;/point_stat -v 1 diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index deb9a425fe..7640873bc3 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -690,7 +690,9 @@ static const char conf_key_obs_to_qc_map[] = "obs_to_qc_map"; static const char conf_key_missing_thresh[] = "missing_thresh"; static const char conf_key_control_id[] = "control_id"; static const char conf_key_ens_member_ids[] = "ens_member_ids"; -static const char conf_key_seeps_p1_thresh[] = "seeps_p1_thresh"; +static const char conf_key_seeps_grid_climo_name[] = "seeps_grid_climo_name"; +static const char conf_key_seeps_point_climo_name[] = "seeps_point_climo_name"; +static const char conf_key_seeps_p1_thresh[] = "seeps_p1_thresh"; static const char conf_key_ugrid_coordinates_file[] = "ugrid_coordinates_file"; static const char conf_key_ugrid_dataset[] = "ugrid_dataset"; static const char conf_key_ugrid_map_config[] = "ugrid_map_config"; diff --git a/src/libcode/vx_seeps/seeps.cc b/src/libcode/vx_seeps/seeps.cc index 406a09ee94..c3114acffc 100644 --- a/src/libcode/vx_seeps/seeps.cc +++ b/src/libcode/vx_seeps/seeps.cc @@ -35,14 +35,9 @@ using namespace netCDF; bool standalone_debug_seeps = false; -static SeepsClimo *seeps_climo = 0; +static SeepsClimo *seeps_climo = nullptr; static std::map seeps_climo_grid_map_00; -static const char *def_seeps_filename = - "MET_BASE/climo/seeps/PPT24_seepsweights.nc"; -static const char *def_seeps_grid_filename = - "MET_BASE/climo/seeps/PPT24_seepsweights_grid.nc"; - static const char *var_name_sid = "sid"; static const char *var_name_lat = "lat"; static const char *var_name_lon = "lon"; @@ -55,20 +50,20 @@ double weighted_average(double, double, double, double); //////////////////////////////////////////////////////////////////////// -SeepsClimo *get_seeps_climo() { - if (! seeps_climo) seeps_climo = new SeepsClimo(); +SeepsClimo *get_seeps_climo(ConcatString seeps_point_climo_name) { + if (! seeps_climo) seeps_climo = new SeepsClimo(seeps_point_climo_name); return seeps_climo; } //////////////////////////////////////////////////////////////////////// void release_seeps_climo() { - if (seeps_climo) { delete seeps_climo; seeps_climo = 0; } + if (seeps_climo) { delete seeps_climo; seeps_climo = nullptr; } } //////////////////////////////////////////////////////////////////////// -SeepsClimoGrid *get_seeps_climo_grid(int month, int hour) { +SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour) { bool not_found = true; SeepsClimoGrid *seeps_climo_grid = nullptr; for (map::iterator it=seeps_climo_grid_map_00.begin(); @@ -81,7 +76,7 @@ SeepsClimoGrid *get_seeps_climo_grid(int month, int hour) { } if (not_found) { - seeps_climo_grid = new SeepsClimoGrid(month, hour); + seeps_climo_grid = new SeepsClimoGrid(month, hour, seeps_grid_climo_name); seeps_climo_grid_map_00[month] = seeps_climo_grid; } return seeps_climo_grid; @@ -174,9 +169,11 @@ SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { //////////////////////////////////////////////////////////////////////// +SeepsClimoBase::SeepsClimoBase(ConcatString seeps_climo_name) : climo_file_name{seeps_climo_name} { -SeepsClimoBase::SeepsClimoBase() { clear(); + seeps_ready = false; + } //////////////////////////////////////////////////////////////////////// @@ -188,13 +185,56 @@ SeepsClimoBase::~SeepsClimoBase() { //////////////////////////////////////////////////////////////////////// void SeepsClimoBase::clear() { - seeps_ready = false; filtered_count = 0; seeps_p1_thresh.clear(); } //////////////////////////////////////////////////////////////////////// +ConcatString SeepsClimoBase::get_climo_filename() { + ConcatString log_seeps_filename; + ConcatString seeps_filename; + const char *method_name = "SeepsClimoBase::get_climo_filename() -> "; + + // Use the environment variable, if set. + ConcatString env_climo_name = get_env_climo_name(); + bool use_env = get_env(env_climo_name.c_str(), seeps_filename); + if(!use_env) { + seeps_filename = climo_file_name.nonempty() ? climo_file_name : get_def_climo_name(); + } + seeps_filename = replace_path(seeps_filename); + + seeps_ready = file_exists(seeps_filename.c_str()); + if (seeps_ready) { + mlog << Debug(7) << method_name << "SEEPS climo name=\"" + << seeps_filename.c_str() << "\"\n"; + } + else { + ConcatString message = ""; + ConcatString message2 = ""; + if (use_env) { + message.add("from the environment variable "); + message.add(env_climo_name); + message2.add("Correct the environment variable"); + } + else { + message.add(climo_file_name.nonempty() + ? "from the configuration" : "from the default"); + message2.add("Correct the configuration"); + } + mlog << Warning << "\n" << method_name + << "The SEEPS climo name \"" << seeps_filename.c_str() + << "\" " << message << " does not exist!\n" + << message2 << " to set its location " + << "or disable output for SEEPS and SEEPS_MPR.\n\n"; + exit(1); + } + + return seeps_filename; +} + +//////////////////////////////////////////////////////////////////////// + void SeepsClimoBase::set_p1_thresh(const SingleThresh &p1_thresh) { seeps_p1_thresh = p1_thresh; } @@ -203,19 +243,12 @@ void SeepsClimoBase::set_p1_thresh(const SingleThresh &p1_thresh) { //////////////////////////////////////////////////////////////////////// -SeepsClimo::SeepsClimo() { +SeepsClimo::SeepsClimo(ConcatString seeps_climo_name) : SeepsClimoBase{seeps_climo_name} { + + clear(); + ConcatString seeps_name = get_climo_filename(); + if (file_exists(seeps_name.c_str())) read_seeps_scores(seeps_name); - ConcatString seeps_name = get_seeps_climo_filename(); - seeps_ready = file_exists(seeps_name.c_str()); - if (seeps_ready) read_seeps_scores(seeps_name); - else { - mlog << Error << "\nSeepsClimo::SeepsClimo() -> " - << "The SEEPS point climo data \"" << seeps_name << "\" is missing!\n" - << "Set the " << MET_ENV_SEEPS_POINT_CLIMO_NAME - << " environment variable to define its location " - << "or disable output for SEEPS and SEEPS_MPR.\n\n"; - exit(1); - } } //////////////////////////////////////////////////////////////////////// @@ -287,7 +320,7 @@ SeepsRecord *SeepsClimo::get_record(int sid, int month, int hour) { SeepsRecord *record = nullptr; const char *method_name = "SeepsClimo::get_record() -> "; - if (seeps_ready) { + if (is_seeps_ready()) { SeepsClimoRecord *climo_record = nullptr; map::iterator it; if (hour < 6 || hour >= 18) { @@ -300,7 +333,7 @@ SeepsRecord *SeepsClimo::get_record(int sid, int month, int hour) { } if (nullptr != climo_record) { double p1 = climo_record->p1[month-1]; - if (seeps_p1_thresh.check(p1)) { + if (check_seeps_p1_thresh(p1)) { record = new SeepsRecord; record->sid = climo_record->sid; record->lat = climo_record->lat; @@ -316,7 +349,7 @@ SeepsRecord *SeepsClimo::get_record(int sid, int month, int hour) { } } else if (!is_eq(p1, bad_data_double)) { - filtered_count++; + increase_filtered_count(); mlog << Debug(7) << method_name << " filtered by threshold p1=" << climo_record->p1[month-1] <<"\n"; } @@ -336,35 +369,6 @@ SeepsRecord *SeepsClimo::get_record(int sid, int month, int hour) { //////////////////////////////////////////////////////////////////////// -ConcatString SeepsClimo::get_seeps_climo_filename() { - ConcatString seeps_filename; - const char *method_name = "SeepsClimo::get_seeps_climo_filename() -> "; - - // Use the environment variable, if set. - bool use_env = get_env(MET_ENV_SEEPS_POINT_CLIMO_NAME, seeps_filename); - if(use_env) seeps_filename = replace_path(seeps_filename); - else seeps_filename = replace_path(def_seeps_filename); - - if (seeps_ready = file_exists(seeps_filename.c_str())) { - mlog << Debug(7) << method_name << "SEEPS point climo name=\"" - << seeps_filename.c_str() << "\"\n"; - } - else { - ConcatString message = ""; - if (use_env) { - message.add("from the env. name "); - message.add(MET_ENV_SEEPS_POINT_CLIMO_NAME); - } - mlog << Warning << "\n" << method_name - << "The SEEPS point climo name \"" << seeps_filename.c_str() - << "\"" << message << " does not exist!\n\n"; - } - - return seeps_filename; -} - -//////////////////////////////////////////////////////////////////////// - double SeepsClimo::get_score(int sid, double p_fcst, double p_obs, int month, int hour) { double score = bad_data_double; @@ -484,6 +488,8 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { double matrix_12_buf[SEEPS_MONTH*SEEPS_MATRIX_SIZE]; NcFile *nc_file = open_ncfile(filename.c_str()); + clear(); + // dimensions: month = 12 ; nstn = 5293 ; nmatrix = 9 ; get_dim(nc_file, dim_name_nstn, nstn, true); mlog << Debug(6) << method_name << "dimensions nstn = " << nstn << "\n"; @@ -642,7 +648,7 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { } catch(int i_err) { - seeps_ready = false; + set_seeps_ready(false); mlog << Error << "\n" << method_name << "encountered an error on reading " << filename << ". ecception_code=" << i_err << "\n\n"; @@ -656,23 +662,16 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { //////////////////////////////////////////////////////////////////////// -SeepsClimoGrid::SeepsClimoGrid(int month, int hour) : month{month}, hour{hour} +SeepsClimoGrid::SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name) + : month{month}, hour{hour}, SeepsClimoBase{seeps_climo_name} { + clear(); p1_buf = p2_buf = t1_buf = t2_buf = nullptr; s12_buf = s13_buf = s21_buf = s23_buf = s31_buf = s32_buf = nullptr; - ConcatString seeps_name = get_seeps_climo_filename(); - seeps_ready = file_exists(seeps_name.c_str()); - if (seeps_ready) read_seeps_scores(seeps_name); - else { - mlog << Error << "\nSeepsClimoGrid::SeepsClimoGrid -> " - << "The SEEPS grid climo data \"" << seeps_name << "\" is missing!\n" - << "Set the " << MET_ENV_SEEPS_GRID_CLIMO_NAME - << " environment variable to define its location " - << "or disable output for SEEPS.\n\n"; - exit(1); - } + ConcatString seeps_name = get_climo_filename(); + if (file_exists(seeps_name.c_str())) read_seeps_scores(seeps_name); } @@ -708,7 +707,7 @@ SeepsScore *SeepsClimoGrid::get_record(int ix, int iy, int offset = iy * nx + ix; double p1 = p1_buf[offset]; - if (seeps_p1_thresh.check(p1)) { + if (check_seeps_p1_thresh(p1)) { // Determine location in contingency table int ic = (p_obs>t1_buf[offset])+(p_obs>t2_buf[offset]); int jc = (p_fcst>t1_buf[offset])+(p_fcst>t2_buf[offset]); @@ -725,7 +724,7 @@ SeepsScore *SeepsClimoGrid::get_record(int ix, int iy, seeps_record->score = score; } else if (~is_eq(p1, bad_data_double)) { - filtered_count++; + increase_filtered_count(); mlog << Debug(7) << method_name << " filtered by threshold p1=" << p1_buf[offset] <<"\n"; } } @@ -781,37 +780,6 @@ double SeepsClimoGrid::get_score(int ix, int iy, double p_fcst, double p_obs) { //////////////////////////////////////////////////////////////////////// -ConcatString SeepsClimoGrid::get_seeps_climo_filename() { - ConcatString seeps_filename; - const char *method_name = "SeepsClimoGrid::get_seeps_climo_filename() -> "; - - // Use the environment variable, if set. - bool use_env = get_env(MET_ENV_SEEPS_GRID_CLIMO_NAME, seeps_filename); - if(use_env) { - seeps_filename = replace_path(seeps_filename); - } - else seeps_filename = replace_path(def_seeps_grid_filename); - - if (seeps_ready = file_exists(seeps_filename.c_str())) { - mlog << Debug(7) << method_name << "SEEPS grid climo name=\"" - << seeps_filename.c_str() << "\"\n"; - } - else { - ConcatString message = ""; - if (use_env) { - message.add("from the env. name "); - message.add(MET_ENV_SEEPS_GRID_CLIMO_NAME); - } - mlog << Warning << "\n" << method_name - << "The SEEPS grid climo name \"" << seeps_filename.c_str() - << "\"" << message << " does not exist!\n\n"; - } - - return seeps_filename; -} - -//////////////////////////////////////////////////////////////////////// - void SeepsClimoGrid::read_seeps_scores(ConcatString filename) { clock_t clock_time = clock(); const char *method_name = "SeepsClimoGrid::read_seeps_scores() -> "; @@ -922,7 +890,7 @@ void SeepsClimoGrid::read_seeps_scores(ConcatString filename) { } catch(...) { - seeps_ready = false; + set_seeps_ready(false); mlog << Error << "\n" << method_name << "encountered an error on reading " << filename << ".\n\n"; diff --git a/src/libcode/vx_seeps/seeps.h b/src/libcode/vx_seeps/seeps.h index 60bca4468b..208275e7cd 100644 --- a/src/libcode/vx_seeps/seeps.h +++ b/src/libcode/vx_seeps/seeps.h @@ -17,44 +17,49 @@ //////////////////////////////////////////////////////////////////////// -#define SEEPS_MONTH 12 -#define SEEPS_MATRIX_SIZE 9 +constexpr int SEEPS_MONTH = 12; +constexpr int SEEPS_MATRIX_SIZE = 9; -#define SAMPLE_STATION_ID 11035 +constexpr int SAMPLE_STATION_ID = 11035; //////////////////////////////////////////////////////////////////////// -static const char *MET_ENV_SEEPS_POINT_CLIMO_NAME = "MET_SEEPS_POINT_CLIMO_NAME"; -static const char *MET_ENV_SEEPS_GRID_CLIMO_NAME = "MET_SEEPS_GRID_CLIMO_NAME"; - -static const char *dim_name_nstn = "nstn"; - -static const char *var_name_p1_00 = "p1_00"; -static const char *var_name_p2_00 = "p2_00"; -static const char *var_name_t1_00 = "t1_00"; -static const char *var_name_t2_00 = "t2_00"; -static const char *var_name_p1_12 = "p1_12"; -static const char *var_name_p2_12 = "p2_12"; -static const char *var_name_t1_12 = "t1_12"; -static const char *var_name_t2_12 = "t2_12"; -static const char *var_name_matrix_00 = "matrix_00"; -static const char *var_name_matrix_12 = "matrix_12"; -static const char *var_name_s12_00 = "s12_00"; -static const char *var_name_s13_00 = "s13_00"; -static const char *var_name_s21_00 = "s21_00"; -static const char *var_name_s23_00 = "s23_00"; -static const char *var_name_s31_00 = "s31_00"; -static const char *var_name_s32_00 = "s32_00"; -static const char *var_name_s12_12 = "s12_12"; -static const char *var_name_s13_12 = "s13_12"; -static const char *var_name_s21_12 = "s21_12"; -static const char *var_name_s23_12 = "s23_12"; -static const char *var_name_s31_12 = "s31_12"; -static const char *var_name_s32_12 = "s32_12"; +constexpr char MET_ENV_SEEPS_POINT_CLIMO_NAME[] = "MET_SEEPS_POINT_CLIMO_NAME"; +constexpr char MET_ENV_SEEPS_GRID_CLIMO_NAME[] = "MET_SEEPS_GRID_CLIMO_NAME"; + +constexpr char dim_name_nstn[] = "nstn"; + +constexpr char var_name_p1_00[] = "p1_00"; +constexpr char var_name_p2_00[] = "p2_00"; +constexpr char var_name_t1_00[] = "t1_00"; +constexpr char var_name_t2_00[] = "t2_00"; +constexpr char var_name_p1_12[] = "p1_12"; +constexpr char var_name_p2_12[] = "p2_12"; +constexpr char var_name_t1_12[] = "t1_12"; +constexpr char var_name_t2_12[] = "t2_12"; +constexpr char var_name_matrix_00[] = "matrix_00"; +constexpr char var_name_matrix_12[] = "matrix_12"; +constexpr char var_name_s12_00[] = "s12_00"; +constexpr char var_name_s13_00[] = "s13_00"; +constexpr char var_name_s21_00[] = "s21_00"; +constexpr char var_name_s23_00[] = "s23_00"; +constexpr char var_name_s31_00[] = "s31_00"; +constexpr char var_name_s32_00[] = "s32_00"; +constexpr char var_name_s12_12[] = "s12_12"; +constexpr char var_name_s13_12[] = "s13_12"; +constexpr char var_name_s21_12[] = "s21_12"; +constexpr char var_name_s23_12[] = "s23_12"; +constexpr char var_name_s31_12[] = "s31_12"; +constexpr char var_name_s32_12[] = "s32_12"; + +constexpr char def_seeps_point_filename[] = + "MET_BASE/climo/seeps/PPT24_seepsweights.nc"; +constexpr char def_seeps_grid_filename[] = + "MET_BASE/climo/seeps/PPT24_seepsweights_grid.nc"; //density_radius = 0.75 degrees (83km; this is described as “the smallest possible // value that ensures approximately equal representation of all subregions of Europe”.) -static double density_radius = 0.75; +constexpr double density_radius = 0.75; const double density_radius_rad = density_radius * rad_per_deg; //////////////////////////////////////////////////////////////////////// @@ -135,21 +140,31 @@ struct SeepsClimoRecord { class SeepsClimoBase { - protected: - + private: bool seeps_ready; int filtered_count; - SingleThresh seeps_p1_thresh; // Range of SEEPS p1 (probability of being dry)std::map seeps_score_00_map; + SingleThresh seeps_p1_thresh; // Range of SEEPS p1 (probability of being dry) + ConcatString climo_file_name; + + protected: + + bool is_seeps_ready() { return seeps_ready; }; + void increase_filtered_count() { filtered_count++; }; + bool check_seeps_p1_thresh(double p1) { return seeps_p1_thresh.check(p1); }; + ConcatString get_climo_filename(); virtual void clear(); + virtual ConcatString get_env_climo_name() { return "not defined"; }; + virtual char *get_def_climo_name() { return nullptr; }; + virtual void read_seeps_scores(ConcatString filename) {}; + void set_seeps_ready(bool _seeps_ready) { seeps_ready = _seeps_ready; }; public: - SeepsClimoBase(); - ~SeepsClimoBase(); - + SeepsClimoBase(ConcatString seeps_climo_name); + virtual ~SeepsClimoBase(); void set_p1_thresh(const SingleThresh &p1_thresh); - int get_filtered_count(); + int get_filtered_count() const; }; @@ -169,15 +184,17 @@ class SeepsClimo : public SeepsClimoBase { void print_record(SeepsClimoRecord *record, bool with_header=false); void read_records(ConcatString filename); - ConcatString get_seeps_climo_filename(); - void read_seeps_scores(ConcatString filename); + protected: + void clear() override; + ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_POINT_CLIMO_NAME; }; + char *get_def_climo_name() override { return (char *)def_seeps_point_filename; }; + void read_seeps_scores(ConcatString filename) override; public: - SeepsClimo(); + SeepsClimo(ConcatString seeps_climo_name); ~SeepsClimo(); - void clear(); SeepsRecord *get_record(int sid, int month, int hour); double get_score(int sid, double p_fcst, double p_obs, int month, int hour); SeepsScore *get_seeps_score(int sid, double p_fcst, double p_obs, int month, int hour); @@ -199,7 +216,7 @@ class SeepsClimoGrid : public SeepsClimoBase { private: int month; - int hour; + int hour; // not implemented int nx; int ny; double *p1_buf; @@ -213,15 +230,17 @@ class SeepsClimoGrid : public SeepsClimoBase { double *s31_buf; double *s32_buf; - ConcatString get_seeps_climo_filename(); - void read_seeps_scores(ConcatString filename); + protected: + void clear() override; + ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_GRID_CLIMO_NAME; }; + char *get_def_climo_name() override { return (char *)def_seeps_grid_filename; }; + void read_seeps_scores(ConcatString filename) override; public: - SeepsClimoGrid(int month, int hour); + SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name); ~SeepsClimoGrid(); - void clear(); SeepsScore *get_record(int ix, int iy, double p_fcst, double p_obs); double get_score(int offset, int obs_cat, int fcst_cat); double get_score(int ix, int iy, double p_fcst, double p_obs); @@ -236,12 +255,12 @@ class SeepsClimoGrid : public SeepsClimoBase { //////////////////////////////////////////////////////////////////////// -inline int SeepsClimoBase::get_filtered_count() { return filtered_count; } +inline int SeepsClimoBase::get_filtered_count() const { return filtered_count; } //////////////////////////////////////////////////////////////////////// -extern SeepsClimo *get_seeps_climo(); -extern SeepsClimoGrid *get_seeps_climo_grid(int month, int hour=0); +extern SeepsClimo *get_seeps_climo(ConcatString seeps_point_climo_name); +extern SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour=0); extern void release_seeps_climo(); extern void release_seeps_climo_grid(); diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index e4fe518558..d775637dd3 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -1547,7 +1547,8 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps) { void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &obs_dp, DataPlane &seeps_dp, DataPlane &seeps_dp_fcat, DataPlane &seeps_dp_ocat,SeepsAggScore *seeps, - int month, int hour, const SingleThresh &seeps_p1_thresh) { + int month, int hour, const SingleThresh &seeps_p1_thresh, + const ConcatString &seeps_climo_name) { int fcst_cat, obs_cat; int seeps_count, count_diagonal, nan_count, bad_count; int nx = fcst_dp.nx(); @@ -1569,7 +1570,7 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob c12 = c13 = c21 = c23 = c31 = c32 = 0; seeps->clear(); - SeepsClimoGrid *seeps_climo = get_seeps_climo_grid(month); + SeepsClimoGrid *seeps_climo = get_seeps_climo_grid(month, seeps_climo_name); seeps_climo->set_p1_thresh(seeps_p1_thresh); for (int i=0; i &density_vector); diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index d33d8f2311..1041f80324 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -183,8 +183,8 @@ bool PairDataPoint::add_point_pair(const char *sid, double lat, double lon, //////////////////////////////////////////////////////////////////////// -void PairDataPoint::load_seeps_climo() { - if (nullptr == seeps_climo) seeps_climo = get_seeps_climo(); +void PairDataPoint::load_seeps_climo(const ConcatString &seeps_climo_name) { + if (nullptr == seeps_climo) seeps_climo = get_seeps_climo(seeps_climo_name); } //////////////////////////////////////////////////////////////////////// @@ -1674,11 +1674,11 @@ void VxPairDataPoint::set_obs_perc_value(int percentile) { //////////////////////////////////////////////////////////////////////// -void VxPairDataPoint::load_seeps_climo() { +void VxPairDataPoint::load_seeps_climo(const ConcatString &seeps_climo_name) { for(int i=0; i < n_msg_typ; i++){ for(int j=0; j < n_mask; j++){ for(int k=0; k < n_interp; k++){ - pd[i][j][k].load_seeps_climo(); + pd[i][j][k].load_seeps_climo(seeps_climo_name); } } } diff --git a/src/libcode/vx_statistics/pair_data_point.h b/src/libcode/vx_statistics/pair_data_point.h index c68ddf1f33..166e177b84 100644 --- a/src/libcode/vx_statistics/pair_data_point.h +++ b/src/libcode/vx_statistics/pair_data_point.h @@ -59,7 +59,7 @@ class PairDataPoint : public PairBase { bool add_point_pair(const char *, double, double, double, double, unixtime, double, double, double, double, const char *, double, double, double); - void load_seeps_climo(); + void load_seeps_climo(const ConcatString &seeps_climo_name); void set_seeps_thresh(const SingleThresh &p1_thresh); void set_seeps_score(SeepsScore *, int index=-1); @@ -229,7 +229,7 @@ class VxPairDataPoint { void set_mpr_thresh(const StringArray &, const ThreshArray &); - void load_seeps_climo(); + void load_seeps_climo(const ConcatString &seeps_climo_name); void set_seeps_thresh(const SingleThresh &p1_thresh); void set_climo_cdf_info_ptr(const ClimoCDFInfo *); diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 6d8e13864d..ccb03a7df1 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -1206,7 +1206,7 @@ void process_scores() { compute_aggregated_seeps_grid(fcst_dp_smooth, obs_dp_smooth, seeps_dp, seeps_dp_fcat, seeps_dp_ocat, &seeps, month, hour, - conf_info.vx_opt[i].seeps_p1_thresh); + 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); 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 db34b15925..b9e8b8587a 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -84,6 +84,9 @@ void GridStatConfInfo::clear() { output_ascii_flag = false; output_nc_flag = false; + seeps_climo_name.clear(); + seeps_p1_thresh.clear(); + // Deallocate memory if(vx_opt) { delete [] vx_opt; vx_opt = (GridStatVxOpt *) nullptr; } @@ -162,6 +165,12 @@ void GridStatConfInfo::process_config(GrdFileType ftype, // Conf: tmp_dir tmp_dir = parse_conf_tmp_dir(&conf); + // Conf: threshold for SEEPS p1 + seeps_p1_thresh = conf.lookup_thresh(conf_key_seeps_p1_thresh); + + // Conf: SEEPS climo filename + seeps_climo_name = conf.lookup_string(conf_key_seeps_grid_climo_name, false); + #ifdef WITH_UGRID // Conf: ugrid_dataset if (!ignore_ugrid_dataset) ugrid_dataset = parse_conf_ugrid_dataset(&conf); @@ -618,8 +627,6 @@ void GridStatVxOpt::clear() { hss_ec_value = bad_data_double; rank_corr_flag = false; - seeps_p1_thresh.clear(); - for(i=0; iseeps_climo_name); + vx_pd.set_seeps_thresh(conf_info->seeps_p1_thresh); } return; } diff --git a/src/tools/core/point_stat/point_stat_conf_info.h b/src/tools/core/point_stat/point_stat_conf_info.h index befde20349..fb838bae0a 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.h +++ b/src/tools/core/point_stat/point_stat_conf_info.h @@ -131,7 +131,6 @@ class PointStatVxOpt { StringArray mpr_sa; // MPR column names ThreshArray mpr_ta; // MPR column thresholds - SingleThresh seeps_p1_thresh; // SEESP p1 threshold // Vector of MaskLatLon objects defining Lat/Lon Point masks std::vector mask_llpnt; @@ -246,6 +245,10 @@ class PointStatConfInfo { ConcatString tmp_dir; // Directory for temporary files ConcatString output_prefix; // String to customize output file name ConcatString version; // Config file version + + ConcatString seeps_climo_name; // SEESP climo filename + SingleThresh seeps_p1_thresh; // SEESP p1 threshold + #ifdef WITH_UGRID bool ignore_ugrid_dataset; ConcatString ugrid_nc; // NetCDF for coordinate variables of unstructured grid From bd4ef7a5c0af4bdd834d88cf261aeaae1869dcc0 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 2 Jul 2024 11:35:45 -0600 Subject: [PATCH 092/114] Feature 2673 sonarqube beta5 redundant parentheses (#2930) * #2673 Removed redundant_parentheses * #2673 Removed redundant_parentheses * #2673 Removed redundant parentheses * #2673 Removed redundant parentheses --------- Co-authored-by: Howard Soh --- src/basic/vx_config/dictionary.h | 20 ++-- src/basic/vx_config/icode.h | 10 +- src/basic/vx_config/idstack.h | 4 +- src/basic/vx_config/number_stack.h | 2 +- src/basic/vx_config/threshold.h | 32 +++---- src/basic/vx_log/logger.h | 8 +- src/basic/vx_log/string_array.cc | 30 +++--- src/basic/vx_log/string_array.h | 6 +- src/basic/vx_math/affine.cc | 2 +- src/basic/vx_math/affine.h | 48 +++++----- src/basic/vx_math/hist.h | 14 +-- src/basic/vx_math/is_bad_data.h | 22 ++--- src/basic/vx_math/legendre.h | 10 +- src/basic/vx_math/ptile.cc | 2 +- src/basic/vx_math/vx_vector.h | 6 +- src/basic/vx_util/CircularTemplate.h | 2 +- src/basic/vx_util/GridPoint.h | 6 +- src/basic/vx_util/RectangularTemplate.h | 2 +- src/basic/vx_util/ascii_header.h | 12 +-- src/basic/vx_util/ascii_table.h | 28 +++--- src/basic/vx_util/check_endian.h | 8 +- src/basic/vx_util/command_line.h | 6 +- src/basic/vx_util/crc_array.h | 32 +++---- src/basic/vx_util/data_line.h | 16 ++-- src/basic/vx_util/data_plane.cc | 4 +- src/basic/vx_util/data_plane.h | 22 ++--- src/basic/vx_util/is_number.h | 2 +- src/basic/vx_util/long_array.h | 4 +- src/basic/vx_util/mask_poly.h | 6 +- src/basic/vx_util/met_buffer.h | 6 +- src/basic/vx_util/ncrr_array.h | 8 +- src/basic/vx_util/num_array.cc | 10 +- src/basic/vx_util/polyline.cc | 16 ++-- src/basic/vx_util/smart_buffer.h | 8 +- src/basic/vx_util/string_fxns.cc | 2 +- src/basic/vx_util/thresh_array.h | 8 +- src/basic/vx_util/two_d_array.h | 36 +++---- src/libcode/vx_analysis_util/mode_atts.cc | 16 ++-- src/libcode/vx_analysis_util/mode_job.cc | 4 +- src/libcode/vx_analysis_util/mode_job.h | 2 +- src/libcode/vx_analysis_util/stat_job.cc | 18 ++-- src/libcode/vx_analysis_util/stat_job.h | 2 +- src/libcode/vx_analysis_util/stat_line.h | 2 +- src/libcode/vx_analysis_util/time_series.h | 6 +- src/libcode/vx_bool_calc/token_stack.h | 2 +- src/libcode/vx_color/color.h | 16 ++-- src/libcode/vx_color/color_list.h | 6 +- src/libcode/vx_color/color_table.cc | 4 +- src/libcode/vx_data2d/data_class.h | 4 +- src/libcode/vx_data2d/level_info.h | 18 ++-- src/libcode/vx_data2d/table_lookup.cc | 38 ++++---- src/libcode/vx_data2d/table_lookup.h | 4 +- src/libcode/vx_data2d/var_info.h | 62 ++++++------ src/libcode/vx_data2d_grib/data2d_grib.h | 4 +- src/libcode/vx_data2d_grib/grib_classes.cc | 4 +- src/libcode/vx_data2d_grib/grib_strings.cc | 4 +- src/libcode/vx_data2d_grib/grib_utils.cc | 2 +- src/libcode/vx_data2d_grib/var_info_grib.h | 18 ++-- src/libcode/vx_data2d_grib2/data2d_grib2.h | 2 +- src/libcode/vx_data2d_grib2/var_info_grib2.h | 46 ++++----- src/libcode/vx_data2d_nc_cf/nc_cf_file.cc | 4 +- src/libcode/vx_data2d_nc_cf/var_info_nc_cf.h | 16 ++-- src/libcode/vx_data2d_nc_met/data2d_nc_met.h | 2 +- src/libcode/vx_data2d_nc_met/met_file.cc | 8 +- .../vx_data2d_nc_met/var_info_nc_met.h | 8 +- src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc | 4 +- .../vx_data2d_nc_wrf/var_info_nc_wrf.h | 16 ++-- src/libcode/vx_data2d_nc_wrf/wrf_file.cc | 10 +- src/libcode/vx_data2d_python/data2d_python.h | 4 +- .../vx_data2d_python/var_info_python.h | 2 +- src/libcode/vx_data2d_ugrid/ugrid_file.cc | 6 +- src/libcode/vx_data2d_ugrid/var_info_ugrid.h | 16 ++-- src/libcode/vx_geodesy/spheroid.h | 10 +- src/libcode/vx_gis/dbf_file.h | 4 +- src/libcode/vx_gis/shp_array.h | 12 +-- src/libcode/vx_gis/shp_file.h | 6 +- src/libcode/vx_grid/goes_grid.cc | 9 +- src/libcode/vx_grid/goes_grid.h | 2 +- src/libcode/vx_grid/laea_grid.h | 6 +- src/libcode/vx_grid/latlon_grid.h | 4 +- src/libcode/vx_grid/lc_grid.h | 10 +- src/libcode/vx_grid/st_grid.cc | 2 +- src/libcode/vx_grid/st_grid.h | 6 +- src/libcode/vx_grid/tcrmw_grid.h | 14 +-- src/libcode/vx_grid/unstructured_grid.cc | 2 +- src/libcode/vx_grid/unstructured_grid.h | 4 +- src/libcode/vx_gsl_prob/gsl_cdf.cc | 2 +- src/libcode/vx_gsl_prob/gsl_randist.cc | 30 +++--- src/libcode/vx_gsl_prob/gsl_wavelet2d.cc | 2 +- src/libcode/vx_nav/nav.cc | 2 +- src/libcode/vx_nc_obs/nc_obs_util.cc | 6 +- src/libcode/vx_nc_util/nc_utils.hpp | 12 +-- src/libcode/vx_ps/ps_text.h | 20 ++-- src/libcode/vx_ps/table_helper.h | 4 +- src/libcode/vx_ps/vx_ps.h | 10 +- src/libcode/vx_pxm/pcm.h | 4 +- src/libcode/vx_pxm/pxm_base.h | 12 +-- src/libcode/vx_python3_utils/python3_dict.h | 2 +- src/libcode/vx_python3_utils/python3_list.h | 2 +- src/libcode/vx_python3_utils/python3_numpy.h | 18 ++-- src/libcode/vx_python3_utils/python3_script.h | 10 +- src/libcode/vx_python3_utils/wchar_argv.h | 4 +- src/libcode/vx_render/renderinfo.h | 14 +-- src/libcode/vx_shapedata/engine.cc | 40 ++++---- src/libcode/vx_shapedata/ihull.h | 2 +- src/libcode/vx_shapedata/node.cc | 4 +- src/libcode/vx_shapedata/shapedata.h | 10 +- src/libcode/vx_stat_out/stat_columns.cc | 2 +- src/libcode/vx_stat_out/stat_hdr_columns.h | 66 ++++++------- src/libcode/vx_statistics/compute_ci.cc | 22 ++--- src/libcode/vx_statistics/contable.h | 16 ++-- src/libcode/vx_statistics/contable_nx2.cc | 2 +- src/libcode/vx_statistics/contable_stats.cc | 2 +- src/libcode/vx_statistics/met_stats.cc | 4 +- src/libcode/vx_statistics/met_stats.h | 2 +- src/libcode/vx_statistics/obs_error.h | 4 +- src/libcode/vx_statistics/pair_base.h | 2 +- src/libcode/vx_statistics/pair_data_point.cc | 8 +- src/libcode/vx_tc_util/atcf_line_base.h | 14 +-- src/libcode/vx_tc_util/diag_file.h | 22 ++--- src/libcode/vx_tc_util/gen_shape_info.h | 10 +- src/libcode/vx_tc_util/genesis_info.h | 12 +-- src/libcode/vx_tc_util/pair_data_genesis.h | 14 +-- src/libcode/vx_tc_util/prob_gen_info.h | 8 +- src/libcode/vx_tc_util/prob_info_array.cc | 4 +- src/libcode/vx_tc_util/prob_info_array.h | 4 +- src/libcode/vx_tc_util/prob_info_base.h | 30 +++--- src/libcode/vx_tc_util/prob_rirw_info.cc | 4 +- src/libcode/vx_tc_util/prob_rirw_info.h | 8 +- src/libcode/vx_tc_util/prob_rirw_pair_info.h | 38 ++++---- src/libcode/vx_tc_util/tc_hdr_columns.h | 30 +++--- src/libcode/vx_tc_util/track_info.h | 52 +++++----- src/libcode/vx_tc_util/track_pair_info.h | 36 +++---- src/libcode/vx_tc_util/track_point.h | 62 ++++++------ .../vx_time_series/time_series_util.cc | 6 +- src/tools/core/ensemble_stat/ensemble_stat.cc | 44 ++++----- .../ensemble_stat/ensemble_stat_conf_info.cc | 24 ++--- src/tools/core/grid_stat/grid_stat.cc | 24 ++--- .../core/grid_stat/grid_stat_conf_info.cc | 44 ++++----- .../core/grid_stat/grid_stat_conf_info.h | 26 ++--- src/tools/core/point_stat/point_stat.cc | 32 +++---- .../core/point_stat/point_stat_conf_info.cc | 44 ++++----- .../core/point_stat/point_stat_conf_info.h | 12 +-- .../series_analysis_conf_info.h | 4 +- .../core/stat_analysis/aggr_stat_line.cc | 94 +++++++++--------- src/tools/core/stat_analysis/aggr_stat_line.h | 4 +- src/tools/core/stat_analysis/stat_analysis.cc | 12 +-- .../core/stat_analysis/stat_analysis_job.cc | 72 +++++++------- .../wavelet_stat/wavelet_stat_conf_info.cc | 36 +++---- .../wavelet_stat/wavelet_stat_conf_info.h | 10 +- src/tools/dev_utils/gen_climo_bin.cc | 2 +- src/tools/dev_utils/met_nc_file.cc | 4 +- src/tools/other/ascii2nc/aeronet_handler.cc | 2 +- src/tools/other/ascii2nc/file_handler.cc | 2 +- src/tools/other/ascii2nc/iabp_handler.cc | 14 +-- src/tools/other/ascii2nc/met_handler.cc | 2 +- .../gen_ens_prod/gen_ens_prod_conf_info.h | 8 +- src/tools/other/gsi_tools/conv_record.h | 10 +- src/tools/other/gsi_tools/gsi_record.h | 4 +- src/tools/other/gsi_tools/rad_record.h | 30 +++--- src/tools/other/madis2nc/madis2nc.cc | 34 +++---- src/tools/other/mode_graphics/cgraph_font.h | 2 +- src/tools/other/mode_graphics/cgraph_main.h | 4 +- src/tools/other/mode_graphics/color_stack.h | 2 +- .../other/mode_graphics/mode_nc_output_file.h | 22 ++--- .../other/mode_graphics/plot_mode_field.cc | 8 +- src/tools/other/mode_time_domain/2d_att.h | 44 ++++----- .../other/mode_time_domain/2d_att_array.h | 4 +- src/tools/other/mode_time_domain/2d_moments.h | 2 +- src/tools/other/mode_time_domain/3d_att.h | 96 +++++++++---------- .../mode_time_domain/3d_att_pair_array.h | 4 +- .../mode_time_domain/3d_att_single_array.h | 4 +- src/tools/other/mode_time_domain/3d_moments.h | 2 +- src/tools/other/mode_time_domain/fo_graph.h | 6 +- src/tools/other/mode_time_domain/fo_node.h | 10 +- .../other/mode_time_domain/fo_node_array.h | 4 +- src/tools/other/mode_time_domain/mm_engine.h | 6 +- .../other/mode_time_domain/mtd_file_base.h | 16 ++-- .../other/mode_time_domain/mtd_file_float.h | 14 +-- .../other/mode_time_domain/mtd_file_int.h | 18 ++-- .../other/mode_time_domain/mtd_partition.h | 12 +-- .../other/modis_regrid/cloudsat_swath_file.h | 42 ++++---- src/tools/other/modis_regrid/modis_file.h | 8 +- src/tools/other/pb2nc/pb2nc.cc | 14 +-- src/tools/other/wwmca_tool/af_file.h | 10 +- src/tools/other/wwmca_tool/interp_base.h | 4 +- src/tools/other/wwmca_tool/wwmca_ref.h | 2 +- src/tools/tc_utils/tc_dland/tc_poly.h | 4 +- src/tools/tc_utils/tc_gen/tc_gen.cc | 30 +++--- src/tools/tc_utils/tc_stat/tc_stat_job.h | 2 +- 190 files changed, 1307 insertions(+), 1308 deletions(-) diff --git a/src/basic/vx_config/dictionary.h b/src/basic/vx_config/dictionary.h index 742789000b..97faa4e3dc 100644 --- a/src/basic/vx_config/dictionary.h +++ b/src/basic/vx_config/dictionary.h @@ -154,9 +154,9 @@ class DictionaryEntry { //////////////////////////////////////////////////////////////////////// -inline ConfigObjectType DictionaryEntry::type() const { return ( Type ); } +inline ConfigObjectType DictionaryEntry::type() const { return Type; } -inline ConcatString DictionaryEntry::name() const { return ( Name ); } +inline ConcatString DictionaryEntry::name() const { return Name; } inline bool DictionaryEntry::is_number() const { return ( (Type == IntegerType) || (Type == FloatType) ); } @@ -164,11 +164,11 @@ inline bool DictionaryEntry::is_dictionary() const { return ( Type == Dictionary inline bool DictionaryEntry::is_array() const { return ( Type == ArrayType ); } -inline int DictionaryEntry::n_args() const { return ( Nargs ); } +inline int DictionaryEntry::n_args() const { return Nargs; } -inline const IcodeVector * DictionaryEntry::icv() const { return ( v ); } +inline const IcodeVector * DictionaryEntry::icv() const { return v; } -inline Dictionary * DictionaryEntry::dict() const { return ( Dict ); } +inline Dictionary * DictionaryEntry::dict() const { return Dict; } //////////////////////////////////////////////////////////////////////// @@ -344,15 +344,15 @@ class Dictionary { //////////////////////////////////////////////////////////////////////// -inline int Dictionary::n_entries() const { return ( Nentries ); } +inline int Dictionary::n_entries() const { return Nentries; } -inline const Dictionary * Dictionary::parent() const { return ( Parent ); } +inline const Dictionary * Dictionary::parent() const { return Parent; } inline void Dictionary::set_is_array(bool __tf) { IsArray = __tf; return; } -inline bool Dictionary::is_array() const { return ( IsArray ); } +inline bool Dictionary::is_array() const { return IsArray; } -inline bool Dictionary::last_lookup_status() const { return ( LastLookupStatus ); } +inline bool Dictionary::last_lookup_status() const { return LastLookupStatus; } //////////////////////////////////////////////////////////////////////// @@ -434,7 +434,7 @@ class DictionaryStack { //////////////////////////////////////////////////////////////////////// -inline int DictionaryStack::n_elements () const { return ( Nelements ); } +inline int DictionaryStack::n_elements () const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/icode.h b/src/basic/vx_config/icode.h index d344b797dd..6e99455933 100644 --- a/src/basic/vx_config/icode.h +++ b/src/basic/vx_config/icode.h @@ -216,7 +216,7 @@ class IcodeVector { //////////////////////////////////////////////////////////////////////// -inline int IcodeVector::length() const { return ( Ncells ); } +inline int IcodeVector::length() const { return Ncells; } //////////////////////////////////////////////////////////////////////// @@ -267,7 +267,7 @@ class CellStack { //////////////////////////////////////////////////////////////////////// -inline int CellStack::depth() const { return ( Depth ); } +inline int CellStack::depth() const { return Depth; } //////////////////////////////////////////////////////////////////////// @@ -319,7 +319,7 @@ class ICVStack { //////////////////////////////////////////////////////////////////////// -inline int ICVStack::depth() const { return ( Depth ); } +inline int ICVStack::depth() const { return Depth; } //////////////////////////////////////////////////////////////////////// @@ -358,7 +358,7 @@ class ICVQueue { //////////////////////////////////////////////////////////////////////// -inline int ICVQueue::n_elements() const { return ( Nelements ); } +inline int ICVQueue::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// @@ -402,7 +402,7 @@ class ICVArray { //////////////////////////////////////////////////////////////////////// -inline int ICVArray::n_elements() const { return ( Nelements ); } +inline int ICVArray::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/idstack.h b/src/basic/vx_config/idstack.h index 7c274744d4..ab45105b1c 100644 --- a/src/basic/vx_config/idstack.h +++ b/src/basic/vx_config/idstack.h @@ -101,7 +101,7 @@ class IdentifierQueue { //////////////////////////////////////////////////////////////////////// -inline int IdentifierQueue::n_elements() const { return ( Nelements ); } +inline int IdentifierQueue::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// @@ -153,7 +153,7 @@ class IdentifierArray { //////////////////////////////////////////////////////////////////////// -inline int IdentifierArray::n_elements() const { return ( Nelements ); } +inline int IdentifierArray::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/number_stack.h b/src/basic/vx_config/number_stack.h index 298a1b73ca..0a64f7323b 100644 --- a/src/basic/vx_config/number_stack.h +++ b/src/basic/vx_config/number_stack.h @@ -95,7 +95,7 @@ class NumberStack { //////////////////////////////////////////////////////////////////////// -inline int NumberStack::depth() const { return ( Nelements ); } +inline int NumberStack::depth() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/threshold.h b/src/basic/vx_config/threshold.h index 3eb74b5a0b..0f39bd3413 100644 --- a/src/basic/vx_config/threshold.h +++ b/src/basic/vx_config/threshold.h @@ -221,10 +221,10 @@ class Or_Node : public ThreshNode { //////////////////////////////////////////////////////////////////////// -inline ThreshType Or_Node::type() const { return ( thresh_complex ); } -inline double Or_Node::value() const { return ( bad_data_double ); } -inline PercThreshType Or_Node::ptype() const { return ( no_perc_thresh_type ); } -inline double Or_Node::pvalue() const { return ( bad_data_double ); } +inline ThreshType Or_Node::type() const { return thresh_complex ; } +inline double Or_Node::value() const { return bad_data_double ; } +inline PercThreshType Or_Node::ptype() const { return no_perc_thresh_type ; } +inline double Or_Node::pvalue() const { return bad_data_double ; } //////////////////////////////////////////////////////////////////////// @@ -272,10 +272,10 @@ class And_Node : public ThreshNode { //////////////////////////////////////////////////////////////////////// -inline ThreshType And_Node::type() const { return ( thresh_complex ); } -inline double And_Node::value() const { return ( bad_data_double ); } -inline PercThreshType And_Node::ptype() const { return ( no_perc_thresh_type ); } -inline double And_Node::pvalue() const { return ( bad_data_double ); } +inline ThreshType And_Node::type() const { return thresh_complex ; } +inline double And_Node::value() const { return bad_data_double ; } +inline PercThreshType And_Node::ptype() const { return no_perc_thresh_type ; } +inline double And_Node::pvalue() const { return bad_data_double ; } //////////////////////////////////////////////////////////////////////// @@ -322,10 +322,10 @@ class Not_Node : public ThreshNode { //////////////////////////////////////////////////////////////////////// -inline ThreshType Not_Node::type() const { return ( thresh_complex ); } -inline double Not_Node::value() const { return ( bad_data_double ); } -inline PercThreshType Not_Node::ptype() const { return ( no_perc_thresh_type ); } -inline double Not_Node::pvalue() const { return ( bad_data_double ); } +inline ThreshType Not_Node::type() const { return thresh_complex ; } +inline double Not_Node::value() const { return bad_data_double ; } +inline PercThreshType Not_Node::ptype() const { return no_perc_thresh_type ; } +inline double Not_Node::pvalue() const { return bad_data_double ; } //////////////////////////////////////////////////////////////////////// @@ -394,10 +394,10 @@ class Simple_Node : public ThreshNode { //////////////////////////////////////////////////////////////////////// -inline ThreshType Simple_Node::type() const { return ( op ); } -inline double Simple_Node::value() const { return ( T ); } -inline PercThreshType Simple_Node::ptype() const { return ( Ptype ); } -inline double Simple_Node::pvalue() const { return ( PT ); } +inline ThreshType Simple_Node::type() const { return op ; } +inline double Simple_Node::value() const { return T ; } +inline PercThreshType Simple_Node::ptype() const { return Ptype ; } +inline double Simple_Node::pvalue() const { return PT ; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/logger.h b/src/basic/vx_log/logger.h index d88333e98b..5f2c687e16 100644 --- a/src/basic/vx_log/logger.h +++ b/src/basic/vx_log/logger.h @@ -177,9 +177,9 @@ class LoggerDebug { ////////////////////////////////////////////////////////////////// -inline int LoggerDebug::value() const { return (Value); } +inline int LoggerDebug::value() const { return Value; } -inline LoggerDebug::operator int () const { return (Value); } +inline LoggerDebug::operator int () const { return Value; } ////////////////////////////////////////////////////////////////// @@ -292,9 +292,9 @@ class Logger ////////////////////////////////////////////////////////////////// -inline ConcatString Logger::log_filename() const { return (LogFilename); } +inline ConcatString Logger::log_filename() const { return LogFilename; } -inline int Logger::verbosity_level() const { return (VerbosityLevel); } +inline int Logger::verbosity_level() const { return VerbosityLevel; } inline bool Logger::is_open() const { return (out != nullptr); } diff --git a/src/basic/vx_log/string_array.cc b/src/basic/vx_log/string_array.cc index aacf27baf4..60ebc4190d 100644 --- a/src/basic/vx_log/string_array.cc +++ b/src/basic/vx_log/string_array.cc @@ -363,7 +363,7 @@ void StringArray::add_css(const std::string text) } Sorted = false; - + return; } @@ -450,7 +450,7 @@ void StringArray::insert(int i, const char * text) s.insert(s.begin()+i, text); Sorted = false; - + return; } @@ -464,7 +464,7 @@ bool StringArray::has(const std::string text) const { bool found = false; bool forward = true; - + if (Sorted && !IgnoreCase) { found = binary_search(s.begin(), s.end(), text); } @@ -496,13 +496,13 @@ bool StringArray::has(const std::string text, int & index, bool forward) const // bool found = false; index = -1; - + if (!s.empty()) { int count; std::string lower_text = text; std::vector::const_iterator it; if ( IgnoreCase ) transform(lower_text.begin(), lower_text.end(), lower_text.begin(), ::tolower); - + if (forward) { count = 0; for(it = s.begin(); it != s.end(); it++, count++) { @@ -552,7 +552,7 @@ bool StringArray::has(const std::string text, int & index, bool forward) const } if (found) index = count; } - + return found; } @@ -595,7 +595,7 @@ void StringArray::parse_delim(const std::string text, const char *delim) clear(); std::string str = text; - + size_t start = 0; size_t end = str.find_first_of(delim); while (end != string::npos) { @@ -608,7 +608,7 @@ void StringArray::parse_delim(const std::string text, const char *delim) s.push_back(str.substr(start).c_str()); Sorted = false; - + return; } @@ -729,15 +729,15 @@ void StringArray::sort() Sorted = true; return; } - + if ( !Sorted ) { std::sort(s.begin(), s.end()); } - + Sorted = true; - + return; - + } @@ -751,7 +751,7 @@ StringArray StringArray::uniq() const StringArray sa; sa.s = s; - + std::vector::iterator it; it = std::unique(sa.s.begin(), sa.s.end()); @@ -783,7 +783,7 @@ regex_t buffer; regex_t *preg = &buffer; // Check for null pointers -if( !reg_exp_str || !test_str ) return( false ); +if( !reg_exp_str || !test_str ) return false; if( regcomp(preg, reg_exp_str, REG_EXTENDED*REG_NOSUB) != 0 ) { mlog << Error << "\ncheck_reg_exp(char *, char *) -> " @@ -798,7 +798,7 @@ if( regexec(preg, test_str, 0, 0, 0) == 0 ) { valid = true; } // Free allocated memory. regfree( preg ); -return( valid ); +return valid; } diff --git a/src/basic/vx_log/string_array.h b/src/basic/vx_log/string_array.h index 41103fa513..1061eb83e8 100644 --- a/src/basic/vx_log/string_array.h +++ b/src/basic/vx_log/string_array.h @@ -132,11 +132,11 @@ class StringArray { //////////////////////////////////////////////////////////////////////// -inline int StringArray::n_elements() const { return ( (int) (s.size()) ); } +inline int StringArray::n_elements() const { return (int) s.size(); } -inline int StringArray::n () const { return ( s.size() ); } +inline int StringArray::n () const { return s.size(); } -inline int StringArray::max_length() const { return ( MaxLength ); } +inline int StringArray::max_length() const { return MaxLength; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/affine.cc b/src/basic/vx_math/affine.cc index 9fa0965bd6..75dbc4cac5 100644 --- a/src/basic/vx_math/affine.cc +++ b/src/basic/vx_math/affine.cc @@ -1262,7 +1262,7 @@ rho = image_aspect/view_aspect; mag = min(rho, 1.0); -mag *= (view_width)/(image_width); +mag *= view_width/image_width; return mag; diff --git a/src/basic/vx_math/affine.h b/src/basic/vx_math/affine.h index 38f744a010..4c2bf5001c 100644 --- a/src/basic/vx_math/affine.h +++ b/src/basic/vx_math/affine.h @@ -129,17 +129,17 @@ class Box { //////////////////////////////////////////////////////////////////////// -inline double Box::left () const { return ( Left ); } -inline double Box::right() const { return ( Right ); } +inline double Box::left () const { return Left; } +inline double Box::right() const { return Right; } -inline double Box::bottom () const { return ( Bottom ); } -inline double Box::top () const { return ( Top ); } +inline double Box::bottom () const { return Bottom; } +inline double Box::top () const { return Top; } -inline double Box::x_ll () const { return ( Left ); } -inline double Box::y_ll () const { return ( Bottom ); } +inline double Box::x_ll () const { return Left; } +inline double Box::y_ll () const { return Bottom; } -inline double Box::x_ur () const { return ( Right ); } -inline double Box::y_ur () const { return ( Top ); } +inline double Box::x_ur () const { return Right; } +inline double Box::y_ur () const { return Top; } inline double Box::width () const { return ( Right - Left ); } inline double Box::height () const { return ( Top - Bottom ); } @@ -287,15 +287,15 @@ class Affine : public GeneralAffine { //////////////////////////////////////////////////////////////////////// -inline double Affine::m11() const { return ( M11 ); } -inline double Affine::m12() const { return ( M12 ); } -inline double Affine::m21() const { return ( M21 ); } -inline double Affine::m22() const { return ( M22 ); } +inline double Affine::m11() const { return M11; } +inline double Affine::m12() const { return M12; } +inline double Affine::m21() const { return M21; } +inline double Affine::m22() const { return M22; } -inline double Affine::tx () const { return ( TX ); } -inline double Affine::ty () const { return ( TY ); } +inline double Affine::tx () const { return TX; } +inline double Affine::ty () const { return TY; } -inline double Affine::det() const { return ( Det ); } +inline double Affine::det() const { return Det; } inline void Affine::calc_det() { Det = M11*M22 - M21*M12; return; } @@ -428,21 +428,21 @@ class ConformalAffine : public GeneralAffine { //////////////////////////////////////////////////////////////////////// -inline double ConformalAffine::angle() const { return ( Angle ); } +inline double ConformalAffine::angle() const { return Angle; } -inline double ConformalAffine::scale() const { return ( Scale ); } +inline double ConformalAffine::scale() const { return Scale; } -inline bool ConformalAffine::is_conformal() const { return ( true ); } +inline bool ConformalAffine::is_conformal() const { return true; } -inline double ConformalAffine::m11() const { return ( Scale*CosAngle ); } -inline double ConformalAffine::m12() const { return ( Scale*SinAngle ); } +inline double ConformalAffine::m11() const { return Scale*CosAngle; } +inline double ConformalAffine::m12() const { return Scale*SinAngle; } -inline double ConformalAffine::m21() const { return ( -Scale*SinAngle ); } -inline double ConformalAffine::m22() const { return ( Scale*CosAngle ); } +inline double ConformalAffine::m21() const { return -Scale*SinAngle; } +inline double ConformalAffine::m22() const { return Scale*CosAngle; } -inline double ConformalAffine::tx () const { return ( TX ); } -inline double ConformalAffine::ty () const { return ( TY ); } +inline double ConformalAffine::tx () const { return TX; } +inline double ConformalAffine::ty () const { return TY; } inline double ConformalAffine::det() const { return ( Scale*Scale ); } diff --git a/src/basic/vx_math/hist.h b/src/basic/vx_math/hist.h index dbee0e445b..f88f2c00b3 100644 --- a/src/basic/vx_math/hist.h +++ b/src/basic/vx_math/hist.h @@ -100,16 +100,16 @@ class Histogram { //////////////////////////////////////////////////////////////////////// -inline int Histogram::nbins () const { return ( Nbins ); } +inline int Histogram::nbins () const { return Nbins ; } -inline double Histogram::bottom () const { return ( Bottom ); } -inline double Histogram::delta () const { return ( Delta ); } +inline double Histogram::bottom () const { return Bottom; } +inline double Histogram::delta () const { return Delta ; } -inline double Histogram::min_data_value () const { return ( MinValue ); } -inline double Histogram::max_data_value () const { return ( MaxValue ); } +inline double Histogram::min_data_value () const { return MinValue; } +inline double Histogram::max_data_value () const { return MaxValue; } -inline int Histogram::too_big_count () const { return ( TooBigCount ); } -inline int Histogram::too_small_count () const { return ( TooSmallCount ); } +inline int Histogram::too_big_count () const { return TooBigCount; } +inline int Histogram::too_small_count () const { return TooSmallCount; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/is_bad_data.h b/src/basic/vx_math/is_bad_data.h index 8b3f3ce7f7..d8d7b334c3 100644 --- a/src/basic/vx_math/is_bad_data.h +++ b/src/basic/vx_math/is_bad_data.h @@ -28,23 +28,23 @@ inline int is_bad_data(int a) { - if(a == bad_data_int || std::isnan(a)) return(1); - else return(0); + if(a == bad_data_int || std::isnan(a)) return 1; + else return 0; } inline int is_bad_data(long long a) { - if(a == bad_data_ll || std::isnan(a)) return(1); - else return(0); + if(a == bad_data_ll || std::isnan(a)) return 1; + else return 0; } inline int is_bad_data(double a) { - if(fabs(a - bad_data_double) < default_tol || std::isnan(a)) return(1); - else return(0); + if(fabs(a - bad_data_double) < default_tol || std::isnan(a)) return 1; + else return 0; } inline int is_bad_data(float a) { - if(fabs(a - bad_data_float) < default_tol || std::isnan(a)) return(1); - else return(0); + if(fabs(a - bad_data_float) < default_tol || std::isnan(a)) return 1; + else return 0; } inline int is_bad_data(char a) { @@ -52,12 +52,12 @@ inline int is_bad_data(char a) { } inline int is_eq(double a, double b, double tol) { - if(fabs(a - b) < tol) return(1); - else return(0); + if(fabs(a - b) < tol) return 1; + else return 0; } inline int is_eq(double a, double b) { - return(is_eq(a, b, default_tol)); + return is_eq(a, b, default_tol); } diff --git a/src/basic/vx_math/legendre.h b/src/basic/vx_math/legendre.h index 6fcb1b508a..4d0265801f 100644 --- a/src/basic/vx_math/legendre.h +++ b/src/basic/vx_math/legendre.h @@ -90,15 +90,15 @@ class Legendre { //////////////////////////////////////////////////////////////////////// -inline double Legendre::value() const { return ( P[MaxDegree] ); } +inline double Legendre::value() const { return P[MaxDegree]; } -inline double Legendre::last_x() const { return ( X ); } +inline double Legendre::last_x() const { return X; } -inline double Legendre::value(int __n__) const { return ( P[__n__] ); } +inline double Legendre::value(int __n__) const { return P[__n__]; } -inline double Legendre::der_value() const { return ( PP[MaxDegree] ); } +inline double Legendre::der_value() const { return PP[MaxDegree]; } -inline double Legendre::der_value(int __n__) const { return ( PP[__n__] ); } +inline double Legendre::der_value(int __n__) const { return PP[__n__]; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/ptile.cc b/src/basic/vx_math/ptile.cc index 44156fb3fb..e3253631f6 100644 --- a/src/basic/vx_math/ptile.cc +++ b/src/basic/vx_math/ptile.cc @@ -298,7 +298,7 @@ if(ties_current != 0) { if(rank_info) { delete [] rank_info; rank_info = (RankInfo *) nullptr; } if(ordered_array) { delete [] ordered_array; ordered_array = (double *) nullptr; } -return(ties_total); +return ties_total; } diff --git a/src/basic/vx_math/vx_vector.h b/src/basic/vx_math/vx_vector.h index 425287b564..faa523241f 100644 --- a/src/basic/vx_math/vx_vector.h +++ b/src/basic/vx_math/vx_vector.h @@ -111,9 +111,9 @@ class Vector { //////////////////////////////////////////////////////////////////////// -inline double Vector::x() const { return ( X ); } -inline double Vector::y() const { return ( Y ); } -inline double Vector::z() const { return ( Z ); } +inline double Vector::x() const { return X; } +inline double Vector::y() const { return Y; } +inline double Vector::z() const { return Z; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/CircularTemplate.h b/src/basic/vx_util/CircularTemplate.h index 9ba5d9417c..29b38f1980 100644 --- a/src/basic/vx_util/CircularTemplate.h +++ b/src/basic/vx_util/CircularTemplate.h @@ -61,7 +61,7 @@ class CircularTemplate : public GridTemplate { // Return the class name for error messages. static const char* _className(void) { - return("CircleTemplate"); + return "CircleTemplate"; } }; diff --git a/src/basic/vx_util/GridPoint.h b/src/basic/vx_util/GridPoint.h index 4e3cacd53e..accb34da02 100644 --- a/src/basic/vx_util/GridPoint.h +++ b/src/basic/vx_util/GridPoint.h @@ -103,14 +103,14 @@ class GridPoint bool operator==(const GridPoint &other) const { return (this->x == other.x && - this->y == other.y); + this->y == other.y); } bool operator!=(const GridPoint &other) const { return (this->x != other.x || - this->y != other.y); + this->y != other.y); } @@ -134,7 +134,7 @@ class GridPoint static const char *_className(void) { - return("GridPoint"); + return "GridPoint"; } }; diff --git a/src/basic/vx_util/RectangularTemplate.h b/src/basic/vx_util/RectangularTemplate.h index 768315b68e..c6efef462d 100644 --- a/src/basic/vx_util/RectangularTemplate.h +++ b/src/basic/vx_util/RectangularTemplate.h @@ -66,7 +66,7 @@ class RectangularTemplate : public GridTemplate { // Return the class name for error messages. static const char* _className(void) { - return("RectangularTemplate"); + return "RectangularTemplate"; } }; diff --git a/src/basic/vx_util/ascii_header.h b/src/basic/vx_util/ascii_header.h index 499803bbab..a75074228b 100644 --- a/src/basic/vx_util/ascii_header.h +++ b/src/basic/vx_util/ascii_header.h @@ -86,12 +86,12 @@ inline void AsciiHeaderLine::set_version (const char *s) { Version = s; Versi inline void AsciiHeaderLine::set_data_type(const char *s) { DataType = s; DataType.ws_strip(); } inline void AsciiHeaderLine::set_line_type(const char *s) { LineType = s; LineType.ws_strip(); } -inline const char * AsciiHeaderLine::version() const { return(Version.c_str()); } -inline const char * AsciiHeaderLine::data_type() const { return(DataType.c_str()); } -inline const char * AsciiHeaderLine::line_type() const { return(LineType.c_str()); } -inline const char * AsciiHeaderLine::var_index_name() const { return(VarIndexName.c_str()); } -inline int AsciiHeaderLine::var_index_offset() const { return(VarIndexOffset); } -inline int AsciiHeaderLine::var_beg_offset() const { return(VarBegOffset); } +inline const char * AsciiHeaderLine::version() const { return Version.c_str(); } +inline const char * AsciiHeaderLine::data_type() const { return DataType.c_str(); } +inline const char * AsciiHeaderLine::line_type() const { return LineType.c_str(); } +inline const char * AsciiHeaderLine::var_index_name() const { return VarIndexName.c_str(); } +inline int AsciiHeaderLine::var_index_offset() const { return VarIndexOffset; } +inline int AsciiHeaderLine::var_beg_offset() const { return VarBegOffset; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/ascii_table.h b/src/basic/vx_util/ascii_table.h index 5e6de9b239..c7a47b0c86 100644 --- a/src/basic/vx_util/ascii_table.h +++ b/src/basic/vx_util/ascii_table.h @@ -328,34 +328,34 @@ class AsciiTable { //////////////////////////////////////////////////////////////////////// -inline int AsciiTable::nrows() const { return ( Nrows ); } +inline int AsciiTable::nrows() const { return Nrows; } -inline int AsciiTable::ncols() const { return ( Ncols ); } +inline int AsciiTable::ncols() const { return Ncols; } -inline char AsciiTable::col_sep_char() const { return ( ColSepChar ); } +inline char AsciiTable::col_sep_char() const { return ColSepChar; } -inline char AsciiTable::pad_char() const { return ( PadChar ); } +inline char AsciiTable::pad_char() const { return PadChar; } -inline bool AsciiTable::fill_blank () const { return ( FillBlank ); } +inline bool AsciiTable::fill_blank () const { return FillBlank; } inline void AsciiTable::set_fill_blank (bool tf) { FillBlank = tf; return; } -inline int AsciiTable::table_indent () const { return ( TableIndent ); } +inline int AsciiTable::table_indent () const { return TableIndent; } -inline int AsciiTable::precision() const { return ( Precision ); } +inline int AsciiTable::precision() const { return Precision; } -inline const char * AsciiTable::f_float_format() const { return ( f_FloatFormat ); } -inline const char * AsciiTable::g_float_format() const { return ( g_FloatFormat ); } +inline const char * AsciiTable::f_float_format() const { return f_FloatFormat; } +inline const char * AsciiTable::g_float_format() const { return g_FloatFormat; } -inline bool AsciiTable::comma_string() const { return ( DoCommaString ); } +inline bool AsciiTable::comma_string() const { return DoCommaString; } -inline bool AsciiTable::delete_trailing_blank_rows() const { return ( DeleteTrailingBlankRows ); } +inline bool AsciiTable::delete_trailing_blank_rows() const { return DeleteTrailingBlankRows; } -inline bool AsciiTable::elim_trailing_whitespace() const { return ( ElimTrailingWhitespace ); } +inline bool AsciiTable::elim_trailing_whitespace() const { return ElimTrailingWhitespace; } -inline bool AsciiTable::align_decimal_points() const { return ( AlignDecimalPoints ); } +inline bool AsciiTable::align_decimal_points() const { return AlignDecimalPoints; } -inline bool AsciiTable::decimal_points_aligned() const { return ( DecimalPointsAligned ); } +inline bool AsciiTable::decimal_points_aligned() const { return DecimalPointsAligned; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/check_endian.h b/src/basic/vx_util/check_endian.h index d81b6db824..de682470ff 100644 --- a/src/basic/vx_util/check_endian.h +++ b/src/basic/vx_util/check_endian.h @@ -85,8 +85,8 @@ extern void shuffle_8(void *); inline void handle_big_4 (void *) { return; } inline void handle_big_8 (void *) { return; } - inline bool is_little_endian () { return ( false ); } - inline bool is_big_endian () { return ( true ); } + inline bool is_little_endian () { return false; } + inline bool is_big_endian () { return true ; } #else @@ -98,8 +98,8 @@ extern void shuffle_8(void *); inline void handle_big_4 (void * p) { shuffle_4(p); return; } inline void handle_big_8 (void * p) { shuffle_8(p); return; } - inline bool is_little_endian () { return ( true ); } - inline bool is_big_endian () { return ( false ); } + inline bool is_little_endian () { return true ; } + inline bool is_big_endian () { return false; } #endif diff --git a/src/basic/vx_util/command_line.h b/src/basic/vx_util/command_line.h index 9c8f25592a..b4734e855f 100644 --- a/src/basic/vx_util/command_line.h +++ b/src/basic/vx_util/command_line.h @@ -120,7 +120,7 @@ class CLOptionInfoArray { //////////////////////////////////////////////////////////////////////// -inline int CLOptionInfoArray::n_elements() const { return ( Nelements ); } +inline int CLOptionInfoArray::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// @@ -219,9 +219,9 @@ class CommandLine { //////////////////////////////////////////////////////////////////////// -inline int CommandLine::n() const { return ( args.n_elements() ); } +inline int CommandLine::n() const { return args.n_elements(); } -inline int CommandLine::max_length() const { return ( args.max_length() ); } +inline int CommandLine::max_length() const { return args.max_length(); } inline void CommandLine::set_usage(UsageFunction f) { Usage = f; return; } diff --git a/src/basic/vx_util/crc_array.h b/src/basic/vx_util/crc_array.h index 5603c1eb78..02805d1bf5 100644 --- a/src/basic/vx_util/crc_array.h +++ b/src/basic/vx_util/crc_array.h @@ -65,11 +65,11 @@ class CRC_Array { CRC_Array & operator=(const CRC_Array & _a) { - if ( this == &_a ) return ( * this ); + if ( this == &_a ) return *this; assign(_a); - return ( * this ); + return *this; } @@ -94,8 +94,8 @@ class CRC_Array { // get stuff // - int n_elements() const { return ( Nelements ); } - int n () const { return ( Nelements ); } + int n_elements() const { return Nelements; } + int n () const { return Nelements; } T operator[] (int) const; @@ -145,7 +145,7 @@ clear(); for(int j=0; j::operator==(const CRC_Array & a) const { -if ( Nelements != a.Nelements ) return ( false ); +if ( Nelements != a.Nelements ) return false; for(int j=0; j= Nelements) ) { } -return ( e[i] ); +return e[i]; } @@ -424,7 +424,7 @@ else { } } -return ( found ); +return found; } @@ -454,7 +454,7 @@ else { } } -return ( found ); +return found; } @@ -577,7 +577,7 @@ for(j=0, count=0; j::min() const { -if ( Nelements == 0 ) return ( bad_data_int ); +if ( Nelements == 0 ) return bad_data_int; int j; @@ -605,7 +605,7 @@ for(j=0; j::max() const { -if(Nelements == 0) return(bad_data_int); +if(Nelements == 0) return bad_data_int; int j; @@ -633,7 +633,7 @@ for(j=0; j & DataPlane::buf() { return ( Data ); } +inline const double * DataPlane::data() const { return Data.data(); } +inline std::vector & DataPlane::buf() { return Data; } //////////////////////////////////////////////////////////////////////// @@ -244,7 +244,7 @@ class DataPlaneArray { //////////////////////////////////////////////////////////////////////// -inline int DataPlaneArray::n_planes () const { return ( Nplanes ); } +inline int DataPlaneArray::n_planes () const { return Nplanes; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/is_number.h b/src/basic/vx_util/is_number.h index 991416d2d1..2807ae7c9f 100644 --- a/src/basic/vx_util/is_number.h +++ b/src/basic/vx_util/is_number.h @@ -45,7 +45,7 @@ inline std::ostream & operator<<(std::ostream & __out, const Number & __n) if ( __n.is_int ) __out << (__n.i); else __out << (__n.d); -return ( __out ); +return __out; } diff --git a/src/basic/vx_util/long_array.h b/src/basic/vx_util/long_array.h index 99380b88ad..83864f9684 100644 --- a/src/basic/vx_util/long_array.h +++ b/src/basic/vx_util/long_array.h @@ -78,9 +78,9 @@ class LongArray { //////////////////////////////////////////////////////////////////////// -inline int LongArray::n_elements() const { return ( Nelements ); } +inline int LongArray::n_elements() const { return Nelements; } -inline LongArray::operator long * () const { return ( e ); } +inline LongArray::operator long * () const { return e; } inline void LongArray::erase() { Nelements = 0; return; } diff --git a/src/basic/vx_util/mask_poly.h b/src/basic/vx_util/mask_poly.h index 0b9c3c1b30..76f3f0ef1a 100644 --- a/src/basic/vx_util/mask_poly.h +++ b/src/basic/vx_util/mask_poly.h @@ -95,9 +95,9 @@ class MaskPoly { //////////////////////////////////////////////////////////////////////// -inline ConcatString MaskPoly::name() const { return ( Name ); } -inline ConcatString MaskPoly::file_name() const { return ( FileName ); } -inline int MaskPoly::n_points() const { return ( Npoints ); } +inline ConcatString MaskPoly::name() const { return Name ; } +inline ConcatString MaskPoly::file_name() const { return FileName; } +inline int MaskPoly::n_points() const { return Npoints ; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/met_buffer.h b/src/basic/vx_util/met_buffer.h index 2f6ff02f42..0386e906a8 100644 --- a/src/basic/vx_util/met_buffer.h +++ b/src/basic/vx_util/met_buffer.h @@ -98,10 +98,10 @@ class MetBuffer { //////////////////////////////////////////////////////////////////////// -inline unsigned char * MetBuffer::operator()() const { return ( Buf ); } +inline unsigned char * MetBuffer::operator()() const { return Buf; } -inline bigint MetBuffer::n_bytes() const { return ( Nbytes ); } -inline bigint MetBuffer::n_alloc() const { return ( Nalloc ); } +inline bigint MetBuffer::n_bytes() const { return Nbytes; } +inline bigint MetBuffer::n_alloc() const { return Nalloc; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/ncrr_array.h b/src/basic/vx_util/ncrr_array.h index b802b7372c..e4b1fdc511 100644 --- a/src/basic/vx_util/ncrr_array.h +++ b/src/basic/vx_util/ncrr_array.h @@ -67,11 +67,11 @@ class NCRR_Array { NCRR_Array & operator=(const NCRR_Array & _a) { - if ( this == _a ) return ( * this ); + if ( this == _a ) return *this; assign(_a); - return ( * this ); + return *this; } @@ -89,9 +89,9 @@ class NCRR_Array { // get stuff // - int n_elements() const { return ( Nelements );} + int n_elements() const { return Nelements;} - int n () const { return ( Nelements );} + int n () const { return Nelements;} T & operator[](int) const; diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index baaac11c6a..e2a8c79ff0 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -1127,7 +1127,7 @@ double NumArray::mean_sqrt() const // for simple mean, call weighted mean with constant weight wgt.add_const(1.0, n_elements()); - return(wmean_sqrt(wgt)); + return wmean_sqrt(wgt); } @@ -1144,7 +1144,7 @@ double NumArray::mean_fisher() const // for simple mean, call weighted mean with constant weight wgt.add_const(1.0, n_elements()); - return(wmean_fisher(wgt)); + return wmean_fisher(wgt); } @@ -1177,7 +1177,7 @@ double NumArray::wmean(const NumArray &wgt) const if(count == 0) wmn = bad_data_double; else wmn = s/w; - return(wmn); + return wmn; } @@ -1267,7 +1267,7 @@ double NumArray::variance(int skip_index) const var = bad_data_double; } - return(var); + return var; } @@ -1335,7 +1335,7 @@ double NumArray::wmean_abs_diff() const else wmad = wgt * mad; - return(wmad); + return wmad; } diff --git a/src/basic/vx_util/polyline.cc b/src/basic/vx_util/polyline.cc index f75ee6ef50..5d96776544 100644 --- a/src/basic/vx_util/polyline.cc +++ b/src/basic/vx_util/polyline.cc @@ -655,7 +655,7 @@ double polyline_dist(const Polyline & a, const Polyline & b) { // done // - return ( min_dist ); + return min_dist; } /////////////////////////////////////////////////////////////////////////////// @@ -679,9 +679,9 @@ double polyline_pw_ls_mean_dist(const Polyline &a, const Polyline &b) { for(j=0; j qmp ) { dx = x_test - qx; dy = y_test - qy; - return ( sqrt( dx*dx + dy*dy ) ); + return sqrt( dx*dx + dy*dy ); } vx = rmpx - t0*cx; vy = rmpy - t0*cy; - return ( sqrt( vx*vx + vy*vy ) ); + return sqrt( vx*vx + vy*vy ); } diff --git a/src/basic/vx_util/smart_buffer.h b/src/basic/vx_util/smart_buffer.h index 2d85465381..bad1524476 100644 --- a/src/basic/vx_util/smart_buffer.h +++ b/src/basic/vx_util/smart_buffer.h @@ -90,13 +90,13 @@ class SmartBuffer { //////////////////////////////////////////////////////////////////////// -inline int SmartBuffer::size() const { return ( Size ); } +inline int SmartBuffer::size() const { return Size; } -inline bool SmartBuffer::is_empty() const { return ( Buf == 0 ); } +inline bool SmartBuffer::is_empty() const { return ( Buf == nullptr ); } -inline SmartBuffer::operator unsigned char * () const { return ( Buf ); } +inline SmartBuffer::operator unsigned char * () const { return Buf; } -inline SmartBuffer::operator void * () const { return ( Buf ); } +inline SmartBuffer::operator void * () const { return Buf; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/string_fxns.cc b/src/basic/vx_util/string_fxns.cc index e0e0d37f6b..df21a7d754 100644 --- a/src/basic/vx_util/string_fxns.cc +++ b/src/basic/vx_util/string_fxns.cc @@ -192,7 +192,7 @@ void strip_char(char *str, const char c) ptr = str + m_strlen(str) - 1; if(*ptr == c) { - *(ptr) = 0; + *ptr = 0; } return; diff --git a/src/basic/vx_util/thresh_array.h b/src/basic/vx_util/thresh_array.h index 4ad5cf5146..20a88193ad 100644 --- a/src/basic/vx_util/thresh_array.h +++ b/src/basic/vx_util/thresh_array.h @@ -93,10 +93,10 @@ class ThreshArray { //////////////////////////////////////////////////////////////////////// -inline int ThreshArray::n_elements() const { return ( Nelements ); } -inline int ThreshArray::n() const { return ( Nelements ); } -inline const SingleThresh * ThreshArray::thresh() const { return ( t ); } -inline SingleThresh * ThreshArray::buf() const { return ( t ); } +inline int ThreshArray::n_elements() const { return Nelements; } +inline int ThreshArray::n() const { return Nelements; } +inline const SingleThresh * ThreshArray::thresh() const { return t; } +inline SingleThresh * ThreshArray::buf() const { return t; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/two_d_array.h b/src/basic/vx_util/two_d_array.h index 3fac01a76b..1907d37644 100644 --- a/src/basic/vx_util/two_d_array.h +++ b/src/basic/vx_util/two_d_array.h @@ -54,11 +54,11 @@ class TwoD_Array { TwoD_Array & operator=(const TwoD_Array & _t) { - if ( this == &_t ) return ( * this ); + if ( this == &_t ) return *this; assign(_t); - return ( * this ); + return *this; } @@ -78,14 +78,14 @@ class TwoD_Array { // get stuff // - int nx() const { return ( Nx ); } - int ny() const { return ( Ny ); } + int nx() const { return Nx; } + int ny() const { return Ny; } bool is_empty() const { return ( Nx*Ny == 0 ); } int count() const; - const T * data() const { return ( E ); } + const T * data() const { return E; } - T * buf() { return ( E ); } // careful with this + T * buf() { return E; } // careful with this T operator()(int, int) const; @@ -244,7 +244,7 @@ for (j=0,n=0; j::operator()(int _x, int _y) const { -return ( get(_x, _y) ); +return get(_x, _y); } @@ -292,7 +292,7 @@ if (E == nullptr) { exit ( 1 ); } -return ( E[two_to_one(_x, _y)] ); +return E[two_to_one(_x, _y)]; } @@ -320,15 +320,15 @@ bool TwoD_Array::f_is_on(int _x, int _y) const { -if ( s_is_on(_x, _y) ) return ( true ); +if ( s_is_on(_x, _y) ) return true; -if( (_x > 0) && s_is_on(_x - 1, _y) ) return ( true ); +if( (_x > 0) && s_is_on(_x - 1, _y) ) return true; -if( (_x > 0) && (_y > 0) && s_is_on(_x - 1, _y - 1)) return ( true ); +if( (_x > 0) && (_y > 0) && s_is_on(_x - 1, _y - 1)) return true; -if( (_y > 0 ) && s_is_on(_x, _y - 1) ) return ( true ); +if( (_y > 0 ) && s_is_on(_x, _y - 1) ) return true; -return ( false ); +return false; } @@ -355,12 +355,12 @@ int j; for (j=0; j=0; --j) { - if ( f_is_on(j, _y) ) return ( j ); + if ( f_is_on(j, _y) ) return j; } -return ( -1 ); +return -1; } diff --git a/src/libcode/vx_analysis_util/mode_atts.cc b/src/libcode/vx_analysis_util/mode_atts.cc index e51f63cef8..3538f47c84 100644 --- a/src/libcode/vx_analysis_util/mode_atts.cc +++ b/src/libcode/vx_analysis_util/mode_atts.cc @@ -1367,8 +1367,8 @@ if ( is_fcst_toggle_set ) { i = L.is_fcst(); - if ( ( is_fcst) && ( !i ) ) return 0; - if ( (!is_fcst) && ( i ) ) return 0; + if ( is_fcst && !i ) return 0; + if ( !is_fcst && i ) return 0; } @@ -1376,8 +1376,8 @@ if ( is_single_toggle_set ) { i = L.is_single(); - if ( ( is_single) && ( !i ) ) return 0; - if ( (!is_single) && ( i ) ) return 0; + if ( is_single && !i ) return 0; + if ( !is_single && i ) return 0; } @@ -1385,8 +1385,8 @@ if ( is_simple_toggle_set ) { i = L.is_simple(); - if ( ( is_simple) && ( !i ) ) return 0; - if ( (!is_simple) && ( i ) ) return 0; + if ( is_simple && !i ) return 0; + if ( !is_simple && i ) return 0; } @@ -1394,8 +1394,8 @@ if ( is_matched_toggle_set ) { i = L.is_matched(); - if ( ( is_matched) && ( !i ) ) return 0; - if ( (!is_matched) && ( i ) ) return 0; + if ( is_matched && !i ) return 0; + if ( !is_matched && i ) return 0; } diff --git a/src/libcode/vx_analysis_util/mode_job.cc b/src/libcode/vx_analysis_util/mode_job.cc index 368a968ea1..e97c8c3994 100644 --- a/src/libcode/vx_analysis_util/mode_job.cc +++ b/src/libcode/vx_analysis_util/mode_job.cc @@ -138,7 +138,7 @@ if ( accums ) { delete [] accums; accums = (NumArray *) nullptr; } n_lines_read = n_lines_kept = 0; // Write any remaning lines to the dump file -if ( dumpfile ) *(dumpfile) << dump_at; +if ( dumpfile ) *dumpfile << dump_at; dumpfile = (ostream *) nullptr; // don't delete @@ -346,7 +346,7 @@ n_dump++; // Write the buffer, if full if ( n_dump%dump_at.nrows() == 0 ) { - *(dumpfile) << dump_at; + *dumpfile << dump_at; dump_at.erase(); } diff --git a/src/libcode/vx_analysis_util/mode_job.h b/src/libcode/vx_analysis_util/mode_job.h index 57354a04b9..a84306c85b 100644 --- a/src/libcode/vx_analysis_util/mode_job.h +++ b/src/libcode/vx_analysis_util/mode_job.h @@ -100,7 +100,7 @@ class BasicModeAnalysisJob { inline void BasicModeAnalysisJob::set_precision (int p) { precision = p; return; } -inline int BasicModeAnalysisJob::get_precision () const { return(precision); } +inline int BasicModeAnalysisJob::get_precision () const { return precision; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index ced4361068..820f8839b2 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -1216,7 +1216,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { << "unrecognized job type specified \"" << jc_array[i] << "\" in job command line: " << jobstring << "\n\n"; if(line) { delete [] line; line = (char *) nullptr; } - throw(1); + throw 1; } i++; } @@ -1638,7 +1638,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { << "\" in job command line: " << jobstring << "\n\n"; if(line) { delete [] line; line = (char *) nullptr; } - throw(1); + throw 1; } // end if } // end for @@ -1660,7 +1660,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { << (line_type.n() == 1 ? line_type[0] : "header") << " column named \"" << hdr_name[i] << "\"\n\n"; if(line) { delete [] line; line = (char *) nullptr; } - throw(1); + throw 1; } } // end for } @@ -1897,7 +1897,7 @@ void STATAnalysisJob::open_dump_row_file() { << "can't open the output file \"" << dump_row << "\" for writing!\n\n"; - throw(1); + throw 1; } return; @@ -1912,7 +1912,7 @@ void STATAnalysisJob::close_dump_row_file() { // // Write any remaining lines // - *(dr_out) << dump_at; + *dr_out << dump_at; dr_out->close(); delete dr_out; @@ -1941,7 +1941,7 @@ void STATAnalysisJob::open_stat_file() { << "can't open the output STAT file \"" << stat_file << "\" for writing!\n\n"; - throw(1); + throw 1; } return; @@ -2133,7 +2133,7 @@ void STATAnalysisJob::close_stat_file() { // // Write any remaining lines // - *(stat_out) << stat_at; + *stat_out << stat_at; stat_out->close(); delete stat_out; @@ -2284,7 +2284,7 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, default: mlog << Error << "\ndump_stat_line() -> " << "unexpected line type value " << line_type[0] << "\n\n"; - throw(1); + throw 1; } // end switch } // @@ -2325,7 +2325,7 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, // Write the buffer, if full // if(n_dump%dump_at.nrows() == 0) { - *(dr_out) << dump_at; + *dr_out << dump_at; dump_at.erase(); } diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 88b709adf7..6e69316aab 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -364,7 +364,7 @@ class STATAnalysisJob { inline void STATAnalysisJob::set_job_type (const STATJobType t) { job_type = t; return; } inline void STATAnalysisJob::set_precision (int p) { precision = p; return; } -inline int STATAnalysisJob::get_precision () const { return(precision); } +inline int STATAnalysisJob::get_precision () const { return precision; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/stat_line.h b/src/libcode/vx_analysis_util/stat_line.h index 9a30820fcc..6d099a8e59 100644 --- a/src/libcode/vx_analysis_util/stat_line.h +++ b/src/libcode/vx_analysis_util/stat_line.h @@ -118,7 +118,7 @@ class STATLine : public DataLine { //////////////////////////////////////////////////////////////////////// -inline STATLineType STATLine::type () const { return ( Type ); } +inline STATLineType STATLine::type () const { return Type; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_analysis_util/time_series.h b/src/libcode/vx_analysis_util/time_series.h index 48e523e6c8..fe3d7469ff 100644 --- a/src/libcode/vx_analysis_util/time_series.h +++ b/src/libcode/vx_analysis_util/time_series.h @@ -72,10 +72,10 @@ class TimeSeries { //////////////////////////////////////////////////////////////////////// -inline unixtime TimeSeries::time_start() const { return ( TimeStart ); } -inline int TimeSeries::time_delta() const { return ( TimeDelta ); } +inline unixtime TimeSeries::time_start() const { return TimeStart; } +inline int TimeSeries::time_delta() const { return TimeDelta; } -inline int TimeSeries::n_elements() const { return ( Nelements ); } +inline int TimeSeries::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/token_stack.h b/src/libcode/vx_bool_calc/token_stack.h index 4f4cd898d4..0987216a73 100644 --- a/src/libcode/vx_bool_calc/token_stack.h +++ b/src/libcode/vx_bool_calc/token_stack.h @@ -74,7 +74,7 @@ class TokenStack { //////////////////////////////////////////////////////////////////////// -inline int TokenStack::depth() const { return ( Nelements ); } +inline int TokenStack::depth() const { return Nelements; } inline bool TokenStack::empty() const { return ( Nelements == 0 ); } diff --git a/src/libcode/vx_color/color.h b/src/libcode/vx_color/color.h index cdf84f5113..8837f13c4c 100644 --- a/src/libcode/vx_color/color.h +++ b/src/libcode/vx_color/color.h @@ -77,9 +77,9 @@ class Color { //////////////////////////////////////////////////////////////////////// -inline unsigned char Color::red () const { return ( R ); } -inline unsigned char Color::green () const { return ( G ); } -inline unsigned char Color::blue () const { return ( B ); } +inline unsigned char Color::red () const { return R; } +inline unsigned char Color::green () const { return G; } +inline unsigned char Color::blue () const { return B; } inline bool Color::is_gray() const { return ( (R == G) && (G == B) ); } @@ -182,10 +182,10 @@ class CtableEntry { inline void CtableEntry::set_color(const Color & c) { C = c; return; } -inline const Color & CtableEntry::color() const { return ( C ); } +inline const Color & CtableEntry::color() const { return C; } -inline double CtableEntry::value_low() const { return ( ValueLo ); } -inline double CtableEntry::value_high() const { return ( ValueHi ); } +inline double CtableEntry::value_low() const { return ValueLo; } +inline double CtableEntry::value_high() const { return ValueHi; } //////////////////////////////////////////////////////////////////////// @@ -282,9 +282,9 @@ class ColorTable { //////////////////////////////////////////////////////////////////////// -inline int ColorTable::n_entries() const { return ( Nentries ); } +inline int ColorTable::n_entries() const { return Nentries; } -inline double ColorTable::gamma() const { return ( Gamma ); } +inline double ColorTable::gamma() const { return Gamma; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_color/color_list.h b/src/libcode/vx_color/color_list.h index 218c9344f0..9489e5cbb5 100644 --- a/src/libcode/vx_color/color_list.h +++ b/src/libcode/vx_color/color_list.h @@ -63,9 +63,9 @@ class ClistEntry { //////////////////////////////////////////////////////////////////////// -inline Dcolor ClistEntry::dc() const { return ( D ); } +inline Dcolor ClistEntry::dc() const { return D; } -inline const char * ClistEntry::name() const { return ( Name.c_str() ); } +inline const char * ClistEntry::name() const { return Name.c_str(); } //////////////////////////////////////////////////////////////////////// @@ -118,7 +118,7 @@ class ColorList { //////////////////////////////////////////////////////////////////////// -inline int ColorList::n_elements() const { return ( Nelements ); } +inline int ColorList::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_color/color_table.cc b/src/libcode/vx_color/color_table.cc index 7a7698c487..bb63ab05fb 100644 --- a/src/libcode/vx_color/color_table.cc +++ b/src/libcode/vx_color/color_table.cc @@ -1068,7 +1068,7 @@ if(is_eq(old_v_lo, bad_data_value)) { new_v_lo = bad_data_value; } else { - v_lo = (old_v_lo - old_b)/(old_m); + v_lo = (old_v_lo - old_b)/old_m; new_v_lo = v_lo*new_m + new_b; } @@ -1080,7 +1080,7 @@ if(is_eq(old_v_hi, bad_data_value)) { new_v_hi = bad_data_value; } else { - v_hi = (old_v_hi - old_b)/(old_m); + v_hi = (old_v_hi - old_b)/old_m; new_v_hi = v_hi*new_m + new_b; } diff --git a/src/libcode/vx_data2d/data_class.h b/src/libcode/vx_data2d/data_class.h index 2e2bf2c7e1..5fbf07e266 100644 --- a/src/libcode/vx_data2d/data_class.h +++ b/src/libcode/vx_data2d/data_class.h @@ -174,9 +174,9 @@ inline int Met2dDataFile::ny() const { return ( Dest_Grid ? (Dest_Grid->ny()) : inline int Met2dDataFile::raw_nx() const { return ( Raw_Grid ? (Raw_Grid->nx()) : 0 ); } inline int Met2dDataFile::raw_ny() const { return ( Raw_Grid ? (Raw_Grid->ny()) : 0 ); } -inline const char * Met2dDataFile::filename() const { return ( Filename.c_str() ); } +inline const char * Met2dDataFile::filename() const { return Filename.c_str(); } -inline int Met2dDataFile::shift_right() const { return ( ShiftRight ); } +inline int Met2dDataFile::shift_right() const { return ShiftRight; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/level_info.h b/src/libcode/vx_data2d/level_info.h index 4a1dc28f1d..d6956ca4f4 100644 --- a/src/libcode/vx_data2d/level_info.h +++ b/src/libcode/vx_data2d/level_info.h @@ -98,15 +98,15 @@ class LevelInfo /////////////////////////////////////////////////////////////////////////////// -inline LevelType LevelInfo::type() const { return(Type); } -inline int LevelInfo::type_num() const { return(TypeNum); } -inline ConcatString LevelInfo::req_name() const { return(ReqName); } -inline ConcatString LevelInfo::name() const { return(Name); } -inline ConcatString LevelInfo::units() const { return(Units); } -inline double LevelInfo::upper() const { return(Upper); } -inline double LevelInfo::lower() const { return(Lower); } -inline double LevelInfo::increment()const { return(Increment);} -inline bool LevelInfo::is_offset()const { return(Is_offset);} +inline LevelType LevelInfo::type() const { return Type; } +inline int LevelInfo::type_num() const { return TypeNum; } +inline ConcatString LevelInfo::req_name() const { return ReqName; } +inline ConcatString LevelInfo::name() const { return Name; } +inline ConcatString LevelInfo::units() const { return Units; } +inline double LevelInfo::upper() const { return Upper; } +inline double LevelInfo::lower() const { return Lower; } +inline double LevelInfo::increment()const { return Increment;} +inline bool LevelInfo::is_offset()const { return Is_offset;} /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/table_lookup.cc b/src/libcode/vx_data2d/table_lookup.cc index e0db7aab3b..8ab83eeae2 100644 --- a/src/libcode/vx_data2d/table_lookup.cc +++ b/src/libcode/vx_data2d/table_lookup.cc @@ -1083,9 +1083,9 @@ bool TableFlatFile::lookup_grib1(const char * parm_name, int table_number, int c for(vector::iterator it = matches.begin(); it < matches.end(); it++) - mlog << Debug(3) << " parm_name: " << (it)->parm_name - << ", table_number = " << (it)->table_number - << ", code = " << (it)->code << "\n"; + mlog << Debug(3) << " parm_name: " << it->parm_name + << ", table_number = " << it->table_number + << ", code = " << it->code << "\n"; mlog << Debug(3) << "Using the first match found: " << " parm_name: " << e.parm_name @@ -1146,11 +1146,11 @@ bool TableFlatFile::lookup_grib1(const char * parm_name, int table_number, int c for(vector::iterator it = matches.begin(); it < matches.end(); it++) { - mlog << Debug(3) << " parm_name: " << (it)->parm_name - << ", table_number = " << (it)->table_number - << ", code = " << (it)->code - << ", center = " << (it)->center - << ", subcenter = " << (it)->subcenter << "\n"; + mlog << Debug(3) << " parm_name: " << it->parm_name + << ", table_number = " << it->table_number + << ", code = " << it->code + << ", center = " << it->center + << ", subcenter = " << it->subcenter << "\n"; } mlog << Debug(3) << "Using the first match found: " @@ -1282,10 +1282,10 @@ bool TableFlatFile::lookup_grib2(const char * parm_name, int a, int b, int c, for(vector::iterator it = matches.begin(); it < matches.end(); it++) - mlog << Debug(3) << " parm_name: " << (it)->parm_name - << ", index_a = " << (it)->index_a - << ", index_b = " << (it)->index_b - << ", index_c = " << (it)->index_c << "\n"; + mlog << Debug(3) << " parm_name: " << it->parm_name + << ", index_a = " << it->index_a + << ", index_b = " << it->index_b + << ", index_c = " << it->index_c << "\n"; mlog << Debug(3) << "Using the first match found: " << " parm_name: " << e.parm_name @@ -1349,13 +1349,13 @@ bool TableFlatFile::lookup_grib2(const char * parm_name, for(vector::iterator it = matches.begin(); it < matches.end(); it++) - mlog << Debug(3) << " parm_name: " << (it)->parm_name - << ", index_a = " << (it)->index_a - << ", grib2_mtab = " << (it)->mtab_set - << ", grib2_cntr = " << (it)->cntr - << ", grib2_ltab = " << (it)->ltab - << ", index_b = " << (it)->index_b - << ", index_c = " << (it)->index_c + mlog << Debug(3) << " parm_name: " << it->parm_name + << ", index_a = " << it->index_a + << ", grib2_mtab = " << it->mtab_set + << ", grib2_cntr = " << it->cntr + << ", grib2_ltab = " << it->ltab + << ", index_b = " << it->index_b + << ", index_c = " << it->index_c << "\n"; mlog << Debug(3) << "Using the first match found: " diff --git a/src/libcode/vx_data2d/table_lookup.h b/src/libcode/vx_data2d/table_lookup.h index a1a1d56c0e..39dd488e23 100644 --- a/src/libcode/vx_data2d/table_lookup.h +++ b/src/libcode/vx_data2d/table_lookup.h @@ -209,8 +209,8 @@ class TableFlatFile { //////////////////////////////////////////////////////////////////////// -inline int TableFlatFile::n_grib1_elements() const { return ( N_grib1_elements ); } -inline int TableFlatFile::n_grib2_elements() const { return ( N_grib2_elements ); } +inline int TableFlatFile::n_grib1_elements() const { return N_grib1_elements; } +inline int TableFlatFile::n_grib2_elements() const { return N_grib2_elements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/var_info.h b/src/libcode/vx_data2d/var_info.h index ccb58a93f1..0d8717f416 100644 --- a/src/libcode/vx_data2d/var_info.h +++ b/src/libcode/vx_data2d/var_info.h @@ -98,7 +98,7 @@ class VarInfo void clear(); void clone_base() const; - + virtual void dump(std::ostream &) const; // @@ -212,48 +212,48 @@ class VarInfo inline void VarInfo::add_grib_code(Dictionary &d) { return; } -inline ConcatString VarInfo::magic_str() const { return(MagicStr); } -inline ConcatString VarInfo::req_name() const { return(ReqName); } -inline ConcatString VarInfo::name() const { return(Name); } -inline ConcatString VarInfo::units() const { return(Units); } -inline LevelInfo VarInfo::level() const { return(Level); } -inline ConcatString VarInfo::req_level_name() const { return(Level.req_name()); } -inline ConcatString VarInfo::level_name() const { return(Level.name()); } -inline ConcatString VarInfo::long_name() const { return(LongName); } -inline ConcatString VarInfo::ens() const { return(Ensemble); } +inline ConcatString VarInfo::magic_str() const { return MagicStr; } +inline ConcatString VarInfo::req_name() const { return ReqName; } +inline ConcatString VarInfo::name() const { return Name; } +inline ConcatString VarInfo::units() const { return Units; } +inline LevelInfo VarInfo::level() const { return Level; } +inline ConcatString VarInfo::req_level_name() const { return Level.req_name(); } +inline ConcatString VarInfo::level_name() const { return Level.name(); } +inline ConcatString VarInfo::long_name() const { return LongName; } +inline ConcatString VarInfo::ens() const { return Ensemble; } -inline bool VarInfo::p_flag() const { return(PFlag); } -inline ConcatString VarInfo::p_name() const { return(PName); } -inline ConcatString VarInfo::p_units() const { return(PUnits); } -inline SingleThresh VarInfo::p_thresh_lo() const { return(PThreshLo); } -inline SingleThresh VarInfo::p_thresh_hi() const { return(PThreshHi); } -inline bool VarInfo::p_as_scalar() const { return(PAsScalar); } +inline bool VarInfo::p_flag() const { return PFlag; } +inline ConcatString VarInfo::p_name() const { return PName; } +inline ConcatString VarInfo::p_units() const { return PUnits; } +inline SingleThresh VarInfo::p_thresh_lo() const { return PThreshLo; } +inline SingleThresh VarInfo::p_thresh_hi() const { return PThreshHi; } +inline bool VarInfo::p_as_scalar() const { return PAsScalar; } -inline int VarInfo::uv_index() const { return(UVIndex); } +inline int VarInfo::uv_index() const { return UVIndex; } -inline unixtime VarInfo::init() const { return(Init); } -inline unixtime VarInfo::valid() const { return(Valid); } -inline int VarInfo::lead() const { return(Lead); } +inline unixtime VarInfo::init() const { return Init; } +inline unixtime VarInfo::valid() const { return Valid; } +inline int VarInfo::lead() const { return Lead; } -inline ThreshArray VarInfo::censor_thresh() const { return(CensorThresh); } -inline NumArray VarInfo::censor_val() const { return(CensorVal); } +inline ThreshArray VarInfo::censor_thresh() const { return CensorThresh; } +inline NumArray VarInfo::censor_val() const { return CensorVal; } -inline int VarInfo::n_bins() const { return(nBins); } -inline NumArray VarInfo::range() const { return(Range); } +inline int VarInfo::n_bins() const { return nBins; } +inline NumArray VarInfo::range() const { return Range; } -inline RegridInfo VarInfo::regrid() const { return(Regrid); } +inline RegridInfo VarInfo::regrid() const { return Regrid; } inline ConcatString VarInfo::name_attr() const { return(SetAttrName.empty() ? name() : SetAttrName); } inline ConcatString VarInfo::units_attr() const { return(SetAttrUnits.empty() ? units() : SetAttrUnits); } inline ConcatString VarInfo::level_attr() const { return(SetAttrLevel.empty() ? level_name() : SetAttrLevel); } inline ConcatString VarInfo::long_name_attr() const { return(SetAttrLongName.empty() ? long_name() : SetAttrLongName); } -inline Grid VarInfo::grid_attr() const { return(SetAttrGrid); } +inline Grid VarInfo::grid_attr() const { return SetAttrGrid; } -inline unixtime VarInfo::init_attr() const { return(SetAttrInit); } -inline unixtime VarInfo::valid_attr() const { return(SetAttrValid); } -inline int VarInfo::lead_attr() const { return(SetAttrLead); } -inline int VarInfo::accum_attr() const { return(SetAttrAccum); } +inline unixtime VarInfo::init_attr() const { return SetAttrInit; } +inline unixtime VarInfo::valid_attr() const { return SetAttrValid; } +inline int VarInfo::lead_attr() const { return SetAttrLead; } +inline int VarInfo::accum_attr() const { return SetAttrAccum; } //////////////////////////////////////////////////////////////////////// @@ -294,7 +294,7 @@ class EnsVarInfo { void set_ctrl(VarInfo *); VarInfo * get_ctrl(int); - // Get VarInfo from first InputInfo if requested VarInfo is nullptr + // Get VarInfo from first InputInfo if requested VarInfo is nullptr VarInfo * get_var_info(int index=0); ConcatString get_file(int index=0); int get_file_index(int index=0); diff --git a/src/libcode/vx_data2d_grib/data2d_grib.h b/src/libcode/vx_data2d_grib/data2d_grib.h index 103413652c..bcfbc45ab9 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib.h +++ b/src/libcode/vx_data2d_grib/data2d_grib.h @@ -102,8 +102,8 @@ class MetGrib1DataFile : public Met2dDataFile { //////////////////////////////////////////////////////////////////////// -inline double MetGrib1DataFile::operator () (int x, int y) const { return ( get(x, y) ); } -inline GrdFileType MetGrib1DataFile::file_type () const { return ( FileType_Gb1 ); } +inline double MetGrib1DataFile::operator () (int x, int y) const { return get(x, y) ; } +inline GrdFileType MetGrib1DataFile::file_type () const { return FileType_Gb1; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/grib_classes.cc b/src/libcode/vx_data2d_grib/grib_classes.cc index 5e3a26ab42..8a0c626eb1 100644 --- a/src/libcode/vx_data2d_grib/grib_classes.cc +++ b/src/libcode/vx_data2d_grib/grib_classes.cc @@ -1805,7 +1805,7 @@ else if ((h.type == 3) || (h.type == 13)) file << " lat_sp: " << char3_to_int(h.grid_type.lambert_conf.lat_sp) << "\n"; file << " lon_sp: " << char3_to_int(h.grid_type.lambert_conf.lon_sp) << "\n\n"; } -else if ((h.type == 5)) +else if (h.type == 5) { file << " lat1: " << char3_to_int(h.grid_type.stereographic.lat1) << "\n"; @@ -1822,7 +1822,7 @@ else if ((h.type == 5)) file << " scan_flag: " << (int) h.grid_type.stereographic.scan_flag << "\n\n"; } -else if ((h.type == 10)) +else if (h.type == 10) { file << " lat1: " << char3_to_int(h.grid_type.rot_latlon_grid.lat1) << "\n"; diff --git a/src/libcode/vx_data2d_grib/grib_strings.cc b/src/libcode/vx_data2d_grib/grib_strings.cc index d8239f7e3d..b8707b9040 100644 --- a/src/libcode/vx_data2d_grib/grib_strings.cc +++ b/src/libcode/vx_data2d_grib/grib_strings.cc @@ -111,11 +111,11 @@ ConcatString get_grib_level_list_str(int k, int grib_level) if(match > 0) { switch(k) { - case(0): // GRIB Level Name + case 0: // GRIB Level Name str = grib_level_list[match].name; break; - case(1): // GRIB Level Abbreviation + case 1: // GRIB Level Abbreviation str = grib_level_list[match].abbr; break; diff --git a/src/libcode/vx_data2d_grib/grib_utils.cc b/src/libcode/vx_data2d_grib/grib_utils.cc index e353471d3d..e89c51d806 100644 --- a/src/libcode/vx_data2d_grib/grib_utils.cc +++ b/src/libcode/vx_data2d_grib/grib_utils.cc @@ -676,7 +676,7 @@ c[0] &= 127; else if ( n == 3 ) answer = (double) 0.001*parity*char3_to_int(c); else answer = (double) bad_data_float; -return ( answer ); +return answer; } diff --git a/src/libcode/vx_data2d_grib/var_info_grib.h b/src/libcode/vx_data2d_grib/var_info_grib.h index 4d37432e9f..d4a5aa2a10 100644 --- a/src/libcode/vx_data2d_grib/var_info_grib.h +++ b/src/libcode/vx_data2d_grib/var_info_grib.h @@ -116,15 +116,15 @@ class VarInfoGrib : public VarInfo /////////////////////////////////////////////////////////////////////////////// -inline GrdFileType VarInfoGrib::file_type() const { return(FileType_Gb1); } -inline int VarInfoGrib::ptv() const { return(PTV); } -inline int VarInfoGrib::code() const { return(Code); } -inline int VarInfoGrib::lvl_type() const { return(LvlType); } -inline int VarInfoGrib::p_code() const { return(PCode); } -inline int VarInfoGrib::center() const { return(Center); } -inline int VarInfoGrib::subcenter() const { return(Subcenter); } -inline int VarInfoGrib::field_rec() const { return(FieldRec); } -inline int VarInfoGrib::tri() const { return(TRI); } +inline GrdFileType VarInfoGrib::file_type() const { return FileType_Gb1; } +inline int VarInfoGrib::ptv() const { return PTV; } +inline int VarInfoGrib::code() const { return Code; } +inline int VarInfoGrib::lvl_type() const { return LvlType; } +inline int VarInfoGrib::p_code() const { return PCode; } +inline int VarInfoGrib::center() const { return Center; } +inline int VarInfoGrib::subcenter() const { return Subcenter; } +inline int VarInfoGrib::field_rec() const { return FieldRec; } +inline int VarInfoGrib::tri() const { return TRI; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.h b/src/libcode/vx_data2d_grib2/data2d_grib2.h index 46c50ee2f5..3811f7cfa8 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.h +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.h @@ -164,7 +164,7 @@ class MetGrib2DataFile : public Met2dDataFile { //////////////////////////////////////////////////////////////////////// -inline GrdFileType MetGrib2DataFile::file_type () const { return ( FileType_Gb2 ); } +inline GrdFileType MetGrib2DataFile::file_type () const { return FileType_Gb2; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib2/var_info_grib2.h b/src/libcode/vx_data2d_grib2/var_info_grib2.h index 7848aefb7f..2ce946d0db 100644 --- a/src/libcode/vx_data2d_grib2/var_info_grib2.h +++ b/src/libcode/vx_data2d_grib2/var_info_grib2.h @@ -147,31 +147,31 @@ class VarInfoGrib2 : public VarInfo /////////////////////////////////////////////////////////////////////////////// -inline GrdFileType VarInfoGrib2::file_type() const { return(FileType_Gb2); } -inline int VarInfoGrib2::record() const { return(Record); } -inline int VarInfoGrib2::discipline() const { return(Discipline); } -inline int VarInfoGrib2::m_table() const { return(MTable); } -inline int VarInfoGrib2::l_table() const { return(LTable); } -inline int VarInfoGrib2::parm_cat() const { return(ParmCat); } -inline int VarInfoGrib2::parm() const { return(Parm); } -inline int VarInfoGrib2::pdt() const { return(PDTmpl); } -inline int VarInfoGrib2::process() const { return(Process); } -inline int VarInfoGrib2::ens_type() const { return(EnsType); } -inline int VarInfoGrib2::der_type() const { return(DerType); } -inline int VarInfoGrib2::stat_type() const { return(StatType); } -inline int VarInfoGrib2::perc_val() const { return(PercVal); } - -inline int VarInfoGrib2::aerosol_type() const { return(AerosolType); } -inline int VarInfoGrib2::aerosol_interval_type() const { return(AerosolIntervalType); } -inline double VarInfoGrib2::aerosol_size_lower() const { return(AerosolSizeLower); } -inline double VarInfoGrib2::aerosol_size_upper() const { return(AerosolSizeUpper); } - -inline int VarInfoGrib2::n_ipdtmpl() const { - return(IPDTmplIndex.n()); } +inline GrdFileType VarInfoGrib2::file_type() const { return FileType_Gb2; } +inline int VarInfoGrib2::record() const { return Record; } +inline int VarInfoGrib2::discipline() const { return Discipline; } +inline int VarInfoGrib2::m_table() const { return MTable; } +inline int VarInfoGrib2::l_table() const { return LTable; } +inline int VarInfoGrib2::parm_cat() const { return ParmCat; } +inline int VarInfoGrib2::parm() const { return Parm; } +inline int VarInfoGrib2::pdt() const { return PDTmpl; } +inline int VarInfoGrib2::process() const { return Process; } +inline int VarInfoGrib2::ens_type() const { return EnsType; } +inline int VarInfoGrib2::der_type() const { return DerType; } +inline int VarInfoGrib2::stat_type() const { return StatType; } +inline int VarInfoGrib2::perc_val() const { return PercVal; } + +inline int VarInfoGrib2::aerosol_type() const { return AerosolType; } +inline int VarInfoGrib2::aerosol_interval_type() const { return AerosolIntervalType; } +inline double VarInfoGrib2::aerosol_size_lower() const { return AerosolSizeLower; } +inline double VarInfoGrib2::aerosol_size_upper() const { return AerosolSizeUpper; } + +inline int VarInfoGrib2::n_ipdtmpl() const { + return IPDTmplIndex.n(); } inline int VarInfoGrib2::ipdtmpl_index(int i) const { - return(IPDTmplIndex[i]); } + return IPDTmplIndex[i]; } inline int VarInfoGrib2::ipdtmpl_val(int i) const { - return(IPDTmplVal[i]); } + return IPDTmplVal[i]; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index eebf2ae1b6..61c5be7451 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -880,7 +880,7 @@ double NcCfFile::getData(NcVar * var, const LongArray & a) const if (dim_count != a.n_elements()) { mlog << Error << "\n" << method_name - << "needed " << (dim_count) << " arguments for variable " + << "needed " << dim_count << " arguments for variable " << (GET_NC_NAME_P(var)) << ", got " << (a.n_elements()) << "\n\n"; exit(1); } @@ -951,7 +951,7 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const if (dim_count != a.n_elements()) { mlog << Error << "\n" << method_name - << "needed " << (dim_count) << " arguments for variable " + << "needed " << dim_count << " arguments for variable " << (GET_NC_NAME_P(v)) << ", got " << (a.n_elements()) << "\n\n"; exit(1); } diff --git a/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.h b/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.h index 36b3f7b892..439369d95f 100644 --- a/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.h +++ b/src/libcode/vx_data2d_nc_cf/var_info_nc_cf.h @@ -86,14 +86,14 @@ class VarInfoNcCF : public VarInfo /////////////////////////////////////////////////////////////////////////////// -inline GrdFileType VarInfoNcCF::file_type() const { return(FileType_NcCF); } -inline const LongArray & VarInfoNcCF::dimension() const { return(Dimension); } -inline int VarInfoNcCF::dimension(int i) const { return(Dimension[i]); } -inline int VarInfoNcCF::n_dimension() const { return(Dimension.n_elements());} -inline const NumArray & VarInfoNcCF::dim_value() const { return(Dim_value); } -inline double VarInfoNcCF::dim_value(int i) const { return(Dim_value[i]); } -inline const BoolArray & VarInfoNcCF::is_offset() const { return(Is_offset); } -inline bool VarInfoNcCF::is_offset(int i) const { return(Is_offset[i]); } +inline GrdFileType VarInfoNcCF::file_type() const { return FileType_NcCF; } +inline const LongArray & VarInfoNcCF::dimension() const { return Dimension; } +inline int VarInfoNcCF::dimension(int i) const { return Dimension[i]; } +inline int VarInfoNcCF::n_dimension() const { return Dimension.n_elements();} +inline const NumArray & VarInfoNcCF::dim_value() const { return Dim_value; } +inline double VarInfoNcCF::dim_value(int i) const { return Dim_value[i]; } +inline const BoolArray & VarInfoNcCF::is_offset() const { return Is_offset; } +inline bool VarInfoNcCF::is_offset(int i) const { return Is_offset[i]; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_met/data2d_nc_met.h b/src/libcode/vx_data2d_nc_met/data2d_nc_met.h index db7f166ce1..d4ae16fc55 100644 --- a/src/libcode/vx_data2d_nc_met/data2d_nc_met.h +++ b/src/libcode/vx_data2d_nc_met/data2d_nc_met.h @@ -85,7 +85,7 @@ class MetNcMetDataFile : public Met2dDataFile { //////////////////////////////////////////////////////////////////////// -inline GrdFileType MetNcMetDataFile::file_type () const { return ( FileType_NcMet ); } +inline GrdFileType MetNcMetDataFile::file_type () const { return FileType_NcMet; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_met/met_file.cc b/src/libcode/vx_data2d_nc_met/met_file.cc index 32fe15c4c7..d937950aeb 100644 --- a/src/libcode/vx_data2d_nc_met/met_file.cc +++ b/src/libcode/vx_data2d_nc_met/met_file.cc @@ -264,7 +264,7 @@ for (j=0; jgetName()) << ", got " << (a.n_elements()) << "\n\n"; + << "needed " << dimCount << " arguments for variable " + << var->getName() << ", got " << a.n_elements() << "\n\n"; exit ( 1 ); @@ -457,7 +457,7 @@ int dimCount = GET_NC_DIM_COUNT_P(v); if ( dimCount != a.n_elements() ) { mlog << Error << "\n" << method_name - << "needed " << (dimCount) << " arguments for variable " + << "needed " << dimCount << " arguments for variable " << (GET_NC_NAME_P(v)) << ", got " << (a.n_elements()) << "\n\n"; exit ( 1 ); diff --git a/src/libcode/vx_data2d_nc_met/var_info_nc_met.h b/src/libcode/vx_data2d_nc_met/var_info_nc_met.h index 737a22a714..750662da18 100644 --- a/src/libcode/vx_data2d_nc_met/var_info_nc_met.h +++ b/src/libcode/vx_data2d_nc_met/var_info_nc_met.h @@ -78,10 +78,10 @@ class VarInfoNcMet : public VarInfo /////////////////////////////////////////////////////////////////////////////// -inline GrdFileType VarInfoNcMet::file_type() const { return(FileType_NcMet); } -inline const LongArray & VarInfoNcMet::dimension() const { return(Dimension); } -inline int VarInfoNcMet::dimension(int i) const { return(Dimension[i]); } -inline int VarInfoNcMet::n_dimension() const { return(Dimension.n_elements()); } +inline GrdFileType VarInfoNcMet::file_type() const { return FileType_NcMet; } +inline const LongArray & VarInfoNcMet::dimension() const { return Dimension; } +inline int VarInfoNcMet::dimension(int i) const { return Dimension[i]; } +inline int VarInfoNcMet::n_dimension() const { return Dimension.n_elements(); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc b/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc index 312a5397a4..801ceeb253 100644 --- a/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc +++ b/src/libcode/vx_data2d_nc_wrf/get_wrf_grid.cc @@ -439,7 +439,7 @@ lon_rad = -u; lon_deg = lon_rad*deg_per_rad; -return ( lon_deg ); +return lon_deg; } @@ -455,7 +455,7 @@ double lat; lat = 2.0*atand(exp(v)) - 90.0; -return ( lat ); +return lat; } diff --git a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.h b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.h index 4bb201cb15..44f4f48cfd 100644 --- a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.h +++ b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.h @@ -247,14 +247,14 @@ class VarInfoNcWrf : public VarInfo /////////////////////////////////////////////////////////////////////////////// -inline GrdFileType VarInfoNcWrf::file_type() const { return(FileType_NcWrf); } -inline const LongArray & VarInfoNcWrf::dimension() const { return(Dimension); } -inline int VarInfoNcWrf::dimension(int i) const { return(Dimension[i]); } -inline int VarInfoNcWrf::n_dimension() const { return(Dimension.n_elements()); } -inline const NumArray & VarInfoNcWrf::dim_value() const { return(Dim_value); } -inline double VarInfoNcWrf::dim_value(int i) const { return(Dim_value[i]); } -inline const BoolArray & VarInfoNcWrf::is_offset() const { return(Is_offset); } -inline bool VarInfoNcWrf::is_offset(int i) const { return(Is_offset[i]); } +inline GrdFileType VarInfoNcWrf::file_type() const { return FileType_NcWrf; } +inline const LongArray & VarInfoNcWrf::dimension() const { return Dimension; } +inline int VarInfoNcWrf::dimension(int i) const { return Dimension[i]; } +inline int VarInfoNcWrf::n_dimension() const { return Dimension.n_elements(); } +inline const NumArray & VarInfoNcWrf::dim_value() const { return Dim_value; } +inline double VarInfoNcWrf::dim_value(int i) const { return Dim_value[i]; } +inline const BoolArray & VarInfoNcWrf::is_offset() const { return Is_offset; } +inline bool VarInfoNcWrf::is_offset(int i) const { return Is_offset[i]; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc index f950201ea3..5279ca49f7 100644 --- a/src/libcode/vx_data2d_nc_wrf/wrf_file.cc +++ b/src/libcode/vx_data2d_nc_wrf/wrf_file.cc @@ -317,7 +317,7 @@ InitTime = parse_init_time(att_value.c_str()); dimNames.clear(); get_dim_names(&v, &dimNames); string c; - for (k=0; k<(dim_count); ++k) { + for (k=0; kgetDimCount(); if ( dim_count != a.n_elements() ) { mlog << Error << "\n" << method_name - << "needed " << (dim_count) << " arguments for variable " + << "needed " << dim_count << " arguments for variable " << (GET_NC_NAME_P(var)) << ", got " << (a.n_elements()) << "\n\n"; exit ( 1 ); @@ -585,7 +585,7 @@ if ( dim_count != a.n_elements() ) { mlog << Warning << "\n" << method_name << "needed " << dim_count << " arguments for variable " - << (var_name) << ", got " << (a.n_elements()) << "\n\n"; + << var_name << ", got " << a.n_elements() << "\n\n"; exit ( 1 ); @@ -594,7 +594,7 @@ if ( dim_count != a.n_elements() ) { if (dim_count >= max_wrf_args ) { mlog << Warning << "\n" << method_name - << " too may arguments for variable \"" << (var_name) << "\"\n\n"; + << " too may arguments for variable \"" << var_name << "\"\n\n"; return false; @@ -626,7 +626,7 @@ for (j=0; j= 0 ); } diff --git a/src/libcode/vx_gis/shp_array.h b/src/libcode/vx_gis/shp_array.h index f0bfe543c0..cf3f4b846b 100644 --- a/src/libcode/vx_gis/shp_array.h +++ b/src/libcode/vx_gis/shp_array.h @@ -67,11 +67,11 @@ class Shp_Array { Shp_Array & operator=(const Shp_Array & _a) { - if ( this == &_a ) return ( * this ); + if ( this == &_a ) return *this; assign(_a); - return ( * this ); + return *this; } @@ -95,9 +95,9 @@ class Shp_Array { // get stuff // - int n() const { return ( Nelements ); } + int n() const { return Nelements; } - int n_elements() const { return ( Nelements ); } + int n_elements() const { return Nelements; } // // do stuff @@ -371,7 +371,7 @@ if ( (N < 0) || (N >= Nelements) ) { exit ( 1 ); } -return ( E[N] ); +return E[N]; } @@ -385,7 +385,7 @@ T * Shp_Array::buf() const { -return ( E ); +return E; } diff --git a/src/libcode/vx_gis/shp_file.h b/src/libcode/vx_gis/shp_file.h index 2dd900aefc..64ae681880 100644 --- a/src/libcode/vx_gis/shp_file.h +++ b/src/libcode/vx_gis/shp_file.h @@ -159,11 +159,11 @@ class ShpFile { //////////////////////////////////////////////////////////////////////// -inline const ShpFileHeader * ShpFile::header() const { return ( &Header ); } +inline const ShpFileHeader * ShpFile::header() const { return &Header; } -inline int ShpFile::shape_type() const { return ( Header.shape_type ); } +inline int ShpFile::shape_type() const { return Header.shape_type; } -inline bool ShpFile::at_eof() const { return ( At_Eof ); } +inline bool ShpFile::at_eof() const { return At_Eof; } inline bool ShpFile::is_open() const { return ( fd >= 0 ); } diff --git a/src/libcode/vx_grid/goes_grid.cc b/src/libcode/vx_grid/goes_grid.cc index 58c5c143b0..c00babc717 100644 --- a/src/libcode/vx_grid/goes_grid.cc +++ b/src/libcode/vx_grid/goes_grid.cc @@ -121,22 +121,21 @@ void GoesImagerGrid::latlon_to_xy(double lat, double lon, double & x_idx, double float sy = -rc*cos_clat*sin(del_lon_angle); float sz = rc*sin(c_lat); - // // check that point is on disk of the earth + // check that point is on disk of the earth if((Data.H*(Data.H - sx)) < (sy*sy + Data.radius_ratio2*sz*sz)) { x_idx = -1; y_idx = -1; return; } - float rl = sqrt((sx*sx + sy*sy + sz*sz)); - float xx = asin((-sy/rl)); - float yy = atan((sz/sx)); + float rl = sqrt(sx*sx + sy*sy + sz*sz); + float xx = asin(-sy/rl); + float yy = atan(sz/sx); x_idx = round((xx - Data.x_image_bounds[0])/Data.dx_rad); y_idx = round((Data.y_image_bounds[0] - yy)/Data.dy_rad); - // cerr << "lat: " << lat << " lon: " << lon << " ximage: " << xx << " yimage: " << yy << endl; return; } diff --git a/src/libcode/vx_grid/goes_grid.h b/src/libcode/vx_grid/goes_grid.h index 039d75c638..b3157bfeac 100644 --- a/src/libcode/vx_grid/goes_grid.h +++ b/src/libcode/vx_grid/goes_grid.h @@ -80,7 +80,7 @@ class GoesImagerGrid : public GridRep { //////////////////////////////////////////////////////////////////////// -inline double GoesImagerGrid::scale_km() const { return ( 1.0 ); } +inline double GoesImagerGrid::scale_km() const { return 1.0; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/laea_grid.h b/src/libcode/vx_grid/laea_grid.h index 3a9c92751a..ea1b78315a 100644 --- a/src/libcode/vx_grid/laea_grid.h +++ b/src/libcode/vx_grid/laea_grid.h @@ -144,9 +144,9 @@ class LaeaGrid : public GridRep { //////////////////////////////////////////////////////////////////////// -inline bool LaeaGrid::is_north () const { return ( true ); } -inline bool LaeaGrid::is_south () const { return ( false ); } -inline double LaeaGrid::scale_km() const { return ( -1.0 ); } +inline bool LaeaGrid::is_north () const { return true; } +inline bool LaeaGrid::is_south () const { return false; } +inline double LaeaGrid::scale_km() const { return -1.0; } inline void LaeaGrid::set_so2(double) { return; } diff --git a/src/libcode/vx_grid/latlon_grid.h b/src/libcode/vx_grid/latlon_grid.h index bcac543474..c4dd812bc2 100644 --- a/src/libcode/vx_grid/latlon_grid.h +++ b/src/libcode/vx_grid/latlon_grid.h @@ -89,8 +89,8 @@ class LatLonGrid : public GridRep { //////////////////////////////////////////////////////////////////////// -inline double LatLonGrid::scale_km() const { return ( -1.0 ); } -inline bool LatLonGrid::wrap_lon() const { return ( wrapLon ); } +inline double LatLonGrid::scale_km() const { return -1.0; } +inline bool LatLonGrid::wrap_lon() const { return wrapLon; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/lc_grid.h b/src/libcode/vx_grid/lc_grid.h index 26134eab3d..be111dd40e 100644 --- a/src/libcode/vx_grid/lc_grid.h +++ b/src/libcode/vx_grid/lc_grid.h @@ -128,14 +128,14 @@ class LambertGrid : public GridRep { //////////////////////////////////////////////////////////////////////// -inline bool LambertGrid::is_north() const { return ( IsNorthHemisphere ); } -inline bool LambertGrid::is_south() const { return ( ! IsNorthHemisphere ); } +inline bool LambertGrid::is_north() const { return IsNorthHemisphere; } +inline bool LambertGrid::is_south() const { return !IsNorthHemisphere; } -inline double LambertGrid::scale_km() const { return ( Data.d_km ); } +inline double LambertGrid::scale_km() const { return Data.d_km; } -inline bool LambertGrid::has_so2() const { return ( Has_SO2 ); } +inline bool LambertGrid::has_so2() const { return Has_SO2; } -inline double LambertGrid::so2_angle() const { return ( SO2_Angle ); } +inline double LambertGrid::so2_angle() const { return SO2_Angle; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/st_grid.cc b/src/libcode/vx_grid/st_grid.cc index 840a6a69f8..762f7d4968 100644 --- a/src/libcode/vx_grid/st_grid.cc +++ b/src/libcode/vx_grid/st_grid.cc @@ -791,7 +791,7 @@ double stereographic_alpha(double scale_lat, double r_km, double d_km) double alpha; -alpha = (1.0 + sind(fabs(scale_lat)))*((r_km)/(d_km)); +alpha = (1.0 + sind(fabs(scale_lat)))*(r_km/d_km); return alpha; diff --git a/src/libcode/vx_grid/st_grid.h b/src/libcode/vx_grid/st_grid.h index 3d23bfe514..8f251871a7 100644 --- a/src/libcode/vx_grid/st_grid.h +++ b/src/libcode/vx_grid/st_grid.h @@ -107,10 +107,10 @@ class StereographicGrid : public GridRep { //////////////////////////////////////////////////////////////////////// -inline bool StereographicGrid::is_north () const { return ( IsNorthHemisphere ); } -inline bool StereographicGrid::is_south () const { return ( ! IsNorthHemisphere ); } +inline bool StereographicGrid::is_north () const { return IsNorthHemisphere; } +inline bool StereographicGrid::is_south () const { return !IsNorthHemisphere; } -inline double StereographicGrid::scale_km () const { return ( Data.d_km ); } +inline double StereographicGrid::scale_km () const { return Data.d_km; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/tcrmw_grid.h b/src/libcode/vx_grid/tcrmw_grid.h index b7304b614e..ee45b5e228 100644 --- a/src/libcode/vx_grid/tcrmw_grid.h +++ b/src/libcode/vx_grid/tcrmw_grid.h @@ -101,17 +101,17 @@ class TcrmwGrid : public RotatedLatLonGrid { //////////////////////////////////////////////////////////////////////// -inline int TcrmwGrid::range_n () const { return ( Range_n ); } -inline int TcrmwGrid::azimuth_n () const { return ( Azimuth_n ); } +inline int TcrmwGrid::range_n () const { return Range_n; } +inline int TcrmwGrid::azimuth_n () const { return Azimuth_n; } -inline double TcrmwGrid::range_max_km () const { return ( Range_max_km ); } +inline double TcrmwGrid::range_max_km () const { return Range_max_km; } -inline double TcrmwGrid::range_delta_km () const { return ( Range_max_km/(Range_n - 1) ); } +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 ); } +inline double TcrmwGrid::azimuth_delta_deg () const { return 360.0/Azimuth_n; } -inline double TcrmwGrid::lat_center_deg () const { return ( Lat_Center_Deg ); } -inline double TcrmwGrid::lon_center_deg () const { return ( Lon_Center_Deg ); } +inline double TcrmwGrid::lat_center_deg () const { return Lat_Center_Deg; } +inline double TcrmwGrid::lon_center_deg () const { return Lon_Center_Deg; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_grid/unstructured_grid.cc b/src/libcode/vx_grid/unstructured_grid.cc index d1a56ff9f0..98cf8bccb9 100644 --- a/src/libcode/vx_grid/unstructured_grid.cc +++ b/src/libcode/vx_grid/unstructured_grid.cc @@ -421,7 +421,7 @@ void UnstructuredData::set_points(int count, const std::vector &ptL n_face = count; point_lonlat.reserve(count); for (int i=0; i= UGRID_DEBUG_LEVEL) mlog << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(int, std::vector &) first: (" diff --git a/src/libcode/vx_grid/unstructured_grid.h b/src/libcode/vx_grid/unstructured_grid.h index d3c0d40c66..3f46913472 100644 --- a/src/libcode/vx_grid/unstructured_grid.h +++ b/src/libcode/vx_grid/unstructured_grid.h @@ -85,8 +85,8 @@ class UnstructuredGrid : public GridRep { //////////////////////////////////////////////////////////////////////// -inline double UnstructuredGrid::scale_km() const { return ( -1.0 ); } -inline bool UnstructuredGrid::wrap_lon() const { return ( wrapLon ); } +inline double UnstructuredGrid::scale_km() const { return -1.0; } +inline bool UnstructuredGrid::wrap_lon() const { return wrapLon; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_gsl_prob/gsl_cdf.cc b/src/libcode/vx_gsl_prob/gsl_cdf.cc index 414ad355e0..6b2cfb8f17 100644 --- a/src/libcode/vx_gsl_prob/gsl_cdf.cc +++ b/src/libcode/vx_gsl_prob/gsl_cdf.cc @@ -259,7 +259,7 @@ bot = gsl_ran_fdist_pdf(x, deg_freedom_1, deg_freedom_2); x_new = x - (top/bot); -return ( x_new ); +return x_new; } diff --git a/src/libcode/vx_gsl_prob/gsl_randist.cc b/src/libcode/vx_gsl_prob/gsl_randist.cc index 956e912727..755ce1f4c3 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.cc +++ b/src/libcode/vx_gsl_prob/gsl_randist.cc @@ -219,31 +219,31 @@ double ran_draw(const gsl_rng *r, DistType t, double p1, double p2) { // Switch on the distribution type switch(t) { - case(DistType::Normal): + case DistType::Normal: v = gsl_ran_gaussian(r, p1); break; - case(DistType::Exponential): + case DistType::Exponential: v = gsl_ran_exponential(r, p1); break; - case(DistType::ChiSquared): + case DistType::ChiSquared: v = gsl_ran_chisq(r, p1); break; - case(DistType::Gamma): + case DistType::Gamma: v = gsl_ran_gamma(r, p1, p2); break; - case(DistType::Uniform): + case DistType::Uniform: v = gsl_ran_flat(r, p1, p2); break; - case(DistType::Beta): + case DistType::Beta: v = gsl_ran_beta(r, p1, p2); break; - case(DistType::None): + case DistType::None: default: v = 0.0; break; @@ -269,31 +269,31 @@ double dist_var(DistType t, double p1, double p2) { // Switch on the distribution type switch(t) { - case(DistType::Normal): + case DistType::Normal: v = p1*p1; break; - case(DistType::Exponential): + case DistType::Exponential: v = 1.0 / (p1*p1); break; - case(DistType::ChiSquared): + case DistType::ChiSquared: v = 2*p1; break; - case(DistType::Gamma): + case DistType::Gamma: v = p1 / (p2*p2); break; - case(DistType::Uniform): + case DistType::Uniform: v = ((p2-p1)*(p2-p1)) / 12.0; break; - case(DistType::Beta): + case DistType::Beta: v = (p1*p2) / ((p1+p2)*(p1+p2)*(p1+p2+1.0)); break; - case(DistType::None): + case DistType::None: default: v = 0.0; break; @@ -312,7 +312,7 @@ int get_seed() { curr_time = time(nullptr); // Swap the first and fourth bytes and the second and third bytes - u = (unsigned char *) &(curr_time); + u = (unsigned char *) &curr_time; t = u[0]; u[0] = u[3]; u[3] = t; diff --git a/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc b/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc index b13af92956..eee5c46905 100644 --- a/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc +++ b/src/libcode/vx_gsl_prob/gsl_wavelet2d.cc @@ -89,7 +89,7 @@ gsl_wavelet_workspace * wavelet_workspace_set(int n) { exit(1); } - return(work); + return work; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nav/nav.cc b/src/libcode/vx_nav/nav.cc index 6109be7192..3ebcfe2596 100644 --- a/src/libcode/vx_nav/nav.cc +++ b/src/libcode/vx_nav/nav.cc @@ -514,7 +514,7 @@ else { } -lon += twopi*floor( 0.5 - ((lon)/twopi) ); +lon += twopi*floor( 0.5 - (lon/twopi) ); lon = lon * deg_per_rad; //lon *= cf; diff --git a/src/libcode/vx_nc_obs/nc_obs_util.cc b/src/libcode/vx_nc_obs/nc_obs_util.cc index 0b6fa731e3..5380923944 100644 --- a/src/libcode/vx_nc_obs/nc_obs_util.cc +++ b/src/libcode/vx_nc_obs/nc_obs_util.cc @@ -327,7 +327,7 @@ void NetcdfObsVars::create_obs_vars (NcFile *f_out) { add_att(&obs_lvl_var, "long_name", "pressure level (hPa) or accumulation interval (sec)"); add_att(&obs_lvl_var, "_FillValue", FILL_VALUE); - long_name_str = (attr_agl) + long_name_str = attr_agl ? "height in meters above sea level or ground level (msl or agl)" : "height in meters above sea level (msl)"; add_att(&obs_hgt_var, "long_name", long_name_str); @@ -589,7 +589,7 @@ void NetcdfObsVars::read_header_data(MetPointHeader &hdr_data) { hdr_data.vld_idx_array.extend(nhdr_count); int buf_size = ((nhdr_count > NC_BUFFER_SIZE_32K) - ? NC_BUFFER_SIZE_32K : (nhdr_count)); + ? NC_BUFFER_SIZE_32K : nhdr_count); // // Allocate space to store the data @@ -948,7 +948,7 @@ void NetcdfObsVars::read_pb_hdr_data(MetPointHeader &hdr_data) { // Read PB report type int buf_size = ((pb_hdr_count > NC_BUFFER_SIZE_32K) - ? NC_BUFFER_SIZE_32K : (pb_hdr_count)); + ? NC_BUFFER_SIZE_32K : pb_hdr_count); int *hdr_prpt_typ_block = new int[buf_size]; int *hdr_irpt_typ_block = new int[buf_size]; int *hdr_inst_typ_block = new int[buf_size]; diff --git a/src/libcode/vx_nc_util/nc_utils.hpp b/src/libcode/vx_nc_util/nc_utils.hpp index f86cb472e9..c9024a471d 100644 --- a/src/libcode/vx_nc_util/nc_utils.hpp +++ b/src/libcode/vx_nc_util/nc_utils.hpp @@ -221,7 +221,7 @@ bool get_var_fill_value(const netCDF::NcVar *var, T &att_val) { if (att) delete att; - return(found); + return found; } //////////////////////////////////////////////////////////////////////// @@ -294,7 +294,7 @@ bool get_nc_data_t(netCDF::NcVar *var, T *data) { if (return_status) { var->getVar(data); } - return(return_status); + return return_status; } //////////////////////////////////////////////////////////////////////// @@ -324,7 +324,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, const T met_missing) { "", GET_NC_NAME_P(var).c_str()); } } - return(return_status); + return return_status; } //////////////////////////////////////////////////////////////////////// @@ -393,7 +393,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &dims "", GET_NC_NAME_P(var).c_str()); } } - return(return_status); + return return_status; } //////////////////////////////////////////////////////////////////////// @@ -449,7 +449,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const long dim, co "", GET_NC_NAME_P(var).c_str()); } } - return(return_status); + return return_status; } //////////////////////////////////////////////////////////////////////// @@ -472,7 +472,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &curs // Retrieve the NetCDF value from the NetCDF variable. return_status = get_nc_data_(var, data, bad_data, dims, curs); } - return(return_status); + return return_status; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/ps_text.h b/src/libcode/vx_ps/ps_text.h index b068f461f2..3d594d7cc8 100644 --- a/src/libcode/vx_ps/ps_text.h +++ b/src/libcode/vx_ps/ps_text.h @@ -121,21 +121,21 @@ class VxpsTextNode { //////////////////////////////////////////////////////////////////////// -inline int VxpsTextNode::font_number() const { return ( FontNumber ); } -inline double VxpsTextNode::font_size() const { return ( FontSize ); } +inline int VxpsTextNode::font_number() const { return FontNumber; } +inline double VxpsTextNode::font_size() const { return FontSize ; } -inline const char * VxpsTextNode::text() const { return ( Text ); } +inline const char * VxpsTextNode::text() const { return Text; } -inline double VxpsTextNode::width () const { return ( Width ); } +inline double VxpsTextNode::width () const { return Width ; } -inline double VxpsTextNode::right () const { return ( Right ); } -inline double VxpsTextNode::left () const { return ( Left ); } -inline double VxpsTextNode::bottom () const { return ( Bottom ); } -inline double VxpsTextNode::top () const { return ( Top ); } +inline double VxpsTextNode::right () const { return Right ; } +inline double VxpsTextNode::left () const { return Left ; } +inline double VxpsTextNode::bottom () const { return Bottom; } +inline double VxpsTextNode::top () const { return Top ; } -inline int VxpsTextNode::nchars() const { return ( Nchars ); } +inline int VxpsTextNode::nchars() const { return Nchars; } -inline double VxpsTextNode::dx () const { return ( Dx ); } +inline double VxpsTextNode::dx () const { return Dx; } inline int VxpsTextNode::is_empty() const { return ( Text ? 0 : 1 ); } diff --git a/src/libcode/vx_ps/table_helper.h b/src/libcode/vx_ps/table_helper.h index 2aa510f7b2..d38399ecdd 100644 --- a/src/libcode/vx_ps/table_helper.h +++ b/src/libcode/vx_ps/table_helper.h @@ -166,8 +166,8 @@ class TableHelper { //////////////////////////////////////////////////////////////////////// -inline int TableHelper::nrows() const { return ( Nrows ); } -inline int TableHelper::ncols() const { return ( Ncols ); } +inline int TableHelper::nrows() const { return Nrows; } +inline int TableHelper::ncols() const { return Ncols; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_ps/vx_ps.h b/src/libcode/vx_ps/vx_ps.h index 33b14d4779..bec3d46bed 100644 --- a/src/libcode/vx_ps/vx_ps.h +++ b/src/libcode/vx_ps/vx_ps.h @@ -293,12 +293,12 @@ class PSfile { ////////////////////////////////////////////////////////////// -inline PSFilter & PSfile::file() const { return ( *Head ); } +inline PSFilter & PSfile::file() const { return *Head; } -inline DocumentOrientation PSfile::orientation () const { return ( Orientation ); } -inline DocumentMedia PSfile::media () const { return ( Media ); } +inline DocumentOrientation PSfile::orientation () const { return Orientation; } +inline DocumentMedia PSfile::media () const { return Media; } -inline ConcatString PSfile::output_filename () const { return ( OutputFilename ); } +inline ConcatString PSfile::output_filename () const { return OutputFilename; } inline double PSfile::page_width () const { return ( (Orientation == OrientationPortrait) ? MediaWidth : MediaHeight); } inline double PSfile::page_height () const { return ( (Orientation == OrientationPortrait) ? MediaHeight : MediaWidth ); } @@ -318,7 +318,7 @@ inline void PSfile::setlinejoin_miter() { setlinejoin(0); return; }; inline void PSfile::setlinejoin_round() { setlinejoin(1); return; }; inline void PSfile::setlinejoin_bevel() { setlinejoin(2); return; }; -inline FontFamily PSfile::family () const { return ( Family ); } +inline FontFamily PSfile::family () const { return Family; } ////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/pcm.h b/src/libcode/vx_pxm/pcm.h index bf07e8593a..6912964471 100644 --- a/src/libcode/vx_pxm/pcm.h +++ b/src/libcode/vx_pxm/pcm.h @@ -103,9 +103,9 @@ class Pcm : public PxmBase { //////////////////////////////////////////////////////////////////////// -inline int Pcm::n_colors() const { return ( Ncolors ); } +inline int Pcm::n_colors() const { return Ncolors; } -inline int Pcm::n_data_bytes() const { return ( Nalloc ); } +inline int Pcm::n_data_bytes() const { return Nalloc; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_pxm/pxm_base.h b/src/libcode/vx_pxm/pxm_base.h index 04a4ed3d31..dd00b45382 100644 --- a/src/libcode/vx_pxm/pxm_base.h +++ b/src/libcode/vx_pxm/pxm_base.h @@ -137,15 +137,15 @@ class PxmBase { //////////////////////////////////////////////////////////////////////// -inline const char * PxmBase::name() const { return ( Name ); } +inline const char * PxmBase::name() const { return Name; } -inline int PxmBase::nrows() const { return ( Nrows ); } -inline int PxmBase::ncols() const { return ( Ncols ); } +inline int PxmBase::nrows() const { return Nrows; } +inline int PxmBase::ncols() const { return Ncols; } -inline int PxmBase::ny() const { return ( Nrows ); } -inline int PxmBase::nx() const { return ( Ncols ); } +inline int PxmBase::ny() const { return Nrows; } +inline int PxmBase::nx() const { return Ncols; } -inline int PxmBase::n_comments() const { return ( Ncomments ); } +inline int PxmBase::n_comments() const { return Ncomments; } inline int PxmBase::ok() const { return ( data ? 1 : 0 ); } diff --git a/src/libcode/vx_python3_utils/python3_dict.h b/src/libcode/vx_python3_utils/python3_dict.h index 851c22b15c..e073af2354 100644 --- a/src/libcode/vx_python3_utils/python3_dict.h +++ b/src/libcode/vx_python3_utils/python3_dict.h @@ -80,7 +80,7 @@ class Python3_Dict { //////////////////////////////////////////////////////////////////////// -inline int Python3_Dict::size() const { return ( Size ); } +inline int Python3_Dict::size() const { return Size; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_list.h b/src/libcode/vx_python3_utils/python3_list.h index 76e877754a..5b45f82432 100644 --- a/src/libcode/vx_python3_utils/python3_list.h +++ b/src/libcode/vx_python3_utils/python3_list.h @@ -71,7 +71,7 @@ class Python3_List { //////////////////////////////////////////////////////////////////////// -inline int Python3_List::size() const { return ( Size ); } +inline int Python3_List::size() const { return Size; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_numpy.h b/src/libcode/vx_python3_utils/python3_numpy.h index 2ead2cf900..d8f2cee6c6 100644 --- a/src/libcode/vx_python3_utils/python3_numpy.h +++ b/src/libcode/vx_python3_utils/python3_numpy.h @@ -122,23 +122,23 @@ class Python3_Numpy { //////////////////////////////////////////////////////////////////////// -inline int Python3_Numpy::n_dims() const { return ( N_Dims ); } +inline int Python3_Numpy::n_dims() const { return N_Dims; } -inline int Python3_Numpy::n_data() const { return ( N_Data ); } +inline int Python3_Numpy::n_data() const { return N_Data; } -inline long Python3_Numpy::item_size() const { return ( Item_Size ); } +inline long Python3_Numpy::item_size() const { return Item_Size; } -inline PyObject * Python3_Numpy::object() const { return ( Object ); } +inline PyObject * Python3_Numpy::object() const { return Object; } -inline PyObject * Python3_Numpy::data_obj() const { return ( Data_Obj ); } +inline PyObject * Python3_Numpy::data_obj() const { return Data_Obj; } -inline Py_buffer & Python3_Numpy::view() { return ( View ); } +inline Py_buffer & Python3_Numpy::view() { return View; } -inline void * Python3_Numpy::buffer() const { return ( Buffer ); } +inline void * Python3_Numpy::buffer() const { return Buffer; } -inline const char * Python3_Numpy::name() const { return ( Name.text() ); } +inline const char * Python3_Numpy::name() const { return Name.text(); } -inline const char * Python3_Numpy::dtype() const { return ( Dtype.text() ); } +inline const char * Python3_Numpy::dtype() const { return Dtype.text(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/python3_script.h b/src/libcode/vx_python3_utils/python3_script.h index 10b648b853..572b1c1fff 100644 --- a/src/libcode/vx_python3_utils/python3_script.h +++ b/src/libcode/vx_python3_utils/python3_script.h @@ -92,15 +92,15 @@ class Python3_Script { //////////////////////////////////////////////////////////////////////// -inline PyObject * Python3_Script::get_module() { return ( Module ); } +inline PyObject * Python3_Script::get_module() { return Module; } -inline PyObject * Python3_Script::dict() { return ( Dict ); } +inline PyObject * Python3_Script::dict() { return Dict; } -inline PyObject * Python3_Script::module_ascii() { return ( ModuleAscii ); } +inline PyObject * Python3_Script::module_ascii() { return ModuleAscii; } -inline PyObject * Python3_Script::dict_ascii() { return ( DictAscii ); } +inline PyObject * Python3_Script::dict_ascii() { return DictAscii; } -inline ConcatString Python3_Script::filename() const { return ( Script_Filename ); } +inline ConcatString Python3_Script::filename() const { return Script_Filename; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/wchar_argv.h b/src/libcode/vx_python3_utils/wchar_argv.h index 9d602de0c0..fa9816d3c6 100644 --- a/src/libcode/vx_python3_utils/wchar_argv.h +++ b/src/libcode/vx_python3_utils/wchar_argv.h @@ -79,9 +79,9 @@ class Wchar_Argv { //////////////////////////////////////////////////////////////////////// -inline int Wchar_Argv::wargc() const { return ( Argc ); } +inline int Wchar_Argv::wargc() const { return Argc; } -inline wchar_t ** Wchar_Argv::wargv() const { return ( W_Argv ); } +inline wchar_t ** Wchar_Argv::wargv() const { return W_Argv; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_render/renderinfo.h b/src/libcode/vx_render/renderinfo.h index 20bab130f3..57fe1dbc5e 100644 --- a/src/libcode/vx_render/renderinfo.h +++ b/src/libcode/vx_render/renderinfo.h @@ -94,16 +94,16 @@ class RenderInfo { //////////////////////////////////////////////////////////////////////// -inline double RenderInfo::x_ll () const { return ( X_ll ); } -inline double RenderInfo::y_ll () const { return ( Y_ll ); } +inline double RenderInfo::x_ll () const { return X_ll; } +inline double RenderInfo::y_ll () const { return Y_ll; } -inline double RenderInfo::x_mag() const { return ( X_mag ); } -inline double RenderInfo::y_mag() const { return ( Y_mag ); } +inline double RenderInfo::x_mag() const { return X_mag; } +inline double RenderInfo::y_mag() const { return Y_mag; } -inline int RenderInfo::n_filters() const { return ( Nfilters ); } +inline int RenderInfo::n_filters() const { return Nfilters; } -inline bool RenderInfo::is_bw () const { return ( BW ); } -inline bool RenderInfo::is_color () const { return ( ! BW ); } +inline bool RenderInfo::is_bw () const { return BW; } +inline bool RenderInfo::is_color () const { return !BW; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index dcc5840a47..ffaba59145 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -1752,20 +1752,20 @@ void ModeFuzzyEngine::do_fcst_merge_engine(const char *default_config, // this will capture any previous merging performed // in the current forecast field. // - *(fcst_engine->fcst_raw) = *(fcst_raw); - *(fcst_engine->obs_raw) = *(fcst_raw); + *(fcst_engine->fcst_raw) = *fcst_raw; + *(fcst_engine->obs_raw) = *fcst_raw; - *(fcst_engine->fcst_conv) = *(fcst_conv); - *(fcst_engine->obs_conv) = *(fcst_conv); + *(fcst_engine->fcst_conv) = *fcst_conv; + *(fcst_engine->obs_conv) = *fcst_conv; - *(fcst_engine->fcst_thresh) = *(fcst_thresh); - *(fcst_engine->obs_thresh) = *(fcst_thresh); + *(fcst_engine->fcst_thresh) = *fcst_thresh; + *(fcst_engine->obs_thresh) = *fcst_thresh; - *(fcst_engine->fcst_mask) = *(fcst_mask); - *(fcst_engine->obs_mask) = *(fcst_mask); + *(fcst_engine->fcst_mask) = *fcst_mask; + *(fcst_engine->obs_mask) = *fcst_mask; - *(fcst_engine->fcst_split) = *(fcst_split); - *(fcst_engine->obs_split) = *(fcst_split); + *(fcst_engine->fcst_split) = *fcst_split; + *(fcst_engine->obs_split) = *fcst_split; fcst_engine->n_fcst = n_fcst; fcst_engine->n_obs = n_fcst; @@ -1919,20 +1919,20 @@ void ModeFuzzyEngine::do_obs_merge_engine(const char *default_config, // this will capture any previous merging performed // in the current observation field. // - *(obs_engine->fcst_raw) = *(obs_raw); - *(obs_engine->obs_raw) = *(obs_raw); + *(obs_engine->fcst_raw) = *obs_raw; + *(obs_engine->obs_raw) = *obs_raw; - *(obs_engine->fcst_conv) = *(obs_conv); - *(obs_engine->obs_conv) = *(obs_conv); + *(obs_engine->fcst_conv) = *obs_conv; + *(obs_engine->obs_conv) = *obs_conv; - *(obs_engine->fcst_thresh) = *(obs_thresh); - *(obs_engine->obs_thresh) = *(obs_thresh); + *(obs_engine->fcst_thresh) = *obs_thresh; + *(obs_engine->obs_thresh) = *obs_thresh; - *(obs_engine->fcst_mask) = *(obs_mask); - *(obs_engine->obs_mask) = *(obs_mask); + *(obs_engine->fcst_mask) = *obs_mask; + *(obs_engine->obs_mask) = *obs_mask; - *(obs_engine->fcst_split) = *(obs_split); - *(obs_engine->obs_split) = *(obs_split); + *(obs_engine->fcst_split) = *obs_split; + *(obs_engine->obs_split) = *obs_split; obs_engine->n_fcst = n_obs; obs_engine->n_obs = n_obs; diff --git a/src/libcode/vx_shapedata/ihull.h b/src/libcode/vx_shapedata/ihull.h index 3206ed2883..c662ad2eb4 100644 --- a/src/libcode/vx_shapedata/ihull.h +++ b/src/libcode/vx_shapedata/ihull.h @@ -48,7 +48,7 @@ const int y2 = p2.y - p0.y; const int k = x1*y2 - x2*y1; -if ( k > 0 ) return ( 1 ); +if ( k > 0 ) return 1; return ( (k < 0) ? -1 : 0 ); diff --git a/src/libcode/vx_shapedata/node.cc b/src/libcode/vx_shapedata/node.cc index 74310ea451..329bd9f961 100644 --- a/src/libcode/vx_shapedata/node.cc +++ b/src/libcode/vx_shapedata/node.cc @@ -143,7 +143,7 @@ void Node::add_child(const Polyline * poly) { exit(1); } - child->p = *(poly); + child->p = *poly; child->child = nullptr; child->sibling = nullptr; @@ -171,7 +171,7 @@ void Node::add_child(const Polyline * poly) { exit(1); } - n_ptr->sibling->p = *(poly); + n_ptr->sibling->p = *poly; n_ptr->sibling->child = nullptr; n_ptr->sibling->sibling = nullptr; diff --git a/src/libcode/vx_shapedata/shapedata.h b/src/libcode/vx_shapedata/shapedata.h index 9654844047..5c1252dbc7 100644 --- a/src/libcode/vx_shapedata/shapedata.h +++ b/src/libcode/vx_shapedata/shapedata.h @@ -186,13 +186,13 @@ class ShapeData { /////////////////////////////////////////////////////////////////////////////// -inline Moments ShapeData::moments() const { return(mom); } +inline Moments ShapeData::moments() const { return mom; } -inline bool ShapeData::is_valid_xy (int x, int y) const { return ( ! ::is_bad_data(data(x, y)) ); } -inline bool ShapeData::is_bad_data (int x, int y) const { return ( ::is_bad_data(data(x, y)) ); } +inline bool ShapeData::is_valid_xy (int x, int y) const { return ! ::is_bad_data(data(x, y) ); } +inline bool ShapeData::is_bad_data (int x, int y) const { return ::is_bad_data(data(x, y) ); } -inline bool ShapeData::is_zero (int x, int y) const { return ( is_eq(data(x, y), 0.0) ); } -inline bool ShapeData::is_nonzero (int x, int y) const { return ( ! is_eq(data(x, y), 0.0) ); } +inline bool ShapeData::is_zero (int x, int y) const { return is_eq(data(x, y), 0.0); } +inline bool ShapeData::is_nonzero (int x, int y) const { return !is_eq(data(x, y), 0.0); } inline void ShapeData::debug_examine() const { data.debug_examine(); } inline std::string ShapeData::sdebug_examine() const { return data.sdebug_examine(); } diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index c6c6244f67..0bd1c9393a 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -39,7 +39,7 @@ void parse_row_col(const char *col_name, int &r, int &c) { mlog << Error << "\nparse_row_col() -> " << "unexpected column name specified: \"" << col_name << "\"\n\n"; - throw(1); + throw 1; } return; diff --git a/src/libcode/vx_stat_out/stat_hdr_columns.h b/src/libcode/vx_stat_out/stat_hdr_columns.h index 8fb9e4f564..0eab56d6bd 100644 --- a/src/libcode/vx_stat_out/stat_hdr_columns.h +++ b/src/libcode/vx_stat_out/stat_hdr_columns.h @@ -214,55 +214,55 @@ class StatHdrColumns { //////////////////////////////////////////////////////////////////////// -inline ConcatString StatHdrColumns::get_model () const { return(model.contents(na_str)); } -inline ConcatString StatHdrColumns::get_desc () const { return(desc.contents(na_str)); } +inline ConcatString StatHdrColumns::get_model () const { return model.contents(na_str); } +inline ConcatString StatHdrColumns::get_desc () const { return desc.contents(na_str); } -inline int StatHdrColumns::get_fcst_lead_sec () const { return(fcst_lead_sec); } -inline ConcatString StatHdrColumns::get_fcst_lead_str () const { return(fcst_lead_str.contents(na_str)); } +inline int StatHdrColumns::get_fcst_lead_sec () const { return fcst_lead_sec; } +inline ConcatString StatHdrColumns::get_fcst_lead_str () const { return fcst_lead_str.contents(na_str); } -inline unixtime StatHdrColumns::get_fcst_valid_beg () const { return(fcst_valid_beg); } -inline ConcatString StatHdrColumns::get_fcst_valid_beg_str() const { return(fcst_valid_beg_str.contents(na_str)); } +inline unixtime StatHdrColumns::get_fcst_valid_beg () const { return fcst_valid_beg; } +inline ConcatString StatHdrColumns::get_fcst_valid_beg_str() const { return fcst_valid_beg_str.contents(na_str); } -inline unixtime StatHdrColumns::get_fcst_valid_end () const { return(fcst_valid_end); } -inline ConcatString StatHdrColumns::get_fcst_valid_end_str() const { return(fcst_valid_end_str.contents(na_str)); } +inline unixtime StatHdrColumns::get_fcst_valid_end () const { return fcst_valid_end; } +inline ConcatString StatHdrColumns::get_fcst_valid_end_str() const { return fcst_valid_end_str.contents(na_str); } -inline int StatHdrColumns::get_obs_lead_sec () const { return(obs_lead_sec); } -inline ConcatString StatHdrColumns::get_obs_lead_str () const { return(obs_lead_str.contents(na_str)); } +inline int StatHdrColumns::get_obs_lead_sec () const { return obs_lead_sec; } +inline ConcatString StatHdrColumns::get_obs_lead_str () const { return obs_lead_str.contents(na_str); } -inline unixtime StatHdrColumns::get_obs_valid_beg () const { return(obs_valid_beg); } -inline ConcatString StatHdrColumns::get_obs_valid_beg_str () const { return(obs_valid_beg_str.contents(na_str)); } +inline unixtime StatHdrColumns::get_obs_valid_beg () const { return obs_valid_beg; } +inline ConcatString StatHdrColumns::get_obs_valid_beg_str () const { return obs_valid_beg_str.contents(na_str); } -inline unixtime StatHdrColumns::get_obs_valid_end () const { return(obs_valid_end); } -inline ConcatString StatHdrColumns::get_obs_valid_end_str () const { return(obs_valid_end_str.contents(na_str)); } +inline unixtime StatHdrColumns::get_obs_valid_end () const { return obs_valid_end; } +inline ConcatString StatHdrColumns::get_obs_valid_end_str () const { return obs_valid_end_str.contents(na_str); } -inline ConcatString StatHdrColumns::get_fcst_var () const { return(fcst_var.contents(na_str)); } -inline ConcatString StatHdrColumns::get_fcst_units () const { return(fcst_units.contents(na_str)); } -inline ConcatString StatHdrColumns::get_fcst_lev () const { return(fcst_lev.contents(na_str)); } +inline ConcatString StatHdrColumns::get_fcst_var () const { return fcst_var.contents(na_str); } +inline ConcatString StatHdrColumns::get_fcst_units () const { return fcst_units.contents(na_str); } +inline ConcatString StatHdrColumns::get_fcst_lev () const { return fcst_lev.contents(na_str); } -inline ConcatString StatHdrColumns::get_obs_var () const { return(obs_var.contents(na_str)); } -inline ConcatString StatHdrColumns::get_obs_units () const { return(obs_units.contents(na_str)); } -inline ConcatString StatHdrColumns::get_obs_lev () const { return(obs_lev.contents(na_str)); } +inline ConcatString StatHdrColumns::get_obs_var () const { return obs_var.contents(na_str); } +inline ConcatString StatHdrColumns::get_obs_units () const { return obs_units.contents(na_str); } +inline ConcatString StatHdrColumns::get_obs_lev () const { return obs_lev.contents(na_str); } -inline ConcatString StatHdrColumns::get_obtype () const { return(obtype.contents(na_str)); } -inline ConcatString StatHdrColumns::get_mask () const { return(mask.contents(na_str)); } +inline ConcatString StatHdrColumns::get_obtype () const { return obtype.contents(na_str); } +inline ConcatString StatHdrColumns::get_mask () const { return mask.contents(na_str); } -inline ConcatString StatHdrColumns::get_interp_mthd () const { return(interp_mthd.contents(na_str)); } -inline int StatHdrColumns::get_interp_pnts () const { return(interp_pnts); } -inline ConcatString StatHdrColumns::get_interp_pnts_str () const { return(interp_pnts_str.contents(na_str)); } +inline ConcatString StatHdrColumns::get_interp_mthd () const { return interp_mthd.contents(na_str); } +inline int StatHdrColumns::get_interp_pnts () const { return interp_pnts; } +inline ConcatString StatHdrColumns::get_interp_pnts_str () const { return interp_pnts_str.contents(na_str); } -inline ConcatString StatHdrColumns::get_line_type () const { return(line_type.contents(na_str)); } +inline ConcatString StatHdrColumns::get_line_type () const { return line_type.contents(na_str); } -inline ThreshArray StatHdrColumns::get_fcst_thresh () const { return(fcst_thresh); } +inline ThreshArray StatHdrColumns::get_fcst_thresh () const { return fcst_thresh; } -inline ThreshArray StatHdrColumns::get_obs_thresh () const { return(obs_thresh); } -inline ConcatString StatHdrColumns::get_obs_thresh_str () const { return(obs_thresh.get_str()); } +inline ThreshArray StatHdrColumns::get_obs_thresh () const { return obs_thresh; } +inline ConcatString StatHdrColumns::get_obs_thresh_str () const { return obs_thresh.get_str(); } -inline SetLogic StatHdrColumns::get_thresh_logic () const { return(thresh_logic); } +inline SetLogic StatHdrColumns::get_thresh_logic () const { return thresh_logic; } -inline ThreshArray StatHdrColumns::get_cov_thresh () const { return(cov_thresh); } -inline ConcatString StatHdrColumns::get_cov_thresh_str () const { return(prob_thresh_to_string(cov_thresh)); } +inline ThreshArray StatHdrColumns::get_cov_thresh () const { return cov_thresh; } +inline ConcatString StatHdrColumns::get_cov_thresh_str () const { return prob_thresh_to_string(cov_thresh); } -inline double StatHdrColumns::get_alpha () const { return(alpha); } +inline double StatHdrColumns::get_alpha () const { return alpha; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/compute_ci.cc b/src/libcode/vx_statistics/compute_ci.cc index e444ab59e5..3edbc66a8f 100644 --- a/src/libcode/vx_statistics/compute_ci.cc +++ b/src/libcode/vx_statistics/compute_ci.cc @@ -384,7 +384,7 @@ void compute_cts_stats_ci_bca(const gsl_rng *rng_ptr, if(cts_r_out) { delete [] cts_r_out; cts_r_out = (ofstream *) nullptr; } if(cts_i_file) { delete [] cts_i_file; cts_i_file = (ConcatString *) nullptr; } if(cts_r_file) { delete [] cts_r_file; cts_r_file = (ConcatString *) nullptr; } - throw(1); + throw 1; } } @@ -812,7 +812,7 @@ void compute_mcts_stats_ci_bca(const gsl_rng *rng_ptr, << "can't open one or more temporary files for writing:\n" << mcts_i_file << "\n" << mcts_r_file << "\n\n"; - throw(1); + throw 1; } // @@ -1024,7 +1024,7 @@ void compute_cnt_stats_ci_bca(const gsl_rng *rng_ptr, << "can't open one or more temporary files for writing:\n" << cnt_i_file << "\n" << cnt_r_file << "\n\n"; - throw(1); + throw 1; } // @@ -1512,7 +1512,7 @@ void compute_cts_stats_ci_perc(const gsl_rng *rng_ptr, if(cts_r_out) { delete [] cts_r_out; cts_r_out = (ofstream *) nullptr; } if(cts_r_file) { delete [] cts_r_file; cts_r_file = (ConcatString *) nullptr; } - throw(1); + throw 1; } } @@ -1897,7 +1897,7 @@ void compute_mcts_stats_ci_perc(const gsl_rng *rng_ptr, mlog << Error << "\ncompute_mcts_stats_ci_perc() -> " << "can't open the temporary file for writing:\n" << mcts_r_file << "\n\n"; - throw(1); + throw 1; } // @@ -2086,7 +2086,7 @@ void compute_cnt_stats_ci_perc(const gsl_rng *rng_ptr, mlog << Error << "\ncompute_cnt_stats_ci_perc() -> " << "can't open the temporary file for writing:\n" << cnt_r_file << "\n\n"; - throw(1); + throw 1; } // @@ -2543,7 +2543,7 @@ void compute_nbrcts_stats_ci_bca(const gsl_rng *rng_ptr, if(nbrcts_i_file) { delete [] nbrcts_i_file; nbrcts_i_file = (ConcatString *) nullptr; } if(nbrcts_r_file) { delete [] nbrcts_r_file; nbrcts_r_file = (ConcatString *) nullptr; } - throw(1); + throw 1; } } @@ -2943,7 +2943,7 @@ void compute_nbrcnt_stats_ci_bca(const gsl_rng *rng_ptr, << "can't open one or more temporary files for writing:\n" << nbrcnt_i_file << "\n" << nbrcnt_r_file << "\n\n"; - throw(1); + throw 1; } // @@ -3184,7 +3184,7 @@ void compute_nbrcts_stats_ci_perc(const gsl_rng *rng_ptr, if(nbrcts_r_out) { delete [] nbrcts_r_out; nbrcts_r_out = (ofstream *) nullptr; } if(nbrcts_r_file) { delete [] nbrcts_r_file; nbrcts_r_file = (ConcatString *) nullptr; } - throw(1); + throw 1; } } @@ -3543,7 +3543,7 @@ void compute_nbrcnt_stats_ci_perc(const gsl_rng *rng_ptr, mlog << Error << "\ncompute_nbrcnt_stats_ci_perc() -> " << "can't open the temporary file for writing:\n" << nbrcnt_r_file << "\n\n"; - throw(1); + throw 1; } // @@ -4009,7 +4009,7 @@ void read_ldf(const ConcatString file_name, int col, NumArray &na) { mlog << Error << "\nread_ldf() -> " << "can't open file: " << file_name << "\n\n" ; - throw(1); + throw 1; } // diff --git a/src/libcode/vx_statistics/contable.h b/src/libcode/vx_statistics/contable.h index a605300e08..cae46f880a 100644 --- a/src/libcode/vx_statistics/contable.h +++ b/src/libcode/vx_statistics/contable.h @@ -139,11 +139,11 @@ class ContingencyTable { //////////////////////////////////////////////////////////////////////// -inline int ContingencyTable::nrows() const { return ( Nrows ); } -inline int ContingencyTable::ncols() const { return ( Ncols ); } +inline int ContingencyTable::nrows() const { return Nrows; } +inline int ContingencyTable::ncols() const { return Ncols; } -inline double ContingencyTable::ec_value() const { return ( ECvalue ); } -inline ConcatString ContingencyTable::name() const { return ( Name ); } +inline double ContingencyTable::ec_value() const { return ECvalue; } +inline ConcatString ContingencyTable::name() const { return Name; } //////////////////////////////////////////////////////////////////////// @@ -252,11 +252,11 @@ class Nx2ContingencyTable : public ContingencyTable { //////////////////////////////////////////////////////////////////////// -inline int Nx2ContingencyTable::event_col_total () const { return ( col_total(nx2_event_column) ); } -inline int Nx2ContingencyTable::nonevent_col_total () const { return ( col_total(nx2_nonevent_column) ); } +inline int Nx2ContingencyTable::event_col_total () const { return col_total(nx2_event_column); } +inline int Nx2ContingencyTable::nonevent_col_total () const { return col_total(nx2_nonevent_column); } -inline int Nx2ContingencyTable::event_count_by_row (int row) const { return ( entry(row, nx2_event_column) ); } -inline int Nx2ContingencyTable::nonevent_count_by_row (int row) const { return ( entry(row, nx2_nonevent_column) ); } +inline int Nx2ContingencyTable::event_count_by_row (int row) const { return entry(row, nx2_event_column); } +inline int Nx2ContingencyTable::nonevent_count_by_row (int row) const { return entry(row, nx2_nonevent_column); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/contable_nx2.cc b/src/libcode/vx_statistics/contable_nx2.cc index e9964a3b28..9af0358511 100644 --- a/src/libcode/vx_statistics/contable_nx2.cc +++ b/src/libcode/vx_statistics/contable_nx2.cc @@ -472,7 +472,7 @@ double Nx2ContingencyTable::baser() const { if( n() == 0 ) v = bad_data_double; else v = (double) event_col_total()/n(); - return ( v ); + return v; } diff --git a/src/libcode/vx_statistics/contable_stats.cc b/src/libcode/vx_statistics/contable_stats.cc index d0c795f2a2..7e7194c11d 100644 --- a/src/libcode/vx_statistics/contable_stats.cc +++ b/src/libcode/vx_statistics/contable_stats.cc @@ -737,7 +737,7 @@ double TTContingencyTable::sedi_ci(double alpha, double TTContingencyTable::cost_loss(double r) const { double num, den, h, m, f, b, v; - if(n() == 0) return(bad_data_double); + if(n() == 0) return bad_data_double; // Total proportion of hits, misses, false alarms, and observations h = (double) fy_oy() / n(); diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index 7f2af8b534..b5a9199ced 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3458,7 +3458,7 @@ double compute_mean(double sum, int n) { v = sum / n; } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -3579,7 +3579,7 @@ double compute_ufss(double o_rate) { if(is_bad_data(o_rate)) ufss = bad_data_double; else ufss = 0.5 + o_rate/2.0; - return(ufss); + return ufss; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index 36a9e2f01d..a89a8fc355 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -675,7 +675,7 @@ class DMAPInfo { //////////////////////////////////////////////////////////////////////// -inline double DMAPInfo::get_beta_value() const { return(beta_value); } +inline double DMAPInfo::get_beta_value() const { return beta_value; } //////////////////////////////////////////////////////////////////////// // diff --git a/src/libcode/vx_statistics/obs_error.h b/src/libcode/vx_statistics/obs_error.h index 11cce141dc..ec6d3878b5 100644 --- a/src/libcode/vx_statistics/obs_error.h +++ b/src/libcode/vx_statistics/obs_error.h @@ -149,8 +149,8 @@ class ObsErrorTable { //////////////////////////////////////////////////////////////////////// -inline int ObsErrorTable::n() const { return(N_elements); } -inline bool ObsErrorTable::is_set() const { return(IsSet); } +inline int ObsErrorTable::n() const { return N_elements; } +inline bool ObsErrorTable::is_set() const { return IsSet; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_base.h b/src/libcode/vx_statistics/pair_base.h index 3a0f869edb..b0881ae34e 100644 --- a/src/libcode/vx_statistics/pair_base.h +++ b/src/libcode/vx_statistics/pair_base.h @@ -181,7 +181,7 @@ class PairBase { //////////////////////////////////////////////////////////////////////// -inline bool PairBase::is_point_vx() const { return(IsPointVx); } +inline bool PairBase::is_point_vx() const { return IsPointVx; } //////////////////////////////////////////////////////////////////////// // diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 1041f80324..5088c22564 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -1792,15 +1792,15 @@ bool check_fo_thresh(double f, double o, double cmn, double csd, } switch(t) { - case(SetLogic::Union): + case SetLogic::Union: if(!fcheck && !ocheck) status = false; break; - case(SetLogic::Intersection): + case SetLogic::Intersection: if(!fcheck || !ocheck) status = false; break; - case(SetLogic::SymDiff): + case SetLogic::SymDiff: if(fcheck == ocheck) status = false; break; @@ -1810,7 +1810,7 @@ bool check_fo_thresh(double f, double o, double cmn, double csd, exit(1); } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/atcf_line_base.h b/src/libcode/vx_tc_util/atcf_line_base.h index 8b1141ffad..0547b7d5b0 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.h +++ b/src/libcode/vx_tc_util/atcf_line_base.h @@ -131,13 +131,13 @@ class ATCFLineBase : public DataLine { //////////////////////////////////////////////////////////////////////// inline void ATCFLineBase::set_basin_map (const std::map *m) - { BasinMap = m; } -inline void ATCFLineBase::set_best_technique(const StringArray *s) { BestTechnique = s; } -inline void ATCFLineBase::set_oper_technique(const StringArray *s) { OperTechnique = s; } -inline void ATCFLineBase::set_tech_suffix (const ConcatString *s) { TechSuffix = s; } -inline void ATCFLineBase::set_technique (const ConcatString &s) { Technique = s; } -inline bool ATCFLineBase::is_best_track () const { return(IsBestTrack); } -inline bool ATCFLineBase::is_oper_track () const { return(IsOperTrack); } + { BasinMap = m; } +inline void ATCFLineBase::set_best_technique(const StringArray *s) { BestTechnique = s; } +inline void ATCFLineBase::set_oper_technique(const StringArray *s) { OperTechnique = s; } +inline void ATCFLineBase::set_tech_suffix (const ConcatString *s) { TechSuffix = s; } +inline void ATCFLineBase::set_technique (const ConcatString &s) { Technique = s; } +inline bool ATCFLineBase::is_best_track () const { return IsBestTrack; } +inline bool ATCFLineBase::is_oper_track () const { return IsOperTrack; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/diag_file.h b/src/libcode/vx_tc_util/diag_file.h index 9c302d5528..f387625758 100644 --- a/src/libcode/vx_tc_util/diag_file.h +++ b/src/libcode/vx_tc_util/diag_file.h @@ -135,17 +135,17 @@ class DiagFile : public LineDataFile { //////////////////////////////////////////////////////////////////////// -inline const ConcatString & DiagFile::storm_id() const { return(StormId); } -inline const ConcatString & DiagFile::basin() const { return(Basin); } -inline const ConcatString & DiagFile::cyclone() const { return(Cyclone); } -inline const StringArray & DiagFile::technique() const { return(Technique); } -inline unixtime DiagFile::init() const { return(InitTime); } -inline int DiagFile::n_time() const { return(NTime); } -inline DiagType DiagFile::diag_source() const { return(DiagSource); } -inline const ConcatString & DiagFile::track_source() const { return(TrackSource); } -inline const ConcatString & DiagFile::field_source() const { return(FieldSource); } -inline int DiagFile::n_diag() const { return(DiagName.n()); } -inline const StringArray & DiagFile::diag_name() const { return(DiagName); } +inline const ConcatString & DiagFile::storm_id() const { return StormId; } +inline const ConcatString & DiagFile::basin() const { return Basin; } +inline const ConcatString & DiagFile::cyclone() const { return Cyclone; } +inline const StringArray & DiagFile::technique() const { return Technique; } +inline unixtime DiagFile::init() const { return InitTime; } +inline int DiagFile::n_time() const { return NTime; } +inline DiagType DiagFile::diag_source() const { return DiagSource; } +inline const ConcatString & DiagFile::track_source() const { return TrackSource; } +inline const ConcatString & DiagFile::field_source() const { return FieldSource; } +inline int DiagFile::n_diag() const { return DiagName.n(); } +inline const StringArray & DiagFile::diag_name() const { return DiagName; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/gen_shape_info.h b/src/libcode/vx_tc_util/gen_shape_info.h index 58ea1d9a6a..f27af62aac 100644 --- a/src/libcode/vx_tc_util/gen_shape_info.h +++ b/src/libcode/vx_tc_util/gen_shape_info.h @@ -91,11 +91,11 @@ class GenShapeInfo { //////////////////////////////////////////////////////////////////////// -inline const ConcatString & GenShapeInfo::basin() const { return(Basin); } +inline const ConcatString & GenShapeInfo::basin() const { return Basin; } -inline unixtime GenShapeInfo::file_time() const { return(FileTime); } -inline unixtime GenShapeInfo::issue_time() const { return(IssueTime); } -inline int GenShapeInfo::issue_hour() const { return(unix_to_sec_of_day(IssueTime)); } +inline unixtime GenShapeInfo::file_time() const { return FileTime ; } +inline unixtime GenShapeInfo::issue_time() const { return IssueTime; } +inline int GenShapeInfo::issue_hour() const { return unix_to_sec_of_day(IssueTime); } //////////////////////////////////////////////////////////////////////// // @@ -140,7 +140,7 @@ class GenShapeInfoArray { //////////////////////////////////////////////////////////////////////// -inline int GenShapeInfoArray::n() const { return(GenShape.size()); } +inline int GenShapeInfoArray::n() const { return GenShape.size(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/genesis_info.h b/src/libcode/vx_tc_util/genesis_info.h index 11df94257e..5ab8da740c 100644 --- a/src/libcode/vx_tc_util/genesis_info.h +++ b/src/libcode/vx_tc_util/genesis_info.h @@ -112,11 +112,11 @@ class GenesisInfo : public TrackInfo { //////////////////////////////////////////////////////////////////////// -inline double GenesisInfo::lat() const { return(Lat); } -inline double GenesisInfo::lon() const { return(Lon); } -inline double GenesisInfo::dland() const { return(DLand); } -inline unixtime GenesisInfo::genesis_time() const { return(GenesisTime); } -inline int GenesisInfo::genesis_lead() const { return(GenesisLead); } +inline double GenesisInfo::lat() const { return Lat; } +inline double GenesisInfo::lon() const { return Lon; } +inline double GenesisInfo::dland() const { return DLand; } +inline unixtime GenesisInfo::genesis_time() const { return GenesisTime; } +inline int GenesisInfo::genesis_lead() const { return GenesisLead; } //////////////////////////////////////////////////////////////////////// // @@ -167,7 +167,7 @@ class GenesisInfoArray { //////////////////////////////////////////////////////////////////////// -inline int GenesisInfoArray::n() const { return(Genesis.size()); } +inline int GenesisInfoArray::n() const { return Genesis.size(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/pair_data_genesis.h b/src/libcode/vx_tc_util/pair_data_genesis.h index 89b0a5b2f6..25fbd653f5 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.h +++ b/src/libcode/vx_tc_util/pair_data_genesis.h @@ -142,13 +142,13 @@ inline void PairDataGenesis::set_desc (const ConcatString &s) { Desc = s; } inline void PairDataGenesis::set_mask (const ConcatString &s) { Mask = s; } inline void PairDataGenesis::set_model(const ConcatString &s) { Model = s; } -inline ConcatString PairDataGenesis::desc() const { return(Desc); } -inline ConcatString PairDataGenesis::mask() const { return(Mask); } -inline ConcatString PairDataGenesis::model() const { return(Model); } -inline int PairDataGenesis::n_pair() const { return(NPair); } -inline const std::string PairDataGenesis::best_storm_id(int i) const { return(BestStormId[i]); } -inline unixtime PairDataGenesis::init(int i) const { return(InitTime[i]); } -inline int PairDataGenesis::lead_time(int i) const { return(LeadTime[i]); } +inline ConcatString PairDataGenesis::desc() const { return Desc; } +inline ConcatString PairDataGenesis::mask() const { return Mask; } +inline ConcatString PairDataGenesis::model() const { return Model; } +inline int PairDataGenesis::n_pair() const { return NPair; } +inline const std::string PairDataGenesis::best_storm_id(int i) const { return BestStormId[i]; } +inline unixtime PairDataGenesis::init(int i) const { return InitTime[i]; } +inline int PairDataGenesis::lead_time(int i) const { return LeadTime[i]; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_gen_info.h b/src/libcode/vx_tc_util/prob_gen_info.h index 514fa9c337..5d5a03c5bc 100644 --- a/src/libcode/vx_tc_util/prob_gen_info.h +++ b/src/libcode/vx_tc_util/prob_gen_info.h @@ -86,10 +86,10 @@ class ProbGenInfo : public ProbInfoBase { //////////////////////////////////////////////////////////////////////// -inline const ConcatString & ProbGenInfo::initials() const { return(Initials); } -inline const ConcatString & ProbGenInfo::gen_or_dis() const { return(GenOrDis); } -inline unixtime ProbGenInfo::genesis_time() const { return(GenesisTime); } -inline int ProbGenInfo::genesis_lead() const { return(GenesisLead); } +inline const ConcatString & ProbGenInfo::initials() const { return Initials; } +inline const ConcatString & ProbGenInfo::gen_or_dis() const { return GenOrDis; } +inline unixtime ProbGenInfo::genesis_time() const { return GenesisTime; } +inline int ProbGenInfo::genesis_lead() const { return GenesisLead; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_info_array.cc b/src/libcode/vx_tc_util/prob_info_array.cc index 35a37708e2..0caaa7ed73 100644 --- a/src/libcode/vx_tc_util/prob_info_array.cc +++ b/src/libcode/vx_tc_util/prob_info_array.cc @@ -244,7 +244,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { // Store based on the input line type switch(l.type()) { - case(ATCFLineType::ProbRI): + case ATCFLineType::ProbRI: // Add line to an existing entry if(ProbRIRW.size() > 0 && @@ -260,7 +260,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { } break; - case(ATCFLineType::ProbGN): + case ATCFLineType::ProbGN: // Add line to an existing entry if(ProbGen.size() > 0 && diff --git a/src/libcode/vx_tc_util/prob_info_array.h b/src/libcode/vx_tc_util/prob_info_array.h index 53856a4a98..182fffd046 100644 --- a/src/libcode/vx_tc_util/prob_info_array.h +++ b/src/libcode/vx_tc_util/prob_info_array.h @@ -79,8 +79,8 @@ class ProbInfoArray { //////////////////////////////////////////////////////////////////////// inline int ProbInfoArray::n_probs() const { return(ProbRIRW.size() + ProbGen.size()); } -inline int ProbInfoArray::n_prob_rirw() const { return(ProbRIRW.size()); } -inline int ProbInfoArray::n_prob_gen() const { return(ProbGen.size()); } +inline int ProbInfoArray::n_prob_rirw() const { return ProbRIRW.size(); } +inline int ProbInfoArray::n_prob_gen() const { return ProbGen.size(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_info_base.h b/src/libcode/vx_tc_util/prob_info_base.h index 09473eb1ab..1bae207793 100644 --- a/src/libcode/vx_tc_util/prob_info_base.h +++ b/src/libcode/vx_tc_util/prob_info_base.h @@ -114,21 +114,21 @@ class ProbInfoBase { //////////////////////////////////////////////////////////////////////// -inline ATCFLineType ProbInfoBase::type() const { return(Type); } -inline const ConcatString & ProbInfoBase::storm_id() const { return(StormId); } -inline const ConcatString & ProbInfoBase::basin() const { return(Basin); } -inline const ConcatString & ProbInfoBase::cyclone() const { return(Cyclone); } -inline const ConcatString & ProbInfoBase::technique() const { return(Technique); } -inline unixtime ProbInfoBase::init() const { return(InitTime); } -inline int ProbInfoBase::init_hour() const { return(unix_to_sec_of_day(InitTime)); } -inline unixtime ProbInfoBase::valid() const { return(ValidTime); } -inline int ProbInfoBase::valid_hour() const { return(unix_to_sec_of_day(ValidTime)); } -inline double ProbInfoBase::lat() const { return(Lat); } -inline double ProbInfoBase::lon() const { return(Lon); } -inline double ProbInfoBase::dland() const { return(DLand); } -inline int ProbInfoBase::n_prob() const { return(NProb); } -inline double ProbInfoBase::prob(int i) const { return(Prob[i]); } -inline double ProbInfoBase::prob_item(int i) const { return(ProbItem[i]); } +inline ATCFLineType ProbInfoBase::type() const { return Type; } +inline const ConcatString & ProbInfoBase::storm_id() const { return StormId; } +inline const ConcatString & ProbInfoBase::basin() const { return Basin; } +inline const ConcatString & ProbInfoBase::cyclone() const { return Cyclone; } +inline const ConcatString & ProbInfoBase::technique() const { return Technique; } +inline unixtime ProbInfoBase::init() const { return InitTime; } +inline int ProbInfoBase::init_hour() const { return unix_to_sec_of_day(InitTime); } +inline unixtime ProbInfoBase::valid() const { return ValidTime; } +inline int ProbInfoBase::valid_hour() const { return unix_to_sec_of_day(ValidTime); } +inline double ProbInfoBase::lat() const { return Lat; } +inline double ProbInfoBase::lon() const { return Lon; } +inline double ProbInfoBase::dland() const { return DLand; } +inline int ProbInfoBase::n_prob() const { return NProb; } +inline double ProbInfoBase::prob(int i) const { return Prob[i]; } +inline double ProbInfoBase::prob_item(int i) const { return ProbItem[i]; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_rirw_info.cc b/src/libcode/vx_tc_util/prob_rirw_info.cc index ea662ef4c3..f12a2d66c5 100644 --- a/src/libcode/vx_tc_util/prob_rirw_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_info.cc @@ -143,8 +143,8 @@ void ProbRIRWInfo::assign(const ProbRIRWInfo &p) { //////////////////////////////////////////////////////////////////////// int ProbRIRWInfo::rirw_window() const { - return((is_bad_data(rirw_beg()) || is_bad_data(rirw_end()) ? - bad_data_int : rirw_end() - rirw_beg())); + return (is_bad_data(rirw_beg()) || is_bad_data(rirw_end()) ? + bad_data_int : rirw_end() - rirw_beg()); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_rirw_info.h b/src/libcode/vx_tc_util/prob_rirw_info.h index fd1ced2893..e2636ea284 100644 --- a/src/libcode/vx_tc_util/prob_rirw_info.h +++ b/src/libcode/vx_tc_util/prob_rirw_info.h @@ -78,10 +78,10 @@ class ProbRIRWInfo : public ProbInfoBase { //////////////////////////////////////////////////////////////////////// -inline double ProbRIRWInfo::value() const { return(Value); } -inline const ConcatString & ProbRIRWInfo::initials() const { return(Initials); } -inline int ProbRIRWInfo::rirw_beg() const { return(RIRWBeg); } -inline int ProbRIRWInfo::rirw_end() const { return(RIRWEnd); } +inline double ProbRIRWInfo::value() const { return Value; } +inline const ConcatString & ProbRIRWInfo::initials() const { return Initials; } +inline int ProbRIRWInfo::rirw_beg() const { return RIRWBeg; } +inline int ProbRIRWInfo::rirw_end() const { return RIRWEnd; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.h b/src/libcode/vx_tc_util/prob_rirw_pair_info.h index e809bc3198..f81dd22b37 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.h +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.h @@ -111,24 +111,24 @@ class ProbRIRWPairInfo { //////////////////////////////////////////////////////////////////////// -inline const ProbRIRWInfo & ProbRIRWPairInfo::prob_rirw() const { return(ProbRIRW); } -inline const TrackInfo * ProbRIRWPairInfo::bdeck() const { return(BDeck); } -inline const ConcatString & ProbRIRWPairInfo::storm_name() const { return(StormName); } -inline const ConcatString & ProbRIRWPairInfo::bmodel() const { return(BModel); } -inline double ProbRIRWPairInfo::blat() const { return(BLat); } -inline double ProbRIRWPairInfo::blon() const { return(BLon); } -inline double ProbRIRWPairInfo::adland() const { return(ADLand); } -inline double ProbRIRWPairInfo::bdland() const { return(BDLand); } -inline double ProbRIRWPairInfo::track_err() const { return(TrackErr); } -inline double ProbRIRWPairInfo::x_err() const { return(XErr); } -inline double ProbRIRWPairInfo::y_err() const { return(YErr); } -inline double ProbRIRWPairInfo::bbegv() const { return(BBegV); } -inline double ProbRIRWPairInfo::bendv() const { return(BEndV); } -inline double ProbRIRWPairInfo::bminv() const { return(BMinV); } -inline double ProbRIRWPairInfo::bmaxv() const { return(BMaxV); } -inline CycloneLevel ProbRIRWPairInfo::bbeglev() const { return(BBegLev); } -inline CycloneLevel ProbRIRWPairInfo::bendlev() const { return(BEndLev); } -inline const TCStatLine & ProbRIRWPairInfo::line() const { return(Line); } +inline const ProbRIRWInfo & ProbRIRWPairInfo::prob_rirw() const { return ProbRIRW; } +inline const TrackInfo * ProbRIRWPairInfo::bdeck() const { return BDeck; } +inline const ConcatString & ProbRIRWPairInfo::storm_name() const { return StormName; } +inline const ConcatString & ProbRIRWPairInfo::bmodel() const { return BModel; } +inline double ProbRIRWPairInfo::blat() const { return BLat; } +inline double ProbRIRWPairInfo::blon() const { return BLon; } +inline double ProbRIRWPairInfo::adland() const { return ADLand; } +inline double ProbRIRWPairInfo::bdland() const { return BDLand; } +inline double ProbRIRWPairInfo::track_err() const { return TrackErr; } +inline double ProbRIRWPairInfo::x_err() const { return XErr; } +inline double ProbRIRWPairInfo::y_err() const { return YErr; } +inline double ProbRIRWPairInfo::bbegv() const { return BBegV; } +inline double ProbRIRWPairInfo::bendv() const { return BEndV; } +inline double ProbRIRWPairInfo::bminv() const { return BMinV; } +inline double ProbRIRWPairInfo::bmaxv() const { return BMaxV; } +inline CycloneLevel ProbRIRWPairInfo::bbeglev() const { return BBegLev; } +inline CycloneLevel ProbRIRWPairInfo::bendlev() const { return BEndLev; } +inline const TCStatLine & ProbRIRWPairInfo::line() const { return Line; } inline void ProbRIRWPairInfo::set_adland(double d) { ADLand = d; return; } inline void ProbRIRWPairInfo::set_bdland(double d) { BDLand = d; return; } @@ -183,7 +183,7 @@ class ProbRIRWPairInfoArray { //////////////////////////////////////////////////////////////////////// -inline int ProbRIRWPairInfoArray::n_pairs() const { return(Pairs.size()); } +inline int ProbRIRWPairInfoArray::n_pairs() const { return Pairs.size(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/tc_hdr_columns.h b/src/libcode/vx_tc_util/tc_hdr_columns.h index 60ecf39260..a2e31a6533 100644 --- a/src/libcode/vx_tc_util/tc_hdr_columns.h +++ b/src/libcode/vx_tc_util/tc_hdr_columns.h @@ -108,21 +108,21 @@ inline void TcHdrColumns::set_init_mask (const ConcatString &s) { InitMask = s inline void TcHdrColumns::set_valid_mask (const ConcatString &s) { ValidMask = s; } inline void TcHdrColumns::set_line_type (const ConcatString &s) { LineType = s; } -inline ConcatString TcHdrColumns::adeck_model () const { return(ADeckModel); } -inline ConcatString TcHdrColumns::bdeck_model () const { return(BDeckModel); } -inline ConcatString TcHdrColumns::desc () const { return(Desc); } -inline ConcatString TcHdrColumns::storm_id () const { return(StormId); } -inline ConcatString TcHdrColumns::basin () const { return(Basin); } -inline ConcatString TcHdrColumns::cyclone () const { return(Cyclone); } -inline ConcatString TcHdrColumns::storm_name () const { return(StormName); } -inline int TcHdrColumns::lead () const { return(LeadTime); } -inline unixtime TcHdrColumns::init () const { return(InitTime); } -inline int TcHdrColumns::init_hour () const { return(unix_to_sec_of_day(InitTime)); } -inline unixtime TcHdrColumns::valid () const { return(ValidTime); } -inline int TcHdrColumns::valid_hour () const { return(unix_to_sec_of_day(ValidTime)); } -inline ConcatString TcHdrColumns::init_mask () const { return(InitMask); } -inline ConcatString TcHdrColumns::valid_mask () const { return(ValidMask); } -inline ConcatString TcHdrColumns::line_type () const { return(LineType); } +inline ConcatString TcHdrColumns::adeck_model () const { return ADeckModel; } +inline ConcatString TcHdrColumns::bdeck_model () const { return BDeckModel; } +inline ConcatString TcHdrColumns::desc () const { return Desc; } +inline ConcatString TcHdrColumns::storm_id () const { return StormId; } +inline ConcatString TcHdrColumns::basin () const { return Basin; } +inline ConcatString TcHdrColumns::cyclone () const { return Cyclone; } +inline ConcatString TcHdrColumns::storm_name () const { return StormName; } +inline int TcHdrColumns::lead () const { return LeadTime; } +inline unixtime TcHdrColumns::init () const { return InitTime; } +inline int TcHdrColumns::init_hour () const { return unix_to_sec_of_day(InitTime); } +inline unixtime TcHdrColumns::valid () const { return ValidTime; } +inline int TcHdrColumns::valid_hour () const { return unix_to_sec_of_day(ValidTime); } +inline ConcatString TcHdrColumns::init_mask () const { return InitMask; } +inline ConcatString TcHdrColumns::valid_mask () const { return ValidMask; } +inline ConcatString TcHdrColumns::line_type () const { return LineType; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_info.h b/src/libcode/vx_tc_util/track_info.h index 5b4bfd298a..fdc127e633 100644 --- a/src/libcode/vx_tc_util/track_info.h +++ b/src/libcode/vx_tc_util/track_info.h @@ -182,9 +182,9 @@ class TrackInfo { //////////////////////////////////////////////////////////////////////// -inline bool TrackInfo::is_best_track() const { return(IsBestTrack); } -inline bool TrackInfo::is_oper_track() const { return(IsOperTrack); } -inline bool TrackInfo::is_anly_track() const { return(IsAnlyTrack); } +inline bool TrackInfo::is_best_track() const { return IsBestTrack; } +inline bool TrackInfo::is_oper_track() const { return IsOperTrack; } +inline bool TrackInfo::is_anly_track() const { return IsAnlyTrack; } inline void TrackInfo::set_storm_id(const char *s) { StormId = s; } inline void TrackInfo::set_basin(const char *s) { Basin = s; } inline void TrackInfo::set_cyclone(const char *s) { Cyclone = s; } @@ -200,28 +200,28 @@ inline void TrackInfo::set_track_source(const char *s) { TrackSource = s; inline void TrackInfo::set_field_source(const char *s) { FieldSource = s; } inline void TrackInfo::set_diag_name(const StringArray &s) { DiagName = s; } -inline const ConcatString & TrackInfo::storm_id() const { return(StormId); } -inline const ConcatString & TrackInfo::basin() const { return(Basin); } -inline const ConcatString & TrackInfo::cyclone() const { return(Cyclone); } -inline const ConcatString & TrackInfo::storm_name() const { return(StormName); } -inline int TrackInfo::technique_number() const { return(TechniqueNumber); } -inline const ConcatString & TrackInfo::technique() const { return(Technique); } -inline const ConcatString & TrackInfo::initials() const { return(Initials); } -inline unixtime TrackInfo::init() const { return(InitTime); } -inline int TrackInfo::init_hour() const { return(unix_to_sec_of_day(InitTime)); } -inline unixtime TrackInfo::valid_min() const { return(MinValidTime); } -inline unixtime TrackInfo::valid_max() const { return(MaxValidTime); } -inline unixtime TrackInfo::warm_core_min() const { return(MinWarmCore); } -inline unixtime TrackInfo::warm_core_max() const { return(MaxWarmCore); } -inline int TrackInfo::n_points() const { return(NPoints); } - -inline DiagType TrackInfo::diag_source() const { return(DiagSource); } -inline const ConcatString & TrackInfo::track_source() const { return(TrackSource); } -inline const ConcatString & TrackInfo::field_source() const { return(FieldSource); } -inline int TrackInfo::n_diag() const { return(DiagName.n()); } -inline const StringArray & TrackInfo::diag_name() const { return(DiagName); } - -inline StringArray TrackInfo::track_lines() const { return(TrackLines); } +inline const ConcatString & TrackInfo::storm_id() const { return StormId; } +inline const ConcatString & TrackInfo::basin() const { return Basin; } +inline const ConcatString & TrackInfo::cyclone() const { return Cyclone; } +inline const ConcatString & TrackInfo::storm_name() const { return StormName; } +inline int TrackInfo::technique_number() const { return TechniqueNumber; } +inline const ConcatString & TrackInfo::technique() const { return Technique; } +inline const ConcatString & TrackInfo::initials() const { return Initials; } +inline unixtime TrackInfo::init() const { return InitTime; } +inline int TrackInfo::init_hour() const { return unix_to_sec_of_day(InitTime); } +inline unixtime TrackInfo::valid_min() const { return MinValidTime; } +inline unixtime TrackInfo::valid_max() const { return MaxValidTime; } +inline unixtime TrackInfo::warm_core_min() const { return MinWarmCore; } +inline unixtime TrackInfo::warm_core_max() const { return MaxWarmCore; } +inline int TrackInfo::n_points() const { return NPoints; } + +inline DiagType TrackInfo::diag_source() const { return DiagSource; } +inline const ConcatString & TrackInfo::track_source() const { return TrackSource; } +inline const ConcatString & TrackInfo::field_source() const { return FieldSource; } +inline int TrackInfo::n_diag() const { return DiagName.n(); } +inline const StringArray & TrackInfo::diag_name() const { return DiagName; } + +inline StringArray TrackInfo::track_lines() const { return TrackLines; } //////////////////////////////////////////////////////////////////////// // @@ -279,7 +279,7 @@ class TrackInfoArray { //////////////////////////////////////////////////////////////////////// -inline int TrackInfoArray::n() const { return(Track.size()); } +inline int TrackInfoArray::n() const { return Track.size(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_pair_info.h b/src/libcode/vx_tc_util/track_pair_info.h index 3b3a884992..4797a8996e 100644 --- a/src/libcode/vx_tc_util/track_pair_info.h +++ b/src/libcode/vx_tc_util/track_pair_info.h @@ -151,24 +151,24 @@ class TrackPairInfo { //////////////////////////////////////////////////////////////////////// -inline int TrackPairInfo::n_points() const { return(NPoints); } -inline const TrackInfo & TrackPairInfo::adeck() const { return(ADeck); } -inline const TrackInfo & TrackPairInfo::bdeck() const { return(BDeck); } -inline double TrackPairInfo::adeck_dland(int i) const { return(ADeckDLand[i]); } -inline double TrackPairInfo::bdeck_dland(int i) const { return(BDeckDLand[i]); } -inline double TrackPairInfo::track_err(int i) const { return(TrackErr[i]); } -inline double TrackPairInfo::x_err(int i) const { return(XErr[i]); } -inline double TrackPairInfo::y_err(int i) const { return(YErr[i]); } -inline double TrackPairInfo::along_track_err(int i) const { return(AlongTrackErr[i]); } -inline double TrackPairInfo::cross_track_err(int i) const { return(CrossTrackErr[i]); } -inline int TrackPairInfo::adeck_rirw(int i) const { return(nint(ADeckRIRW[i])); } -inline int TrackPairInfo::bdeck_rirw(int i) const { return(nint(BDeckRIRW[i])); } -inline int TrackPairInfo::adeck_prv_int(int i) const { return(nint(ADeckPrvInt[i])); } -inline int TrackPairInfo::bdeck_prv_int(int i) const { return(nint(BDeckPrvInt[i])); } -inline int TrackPairInfo::n_lines() const { return(NLines); } -inline const TCStatLine * TrackPairInfo::tcmpr_line(int i) const { return(&TCMPRLine[i]); } -inline const TCStatLine * TrackPairInfo::tcdiag_line(int i) const { return(&TCDIAGLine[i]); } -inline bool TrackPairInfo::keep(int i) const { return(Keep[i] != 0); } +inline int TrackPairInfo::n_points() const { return NPoints; } +inline const TrackInfo & TrackPairInfo::adeck() const { return ADeck; } +inline const TrackInfo & TrackPairInfo::bdeck() const { return BDeck; } +inline double TrackPairInfo::adeck_dland(int i) const { return ADeckDLand[i]; } +inline double TrackPairInfo::bdeck_dland(int i) const { return BDeckDLand[i]; } +inline double TrackPairInfo::track_err(int i) const { return TrackErr[i]; } +inline double TrackPairInfo::x_err(int i) const { return XErr[i]; } +inline double TrackPairInfo::y_err(int i) const { return YErr[i]; } +inline double TrackPairInfo::along_track_err(int i) const { return AlongTrackErr[i]; } +inline double TrackPairInfo::cross_track_err(int i) const { return CrossTrackErr[i]; } +inline int TrackPairInfo::adeck_rirw(int i) const { return nint(ADeckRIRW[i]); } +inline int TrackPairInfo::bdeck_rirw(int i) const { return nint(BDeckRIRW[i]); } +inline int TrackPairInfo::adeck_prv_int(int i) const { return nint(ADeckPrvInt[i]); } +inline int TrackPairInfo::bdeck_prv_int(int i) const { return nint(BDeckPrvInt[i]); } +inline int TrackPairInfo::n_lines() const { return NLines; } +inline const TCStatLine * TrackPairInfo::tcmpr_line(int i) const { return &TCMPRLine[i]; } +inline const TCStatLine * TrackPairInfo::tcdiag_line(int i) const { return &TCDIAGLine[i]; } +inline bool TrackPairInfo::keep(int i) const { return (Keep[i] != 0); } //////////////////////////////////////////////////////////////////////// // diff --git a/src/libcode/vx_tc_util/track_point.h b/src/libcode/vx_tc_util/track_point.h index cffb79c488..0aede58974 100644 --- a/src/libcode/vx_tc_util/track_point.h +++ b/src/libcode/vx_tc_util/track_point.h @@ -103,12 +103,12 @@ inline void QuadInfo::set_se_val(double v) { SEVal = v; } inline void QuadInfo::set_sw_val(double v) { SWVal = v; } inline void QuadInfo::set_nw_val(double v) { NWVal = v; } -inline int QuadInfo::intensity() const { return(Intensity); } -inline double QuadInfo::al_val() const { return(ALVal); } -inline double QuadInfo::ne_val() const { return(NEVal); } -inline double QuadInfo::se_val() const { return(SEVal); } -inline double QuadInfo::sw_val() const { return(SWVal); } -inline double QuadInfo::nw_val() const { return(NWVal); } +inline int QuadInfo::intensity() const { return Intensity; } +inline double QuadInfo::al_val() const { return ALVal; } +inline double QuadInfo::ne_val() const { return NEVal; } +inline double QuadInfo::se_val() const { return SEVal; } +inline double QuadInfo::sw_val() const { return SWVal; } +inline double QuadInfo::nw_val() const { return NWVal; } //////////////////////////////////////////////////////////////////////// // @@ -296,31 +296,31 @@ inline void TrackPoint::set_track_stdev(const double v) { TrackStdev = v; } inline void TrackPoint::set_v_max_stdev(const double v) { VmaxStdev = v; } inline void TrackPoint::set_mslp_stdev(const double v) { MSLPStdev = v; } -inline unixtime TrackPoint::valid() const { return(ValidTime); } -inline int TrackPoint::valid_hour() const { return(unix_to_sec_of_day(ValidTime)); } -inline int TrackPoint::lead() const { return(LeadTime); } -inline double TrackPoint::lat() const { return(Lat); } -inline double TrackPoint::lon() const { return(Lon); } -inline double TrackPoint::v_max() const { return(Vmax); } -inline double TrackPoint::mslp() const { return(MSLP); } -inline CycloneLevel TrackPoint::level() const { return(Level); } -inline double TrackPoint::radp() const { return(RadP); } -inline double TrackPoint::rrp() const { return(RRP); } -inline double TrackPoint::mrd() const { return(MRD); } -inline double TrackPoint::gusts() const { return(Gusts); } -inline double TrackPoint::eye() const { return(Eye); } -inline double TrackPoint::direction() const { return(Direction); } -inline double TrackPoint::speed() const { return(Speed); } -inline SystemsDepth TrackPoint::depth() const { return(Depth); } -inline bool TrackPoint::warm_core() const { return(WarmCore); } -inline WatchWarnType TrackPoint::watch_warn() const { return(WatchWarn); } - -inline int TrackPoint::num_members() const { return(NumMembers); } -inline double TrackPoint::track_spread() const { return(TrackSpread); } -inline double TrackPoint::track_stdev() const { return(TrackStdev); } -inline double TrackPoint::v_max_stdev() const { return(VmaxStdev); } -inline double TrackPoint::mslp_stdev() const { return(MSLPStdev); } -inline int TrackPoint::n_diag() const { return(DiagVal.n()); } +inline unixtime TrackPoint::valid() const { return ValidTime; } +inline int TrackPoint::valid_hour() const { return unix_to_sec_of_day(ValidTime); } +inline int TrackPoint::lead() const { return LeadTime; } +inline double TrackPoint::lat() const { return Lat; } +inline double TrackPoint::lon() const { return Lon; } +inline double TrackPoint::v_max() const { return Vmax; } +inline double TrackPoint::mslp() const { return MSLP; } +inline CycloneLevel TrackPoint::level() const { return Level; } +inline double TrackPoint::radp() const { return RadP; } +inline double TrackPoint::rrp() const { return RRP; } +inline double TrackPoint::mrd() const { return MRD; } +inline double TrackPoint::gusts() const { return Gusts; } +inline double TrackPoint::eye() const { return Eye; } +inline double TrackPoint::direction() const { return Direction; } +inline double TrackPoint::speed() const { return Speed; } +inline SystemsDepth TrackPoint::depth() const { return Depth; } +inline bool TrackPoint::warm_core() const { return WarmCore; } +inline WatchWarnType TrackPoint::watch_warn() const { return WatchWarn; } + +inline int TrackPoint::num_members() const { return NumMembers; } +inline double TrackPoint::track_spread() const { return TrackSpread; } +inline double TrackPoint::track_stdev() const { return TrackStdev; } +inline double TrackPoint::v_max_stdev() const { return VmaxStdev; } +inline double TrackPoint::mslp_stdev() const { return MSLPStdev; } +inline int TrackPoint::n_diag() const { return DiagVal.n(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_time_series/time_series_util.cc b/src/libcode/vx_time_series/time_series_util.cc index d3e40c1201..e92d493f3f 100644 --- a/src/libcode/vx_time_series/time_series_util.cc +++ b/src/libcode/vx_time_series/time_series_util.cc @@ -40,9 +40,9 @@ const char * timeseriestype_to_string(const TimeSeriesType t) { const char *s = (const char *) nullptr; switch(t) { - case(TimeSeriesType::DyDt): s = timeseriestype_dydt_str; break; - case(TimeSeriesType::Swing): s = timeseriestype_swing_str; break; - default: s = na_str; break; + case TimeSeriesType::DyDt: s = timeseriestype_dydt_str; break; + case TimeSeriesType::Swing: s = timeseriestype_swing_str; break; + default: s = na_str; break; } return s; diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index b0fadc0c3a..cab5405f19 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -986,11 +986,11 @@ void process_point_obs(int i_nc) { int hdr_count = met_point_obs->get_hdr_cnt(); int obs_count = met_point_obs->get_obs_cnt(); - mlog << Debug(2) << "Searching " << (obs_count) - << " observations from " << (hdr_count) + mlog << Debug(2) << "Searching " << obs_count + << " observations from " << hdr_count << " header messages.\n"; - const int buf_size = ((obs_count > DEF_NC_BUFFER_SIZE) ? DEF_NC_BUFFER_SIZE : (obs_count)); + const int buf_size = ((obs_count > DEF_NC_BUFFER_SIZE) ? DEF_NC_BUFFER_SIZE : obs_count); int obs_qty_idx_block[buf_size]; float obs_arr_block[buf_size][OBS_ARRAY_LEN]; @@ -1666,7 +1666,7 @@ void process_grid_scores(int i_vx, pd.add_obs_error_entry(e); // Add the ensemble mean value for this point - pd.mn_na.add((emn_flag ? emn_dp(x, y) : bad_data_double)); + pd.mn_na.add(emn_flag ? emn_dp(x, y) : bad_data_double); } // end for y } // end for x @@ -1901,39 +1901,39 @@ void setup_txt_files() { // Get the maximum number of columns for this line type switch(i) { - case(i_rhist): + case i_rhist: max_col = get_n_rhist_columns(max_n_ens+1) + n_header_columns + 1; break; - case(i_phist): + case i_phist: max_col = get_n_phist_columns(n_phist_bin) + n_header_columns + 1; break; - case(i_relp): + case i_relp: max_col = get_n_relp_columns(max_n_ens) + n_header_columns + 1; break; - case(i_orank): + case i_orank: max_col = get_n_orank_columns(max_n_ens) + n_header_columns + 1; break; - case(i_pct): + case i_pct: max_col = get_n_pct_columns(n_prob) + n_header_columns + 1; break; - case(i_pstd): + case i_pstd: max_col = get_n_pstd_columns(n_prob) + n_header_columns + 1; break; - case(i_pjc): + case i_pjc: max_col = get_n_pjc_columns(n_prob) + n_header_columns + 1; break; - case(i_prc): + case i_prc: max_col = get_n_prc_columns(n_prob) + n_header_columns + 1; break; - case(i_eclv): + case i_eclv: max_col = get_n_eclv_columns(n_eclv) + n_header_columns + 1; break; @@ -1949,39 +1949,39 @@ void setup_txt_files() { // Write the text header row switch(i) { - case(i_rhist): + case i_rhist: write_rhist_header_row(1, max_n_ens+1, txt_at[i], 0, 0); break; - case(i_phist): + case i_phist: write_phist_header_row(1, n_phist_bin, txt_at[i], 0, 0); break; - case(i_relp): + case i_relp: write_relp_header_row(1, max_n_ens, txt_at[i], 0, 0); break; - case(i_orank): + case i_orank: write_orank_header_row(1, max_n_ens, txt_at[i], 0, 0); break; - case(i_pct): + case i_pct: write_pct_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pstd): + case i_pstd: write_pstd_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pjc): + case i_pjc: write_pjc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_prc): + case i_prc: write_prc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_eclv): + case i_eclv: write_eclv_header_row(1, n_eclv, txt_at[i], 0, 0); break; diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index e9c7b81182..6f31073d20 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -1051,8 +1051,8 @@ int EnsembleStatVxOpt::n_txt_row(int i_txt_row) const { // Switch on the index of the line type switch(i_txt_row) { - case(i_ecnt): - case(i_rps): + case i_ecnt: + case i_rps: // Maximum number of ECNT and RPS lines possible = // Point Vx: Message Types * Masks * Interpolations * Obs Thresholds * Alphas @@ -1061,9 +1061,9 @@ int EnsembleStatVxOpt::n_txt_row(int i_txt_row) const { get_n_obs_thresh() * get_n_ci_alpha(); break; - case(i_rhist): - case(i_phist): - case(i_relp): + case i_rhist: + case i_phist: + case i_relp: // Maximum number of RHIST, PHIST, and RELP lines possible = // Point Vx: Message Types * Masks * Interpolations * Obs Thresholds @@ -1072,7 +1072,7 @@ int EnsembleStatVxOpt::n_txt_row(int i_txt_row) const { get_n_obs_thresh(); break; - case(i_orank): + case i_orank: // Compute the maximum number of matched pairs to be written // out by summing the number for each VxPairDataEnsemble object @@ -1082,16 +1082,16 @@ int EnsembleStatVxOpt::n_txt_row(int i_txt_row) const { n = vx_pd.get_n_pair() * get_n_obs_thresh(); break; - case(i_ssvar): + case i_ssvar: // Just return zero since we'll resize the output AsciiTables // to accomodate the SSVAR output n = 0; break; - case(i_pct): - case(i_pjc): - case(i_prc): + case i_pct: + case i_pjc: + case i_prc: // Maximum number of PCT, PJC, and PRC lines possible = // Point Vx: Message Types * Masks * Interpolations * Categorical Thresholds * Climo CDF Bins @@ -1100,7 +1100,7 @@ int EnsembleStatVxOpt::n_txt_row(int i_txt_row) const { max(fcat_ta.n(), 1) * cdf_info.cdf_ta.n(); break; - case(i_pstd): + case i_pstd: // Maximum number of PSTD lines possible = // Point Vx: Message Types * Masks * Interpolations * Categorical Thresholds * Climo CDF Bins * Alphas @@ -1109,7 +1109,7 @@ int EnsembleStatVxOpt::n_txt_row(int i_txt_row) const { max(fcat_ta.n(), 1) * cdf_info.cdf_ta.n() * get_n_ci_alpha(); break; - case(i_eclv): + case i_eclv: // Maximum number of ECLV lines possible = // Point Vx: Message Types * Masks * Interpolations * Probability Thresholds * Climo CDF Bins diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index ccb03a7df1..56be2071cf 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -492,27 +492,27 @@ void setup_txt_files(unixtime valid_ut, int lead_sec) { // Get the maximum number of columns for this line type switch(i) { - case(i_mctc): + case i_mctc: max_col = get_n_mctc_columns(n_cat) + n_header_columns + 1; break; - case(i_pct): + case i_pct: max_col = get_n_pct_columns(n_prob) + n_header_columns + 1; break; - case(i_pstd): + case i_pstd: max_col = get_n_pstd_columns(n_prob) + n_header_columns + 1; break; - case(i_pjc): + case i_pjc: max_col = get_n_pjc_columns(n_prob) + n_header_columns + 1; break; - case(i_prc): + case i_prc: max_col = get_n_prc_columns(n_prob) + n_header_columns + 1; break; - case(i_eclv): + case i_eclv: max_col = get_n_eclv_columns(n_eclv) + n_header_columns + 1; break; @@ -528,27 +528,27 @@ void setup_txt_files(unixtime valid_ut, int lead_sec) { // Write the text header row switch(i) { - case(i_mctc): + case i_mctc: write_mctc_header_row(1, n_cat, txt_at[i], 0, 0); break; - case(i_pct): + case i_pct: write_pct_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pstd): + case i_pstd: write_pstd_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pjc): + case i_pjc: write_pjc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_prc): + case i_prc: write_prc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_eclv): + case i_eclv: write_eclv_header_row(1, n_eclv, txt_at[i], 0, 0); break; 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 b9e8b8587a..a2d64873b3 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -1080,15 +1080,15 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { // Switch on the index of the line type switch(i_txt_row) { - case(i_fho): - case(i_ctc): + case i_fho: + case i_ctc: // Number of FHO or CTC lines = // Masks * Smoothing Methods * Thresholds n = (prob_flag ? 0 : get_n_mask() * get_n_interp() * get_n_cat_thresh()); break; - case(i_cts): + case i_cts: // Number of CTS lines = // Masks * Smoothing Methods * Thresholds * Alphas n = (prob_flag ? 0: @@ -1096,21 +1096,21 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_ci_alpha()); break; - case(i_mctc): + case i_mctc: // Number of MCTC lines = // Masks * Smoothing Methods n = (prob_flag ? 0 : get_n_mask() * get_n_interp()); break; - case(i_mcts): + case i_mcts: // Number of MCTS lines = // Masks * Smoothing Methods * Alphas n = (prob_flag ? 0: get_n_mask() * get_n_interp() * get_n_ci_alpha()); break; - case(i_cnt): + case i_cnt: // Number of CNT lines = // Masks * (Smoothing Methods + Fourier Waves) * // Thresholds * Climo Bins * Alphas @@ -1119,8 +1119,8 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_cnt_thresh() * n_bin * get_n_ci_alpha()); break; - case(i_sl1l2): - case(i_sal1l2): + case i_sl1l2: + case i_sal1l2: // Number of SL1L2 or SAL1L2 lines = // Masks * (Smoothing Methods + Fourier Waves) * // Thresholds * Climo Bins @@ -1129,8 +1129,8 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_cnt_thresh() * n_bin); break; - case(i_vl1l2): - case(i_val1l2): + case i_vl1l2: + case i_val1l2: // Number of VL1L2 or VAL1L2 lines = // Masks * (Smoothing Methods + Fourier Waves) * Thresholds n = (!vect_flag ? 0 : @@ -1138,7 +1138,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_wind_thresh()); break; - case(i_vcnt): + case i_vcnt: // Number of VCNT lines = // Masks * (Smoothing Methods + Fourier Waves) * Thresholds * // Alphas @@ -1147,7 +1147,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_wind_thresh() * get_n_ci_alpha()); break; - case(i_nbrctc): + case i_nbrctc: // Number of NBRCTC lines = // Masks * Thresholds * Neighborhoods * Frac Thresholds n = (prob_flag ? 0 : @@ -1155,7 +1155,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_cov_thresh()); break; - case(i_nbrcts): + case i_nbrcts: // Number of NBRCTS lines = // Masks * Thresholds * Neighborhoods * Frac Thresholds * // Alphas @@ -1164,7 +1164,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_cov_thresh() * get_n_ci_alpha()); break; - case(i_nbrcnt): + case i_nbrcnt: // Number of NBRCNT lines = // Masks * Thresholds * Neighborhoods * Alphas n = (prob_flag ? 0 : @@ -1172,9 +1172,9 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_ci_alpha()); break; - case(i_pct): - case(i_pjc): - case(i_prc): + case i_pct: + case i_pjc: + case i_prc: // Number of PCT, PJC, or PRC lines = // Masks * Smoothing Methods * Thresholds * Climo Bins n = (!prob_flag ? 0 : @@ -1182,7 +1182,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { n_bin); break; - case(i_pstd): + case i_pstd: // Number of PSTD lines = // Masks * Smoothing Methods * Thresholds * Alphas * // Climo Bins @@ -1191,7 +1191,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_ci_alpha() * n_bin); break; - case(i_eclv): + case i_eclv: // Number of CTC -> ECLV lines = // Masks * Smoothing Methods * Thresholds n = (prob_flag ? 0 : @@ -1206,21 +1206,21 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { get_n_fprob_thresh() * n_bin); break; - case(i_grad): + case i_grad: // Number of GRAD lines = // Masks * Smoothing Methods * Gradient Sizes n = (prob_flag ? 0 : get_n_mask() * get_n_interp() * get_n_grad()); break; - case(i_dmap): + case i_dmap: // Number of DMAP lines = // Masks * Smoothing Methods * Thresholds n = (prob_flag ? 0 : get_n_mask() * get_n_interp() * get_n_cat_thresh()); break; - case(i_seeps): + case i_seeps: n = (prob_flag ? 0 : get_n_mask() * get_n_interp()); break; 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 b8b792337f..c3e72ee3a4 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.h +++ b/src/tools/core/grid_stat/grid_stat_conf_info.h @@ -234,15 +234,15 @@ class GridStatVxOpt { //////////////////////////////////////////////////////////////////////// -inline int GridStatVxOpt::get_n_mask() const { return(mask_name.n_elements()); } -inline int GridStatVxOpt::get_n_interp() const { return(interp_info.n_interp); } -inline int GridStatVxOpt::get_n_eclv_points() const { return(eclv_points.n_elements()); } -inline int GridStatVxOpt::get_n_cdf_bin() const { return(cdf_info.n_bin); } -inline int GridStatVxOpt::get_n_nbrhd_wdth() const { return(nbrhd_info.width.n_elements()); } -inline int GridStatVxOpt::get_n_cov_thresh() const { return(nbrhd_info.cov_ta.n_elements()); } -inline int GridStatVxOpt::get_n_wave_1d() const { return(wave_1d_beg.n_elements()); } -inline int GridStatVxOpt::get_n_grad() const { return(grad_dx.n_elements()); } -inline int GridStatVxOpt::get_n_ci_alpha() const { return(ci_alpha.n_elements()); } +inline int GridStatVxOpt::get_n_mask() const { return mask_name.n_elements(); } +inline int GridStatVxOpt::get_n_interp() const { return interp_info.n_interp; } +inline int GridStatVxOpt::get_n_eclv_points() const { return eclv_points.n_elements(); } +inline int GridStatVxOpt::get_n_cdf_bin() const { return cdf_info.n_bin; } +inline int GridStatVxOpt::get_n_nbrhd_wdth() const { return nbrhd_info.width.n_elements(); } +inline int GridStatVxOpt::get_n_cov_thresh() const { return nbrhd_info.cov_ta.n_elements(); } +inline int GridStatVxOpt::get_n_wave_1d() const { return wave_1d_beg.n_elements(); } +inline int GridStatVxOpt::get_n_grad() const { return grad_dx.n_elements(); } +inline int GridStatVxOpt::get_n_ci_alpha() const { return ci_alpha.n_elements(); } //////////////////////////////////////////////////////////////////////// @@ -333,10 +333,10 @@ class GridStatConfInfo { //////////////////////////////////////////////////////////////////////// -inline int GridStatConfInfo::get_n_vx() const { return(n_vx); } -inline int GridStatConfInfo::get_compression_level() { return(conf.nc_compression()); } -inline bool GridStatConfInfo::get_output_ascii_flag() const { return(output_ascii_flag); } -inline bool GridStatConfInfo::get_output_nc_flag() const { return(output_nc_flag); } +inline int GridStatConfInfo::get_n_vx() const { return n_vx; } +inline int GridStatConfInfo::get_compression_level() { return conf.nc_compression(); } +inline bool GridStatConfInfo::get_output_ascii_flag() const { return output_ascii_flag; } +inline bool GridStatConfInfo::get_output_nc_flag() const { return output_nc_flag; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index bbfb8774d5..edb59d8814 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -367,7 +367,7 @@ void setup_first_pass(const DataPlane &dp, const Grid &data_grid) { // Determine the verification grid grid = parse_vx_grid(conf_info.vx_opt[0].vx_pd.fcst_info->regrid(), - &(data_grid), &(data_grid)); + &data_grid, &data_grid); // Process the masks conf_info.process_masks(grid); @@ -464,31 +464,31 @@ void setup_txt_files() { // Get the maximum number of columns for this line type switch(i) { - case(i_mctc): + case i_mctc: max_col = get_n_mctc_columns(n_cat) + n_header_columns + 1; break; - case(i_pct): + case i_pct: max_col = get_n_pct_columns(n_prob) + n_header_columns + 1; break; - case(i_pstd): + case i_pstd: max_col = get_n_pstd_columns(n_prob) + n_header_columns + 1; break; - case(i_pjc): + case i_pjc: max_col = get_n_pjc_columns(n_prob) + n_header_columns + 1; break; - case(i_prc): + case i_prc: max_col = get_n_prc_columns(n_prob) + n_header_columns + 1; break; - case(i_eclv): + case i_eclv: max_col = get_n_eclv_columns(n_eclv) + n_header_columns + 1; break; - case(i_orank): + case i_orank: max_col = get_n_orank_columns(n_ens) + n_header_columns + 1; break; @@ -504,31 +504,31 @@ void setup_txt_files() { // Write the text header row switch(i) { - case(i_mctc): + case i_mctc: write_mctc_header_row(1, n_cat, txt_at[i], 0, 0); break; - case(i_pct): + case i_pct: write_pct_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pstd): + case i_pstd: write_pstd_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pjc): + case i_pjc: write_pjc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_prc): + case i_prc: write_prc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_eclv): + case i_eclv: write_eclv_header_row(1, n_eclv, txt_at[i], 0, 0); break; - case(i_orank): + case i_orank: write_orank_header_row(1, n_ens, txt_at[i], 0, 0); break; @@ -810,7 +810,7 @@ void process_obs_file(int i_nc) { StringArray obs_qty_array = met_point_obs->get_qty_data(); if(use_var_id) var_names = met_point_obs->get_var_names(); - const int buf_size = ((obs_count > BUFFER_SIZE) ? BUFFER_SIZE : (obs_count)); + const int buf_size = (obs_count > BUFFER_SIZE) ? BUFFER_SIZE : obs_count; int obs_qty_idx_block[buf_size]; float obs_arr_block[buf_size][OBS_ARRAY_LEN]; diff --git a/src/tools/core/point_stat/point_stat_conf_info.cc b/src/tools/core/point_stat/point_stat_conf_info.cc index 240fe62aa5..1f28857cdc 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.cc +++ b/src/tools/core/point_stat/point_stat_conf_info.cc @@ -1238,14 +1238,14 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { // Switch on the index of the line type switch(i_txt_row) { - case(i_fho): - case(i_ctc): + case i_fho: + case i_ctc: // Number of FHO or CTC lines = // Message Types * Masks * Interpolations * Thresholds n = (prob_flag ? 0 : n_pd * get_n_cat_thresh()); break; - case(i_cts): + case i_cts: // Number of CTS lines = // Message Types * Masks * Interpolations * Thresholds * // Alphas @@ -1253,19 +1253,19 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { get_n_ci_alpha()); break; - case(i_mctc): + case i_mctc: // Number of MCTC lines = // Message Types * Masks * Interpolations n = (prob_flag ? 0 : n_pd); break; - case(i_mcts): + case i_mcts: // Number of MCTS lines = // Message Types * Masks * Interpolations * Alphas n = (prob_flag ? 0 : n_pd * get_n_ci_alpha()); break; - case(i_cnt): + case i_cnt: // Number of CNT lines = // Message Types * Masks * Interpolations * Thresholds * // Climo Bins * Alphas @@ -1273,23 +1273,23 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { get_n_ci_alpha()); break; - case(i_sl1l2): - case(i_sal1l2): + case i_sl1l2: + case i_sal1l2: // Number of SL1L2 and SAL1L2 lines = // Message Types * Masks * Interpolations * Thresholds * // Climo Bins n = (prob_flag ? 0 : n_pd * get_n_cnt_thresh() * n_bin); break; - case(i_vl1l2): - case(i_val1l2): + case i_vl1l2: + case i_val1l2: // Number of VL1L2 or VAL1L2 lines = // Message Types * Masks * Interpolations * Thresholds n = (!vect_flag ? 0 : n_pd * get_n_wind_thresh()); break; - case(i_vcnt): + case i_vcnt: // Number of VCNT lines = // Message Types * Masks * Interpolations * Thresholds * // Alphas @@ -1297,9 +1297,9 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { get_n_wind_thresh() * get_n_ci_alpha()); break; - case(i_pct): - case(i_pjc): - case(i_prc): + case i_pct: + case i_pjc: + case i_prc: // Number of PCT, PJC, or PRC lines possible = // Message Types * Masks * Interpolations * Thresholds * // Climo Bins @@ -1314,7 +1314,7 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { break; - case(i_pstd): + case i_pstd: // Number of PSTD lines = // Message Types * Masks * Interpolations * Thresholds * // Alphas * Climo Bins @@ -1332,8 +1332,8 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { break; - case(i_ecnt): - case(i_rps): + case i_ecnt: + case i_rps: // Number of HiRA ECNT and RPS lines = // Message Types * Masks * HiRA widths * // Alphas @@ -1346,7 +1346,7 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { break; - case(i_orank): + case i_orank: // Number of HiRA ORANK lines possible = // Number of pairs * Categorical Thresholds * // HiRA widths @@ -1360,7 +1360,7 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { break; - case(i_eclv): + case i_eclv: // Number of CTC -> ECLV lines = // Message Types * Masks * Interpolations * Thresholds * // Climo Bins @@ -1375,7 +1375,7 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { break; - case(i_mpr): + case i_mpr: // Compute the number of matched pairs to be written n = vx_pd.get_n_pair(); @@ -1390,13 +1390,13 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { break; - case(i_seeps_mpr): + case i_seeps_mpr: // Compute the number of matched pairs to be written n = vx_pd.get_n_pair(); break; - case(i_seeps): + case i_seeps: // Compute the number of matched pairs to be written n = vx_pd.get_n_pair(); diff --git a/src/tools/core/point_stat/point_stat_conf_info.h b/src/tools/core/point_stat/point_stat_conf_info.h index fb838bae0a..95bf59a7a7 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.h +++ b/src/tools/core/point_stat/point_stat_conf_info.h @@ -192,13 +192,13 @@ class PointStatVxOpt { //////////////////////////////////////////////////////////////////////// -inline int PointStatVxOpt::get_n_msg_typ() const { return(msg_typ.n()); } -inline int PointStatVxOpt::get_n_mask() const { return(mask_name.n()); } -inline int PointStatVxOpt::get_n_interp() const { return(interp_info.n_interp); } +inline int PointStatVxOpt::get_n_msg_typ() const { return msg_typ.n(); } +inline int PointStatVxOpt::get_n_mask() const { return mask_name.n(); } +inline int PointStatVxOpt::get_n_interp() const { return interp_info.n_interp; } -inline int PointStatVxOpt::get_n_eclv_points() const { return(eclv_points.n()); } -inline int PointStatVxOpt::get_n_cdf_bin() const { return(cdf_info.n_bin); } -inline int PointStatVxOpt::get_n_ci_alpha() const { return(ci_alpha.n()); } +inline int PointStatVxOpt::get_n_eclv_points() const { return eclv_points.n(); } +inline int PointStatVxOpt::get_n_cdf_bin() const { return cdf_info.n_bin; } +inline int PointStatVxOpt::get_n_ci_alpha() const { return ci_alpha.n(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.h b/src/tools/core/series_analysis/series_analysis_conf_info.h index 76f7041472..01aff16098 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.h +++ b/src/tools/core/series_analysis/series_analysis_conf_info.h @@ -100,8 +100,8 @@ class SeriesAnalysisConfInfo { //////////////////////////////////////////////////////////////////////// -inline int SeriesAnalysisConfInfo::get_n_fcst() const { return(n_fcst); } -inline int SeriesAnalysisConfInfo::get_n_obs() const { return(n_obs); } +inline int SeriesAnalysisConfInfo::get_n_fcst() const { return n_fcst; } +inline int SeriesAnalysisConfInfo::get_n_obs() const { return n_obs; } inline int SeriesAnalysisConfInfo::get_compression_level() { return conf.nc_compression(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index c40fb0eb64..eb7caeedf6 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -630,7 +630,7 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, << "trouble parsing \"-column " << job.column[i] << "\" option. Either use \"-line_type\" exactly once " << "or use format \"-column LINE_TYPE:COLUMN\".\n\n"; - throw(1); + throw 1; } } @@ -854,7 +854,7 @@ void aggr_ctc_lines(LineDataFile &f, STATAnalysisJob &job, << "line type value of " << statlinetype_to_string(line.type()) << " not currently supported for the aggregation job.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // end switch // @@ -976,7 +976,7 @@ void aggr_ctc_lines(LineDataFile &f, STATAnalysisJob &job, if(n_ties > 0 || n != it->second.valid_ts.n()) { mlog << Error << "\naggr_ctc_lines() -> " << "should be no ties in the valid time array.\n\n"; - throw(1); + throw 1; } // @@ -1045,7 +1045,7 @@ void aggr_mctc_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter multi-category contingency table count " << "(MCTC) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -1087,7 +1087,7 @@ void aggr_mctc_lines(LineDataFile &f, STATAnalysisJob &job, << "lines. Try setting \"-column_eq N_CAT n\", " << m[key].mcts_info.cts.nrows() << " != " << cur.cts.nrows() << "\n\n"; - throw(1); + throw 1; } // @@ -1172,7 +1172,7 @@ void aggr_mctc_lines(LineDataFile &f, STATAnalysisJob &job, if(n_ties > 0 || n != it->second.valid_ts.n()) { mlog << Error << "\naggr_mctc_lines() -> " << "should be no ties in the valid time array.\n\n"; - throw(1); + throw 1; } // @@ -1225,7 +1225,7 @@ void aggr_pct_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter probability contingency table (PCT) " << "line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -1266,7 +1266,7 @@ void aggr_pct_lines(LineDataFile &f, STATAnalysisJob &job, << "thresholds must remain the same for all lines, " << m[key].pct_info.pct.nrows() << " != " << cur.pct.nrows() << "\n\n"; - throw(1); + throw 1; } // @@ -1283,7 +1283,7 @@ void aggr_pct_lines(LineDataFile &f, STATAnalysisJob &job, << "values must remain the same for all lines, " << m[key].pct_info.pct.threshold(i) << " != " << cur.pct.threshold(i) << "\n\n"; - throw(1); + throw 1; } oy = m[key].pct_info.pct.event_count_by_row(i); @@ -1367,7 +1367,7 @@ void aggr_pct_lines(LineDataFile &f, STATAnalysisJob &job, if(n_ties > 0 || n != it->second.valid_ts.n()) { mlog << Error << "\naggr_pct_lines() -> " << "should be no ties in the valid time array.\n\n"; - throw(1); + throw 1; } // @@ -1461,7 +1461,7 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_psum_lines() -> " << "should only encounter partial sum line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // end switch // @@ -1568,7 +1568,7 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, if(n_ties > 0 || n != it->second.valid_ts.n()) { mlog << Error << "\naggr_psum_lines() -> " << "should be no ties in the valid time array.\n\n"; - throw(1); + throw 1; } // @@ -1619,7 +1619,7 @@ void aggr_grad_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_grad_lines() -> " << "should only encounter gradient (GRAD) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -1659,7 +1659,7 @@ void aggr_grad_lines(LineDataFile &f, STATAnalysisJob &job, << " != " << cur.dx << " and " << cur.dy << "). Try setting \"-column_eq DX n -column_eq DY n\"" << " or \"-by DX,DY\".\n\n"; - throw(1); + throw 1; } // @@ -1739,7 +1739,7 @@ void aggr_wind_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_wind_lines() -> " << "should only encounter vector partial sum line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // end switch // @@ -2126,7 +2126,7 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_mpr_lines() -> " << "should only encounter matched pair (MPR) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2203,7 +2203,7 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, << "remain constant. Try setting \"-fcst_var\" and/or " << "\"-obs_var\".\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } } @@ -2250,7 +2250,7 @@ void aggr_isc_lines(LineDataFile &ldf, STATAnalysisJob &job, << "should only encounter intensity-scale " << "(ISC) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2325,7 +2325,7 @@ void aggr_isc_lines(LineDataFile &ldf, STATAnalysisJob &job, << "filter out only those lines you'd like " << "to aggregate.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2508,7 +2508,7 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter ensemble continuous statistics " << "(ECNT) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2569,14 +2569,14 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, // m[key].me_na.add(cur.me); m[key].mae_na.add(cur.mae); - m[key].mse_na.add((is_bad_data(cur.rmse) ? - bad_data_double : - cur.rmse * cur.rmse)); + m[key].mse_na.add(is_bad_data(cur.rmse) ? + bad_data_double : + cur.rmse * cur.rmse); m[key].me_oerr_na.add(cur.me_oerr); m[key].mae_oerr_na.add(cur.mae_oerr); - m[key].mse_oerr_na.add((is_bad_data(cur.rmse_oerr) ? - bad_data_double : - cur.rmse_oerr * cur.rmse_oerr)); + m[key].mse_oerr_na.add(is_bad_data(cur.rmse_oerr) ? + bad_data_double : + cur.rmse_oerr * cur.rmse_oerr); // // Keep track of the unique header column entries @@ -2659,7 +2659,7 @@ void aggr_rps_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter ranked probability score " << "(RPS) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2699,7 +2699,7 @@ void aggr_rps_lines(LineDataFile &f, STATAnalysisJob &job, << "the \"N_PROB\" column must remain constant (" << m[key].rps_info.n_prob << " != " << cur.n_prob << "). Try setting \"-column_eq N_PROB n\".\n\n"; - throw(1); + throw 1; } // @@ -2751,7 +2751,7 @@ void aggr_rhist_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter ranked histogram " << "(RHIST) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2784,7 +2784,7 @@ void aggr_rhist_lines(LineDataFile &f, STATAnalysisJob &job, << "the \"N_RANK\" column must remain constant (" << m[key].ens_pd.rhist_na.n() << " != " << cur.n_rank << "). Try setting \"-column_eq N_RANK n\".\n\n"; - throw(1); + throw 1; } // @@ -2841,7 +2841,7 @@ void aggr_phist_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter probability integral " << "transform histogram (PHIST) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2879,7 +2879,7 @@ void aggr_phist_lines(LineDataFile &f, STATAnalysisJob &job, << "the \"BIN_SIZE\" column must remain constant (" << m[key].ens_pd.phist_bin_size << " != " << cur.bin_size << "). Try setting \"-column_eq BIN_SIZE n\".\n\n"; - throw(1); + throw 1; } // @@ -2932,7 +2932,7 @@ void aggr_relp_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter relative position (RELP) " << "line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -2969,7 +2969,7 @@ void aggr_relp_lines(LineDataFile &f, STATAnalysisJob &job, << "the \"N_ENS\" column must remain constant (" << m[key].ens_pd.relp_na.n() << " != " << cur.n_ens << "). Try setting \"-column_eq N_ENS n\".\n\n"; - throw(1); + throw 1; } // @@ -3024,7 +3024,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter observation rank " << "(ORANK) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3078,7 +3078,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_orank_lines() -> " << "the \"N_ENS\" column must remain constant. " << "Try setting \"-column_eq N_ENS n\".\n\n"; - throw(1); + throw 1; } // @@ -3213,7 +3213,7 @@ void aggr_ssvar_lines(LineDataFile &f, STATAnalysisJob &job, << "should only encounter spread-skill variance " << "(SSVAR) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3229,7 +3229,7 @@ void aggr_ssvar_lines(LineDataFile &f, STATAnalysisJob &job, << "remain constant. Try setting \"-fcst_var\" and/or " << "\"-obs_var\".\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3317,7 +3317,7 @@ void aggr_seeps_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_seeps_lines() -> " << "should only encounter SEEPS line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3333,7 +3333,7 @@ void aggr_seeps_lines(LineDataFile &f, STATAnalysisJob &job, << "remain constant. Try setting \"-fcst_var\" and/or " << "\"-obs_var\".\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3401,7 +3401,7 @@ void aggr_seeps_mpr_lines(LineDataFile &f, STATAnalysisJob &job, mlog << Error << "\naggr_seeps_mpr_lines() -> " << "should only encounter SEEPS_MPR line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3417,7 +3417,7 @@ void aggr_seeps_mpr_lines(LineDataFile &f, STATAnalysisJob &job, << "remain constant. Try setting \"-fcst_var\" and/or " << "\"-obs_var\".\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3520,7 +3520,7 @@ void aggr_time_series_lines(LineDataFile &f, STATAnalysisJob &job, << "remain constant for case \"" << key << "\". Try setting \"-fcst_var\" and/or \"-obs_var\".\n" << line << "\n\n"; - throw(1); + throw 1; } // @@ -3598,7 +3598,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, << "this job may only be called when the \"-model\" option " << "has been used exactly twice to specify the forecast " << "model followed by the reference model.\n\n"; - throw(1); + throw 1; } else { cur.job_info.fcst_model = job.model[0]; @@ -3628,7 +3628,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, << "you must define the skill score index to be computed " << "using the \"-fcst_var\", \"-fcst_lev\", \"-fcst_lead\", " << "\"-line_type\", \"-column\", and \"-weight\" options.\n\n"; - throw(1); + throw 1; } // @@ -3644,7 +3644,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, << n_term << ") or have length 1!\n" << "Check the \"-fcst_var\", \"-fcst_lev\", \"-fcst_lead\", " << "\"-line_type\", \"-column\", and \"-weight\" options.\n\n"; - throw(1); + throw 1; } // @@ -3677,7 +3677,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, << "a skill score index can only be computed using " << "statistics derived from SL1L2 or CTC line types." << "\n\n"; - throw(1); + throw 1; } } diff --git a/src/tools/core/stat_analysis/aggr_stat_line.h b/src/tools/core/stat_analysis/aggr_stat_line.h index e79c0155eb..d0ec0d9c7b 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.h +++ b/src/tools/core/stat_analysis/aggr_stat_line.h @@ -169,7 +169,7 @@ struct ssvar_bin_cmp { bool operator()(const ConcatString & cs1, const ConcatString & cs2) const { // Check for string equality - if( cs1 == cs2) return(0); + if( cs1 == cs2) return 0; // Otherwise, parse list of numbers and compare each element StringArray sa1 = cs1.split(":"); @@ -179,7 +179,7 @@ struct ssvar_bin_cmp { return(atof(sa1[i].c_str()) < atof(sa2[i].c_str())); } } - return(-1); + return -1; } }; diff --git a/src/tools/core/stat_analysis/stat_analysis.cc b/src/tools/core/stat_analysis/stat_analysis.cc index d957137d28..a4a803a9b0 100644 --- a/src/tools/core/stat_analysis/stat_analysis.cc +++ b/src/tools/core/stat_analysis/stat_analysis.cc @@ -208,7 +208,7 @@ int met_main(int argc, char * argv []) { if(jobs_sa.n() == 0) { mlog << Error << "\nmain() -> " << "no jobs defined in \"" << config_file << "\"!\n\n"; - throw(1); + throw 1; } for(i=0; i " << "at least one job must be specified on the command line " << "with \"-job\" or in a configuration file with \"-config\"!\n\n"; - throw(1); + throw 1; } } catch(int j) { // Catch errors @@ -464,7 +464,7 @@ void process_search_dirs() { mlog << Error << "\nprocess_search_dirs() -> " << "no STAT files found in the directories specified!\n\n"; - throw(1); + throw 1; } // @@ -556,7 +556,7 @@ void process_stat_file(const char *filename, const STATAnalysisJob &job, int &n_ << "unable to open input stat file \"" << filename << "\"\n\n"; - throw(1); + throw 1; } @@ -606,7 +606,7 @@ if ( ! pldf->open(user_script_path.c_str(), user_script_args) ) { << "unable to open user script file \"" << user_script_path << "\"\n\n"; - throw(1); + throw 1; } @@ -887,7 +887,7 @@ void open_temps() << "can't open the temporary file \"" << tmp_path << "\" for writing!\n\n"; - throw(1); + throw 1; } diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index 5c22c39d5a..6271114602 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -132,7 +132,7 @@ void set_job_from_config(MetConfig &c, STATAnalysisJob &job) { mlog << Error << "\nset_job_from_config() -> " << "\"" << conf_key_ss_index_vld_thresh << "\" (" << job.ss_index_vld_thresh << ") must be set between 0 and 1.\n\n"; - throw(1); + throw 1; } job.hss_ec_value = c.lookup_double(conf_key_hss_ec_value); @@ -167,7 +167,7 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, mlog << Error << "\ndo_job() -> " << "can't open the temporary file \"" << tmp_path << "\" for reading!\n\n"; - throw(1); + throw 1; } // @@ -255,7 +255,7 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, default: mlog << Error << "\ndo_job() -> " << "Invalid -job type requested!\n\n"; - throw(1); + throw 1; } mlog << Debug(2) << "Job " << n_job << " used " << n_out << " out of " @@ -305,7 +305,7 @@ void do_job_filter(const ConcatString &jobstring, LineDataFile &f, << "this function may only be called when using the " << "-dump_row option in the job command line: " << jobstring << "\n\n"; - throw(1); + throw 1; } mlog << Debug(3) << "Filter Test jobstring:\n" << jobstring << "\n"; @@ -362,7 +362,7 @@ void do_job_summary(const ConcatString &jobstring, LineDataFile &f, mlog << Error << "\ndo_job_summary() -> " << "the \"-column\" option must be used at least once: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -433,7 +433,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, << "this function may only be called when the \"-line_type\" " << "option has been used exactly once to specify the line " << "type for aggregation: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -460,7 +460,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, << "\tSL1L2, SAL1L2, VL1L2, VAL1L2,\n" << "\tPCT, NBRCTC, NBRCNT, GRAD, ISC,\n" << "\tECNT, RPS, RHIST, PHIST, RELP, SSVAR, SEEPS\n\n"; - throw(1); + throw 1; } // @@ -640,7 +640,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, << "the \"-line_type\" option must be used exactly once and " << "the \"-out_line_type\" option must be used at least once: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -813,7 +813,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, << "when \"-out_line_type\" is set to RPS, the " << "\"-out_fcst_thresh\" option must be used to specify " << "monotonically increasing thresholds of interet.\n\n"; - throw(1); + throw 1; } } @@ -872,7 +872,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, << "or SAL1L2, the \"-out_fcst_thresh\" and " << "\"-out_obs_thresh\" options must specify the " << "same number of thresholds.\n\n"; - throw(1); + throw 1; } // Store a single NA threshold @@ -899,7 +899,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, << "\"-out_fcst_thresh\" and \"-out_obs_thresh\" " << "options must specify the same number of thresholds " << "and at least one.\n\n"; - throw(1); + throw 1; } } @@ -916,7 +916,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, << "the \"-out_thresh\" option or \"-out_fcst_thresh\" and " << "\"-out_obs_thresh\" options must specify " << "the same number of thresholds and at least two.\n\n"; - throw(1); + throw 1; } for(i=0; i " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -1554,7 +1554,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_mctc() -> " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -1732,7 +1732,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_pct() -> " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -1932,7 +1932,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_psum() -> " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -2045,7 +2045,7 @@ void write_job_aggr_wind(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_wind() -> " << "the number of U and V forecast and observation points " << "must be the same.\n\n"; - throw(1); + throw 1; } // @@ -3062,7 +3062,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_orank() -> " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -3515,7 +3515,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_mpr() -> " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -3615,7 +3615,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, mlog << Error << "\nwrite_job_aggr_mpr_wind() -> " << "unsupported output line type \"" << statlinetype_to_string(lt) << "\" requested.\n\n"; - throw(1); + throw 1; } } // end for it @@ -4292,7 +4292,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, mlog << Error << "\ndo_job_ramp() -> " << "the \"-line_type\" option may be used at most once to " << "specify the input line type: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -4307,7 +4307,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, mlog << Error << "\ndo_job_ramp() -> " << "the \"-out_line_type\" option must be set to CTC, CTS, and/or MPR: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -4323,7 +4323,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, << "specify the forecast and observation values for the " << "ramp job: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -4334,7 +4334,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, mlog << Error << "\ndo_job_ramp() -> " << "unsupported \"-ramp_type\" option: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -4345,7 +4345,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, mlog << Error << "\ndo_job_ramp() -> " << "the \"-swing_width\" option is required for \"-ramp_type SWING\": " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -4357,7 +4357,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, << "the \"-ramp_thresh\" or \"-ramp_thresh_fcst\" and " << "\"-ramp_thresh_obs\" options must be used to define the " << "ramp events: " << jobstring << "\n\n"; - throw(1); + throw 1; } // @@ -4423,8 +4423,8 @@ void write_table(AsciiTable &at, ofstream *sa_out) { // if(at.nrows() == 0 && at.ncols() == 0) return; - if(sa_out) *(sa_out) << at << "\n" << flush; - else cout << at << "\n" << flush; + if(sa_out) *sa_out << at << "\n" << flush; + else cout << at << "\n" << flush; return; } @@ -4445,8 +4445,8 @@ void write_jobstring(const ConcatString &jobstring, ofstream *sa_out) { void write_line(const ConcatString &str, ofstream *sa_out) { - if(sa_out) *(sa_out) << str << "\n" << flush; - else cout << str << "\n" << flush; + if(sa_out) *sa_out << str << "\n" << flush; + else cout << str << "\n" << flush; return; } diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index 68b2c670d7..e2dc49fb9f 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -332,13 +332,13 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, // Process the wavelet type switch(wvlt_type) { - case(WaveletType::Haar): type = *(gsl_wavelet_haar); break; - case(WaveletType::Haar_Cntr): type = *(gsl_wavelet_haar_centered); break; - case(WaveletType::Daub): type = *(gsl_wavelet_daubechies); break; - case(WaveletType::Daub_Cntr): type = *(gsl_wavelet_daubechies_centered); break; - case(WaveletType::BSpline): type = *(gsl_wavelet_bspline); break; - case(WaveletType::BSpline_Cntr): type = *(gsl_wavelet_bspline_centered); break; - case(WaveletType::None): + case WaveletType::Haar: type = *gsl_wavelet_haar; break; + case WaveletType::Haar_Cntr: type = *gsl_wavelet_haar_centered; break; + case WaveletType::Daub: type = *gsl_wavelet_daubechies; break; + case WaveletType::Daub_Cntr: type = *gsl_wavelet_daubechies_centered; break; + case WaveletType::BSpline: type = *gsl_wavelet_bspline; break; + case WaveletType::BSpline_Cntr: type = *gsl_wavelet_bspline_centered; break; + case WaveletType::None: default: mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "Unsupported wavelet type value of " << enum_class_as_int(wvlt_type) << ".\n\n"; @@ -350,8 +350,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, // Check for valid member number switch(wvlt_type) { - case(WaveletType::Haar): - case(WaveletType::Haar_Cntr): + case WaveletType::Haar: + case WaveletType::Haar_Cntr: if(wvlt_member != 2) { mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "For Haar wavelets, \"" << conf_key_wavelet_member @@ -360,8 +360,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType::Daub): - case(WaveletType::Daub_Cntr): + case WaveletType::Daub: + case WaveletType::Daub_Cntr: if(wvlt_member < 4 || wvlt_member > 20 || wvlt_member%2 == 1) { mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "For Daubechies wavelets, \"" << conf_key_wavelet_member @@ -370,8 +370,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType::BSpline): - case(WaveletType::BSpline_Cntr): + case WaveletType::BSpline: + case WaveletType::BSpline_Cntr: if(wvlt_member != 103 && wvlt_member != 105 && wvlt_member != 202 && wvlt_member != 204 && wvlt_member != 206 && wvlt_member != 208 && wvlt_member != 301 && wvlt_member != 303 && wvlt_member != 305 && @@ -384,7 +384,7 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType::None): + case WaveletType::None: default: mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "Unsupported wavelet type value of " << enum_class_as_int(wvlt_type) << ".\n\n"; @@ -511,7 +511,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { // Tile the input data using tiles of dimension n by n where n // is the largest integer power of 2 less than the smallest // dimension of the input data and allowing no overlap. - case(GridDecompType::Auto): + case GridDecompType::Auto: center_tiles(grid.nx(), grid.ny()); @@ -528,7 +528,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { break; // Apply the tiles specified in the configuration file - case(GridDecompType::Tile): + case GridDecompType::Tile: // Number of tiles based on the user-specified locations n_tile = tile_xll.n(); @@ -547,7 +547,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { // Setup tiles for padding the input fields out to the nearest // integer power of two - case(GridDecompType::Pad): + case GridDecompType::Pad: pad_tiles(grid.nx(), grid.ny()); @@ -562,7 +562,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { break; - case(GridDecompType::None): + case GridDecompType::None: default: mlog << Error << "\nWaveletStatConfInfo::process_tiles() -> " << "Unsupported grid decomposition type of " diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h index 1380ecc6b3..11bdf93f90 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h @@ -146,11 +146,11 @@ class WaveletStatConfInfo { //////////////////////////////////////////////////////////////////////// -inline int WaveletStatConfInfo::get_n_vx() const { return(n_vx); } -inline int WaveletStatConfInfo::get_max_n_thresh() const { return(max_n_thresh); } -inline int WaveletStatConfInfo::get_n_tile() const { return(n_tile); } -inline int WaveletStatConfInfo::get_tile_dim() const { return(tile_dim); } -inline int WaveletStatConfInfo::get_n_scale() const { return(n_scale); } +inline int WaveletStatConfInfo::get_n_vx() const { return n_vx; } +inline int WaveletStatConfInfo::get_max_n_thresh() const { return max_n_thresh; } +inline int WaveletStatConfInfo::get_n_tile() const { return n_tile; } +inline int WaveletStatConfInfo::get_tile_dim() const { return tile_dim; } +inline int WaveletStatConfInfo::get_n_scale() const { return n_scale; } inline int WaveletStatConfInfo::get_compression_level() { return conf.nc_compression(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/gen_climo_bin.cc b/src/tools/dev_utils/gen_climo_bin.cc index 4551342192..e24265ef0d 100644 --- a/src/tools/dev_utils/gen_climo_bin.cc +++ b/src/tools/dev_utils/gen_climo_bin.cc @@ -196,7 +196,7 @@ void process_binary() { // Loop over climo bins, skipping the first and last points for(j=0; j<(n_bin-1); j++) { - int byte_offset = (j+1)*((n_read_bin - 1)/(n_bin))*4; + int byte_offset = (j+1)*((n_read_bin - 1)/n_bin)*4; unsigned char * b = buf + byte_offset; my_memcpy(&v, b, 4); shuffle_4(&v); diff --git a/src/tools/dev_utils/met_nc_file.cc b/src/tools/dev_utils/met_nc_file.cc index 50e1151c51..3579c52f8e 100644 --- a/src/tools/dev_utils/met_nc_file.cc +++ b/src/tools/dev_utils/met_nc_file.cc @@ -156,8 +156,8 @@ bool MetNcFile::readFile(const int desired_grib_code, float *obs_arr = new float[obs_arr_len]; float *hdr_arr = new float[hdr_arr_len]; - mlog << Debug(2) << "Processing " << (obs_count) << " observations at " - << (hdr_count) << " locations.\n"; + mlog << Debug(2) << "Processing " << obs_count << " observations at " + << hdr_count << " locations.\n"; // Loop through the observations, saving the ones that we are // interested in diff --git a/src/tools/other/ascii2nc/aeronet_handler.cc b/src/tools/other/ascii2nc/aeronet_handler.cc index bf6ed08d12..440622938c 100644 --- a/src/tools/other/ascii2nc/aeronet_handler.cc +++ b/src/tools/other/ascii2nc/aeronet_handler.cc @@ -794,7 +794,7 @@ string AeronetHandler::make_var_name_from_header(string hdr_field) { else if ((int) string::npos != hdr_field.find(WAVELENGTHS_PW_NAME)) { var_name = WAVELENGTHS_PW_NAME; } - else if ((hdr_field == OPTICAL_AIR_MASS_NAME)) { + else if (hdr_field == OPTICAL_AIR_MASS_NAME) { var_name = hdr_field; } else { diff --git a/src/tools/other/ascii2nc/file_handler.cc b/src/tools/other/ascii2nc/file_handler.cc index 5495c8b6dc..78fd4bc2e0 100644 --- a/src/tools/other/ascii2nc/file_handler.cc +++ b/src/tools/other/ascii2nc/file_handler.cc @@ -380,6 +380,6 @@ bool FileHandler::_keep_valid_time(const time_t &valid_time) const else if (valid_beg_ut == (time_t) 0 && valid_end_ut != (time_t) 0) { if (valid_time > valid_end_ut) keep = false; } - return(keep); + return keep; } diff --git a/src/tools/other/ascii2nc/iabp_handler.cc b/src/tools/other/ascii2nc/iabp_handler.cc index 71ce27f10c..fd384cbf2e 100644 --- a/src/tools/other/ascii2nc/iabp_handler.cc +++ b/src/tools/other/ascii2nc/iabp_handler.cc @@ -82,7 +82,7 @@ bool IabpHandler::isFileType(LineDataFile &ascii_file) const { if (tokens[6] != "Lat") is_file_type = false; if (tokens[7] != "Lon") is_file_type = false; - return(is_file_type); + return is_file_type; } //////////////////////////////////////////////////////////////////////// @@ -92,7 +92,7 @@ bool IabpHandler::isFileType(LineDataFile &ascii_file) const { bool IabpHandler::_readObservations(LineDataFile &ascii_file) { // Read and save the header information - if(!_readHeaderInfo(ascii_file)) return(false); + if(!_readHeaderInfo(ascii_file)) return false; string header_type = "IABP_STANDARD"; @@ -107,7 +107,7 @@ bool IabpHandler::_readObservations(LineDataFile &ascii_file) << " != " << _numColumns << ") on line number " << dl.line_number() << " of IABP file \"" << ascii_file.filename() << "\"!\n\n"; - return(false); + return false; } // Extract the valid time from the data line, using POS_DOY (scientist is most @@ -119,7 +119,7 @@ bool IabpHandler::_readObservations(LineDataFile &ascii_file) << "No valid time computed in file, line number " << dl.line_number() << " of IABP file \"" << ascii_file.filename() << "\". Ignore this line\n\n"; - return(false); + return false; } double lat = stod(dl[_latPtr]); @@ -139,7 +139,7 @@ bool IabpHandler::_readObservations(LineDataFile &ascii_file) << "Latitude/longitude has missing value " << IABP_MISSING_VALUE << ", line number " << dl.line_number() << " of IABP file \"" << ascii_file.filename() << "\". Ignore this line\n\n"; - return(false); + return false; } if (_bpPtr >= 0) { @@ -184,7 +184,7 @@ bool IabpHandler::_readObservations(LineDataFile &ascii_file) } // end while - return(true); + return true; } // //////////////////////////////////////////////////////////////////////// @@ -207,7 +207,7 @@ bool IabpHandler::_readHeaderInfo(LineDataFile &ascii_file) { << dl.n_items() << " < " << MIN_NUM_HDR_COLS << ") in IABP file \"" << ascii_file.filename() << "\"!\n\n"; - return(false); + return false; } // Map the header information to column numbers diff --git a/src/tools/other/ascii2nc/met_handler.cc b/src/tools/other/ascii2nc/met_handler.cc index dd868d8029..5d68e69942 100644 --- a/src/tools/other/ascii2nc/met_handler.cc +++ b/src/tools/other/ascii2nc/met_handler.cc @@ -186,7 +186,7 @@ bool MetHandler::_readObservations(LineDataFile &ascii_file) double parse_num(const char *s) { if(!s) return bad_data_double; - return( (strcasecmp(s, na_str) == 0 ? bad_data_double : atof(s)) ); + return( strcasecmp(s, na_str) == 0 ? bad_data_double : atof(s) ); } diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.h b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.h index ba23574c30..bb76ce0c63 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.h +++ b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.h @@ -112,10 +112,10 @@ class GenEnsProdConfInfo { //////////////////////////////////////////////////////////////////////// -inline int GenEnsProdConfInfo::get_n_var() const { return(n_var); } -inline int GenEnsProdConfInfo::get_max_n_cat() const { return(max_n_cat); } -inline int GenEnsProdConfInfo::get_n_nbrhd() const { return(nbrhd_prob.width.n()); } -inline int GenEnsProdConfInfo::get_compression_level() { return(conf.nc_compression()); } +inline int GenEnsProdConfInfo::get_n_var() const { return n_var; } +inline int GenEnsProdConfInfo::get_max_n_cat() const { return max_n_cat; } +inline int GenEnsProdConfInfo::get_n_nbrhd() const { return nbrhd_prob.width.n(); } +inline int GenEnsProdConfInfo::get_compression_level() { return conf.nc_compression(); } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/conv_record.h b/src/tools/other/gsi_tools/conv_record.h index f482c6fd0b..658db1cec8 100644 --- a/src/tools/other/gsi_tools/conv_record.h +++ b/src/tools/other/gsi_tools/conv_record.h @@ -89,15 +89,15 @@ class ConvFile { //////////////////////////////////////////////////////////////////////// -inline bool ConvFile::get_swap_endian() const { return ( SwapEndian ); } +inline bool ConvFile::get_swap_endian() const { return SwapEndian; } -inline int ConvFile::get_rec_pad_size() const { return ( RecPadSize ); } +inline int ConvFile::get_rec_pad_size() const { return RecPadSize; } -inline unixtime ConvFile::date() const { return ( Date ); } +inline unixtime ConvFile::date() const { return Date; } -inline int ConvFile::n_rec() const { return ( Nrec ); } +inline int ConvFile::n_rec() const { return Nrec; } -inline int ConvFile::n_pair() const { return ( Npair ); } +inline int ConvFile::n_pair() const { return Npair; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsi_record.h b/src/tools/other/gsi_tools/gsi_record.h index 29392c49eb..2c6c3c3206 100644 --- a/src/tools/other/gsi_tools/gsi_record.h +++ b/src/tools/other/gsi_tools/gsi_record.h @@ -75,8 +75,8 @@ class GsiRecord { //////////////////////////////////////////////////////////////////////// -inline bool GsiRecord::shuffle () const { return ( Shuffle ); } -inline int GsiRecord::rec_pad_length () const { return ( RecPadLength ); } +inline bool GsiRecord::shuffle () const { return Shuffle; } +inline int GsiRecord::rec_pad_length () const { return RecPadLength; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/rad_record.h b/src/tools/other/gsi_tools/rad_record.h index 9f7f11f1ea..9159946d08 100644 --- a/src/tools/other/gsi_tools/rad_record.h +++ b/src/tools/other/gsi_tools/rad_record.h @@ -180,25 +180,25 @@ class RadFile { //////////////////////////////////////////////////////////////////////// -inline bool RadFile::get_swap_endian() const { return ( SwapEndian ); } +inline bool RadFile::get_swap_endian() const { return SwapEndian; } -inline int RadFile::get_rec_pad_size() const { return ( RecPadSize ); } +inline int RadFile::get_rec_pad_size() const { return RecPadSize; } -inline unixtime RadFile::date() const { return ( Date ); } +inline unixtime RadFile::date() const { return Date; } -inline int RadFile::n_channels() const { return ( Nchannels ); } +inline int RadFile::n_channels() const { return Nchannels; } -inline int RadFile::n_diag() const { return ( Ndiag ); } -inline int RadFile::n_rec() const { return ( Nrec ); } -inline int RadFile::n_pair() const { return ( Npair ); } +inline int RadFile::n_diag() const { return Ndiag; } +inline int RadFile::n_rec() const { return Nrec ; } +inline int RadFile::n_pair() const { return Npair; } -inline int RadFile::n1() const { return ( N1 ); } -inline int RadFile::n2() const { return ( N2 ); } +inline int RadFile::n1() const { return N1; } +inline int RadFile::n2() const { return N2; } -inline int RadFile::n12() const { return ( N1*N2 ); } +inline int RadFile::n12() const { return N1*N2; } -inline int RadFile::iextra() const { return ( R_params.iextra ); } -inline int RadFile::jextra() const { return ( R_params.jextra ); } +inline int RadFile::iextra() const { return R_params.iextra; } +inline int RadFile::jextra() const { return R_params.jextra; } inline bool RadFile::has_extra() const { return ( (R_params.iextra != 0) && (R_params.jextra != 0) ); } @@ -271,12 +271,12 @@ class RadRecord : public GsiRecord { //////////////////////////////////////////////////////////////////////// -inline int RadRecord::n1() const { return ( N1 ); } -inline int RadRecord::n2() const { return ( N2 ); } +inline int RadRecord::n1() const { return N1; } +inline int RadRecord::n2() const { return N2; } inline bool RadRecord::has_extra() const { return ( extra != 0 ); } -inline unixtime RadRecord::date() const { return ( Date ); } +inline unixtime RadRecord::date() const { return Date; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index 2c2c4f3853..63626c6908 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -305,38 +305,38 @@ void process_madis_file(const char *madis_file) { // Switch on the MADIS type and process accordingly. switch(my_mtype) { - case(MadisType::metar): + case MadisType::metar: process_madis_metar(f_in); break; - case(MadisType::raob): + case MadisType::raob: process_madis_raob(f_in); break; - case (MadisType::profiler): + case MadisType::profiler: process_madis_profiler(f_in); break; - case(MadisType::maritime): + case MadisType::maritime: process_madis_maritime(f_in); break; - case(MadisType::mesonet): + case MadisType::mesonet: process_madis_mesonet(f_in); break; - case(MadisType::acarsProfiles): + case MadisType::acarsProfiles: process_madis_acarsProfiles(f_in); break; - case(MadisType::coop): - case(MadisType::HDW): - case(MadisType::HDW1h): - case(MadisType::hydro): - case(MadisType::POES): - case(MadisType::acars): - case(MadisType::radiometer): - case(MadisType::sao): - case(MadisType::satrad): - case(MadisType::snow): - case(MadisType::none): + case MadisType::coop: + case MadisType::HDW: + case MadisType::HDW1h: + case MadisType::hydro: + case MadisType::POES: + case MadisType::acars: + case MadisType::radiometer: + case MadisType::sao: + case MadisType::satrad: + case MadisType::snow: + case MadisType::none: default: mlog << Error << "\nprocess_madis_file() -> " << "MADIS type (" << enum_class_as_int(my_mtype) diff --git a/src/tools/other/mode_graphics/cgraph_font.h b/src/tools/other/mode_graphics/cgraph_font.h index f8dc85b537..f6970fbcbd 100644 --- a/src/tools/other/mode_graphics/cgraph_font.h +++ b/src/tools/other/mode_graphics/cgraph_font.h @@ -130,7 +130,7 @@ class CgFontCollection { //////////////////////////////////////////////////////////////////////// -inline int CgFontCollection::n_fonts() const { return ( Nelements ); } +inline int CgFontCollection::n_fonts() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/cgraph_main.h b/src/tools/other/mode_graphics/cgraph_main.h index 6352ee23eb..f7f6ce148b 100644 --- a/src/tools/other/mode_graphics/cgraph_main.h +++ b/src/tools/other/mode_graphics/cgraph_main.h @@ -265,7 +265,7 @@ inline void CgraphBase::stroke() { cairo_stroke (Cr); return; } inline void CgraphBase::fill() { cairo_fill (Cr); return; } inline void CgraphBase::clip() { cairo_clip (Cr); return; } -inline const Box & CgraphBase::page() const { return ( PageBox ); } +inline const Box & CgraphBase::page() const { return PageBox; } inline void CgraphBase::setlinecap_butt() { cairo_set_line_cap (Cr, CAIRO_LINE_CAP_BUTT); return; } inline void CgraphBase::setlinecap_round() { cairo_set_line_cap (Cr, CAIRO_LINE_CAP_ROUND); return; } @@ -275,7 +275,7 @@ inline void CgraphBase::setlinejoin_miter() { cairo_set_line_join (Cr, CAIRO_LIN inline void CgraphBase::setlinejoin_round() { cairo_set_line_join (Cr, CAIRO_LINE_JOIN_ROUND); return; } inline void CgraphBase::setlinejoin_bevel() { cairo_set_line_join (Cr, CAIRO_LINE_JOIN_BEVEL); return; } -inline double CgraphBase::c_fudge_y(double __Y__) const { return ( __Y__ ); } +inline double CgraphBase::c_fudge_y(double __Y__) const { return __Y__; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/color_stack.h b/src/tools/other/mode_graphics/color_stack.h index f225905cd2..4bc5b543d2 100644 --- a/src/tools/other/mode_graphics/color_stack.h +++ b/src/tools/other/mode_graphics/color_stack.h @@ -72,7 +72,7 @@ class ColorStack { //////////////////////////////////////////////////////////////////////// -inline int ColorStack::depth() const { return ( Nelements ); } +inline int ColorStack::depth() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/mode_nc_output_file.h b/src/tools/other/mode_graphics/mode_nc_output_file.h index 177c059905..0187f6a169 100644 --- a/src/tools/other/mode_graphics/mode_nc_output_file.h +++ b/src/tools/other/mode_graphics/mode_nc_output_file.h @@ -161,23 +161,23 @@ class ModeNcOutputFile { //////////////////////////////////////////////////////////////////////// -inline int ModeNcOutputFile::nx() const { return ( Nx ); } -inline int ModeNcOutputFile::ny() const { return ( Ny ); } +inline int ModeNcOutputFile::nx() const { return Nx; } +inline int ModeNcOutputFile::ny() const { return Ny; } -inline const Grid & ModeNcOutputFile::grid() const { return ( *_Grid ); } +inline const Grid & ModeNcOutputFile::grid() const { return *_Grid; } -inline ConcatString ModeNcOutputFile::filename() const { return ( Filename ); } +inline ConcatString ModeNcOutputFile::filename() const { return Filename; } -inline unixtime ModeNcOutputFile::valid_time() const { return ( ValidTime ); } -inline unixtime ModeNcOutputFile::init_time () const { return ( InitTime ); } +inline unixtime ModeNcOutputFile::valid_time() const { return ValidTime; } +inline unixtime ModeNcOutputFile::init_time () const { return InitTime; } -inline int ModeNcOutputFile::accum_time () const { return ( AccumTime ); } +inline int ModeNcOutputFile::accum_time () const { return AccumTime; } -// inline int ModeNcOutputFile::n_fcst_objs () const { return ( NFcstObjs ); } -// inline int ModeNcOutputFile::n_obs_objs () const { return ( NObsObjs ); } +// inline int ModeNcOutputFile::n_fcst_objs () const { return NFcstObjs; } +// inline int ModeNcOutputFile::n_obs_objs () const { return NObsObjs ; } // -// inline int ModeNcOutputFile::n_fcst_clus () const { return ( NFcstClus ); } -// inline int ModeNcOutputFile::n_obs_clus () const { return ( NObsClus ); } +// inline int ModeNcOutputFile::n_fcst_clus () const { return NFcstClus; } +// inline int ModeNcOutputFile::n_obs_clus () const { return NObsClus ; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_graphics/plot_mode_field.cc b/src/tools/other/mode_graphics/plot_mode_field.cc index 6f5e7fe26c..bf37364728 100644 --- a/src/tools/other/mode_graphics/plot_mode_field.cc +++ b/src/tools/other/mode_graphics/plot_mode_field.cc @@ -920,16 +920,16 @@ void draw_map(Cgraph & plot, const Box & map_box, const Grid & grid) { int j; -Dictionary & s = *(sources); -const DictionaryEntry * e = 0; -Dictionary * dict = 0; +Dictionary & s = *sources; +const DictionaryEntry * e = nullptr; +Dictionary * dict = nullptr; for (j=0; jis_dictionary()) ) { + if ( ! e->is_dictionary() ) { mlog << Error << "\n\n " << program_name << ": draw_map() -> non-dictionary found " diff --git a/src/tools/other/mode_time_domain/2d_att.h b/src/tools/other/mode_time_domain/2d_att.h index 6975969278..75f6260ea1 100644 --- a/src/tools/other/mode_time_domain/2d_att.h +++ b/src/tools/other/mode_time_domain/2d_att.h @@ -162,48 +162,48 @@ class SingleAtt2D { //////////////////////////////////////////////////////////////////////// -inline int SingleAtt2D::object_number() const { return ( ObjectNumber ); } +inline int SingleAtt2D::object_number() const { return ObjectNumber; } -inline int SingleAtt2D::cluster_number() const { return ( ClusterNumber ); } +inline int SingleAtt2D::cluster_number() const { return ClusterNumber; } -inline int SingleAtt2D::time_index() const { return ( TimeIndex ); } +inline int SingleAtt2D::time_index() const { return TimeIndex; } inline void SingleAtt2D::set_object_number (int _n) { ObjectNumber = _n; return; } inline void SingleAtt2D::set_cluster_number (int _n) { ClusterNumber = _n; return; } -inline int SingleAtt2D::area() const { return ( Area ); } +inline int SingleAtt2D::area() const { return Area; } inline void SingleAtt2D::set_area(int _A) { Area = _A; return; } inline void SingleAtt2D::set_time_index(int _t) { TimeIndex = _t; return; } -inline double SingleAtt2D::xbar() const { return ( Xbar ); } -inline double SingleAtt2D::ybar() const { return ( Ybar ); } +inline double SingleAtt2D::xbar() const { return Xbar; } +inline double SingleAtt2D::ybar() const { return Ybar; } -inline double SingleAtt2D::centroid_lat() const { return ( CentroidLat ); } -inline double SingleAtt2D::centroid_lon() const { return ( CentroidLon ); } +inline double SingleAtt2D::centroid_lat() const { return CentroidLat; } +inline double SingleAtt2D::centroid_lon() const { return CentroidLon; } -inline double SingleAtt2D::axis() const { return ( AxisAngle ); } +inline double SingleAtt2D::axis() const { return AxisAngle; } -inline double SingleAtt2D::ptile_10() const { return ( Ptile_10 ); } -inline double SingleAtt2D::ptile_25() const { return ( Ptile_25 ); } -inline double SingleAtt2D::ptile_50() const { return ( Ptile_50 ); } -inline double SingleAtt2D::ptile_75() const { return ( Ptile_75 ); } -inline double SingleAtt2D::ptile_90() const { return ( Ptile_90 ); } +inline double SingleAtt2D::ptile_10() const { return Ptile_10; } +inline double SingleAtt2D::ptile_25() const { return Ptile_25; } +inline double SingleAtt2D::ptile_50() const { return Ptile_50; } +inline double SingleAtt2D::ptile_75() const { return Ptile_75; } +inline double SingleAtt2D::ptile_90() const { return Ptile_90; } -inline int SingleAtt2D::ptile_value() const { return ( Ptile_Value ); } -inline double SingleAtt2D::ptile_user() const { return ( Ptile_User ); } +inline int SingleAtt2D::ptile_value() const { return Ptile_Value; } +inline double SingleAtt2D::ptile_user() const { return Ptile_User ; } -inline bool SingleAtt2D::is_fcst() const { return ( IsFcst ); } -inline bool SingleAtt2D::is_obs () const { return ( ! IsFcst ); } +inline bool SingleAtt2D::is_fcst() const { return IsFcst; } +inline bool SingleAtt2D::is_obs () const { return !IsFcst; } -inline bool SingleAtt2D::is_cluster () const { return ( Is_Cluster ); } -inline bool SingleAtt2D::is_simple () const { return ( ! Is_Cluster ); } +inline bool SingleAtt2D::is_cluster () const { return Is_Cluster; } +inline bool SingleAtt2D::is_simple () const { return !Is_Cluster; } -inline unixtime SingleAtt2D::valid_time () const { return ( ValidTime ); } +inline unixtime SingleAtt2D::valid_time () const { return ValidTime; } -inline int SingleAtt2D::lead_time () const { return ( Lead_Time ); } +inline int SingleAtt2D::lead_time () const { return Lead_Time; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/2d_att_array.h b/src/tools/other/mode_time_domain/2d_att_array.h index 6963664805..968b917211 100644 --- a/src/tools/other/mode_time_domain/2d_att_array.h +++ b/src/tools/other/mode_time_domain/2d_att_array.h @@ -84,8 +84,8 @@ class SingleAtt2DArray { //////////////////////////////////////////////////////////////////////// -inline int SingleAtt2DArray::n_elements() const { return ( Nelements ); } -inline int SingleAtt2DArray::n () const { return ( Nelements ); } +inline int SingleAtt2DArray::n_elements() const { return Nelements; } +inline int SingleAtt2DArray::n () const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/2d_moments.h b/src/tools/other/mode_time_domain/2d_moments.h index 1f379a79f5..2052561687 100644 --- a/src/tools/other/mode_time_domain/2d_moments.h +++ b/src/tools/other/mode_time_domain/2d_moments.h @@ -77,7 +77,7 @@ class Mtd_2D_Moments { //////////////////////////////////////////////////////////////////////// -inline int Mtd_2D_Moments::area() const { return ( N ); } +inline int Mtd_2D_Moments::area() const { return N; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_att.h b/src/tools/other/mode_time_domain/3d_att.h index 8d1db58227..91ad4901c3 100644 --- a/src/tools/other/mode_time_domain/3d_att.h +++ b/src/tools/other/mode_time_domain/3d_att.h @@ -196,58 +196,58 @@ class SingleAtt3D { //////////////////////////////////////////////////////////////////////// -inline int SingleAtt3D::object_number () const { return ( ObjectNumber ); } -inline int SingleAtt3D::cluster_number () const { return ( ClusterNumber ); } +inline int SingleAtt3D::object_number () const { return ObjectNumber ; } +inline int SingleAtt3D::cluster_number () const { return ClusterNumber; } -inline bool SingleAtt3D::is_fcst () const { return ( IsFcst ); } -inline bool SingleAtt3D::is_obs () const { return ( ! IsFcst ); } +inline bool SingleAtt3D::is_fcst () const { return IsFcst; } +inline bool SingleAtt3D::is_obs () const { return !IsFcst; } -inline bool SingleAtt3D::is_simple () const { return ( IsSimple ); } -inline bool SingleAtt3D::is_cluster () const { return ( ! IsSimple ); } +inline bool SingleAtt3D::is_simple () const { return IsSimple; } +inline bool SingleAtt3D::is_cluster () const { return !IsSimple; } inline void SingleAtt3D::set_object_number (int _n) { ObjectNumber = _n; return; } inline void SingleAtt3D::set_cluster_number (int _n) { ClusterNumber = _n; return; } -inline int SingleAtt3D::volume() const { return ( Volume ); } +inline int SingleAtt3D::volume() const { return Volume; } inline void SingleAtt3D::set_volume(int _v) { Volume = _v; return; } -inline double SingleAtt3D::complexity() const { return ( Complexity ); } +inline double SingleAtt3D::complexity() const { return Complexity; } inline void SingleAtt3D::set_complexity(double _v) { Complexity = _v; return; } -inline double SingleAtt3D::xbar() const { return ( Xbar ); } -inline double SingleAtt3D::ybar() const { return ( Ybar ); } -inline double SingleAtt3D::tbar() const { return ( Tbar ); } +inline double SingleAtt3D::xbar() const { return Xbar; } +inline double SingleAtt3D::ybar() const { return Ybar; } +inline double SingleAtt3D::tbar() const { return Tbar; } -inline double SingleAtt3D::centroid_lat() const { return ( Centroid_Lat ); } -inline double SingleAtt3D::centroid_lon() const { return ( Centroid_Lon ); } +inline double SingleAtt3D::centroid_lat() const { return Centroid_Lat; } +inline double SingleAtt3D::centroid_lon() const { return Centroid_Lon; } -inline int SingleAtt3D::xmin() const { return ( Xmin ); } -inline int SingleAtt3D::xmax() const { return ( Xmax ); } +inline int SingleAtt3D::xmin() const { return Xmin; } +inline int SingleAtt3D::xmax() const { return Xmax; } -inline int SingleAtt3D::ymin() const { return ( Ymin ); } -inline int SingleAtt3D::ymax() const { return ( Ymax ); } +inline int SingleAtt3D::ymin() const { return Ymin; } +inline int SingleAtt3D::ymax() const { return Ymax; } -inline int SingleAtt3D::tmin() const { return ( Tmin ); } -inline int SingleAtt3D::tmax() const { return ( Tmax ); } +inline int SingleAtt3D::tmin() const { return Tmin; } +inline int SingleAtt3D::tmax() const { return Tmax; } -inline double SingleAtt3D::xdot() const { return ( Xvelocity ); } -inline double SingleAtt3D::ydot() const { return ( Yvelocity ); } +inline double SingleAtt3D::xdot() const { return Xvelocity; } +inline double SingleAtt3D::ydot() const { return Yvelocity; } -inline double SingleAtt3D::spatial_axis() const { return ( SpatialAxisAngle ); } +inline double SingleAtt3D::spatial_axis() const { return SpatialAxisAngle; } -inline double SingleAtt3D::cdist_travelled() const { return ( CdistTravelled ); } +inline double SingleAtt3D::cdist_travelled() const { return CdistTravelled; } -inline double SingleAtt3D::ptile_10() const { return ( Ptile_10 ); } -inline double SingleAtt3D::ptile_25() const { return ( Ptile_25 ); } -inline double SingleAtt3D::ptile_50() const { return ( Ptile_50 ); } -inline double SingleAtt3D::ptile_75() const { return ( Ptile_75 ); } -inline double SingleAtt3D::ptile_90() const { return ( Ptile_90 ); } +inline double SingleAtt3D::ptile_10() const { return Ptile_10; } +inline double SingleAtt3D::ptile_25() const { return Ptile_25; } +inline double SingleAtt3D::ptile_50() const { return Ptile_50; } +inline double SingleAtt3D::ptile_75() const { return Ptile_75; } +inline double SingleAtt3D::ptile_90() const { return Ptile_90; } -inline int SingleAtt3D::ptile_value() const { return ( Ptile_Value ); } -inline double SingleAtt3D::ptile_user() const { return ( Ptile_User ); } +inline int SingleAtt3D::ptile_value() const { return Ptile_Value; } +inline double SingleAtt3D::ptile_user() const { return Ptile_User ; } //////////////////////////////////////////////////////////////////////// @@ -388,33 +388,33 @@ class PairAtt3D { //////////////////////////////////////////////////////////////////////// -inline int PairAtt3D::fcst_obj_number() const { return ( FcstObjectNumber ); } -inline int PairAtt3D::obs_obj_number() const { return ( ObsObjectNumber ); } +inline int PairAtt3D::fcst_obj_number() const { return FcstObjectNumber; } +inline int PairAtt3D::obs_obj_number() const { return ObsObjectNumber; } -inline int PairAtt3D::fcst_cluster_number() const { return ( FcstClusterNumber ); } -inline int PairAtt3D::obs_cluster_number() const { return ( ObsClusterNumber ); } +inline int PairAtt3D::fcst_cluster_number() const { return FcstClusterNumber; } +inline int PairAtt3D::obs_cluster_number() const { return ObsClusterNumber; } -inline int PairAtt3D::intersection_vol () const { return ( IntersectionVol ); } -// inline int PairAtt3D::union_vol () const { return ( UnionVol ); } +inline int PairAtt3D::intersection_vol () const { return IntersectionVol; } +// inline int PairAtt3D::union_vol () const { return UnionVol; } -inline double PairAtt3D::time_centroid_delta () const { return ( TimeCentroidDelta ); } -inline double PairAtt3D::space_centroid_dist () const { return ( SpaceCentroidDist ); } +inline double PairAtt3D::time_centroid_delta () const { return TimeCentroidDelta; } +inline double PairAtt3D::space_centroid_dist () const { return SpaceCentroidDist; } -inline double PairAtt3D::direction_difference () const { return ( DirectionDifference ); } -inline double PairAtt3D::speed_delta () const { return ( SpeedDelta ); } +inline double PairAtt3D::direction_difference () const { return DirectionDifference; } +inline double PairAtt3D::speed_delta () const { return SpeedDelta; } -inline double PairAtt3D::volume_ratio () const { return ( VolumeRatio ); } -inline double PairAtt3D::axis_angle_diff () const { return ( AxisDiff ); } +inline double PairAtt3D::volume_ratio () const { return VolumeRatio; } +inline double PairAtt3D::axis_angle_diff () const { return AxisDiff; } -inline int PairAtt3D::start_time_delta () const { return ( StartTimeDelta ); } -inline int PairAtt3D::end_time_delta () const { return ( EndTimeDelta ); } +inline int PairAtt3D::start_time_delta () const { return StartTimeDelta; } +inline int PairAtt3D::end_time_delta () const { return EndTimeDelta; } -inline int PairAtt3D::duration_difference () const { return ( DurationDifference ); } +inline int PairAtt3D::duration_difference () const { return DurationDifference; } -inline double PairAtt3D::total_interest () const { return ( TotalInterest ); } +inline double PairAtt3D::total_interest () const { return TotalInterest; } -inline bool PairAtt3D::is_simple () const { return ( IsSimple ); } -inline bool PairAtt3D::is_cluster () const { return ( ! IsSimple ); } +inline bool PairAtt3D::is_simple () const { return IsSimple; } +inline bool PairAtt3D::is_cluster () const { return !IsSimple; } inline void PairAtt3D::set_simple () { IsSimple = true; return; } inline void PairAtt3D::set_cluster () { IsSimple = false; return; } diff --git a/src/tools/other/mode_time_domain/3d_att_pair_array.h b/src/tools/other/mode_time_domain/3d_att_pair_array.h index e933bbd6a9..f3cdf13674 100644 --- a/src/tools/other/mode_time_domain/3d_att_pair_array.h +++ b/src/tools/other/mode_time_domain/3d_att_pair_array.h @@ -99,8 +99,8 @@ class PairAtt3DArray { //////////////////////////////////////////////////////////////////////// -inline int PairAtt3DArray::n_elements() const { return ( Nelements ); } -inline int PairAtt3DArray::n () const { return ( Nelements ); } +inline int PairAtt3DArray::n_elements() const { return Nelements; } +inline int PairAtt3DArray::n () const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_att_single_array.h b/src/tools/other/mode_time_domain/3d_att_single_array.h index efe0afd6c1..d501de1d05 100644 --- a/src/tools/other/mode_time_domain/3d_att_single_array.h +++ b/src/tools/other/mode_time_domain/3d_att_single_array.h @@ -77,8 +77,8 @@ class SingleAtt3DArray { //////////////////////////////////////////////////////////////////////// -inline int SingleAtt3DArray::n_elements() const { return ( Nelements ); } -inline int SingleAtt3DArray::n () const { return ( Nelements ); } +inline int SingleAtt3DArray::n_elements() const { return Nelements; } +inline int SingleAtt3DArray::n () const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_moments.h b/src/tools/other/mode_time_domain/3d_moments.h index 603548be44..933fa4e7ad 100644 --- a/src/tools/other/mode_time_domain/3d_moments.h +++ b/src/tools/other/mode_time_domain/3d_moments.h @@ -83,7 +83,7 @@ class Mtd_3D_Moments { //////////////////////////////////////////////////////////////////////// -inline int Mtd_3D_Moments::volume() const { return ( N ); } +inline int Mtd_3D_Moments::volume() const { return N; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/fo_graph.h b/src/tools/other/mode_time_domain/fo_graph.h index 5d0ba7cd7a..ad8b5043d0 100644 --- a/src/tools/other/mode_time_domain/fo_graph.h +++ b/src/tools/other/mode_time_domain/fo_graph.h @@ -107,10 +107,10 @@ class FO_Graph { //////////////////////////////////////////////////////////////////////// -inline int FO_Graph::n_fcst () const { return ( N_fcst ); } -inline int FO_Graph::n_obs () const { return ( N_obs ); } +inline int FO_Graph::n_fcst () const { return N_fcst; } +inline int FO_Graph::n_obs () const { return N_obs ; } -inline int FO_Graph::n_nodes () const { return ( N_nodes ); } +inline int FO_Graph::n_nodes () const { return N_nodes; } inline int FO_Graph::n_total () const { return ( N_fcst + N_obs ); } diff --git a/src/tools/other/mode_time_domain/fo_node.h b/src/tools/other/mode_time_domain/fo_node.h index 5903c8be58..89eec989fb 100644 --- a/src/tools/other/mode_time_domain/fo_node.h +++ b/src/tools/other/mode_time_domain/fo_node.h @@ -90,14 +90,14 @@ class FO_Node { //////////////////////////////////////////////////////////////////////// -inline bool FO_Node::is_fcst() const { return ( IsFcst ); } -inline bool FO_Node::is_obs() const { return ( ! IsFcst ); } +inline bool FO_Node::is_fcst() const { return IsFcst; } +inline bool FO_Node::is_obs() const { return !IsFcst; } -inline bool FO_Node::is_visited() const { return ( IsVisited ); } +inline bool FO_Node::is_visited() const { return IsVisited; } -inline bool FO_Node::has_edge() const { return ( HasEdge ); } +inline bool FO_Node::has_edge() const { return HasEdge; } -inline int FO_Node::number() const { return ( Number ); } +inline int FO_Node::number() const { return Number; } inline void FO_Node::set_fcst() { IsFcst = true; } inline void FO_Node::set_obs() { IsFcst = false; } diff --git a/src/tools/other/mode_time_domain/fo_node_array.h b/src/tools/other/mode_time_domain/fo_node_array.h index d778a78e5e..72928b5046 100644 --- a/src/tools/other/mode_time_domain/fo_node_array.h +++ b/src/tools/other/mode_time_domain/fo_node_array.h @@ -74,8 +74,8 @@ class FO_Node_Array { //////////////////////////////////////////////////////////////////////// -inline int FO_Node_Array::n_elements() const { return ( Nelements ); } -inline int FO_Node_Array::n () const { return ( Nelements ); } +inline int FO_Node_Array::n_elements() const { return Nelements; } +inline int FO_Node_Array::n () const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mm_engine.h b/src/tools/other/mode_time_domain/mm_engine.h index c36850fd91..628089f281 100644 --- a/src/tools/other/mode_time_domain/mm_engine.h +++ b/src/tools/other/mode_time_domain/mm_engine.h @@ -103,10 +103,10 @@ class MM_Engine { //////////////////////////////////////////////////////////////////////// -inline int MM_Engine::n_fcst_simples () const { return ( graph.n_fcst () ); } -inline int MM_Engine::n_obs_simples () const { return ( graph.n_obs () ); } +inline int MM_Engine::n_fcst_simples () const { return graph.n_fcst(); } +inline int MM_Engine::n_obs_simples () const { return graph.n_obs (); } -inline int MM_Engine::n_composites () const { return ( N_Composites ); } +inline int MM_Engine::n_composites () const { return N_Composites; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_file_base.h b/src/tools/other/mode_time_domain/mtd_file_base.h index 92bc827f82..52407160de 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.h +++ b/src/tools/other/mode_time_domain/mtd_file_base.h @@ -164,18 +164,18 @@ class MtdFileBase { //////////////////////////////////////////////////////////////////////// -inline int MtdFileBase::nx() const { return ( Nx ); } -inline int MtdFileBase::ny() const { return ( Ny ); } -inline int MtdFileBase::nt() const { return ( Nt ); } +inline int MtdFileBase::nx() const { return Nx; } +inline int MtdFileBase::ny() const { return Ny; } +inline int MtdFileBase::nt() const { return Nt; } -inline int MtdFileBase::nxy () const { return ( Nx*Ny ); } -inline int MtdFileBase::nxyt () const { return ( Nx*Ny*Nt ); } +inline int MtdFileBase::nxy () const { return Nx*Ny ; } +inline int MtdFileBase::nxyt () const { return Nx*Ny*Nt; } -inline unixtime MtdFileBase::start_valid_time() const { return ( StartValidTime ); } +inline unixtime MtdFileBase::start_valid_time() const { return StartValidTime; } -inline int MtdFileBase::delta_t() const { return ( DeltaT ); } +inline int MtdFileBase::delta_t() const { return DeltaT; } -inline MtdFileType MtdFileBase::filetype() const { return ( FileType ); } +inline MtdFileType MtdFileBase::filetype() const { return FileType; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd_file_float.h b/src/tools/other/mode_time_domain/mtd_file_float.h index a9935531cf..cfa75b2b8d 100644 --- a/src/tools/other/mode_time_domain/mtd_file_float.h +++ b/src/tools/other/mode_time_domain/mtd_file_float.h @@ -137,21 +137,21 @@ class MtdFloatFile : public MtdFileBase { //////////////////////////////////////////////////////////////////////// -inline int MtdFloatFile::spatial_radius() const { return ( Spatial_Radius ); } +inline int MtdFloatFile::spatial_radius() const { return Spatial_Radius; } -inline int MtdFloatFile::time_beg() const { return ( TimeBeg ); } -inline int MtdFloatFile::time_end() const { return ( TimeEnd ); } +inline int MtdFloatFile::time_beg() const { return TimeBeg; } +inline int MtdFloatFile::time_end() const { return TimeEnd; } -inline float MtdFloatFile::data_min() const { return ( DataMin ); } -inline float MtdFloatFile::data_max() const { return ( DataMax ); } +inline float MtdFloatFile::data_min() const { return DataMin; } +inline float MtdFloatFile::data_max() const { return DataMax; } -inline const float * MtdFloatFile::data() const { return ( Data ); } +inline const float * MtdFloatFile::data() const { return Data; } inline float MtdFloatFile::operator()(int _x, int _y, int _t) const { -return ( Data[mtd_three_to_one(Nx, Ny, Nt, _x, _y, _t)] ); +return Data[mtd_three_to_one(Nx, Ny, Nt, _x, _y, _t)]; } diff --git a/src/tools/other/mode_time_domain/mtd_file_int.h b/src/tools/other/mode_time_domain/mtd_file_int.h index 3ab39dbaa1..f40d92fe91 100644 --- a/src/tools/other/mode_time_domain/mtd_file_int.h +++ b/src/tools/other/mode_time_domain/mtd_file_int.h @@ -164,25 +164,25 @@ class MtdIntFile : public MtdFileBase { //////////////////////////////////////////////////////////////////////// -inline int MtdIntFile::radius() const { return ( Radius ); } +inline int MtdIntFile::radius() const { return Radius; } -inline int MtdIntFile::time_beg() const { return ( TimeBeg ); } -inline int MtdIntFile::time_end() const { return ( TimeEnd ); } +inline int MtdIntFile::time_beg() const { return TimeBeg; } +inline int MtdIntFile::time_end() const { return TimeEnd; } -inline double MtdIntFile::threshold() const { return ( Threshold ); } +inline double MtdIntFile::threshold() const { return Threshold; } -inline int MtdIntFile::data_min() const { return ( DataMin ); } -inline int MtdIntFile::data_max() const { return ( DataMax ); } +inline int MtdIntFile::data_min() const { return DataMin; } +inline int MtdIntFile::data_max() const { return DataMax; } -inline int MtdIntFile::n_objects() const { return ( Nobjects ); } +inline int MtdIntFile::n_objects() const { return Nobjects; } -inline const int * MtdIntFile::data() const { return ( Data ); } +inline const int * MtdIntFile::data() const { return Data; } inline int MtdIntFile::operator()(int _x, int _y, int _t) const { -return ( Data[mtd_three_to_one(Nx, Ny, Nt, _x, _y, _t)] ); +return Data[mtd_three_to_one(Nx, Ny, Nt, _x, _y, _t)]; } diff --git a/src/tools/other/mode_time_domain/mtd_partition.h b/src/tools/other/mode_time_domain/mtd_partition.h index caf63598cf..ce8277eca4 100644 --- a/src/tools/other/mode_time_domain/mtd_partition.h +++ b/src/tools/other/mode_time_domain/mtd_partition.h @@ -92,7 +92,7 @@ class EquivalenceClass { //////////////////////////////////////////////////////////////////////// -inline int EquivalenceClass::n_elements() const { return ( Nelements ); } +inline int EquivalenceClass::n_elements() const { return Nelements; } //////////////////////////////////////////////////////////////////////// @@ -107,12 +107,12 @@ int * e = E; for (j=0; jhas(k) ) return ( true ); + if ( (*c)->has(k) ) return true; } -return ( false ); +return false; } diff --git a/src/tools/other/modis_regrid/cloudsat_swath_file.h b/src/tools/other/modis_regrid/cloudsat_swath_file.h index 9853b7c75b..b6be77c59a 100644 --- a/src/tools/other/modis_regrid/cloudsat_swath_file.h +++ b/src/tools/other/modis_regrid/cloudsat_swath_file.h @@ -81,9 +81,9 @@ class SatDimension { //////////////////////////////////////////////////////////////////////// -inline ConcatString SatDimension::name() const { return ( Name ); } +inline ConcatString SatDimension::name() const { return Name; } -inline int SatDimension::size() const { return ( Size ); } +inline int SatDimension::size() const { return Size; } //////////////////////////////////////////////////////////////////////// @@ -167,18 +167,18 @@ class SatAttribute { //////////////////////////////////////////////////////////////////////// -inline ConcatString SatAttribute::name() const { return ( Name ); } +inline ConcatString SatAttribute::name() const { return Name; } -inline int SatAttribute::number_type() const { return ( Numbertype ); } +inline int SatAttribute::number_type() const { return Numbertype; } -inline int SatAttribute::bytes() const { return ( Bytes ); } +inline int SatAttribute::bytes() const { return Bytes; } -inline int SatAttribute::n_values() const { return ( Nvalues ); } +inline int SatAttribute::n_values() const { return Nvalues; } -inline int SatAttribute::ival(int n) const { return ( Ival[n] ); } -inline double SatAttribute::dval(int n) const { return ( Dval[n] ); } +inline int SatAttribute::ival(int n) const { return Ival[n]; } +inline double SatAttribute::dval(int n) const { return Dval[n]; } -inline ConcatString SatAttribute::sval() const { return ( Sval ); } +inline ConcatString SatAttribute::sval() const { return Sval; } //////////////////////////////////////////////////////////////////////// @@ -253,12 +253,12 @@ class SwathDataField { //////////////////////////////////////////////////////////////////////// -inline ConcatString SwathDataField::name() const { return ( Name ); } +inline ConcatString SwathDataField::name() const { return Name; } -inline int SwathDataField::get_rank () const { return ( Rank ); } -inline int SwathDataField::numbertype () const { return ( Numbertype ); } +inline int SwathDataField::get_rank () const { return Rank ; } +inline int SwathDataField::numbertype () const { return Numbertype ; } -inline int SwathDataField::n_dimensions () const { return ( Ndimensions ); } +inline int SwathDataField::n_dimensions () const { return Ndimensions; } //////////////////////////////////////////////////////////////////////// @@ -374,15 +374,15 @@ class CloudsatSwath { //////////////////////////////////////////////////////////////////////// -inline ConcatString CloudsatSwath::name() const { return ( Name ); } +inline ConcatString CloudsatSwath::name() const { return Name; } -inline int CloudsatSwath::swath_id() const { return ( SwathId ); } +inline int CloudsatSwath::swath_id() const { return SwathId; } -inline int CloudsatSwath::n_data_fields() const { return ( Ndatafields ); } +inline int CloudsatSwath::n_data_fields() const { return Ndatafields; } -inline int CloudsatSwath::n_attributes () const { return ( Nattributes ); } +inline int CloudsatSwath::n_attributes () const { return Nattributes; } -inline int CloudsatSwath::n_geo_fields () const { return ( Ngeofields ); } +inline int CloudsatSwath::n_geo_fields () const { return Ngeofields; } //////////////////////////////////////////////////////////////////////// @@ -448,11 +448,11 @@ class CloudsatSwathFile { //////////////////////////////////////////////////////////////////////// -inline ConcatString CloudsatSwathFile::filename() const { return ( Filename ); } +inline ConcatString CloudsatSwathFile::filename() const { return Filename; } -inline int CloudsatSwathFile::file_id() const { return ( FileId ); } +inline int CloudsatSwathFile::file_id() const { return FileId; } -inline int CloudsatSwathFile::n_swaths() const { return ( Nswaths ); } +inline int CloudsatSwathFile::n_swaths() const { return Nswaths; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/modis_regrid/modis_file.h b/src/tools/other/modis_regrid/modis_file.h index 9ef823dfed..245ea3347f 100644 --- a/src/tools/other/modis_regrid/modis_file.h +++ b/src/tools/other/modis_regrid/modis_file.h @@ -137,12 +137,12 @@ class ModisFile { //////////////////////////////////////////////////////////////////////// -inline ConcatString ModisFile::filename() const { return ( Filename ); } +inline ConcatString ModisFile::filename() const { return Filename; } -inline int ModisFile::file_id() const { return ( FileId ); } +inline int ModisFile::file_id() const { return FileId; } -inline int ModisFile::dim0() const { return ( Dim0 ); } -inline int ModisFile::dim1() const { return ( Dim1 ); } +inline int ModisFile::dim0() const { return Dim0; } +inline int ModisFile::dim1() const { return Dim1; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index e393a17f57..a9abdf1be9 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -2032,7 +2032,7 @@ void process_pbfile(int i_pb) { if (cal_cape) { mlog << Debug(3) << "\nDerived CAPE = " << cape_count << "\tZero = " << cape_cnt_zero_values - << "\n\tnot derived: No cape inputs = " << (cape_cnt_no_levels) + << "\n\tnot derived: No cape inputs = " << cape_cnt_no_levels << "\tNo vertical levels = " << cape_cnt_surface_msgs << "\n\tfiltered: " << cape_cnt_missing_values << ", " << cape_cnt_too_big @@ -2811,7 +2811,7 @@ float derive_grib_code(int gc, float *pqtzuv, float *pqtzuv_qty, switch(gc) { // Pressure Reduced to Mean Sea Level - case(prmsl_grib_code): + case prmsl_grib_code: p = (double) pqtzuv[0]; t = (double) pqtzuv[2]; z = (double) pqtzuv[3]; @@ -2822,14 +2822,14 @@ float derive_grib_code(int gc, float *pqtzuv, float *pqtzuv_qty, break; // Humidity mixing ratio - case(mixr_grib_code): + case mixr_grib_code: q = (double) pqtzuv[1]; qty = pqtzuv_qty[1]; result = (float) convert_q_to_w(q); break; // Dewpoint temperature: derived from p and q - case(dpt_grib_code): + case dpt_grib_code: p = (double) pqtzuv[0]; q = (double) pqtzuv[1]; qty = pqtzuv_qty[0]; @@ -2840,7 +2840,7 @@ float derive_grib_code(int gc, float *pqtzuv, float *pqtzuv_qty, break; // Relative humidity - case(rh_grib_code): + case rh_grib_code: p = (double) pqtzuv[0]; q = (double) pqtzuv[1]; t = (double) pqtzuv[2]; @@ -2851,7 +2851,7 @@ float derive_grib_code(int gc, float *pqtzuv, float *pqtzuv_qty, break; // Wind direction (direction wind is coming from): derived from u and v - case(wdir_grib_code): + case wdir_grib_code: u = (double) pqtzuv[4]; v = (double) pqtzuv[5]; qty = pqtzuv_qty[4]; @@ -2860,7 +2860,7 @@ float derive_grib_code(int gc, float *pqtzuv, float *pqtzuv_qty, break; // Wind speed: derived from u and v - case(wind_grib_code): + case wind_grib_code: u = (double) pqtzuv[4]; v = (double) pqtzuv[5]; qty = pqtzuv_qty[4]; diff --git a/src/tools/other/wwmca_tool/af_file.h b/src/tools/other/wwmca_tool/af_file.h index dbcbc0bdf3..eba9dfff68 100644 --- a/src/tools/other/wwmca_tool/af_file.h +++ b/src/tools/other/wwmca_tool/af_file.h @@ -93,12 +93,12 @@ class AFDataFile { //////////////////////////////////////////////////////////////////////// -inline int AFDataFile::nx() const { return ( af_nx ); } -inline int AFDataFile::ny() const { return ( af_ny ); } +inline int AFDataFile::nx() const { return af_nx; } +inline int AFDataFile::ny() const { return af_ny; } -inline unixtime AFDataFile::init () const { return ( Init ); } -inline unixtime AFDataFile::valid () const { return ( Valid ); } -inline char AFDataFile::hemisphere () const { return ( Hemisphere ); } +inline unixtime AFDataFile::init () const { return Init; } +inline unixtime AFDataFile::valid () const { return Valid; } +inline char AFDataFile::hemisphere () const { return Hemisphere; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/interp_base.h b/src/tools/other/wwmca_tool/interp_base.h index 885623521d..52f7015efe 100644 --- a/src/tools/other/wwmca_tool/interp_base.h +++ b/src/tools/other/wwmca_tool/interp_base.h @@ -119,9 +119,9 @@ class Interpolator { //////////////////////////////////////////////////////////////////////// -inline int Interpolator::width() const { return ( Width ); } +inline int Interpolator::width() const { return Width; } -inline int Interpolator::wm1o2() const { return ( Wm1o2 ); } +inline int Interpolator::wm1o2() const { return Wm1o2; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/wwmca_tool/wwmca_ref.h b/src/tools/other/wwmca_tool/wwmca_ref.h index 9cbee01559..3006612804 100644 --- a/src/tools/other/wwmca_tool/wwmca_ref.h +++ b/src/tools/other/wwmca_tool/wwmca_ref.h @@ -134,7 +134,7 @@ class WwmcaRegridder { //////////////////////////////////////////////////////////////////////// -inline GridHemisphere WwmcaRegridder::hemi() const { return ( Hemi ); } +inline GridHemisphere WwmcaRegridder::hemi() const { return Hemi; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_dland/tc_poly.h b/src/tools/tc_utils/tc_dland/tc_poly.h index 55cb053e16..db7d654eb8 100644 --- a/src/tools/tc_utils/tc_dland/tc_poly.h +++ b/src/tools/tc_utils/tc_dland/tc_poly.h @@ -65,7 +65,7 @@ class TCPoly { //////////////////////////////////////////////////////////////////////// -inline ConcatString TCPoly::name() const { return(Name); } +inline ConcatString TCPoly::name() const { return Name; } //////////////////////////////////////////////////////////////////////// @@ -110,7 +110,7 @@ class TCPolyArray { //////////////////////////////////////////////////////////////////////// -inline int TCPolyArray::n_polys() const { return(NPolys); } +inline int TCPolyArray::n_polys() const { return NPolys; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index 04e0b0c408..7c6a44c16e 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -1750,18 +1750,18 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { // 2x2 contingency table output: // 1 header + 2 vx methods * # models * # filters - case(i_fho): - case(i_ctc): - case(i_cts): + case i_fho: + case i_ctc: + case i_cts: n_rows = 1 + 2 * n_model * conf_info.n_vx(); break; // Nx2 probabilistic contingency table output: // 1 header + 1 vx method * # models * # probs * # filters - case(i_pct): - case(i_pstd): - case(i_pjc): - case(i_prc): + case i_pct: + case i_pstd: + case i_pjc: + case i_prc: n_rows = 1 + n_model * max_n_prob * conf_info.n_vx(); break; @@ -1775,19 +1775,19 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { // Compute the number of columns for this line type switch(i) { - case(i_pct): + case i_pct: n_cols = get_n_pct_columns(n_prob) + n_header_columns + 1; break; - case(i_pstd): + case i_pstd: n_cols = get_n_pstd_columns(n_prob) + n_header_columns + 1; break; - case(i_pjc): + case i_pjc: n_cols = get_n_pjc_columns(n_prob) + n_header_columns + 1; break; - case(i_prc): + case i_prc: n_cols = get_n_prc_columns(n_prob) + n_header_columns + 1; break; @@ -1823,19 +1823,19 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { // Write header row switch(i) { - case(i_pct): + case i_pct: write_pct_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pstd): + case i_pstd: write_pstd_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_pjc): + case i_pjc: write_pjc_header_row(1, n_prob, txt_at[i], 0, 0); break; - case(i_prc): + case i_prc: write_prc_header_row(1, n_prob, txt_at[i], 0, 0); break; diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.h b/src/tools/tc_utils/tc_stat/tc_stat_job.h index ba93072c16..8fa68cad5d 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.h +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.h @@ -381,7 +381,7 @@ class TCStatJob { //////////////////////////////////////////////////////////////////////// inline void TCStatJob::set_precision (int p) { Precision = p; return; } -inline int TCStatJob::get_precision () const { return(Precision); } +inline int TCStatJob::get_precision () const { return Precision; } //////////////////////////////////////////////////////////////////////// From 10a449e6d83b7b719be70abece34466d35ea218a Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Tue, 2 Jul 2024 12:12:38 -0600 Subject: [PATCH 093/114] Fix release checksum action (#2929) --- .github/workflows/release-checksum.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-checksum.yml b/.github/workflows/release-checksum.yml index 683f258a6c..55d8b41cb0 100644 --- a/.github/workflows/release-checksum.yml +++ b/.github/workflows/release-checksum.yml @@ -9,6 +9,6 @@ jobs: add-checksum: runs-on: ubuntu-latest steps: - - uses: dtcenter/metplus-action-release-checksum@v1 + - uses: dtcenter/metplus-action-release-checksum@v2 with: token: ${{ secrets.METPLUS_BOT_TOKEN }} From fddc39fd8a22e81e3a0bd9831c6057e9eb1e8dfc Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 9 Jul 2024 14:45:54 -0600 Subject: [PATCH 094/114] Feature 2857 tripolar coordinates (#2928) * #2857 Added MetNcCFDataFile::build_grid_from_lat_lon_vars * #2857 Added NcCfFile::build_grid_from_lat_lon_vars * #2857 Check the coordinates attribute to find latitude, longitude, and time variables * #2857 Get the lat/lon variables from coordinates attribute if exists * #2857 Added two constants * #2857 Deleted debug messages * #2857 Added lat_vname and lon_vname for var_name_map * #2857 Added two unit tests: point2grid_sea_ice_tripolar and point2grid_sea_ice_tripolar_config * #2857 Initial release * #2857 Correct dictinary to get file_type * #2857 DO not check the time variable for point2grid * #2857 Added point2grid_tripolar_rtofs --------- Co-authored-by: Howard Soh --- docs/Users_Guide/reformat_point.rst | 12 +- .../test_unit/config/Point2GridConfig_lat_lon | 4 + internal/test_unit/xml/unit_point2grid.xml | 73 ++++++++ src/basic/vx_config/config_constants.h | 2 + src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc | 8 + src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h | 3 + src/libcode/vx_data2d_nc_cf/nc_cf_file.cc | 33 +++- src/libcode/vx_data2d_nc_cf/nc_cf_file.h | 18 +- src/libcode/vx_nc_util/nc_utils.cc | 168 ++++++++++++------ src/tools/other/point2grid/point2grid.cc | 124 ++++++++++++- 10 files changed, 362 insertions(+), 83 deletions(-) create mode 100644 internal/test_unit/config/Point2GridConfig_lat_lon diff --git a/docs/Users_Guide/reformat_point.rst b/docs/Users_Guide/reformat_point.rst index ec09fa3f83..fb0a7b2766 100644 --- a/docs/Users_Guide/reformat_point.rst +++ b/docs/Users_Guide/reformat_point.rst @@ -1153,7 +1153,7 @@ point2grid Configuration File The default configuration file for the point2grid tool named **Point2GridConfig_default** can be found in the installed *share/met/config* directory. It is recommended that users make a copy of this file prior to modifying its contents. -The point2grid configuration file is optional and only necessary when defining the variable name instead of GRIB code or filtering by time. The contents of the default MADIS2NC configuration file are described below. +The point2grid configuration file is optional and only necessary when defining the variable name instead of GRIB code or filtering by time. The contents of the default point2grid configuration file are described below. _____________________ @@ -1194,6 +1194,16 @@ The configuration option listed above is common to many MET tools and are descri This entry is an array of dictionaries, each containing a **GRIB code** string and mathcing **variable name** string which define a mapping of GRIB code to the output variable names. +.. code-block:: none + + var_name_map = [ + ... + { key = "lat_vname"; val = "NLAT"; }, + { key = "lon_vname"; val = "NLON"; } + ... + ] + +The latitude and longitude variables for NetCDF input can be overridden by the configurations. There are two special keys, **lat_vname** and **lon_vname** which are applied to the NetCDF input, not for GRIB code. Point NetCDF to ASCII Python Utility ==================================== diff --git a/internal/test_unit/config/Point2GridConfig_lat_lon b/internal/test_unit/config/Point2GridConfig_lat_lon new file mode 100644 index 0000000000..80eee8fef6 --- /dev/null +++ b/internal/test_unit/config/Point2GridConfig_lat_lon @@ -0,0 +1,4 @@ +var_name_map = [ + { key = "lat_vname"; val = "NLAT"; }, + { key = "lon_vname"; val = "NLON"; } +]; diff --git a/internal/test_unit/xml/unit_point2grid.xml b/internal/test_unit/xml/unit_point2grid.xml index 213ffcf756..aa9a1d0410 100644 --- a/internal/test_unit/xml/unit_point2grid.xml +++ b/internal/test_unit/xml/unit_point2grid.xml @@ -249,6 +249,78 @@ + + &MET_BIN;/point2grid + + MET_TMP_DIR &OUTPUT_DIR;/point2grid + + \ + &DATA_DIR_OBS;/point_obs/iceh.2018-01-03.c00.small.nc \ + G171 \ + &OUTPUT_DIR;/point2grid/point2grid_sea_ice.nc \ + -field 'name="uvel_d"; level="(0,*,*)";' -field 'name="hi_d"; level="(0,*,*)";' \ + -v 1 + + + &OUTPUT_DIR;/point2grid/point2grid_sea_ice.nc + + + + + &MET_BIN;/point2grid + + MET_TMP_DIR &OUTPUT_DIR;/point2grid + + \ + &DATA_DIR_OBS;/point_obs/iceh.2018-01-03.c00.small.nc \ + G171 \ + &OUTPUT_DIR;/point2grid/point2grid_sea_ice_snow.nc \ + -config &CONFIG_DIR;/Point2GridConfig_lat_lon \ + -field 'name="hs_d_without_att"; level="(0,*,*)";' \ + -v 1 + + + &OUTPUT_DIR;/point2grid/point2grid_sea_ice_snow.nc + + + + + + + &MET_BIN;/point2grid + + MET_TMP_DIR &OUTPUT_DIR;/point2grid + + \ + &DATA_DIR_OBS;/point_obs/rtofs_glo_2ds_f006_ice_coverage.nc \ + "latlon 720 360 -80. -60. 0.5 0.5" \ + &OUTPUT_DIR;/point2grid/point2grid_rtofs_ice_coverage.nc \ + -field 'name="ice_coverage"; level="(0,*,*)";' \ + -v 1 + + + &OUTPUT_DIR;/point2grid/point2grid_rtofs_ice_coverage.nc + + + &MET_BIN;/point2grid @@ -283,4 +355,5 @@ &OUTPUT_DIR;/point2grid/point2grid_2D_time_west_bering_sea.nc + diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index 7640873bc3..d7f2453689 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -612,6 +612,8 @@ static const char conf_key_mask_sid[] = "mask.sid"; static const char conf_key_mask_llpnt[] = "mask.llpnt"; static const char conf_key_lat_thresh[] = "lat_thresh"; static const char conf_key_lon_thresh[] = "lon_thresh"; +static const char conf_key_lat_vname[] = "lat_vname"; +static const char conf_key_lon_vname[] = "lon_vname"; static const char conf_key_ci_alpha[] = "ci_alpha"; static const char conf_key_time_summary[] = "time_summary"; static const char conf_key_flag[] = "flag"; diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc index 1a11af2b0d..8c4373a62c 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc @@ -673,4 +673,12 @@ long MetNcCFDataFile::convert_value_to_offset(double z_value, string z_dim_name) return z_offset; } +//////////////////////////////////////////////////////////////////////// + +Grid MetNcCFDataFile::build_grid_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, + const long lat_counts, const long lon_counts) { + return (nullptr != _file) ? _file->build_grid_from_lat_lon_vars(lat_var, lon_var, lat_counts, lon_counts) : grid(); +} + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h index a80b176c3a..05e68fc54f 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h @@ -102,6 +102,9 @@ class MetNcCFDataFile : public Met2dDataFile { void dump(std::ostream &, int = 0) const; + Grid build_grid_from_lat_lon_vars(netCDF::NcVar *lat_var, netCDF::NcVar *lon_var, + const long lat_counts, const long lon_counts); + }; diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index 61c5be7451..3038965ab6 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -914,7 +914,7 @@ double NcCfFile::getData(NcVar * var, const LongArray & a) const if (!status) { - mlog << Error << "\nNcCfFile::getData(NcVar *, const LongArray &) const -> " + mlog << Error << "\n" << method_name << "bad status for var->get()\n\n"; exit(1); } @@ -1091,8 +1091,8 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const plane.set(value, x, y_offset); - } // for x - } // for y + } /* for y */ + } /* for x */ } else { for (int x = 0; x< nx; ++x) { @@ -1108,8 +1108,8 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const plane.set(value, x, y_offset); - } // for y - } // for x + } /* for y */ + } /* for x */ } delete [] d; @@ -1130,7 +1130,7 @@ bool NcCfFile::getData(const char *var_name, NcVarInfo *&info) const { info = find_var_name(var_name); - if (info == 0) + if (info == nullptr) return false; bool found = getData(info->var, a, plane); @@ -1475,6 +1475,25 @@ void NcCfFile::read_netcdf_grid() //////////////////////////////////////////////////////////////////////// +Grid NcCfFile::build_grid_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, + const long lat_counts, const long lon_counts) { + Grid grid_ll; + bool swap_to_north; + LatLonData data = get_data_from_lat_lon_vars(lat_var, lon_var, + lat_counts, lon_counts, + swap_to_north); + + data.dump(); + + grid_ll.set(data); // resets swap_to_north to false + if (swap_to_north) grid_ll.set_swap_to_north(true); + return grid_ll; +} + + +//////////////////////////////////////////////////////////////////////// + + void NcCfFile::get_grid_from_grid_mapping(const NcVarAtt *grid_mapping_att) { static const string method_name = "NcCfFile::get_grid_from_grid_mapping()"; @@ -3180,7 +3199,7 @@ bool NcCfFile::get_grid_from_dimensions() } if (!has_var(_ncFile, dim_name.c_str())) { - mlog << Debug(4) << method_name << " -> " << "The coordinate variable \"" + mlog << Debug(6) << method_name << " -> " << "The coordinate variable \"" << _dims[dim_num]->getName() << "\" does not exist.\n"; continue; } diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.h b/src/libcode/vx_data2d_nc_cf/nc_cf_file.h index d3e50a30d0..5e29896459 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.h +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.h @@ -61,7 +61,7 @@ class NcCfFile { return GET_NC_SIZE_P(_xDim); } - + int getNy() const { if (_yDim == 0) @@ -69,9 +69,10 @@ class NcCfFile { return GET_NC_SIZE_P(_yDim); } - + NcVarInfo *get_time_var_info() const { return _time_var_info; } - + + // // time // @@ -93,6 +94,7 @@ class NcCfFile { int Nvars; NcVarInfo * Var; // allocated + StringArray coord_var_names; // // Grid @@ -110,13 +112,15 @@ class NcCfFile { bool getData(const char *, const LongArray &, DataPlane &, NcVarInfo *&) const; + Grid build_grid_from_lat_lon_vars(netCDF::NcVar *lat_var, netCDF::NcVar *lon_var, + const long lat_counts, const long lon_counts); NcVarInfo* find_var_name(const char * var_name) const; NcVarInfo* find_var_by_dim_name(const char *dim_name) const; private: static const double DELTA_TOLERANCE; - + netCDF::NcFile * _ncFile; // allocated // @@ -142,7 +146,7 @@ class NcCfFile { netCDF::NcVar *_xCoordVar; netCDF::NcVar *_yCoordVar; NcVarInfo *_time_var_info; - + void init_from_scratch(); NcCfFile(const NcCfFile &); @@ -164,7 +168,7 @@ class NcCfFile { void read_netcdf_grid(); void get_grid_from_grid_mapping(const netCDF::NcVarAtt *grid_mapping_att); - + void get_grid_mapping_albers_conical_equal_area(const netCDF::NcVar *grid_mapping_var); void get_grid_mapping_azimuthal_equidistant(const netCDF::NcVar *grid_mapping_var); void get_grid_mapping_lambert_azimuthal_equal_area(const netCDF::NcVar *grid_mapping_var); @@ -179,7 +183,7 @@ class NcCfFile { void get_grid_mapping_transverse_mercator(const netCDF::NcVar *grid_mapping_var); void get_grid_mapping_vertical_perspective(const netCDF::NcVar *grid_mapping_var); void get_grid_mapping_geostationary(const netCDF::NcVar *grid_mapping_var); - + bool get_grid_from_coordinates(const netCDF::NcVar *data_var); bool get_grid_from_dimensions(); void get_grid_from_lat_lon_vars(netCDF::NcVar *lat_var, netCDF::NcVar *lon_var, diff --git a/src/libcode/vx_nc_util/nc_utils.cc b/src/libcode/vx_nc_util/nc_utils.cc index 3698dbe41a..f773d5178b 100644 --- a/src/libcode/vx_nc_util/nc_utils.cc +++ b/src/libcode/vx_nc_util/nc_utils.cc @@ -887,14 +887,12 @@ void add_att(NcVar *var, const string &att_name, const double att_val) { int get_var_names(NcFile *nc, StringArray *var_names) { - NcVar var; int i = 0; int var_count = nc->getVarCount(); multimap mapVar = GET_NC_VARS_P(nc); - for (multimap::iterator it_var = mapVar.begin(); - it_var != mapVar.end(); ++it_var) { - var = (*it_var).second; + for (auto &kv : mapVar) { + NcVar var = kv.second; var_names->add(var.getName()); i++; } @@ -3323,22 +3321,21 @@ bool is_nc_name_time(const ConcatString name) { //////////////////////////////////////////////////////////////////////// bool is_nc_attr_lat(const ConcatString name) { - bool is_latitude = (is_nc_name_lat(name) || name == "x" || name == "X"); + bool is_latitude = (is_nc_name_lat(name) || name == "y" || name == "Y"); return is_latitude; } //////////////////////////////////////////////////////////////////////// bool is_nc_attr_lon(const ConcatString name) { - bool is_longitude = (is_nc_name_lon(name) || name == "y" || name == "Y"); + bool is_longitude = (is_nc_name_lon(name) || name == "x" || name == "X"); return is_longitude; } //////////////////////////////////////////////////////////////////////// bool is_nc_attr_time(const ConcatString name) { - bool is_time = (is_nc_name_time(name) || name == "T"); - return is_time; + return is_nc_name_time(name); } //////////////////////////////////////////////////////////////////////// @@ -3346,31 +3343,49 @@ bool is_nc_attr_time(const ConcatString name) { NcVar get_nc_var_lat(const NcFile *nc) { NcVar var; bool found = false; + int max_dim_cnt = 0; + ConcatString att_val; + ConcatString coordinates_att; multimap mapVar = GET_NC_VARS_P(nc); static const char *method_name = "get_nc_var_lat() "; - for (multimap::iterator it_var = mapVar.begin(); - it_var != mapVar.end(); ++it_var) { - ConcatString name = (*it_var).first; - //if (is_nc_name_lat(name)) found = true; - if (get_var_standard_name(&(*it_var).second, name)) { - if (is_nc_name_lat(name)) found = true; + for (const auto &kv : mapVar) { + ConcatString name = kv.first; + if (is_nc_name_lat(name)) found = true; + if (!found && get_var_standard_name(&kv.second, att_val)) { + if (is_nc_name_lat(att_val)) found = true; } - if (!found && get_var_units(&(*it_var).second, name)) { - if (is_nc_unit_latitude(name.c_str())) { - if (get_nc_att_value(&(*it_var).second, axis_att_name, name)) { - if (is_nc_attr_lat(name)) found = true; - } - else if (get_nc_att_value(&(*it_var).second, - coordinate_axis_type_att_name, name)) { - if (is_nc_attr_lat(name)) found = true; - } + if (!found && get_var_units(&kv.second, att_val) + && is_nc_unit_latitude(att_val.c_str())) { + if (get_nc_att_value(&kv.second, axis_att_name, att_val)) { + if (is_nc_attr_lat(att_val)) found = true; + } + else if (get_nc_att_value(&kv.second, + coordinate_axis_type_att_name, att_val)) { + if (is_nc_attr_lat(att_val)) found = true; } } if (found) { - var = (*it_var).second; + var = kv.second; break; } + int dim_count = GET_NC_DIM_COUNT(kv.second); + if (dim_count > max_dim_cnt) { + max_dim_cnt = dim_count; + if (get_nc_att_value(&kv.second, coordinates_att_name, att_val)) coordinates_att = att_val; + } + } + + if (!found && !coordinates_att.empty()) { + StringArray coord_names = coordinates_att.split(" "); + for (int i=0; i< coord_names.n(); i++) { + NcVar var_lat = get_nc_var((NcFile *)nc, coord_names[i].c_str()); + if (get_var_units(&var_lat, att_val) && is_nc_unit_latitude(att_val.c_str())) { + found = true; + var = var_lat; + break; + } + } } if (found) { @@ -3388,31 +3403,50 @@ NcVar get_nc_var_lat(const NcFile *nc) { NcVar get_nc_var_lon(const NcFile *nc) { NcVar var; bool found = false; + int max_dim_cnt = 0; + ConcatString att_val; + ConcatString coordinates_att; multimap mapVar = GET_NC_VARS_P(nc); static const char *method_name = "get_nc_var_lon() "; - for (multimap::iterator it_var = mapVar.begin(); - it_var != mapVar.end(); ++it_var) { - ConcatString name = (*it_var).first; - //if (is_nc_name_lon(name)) found = true; - if (get_var_standard_name(&(*it_var).second, name)) { - if (is_nc_name_lon(name)) found = true; + for (const auto &kv : mapVar) { + ConcatString name = kv.first; + if (is_nc_name_lon(name)) found = true; + if (!found && get_var_standard_name(&kv.second, att_val)) { + if (is_nc_name_lon(att_val)) found = true; } - if (!found && get_var_units(&(*it_var).second, name)) { - if (is_nc_unit_longitude(name.c_str())) { - if (get_nc_att_value(&(*it_var).second, axis_att_name, name)) { - if (is_nc_attr_lon(name)) found = true; - } - else if (get_nc_att_value(&(*it_var).second, - coordinate_axis_type_att_name, name)) { - if (is_nc_attr_lon(name)) found = true; - } + if (!found && get_var_units(&kv.second, att_val) + && is_nc_unit_longitude(att_val.c_str())) { + if (get_nc_att_value(&kv.second, axis_att_name, att_val)) { + if (is_nc_attr_lon(att_val)) found = true; + } + else if (get_nc_att_value(&kv.second, + coordinate_axis_type_att_name, att_val)) { + if (is_nc_attr_lon(att_val)) found = true; } } if (found) { - var = (*it_var).second; + var = kv.second; break; } + + int dim_count = GET_NC_DIM_COUNT(kv.second); + if (dim_count > max_dim_cnt) { + max_dim_cnt = dim_count; + if (get_nc_att_value(&kv.second, coordinates_att_name, att_val)) coordinates_att = att_val; + } + } + + if (!found && !coordinates_att.empty()) { + StringArray coord_names = coordinates_att.split(" "); + for (int i=0; i< coord_names.n(); i++) { + NcVar var_lon = get_nc_var((NcFile *)nc, coord_names[i].c_str()); + if (get_var_units(&var_lon, att_val) && is_nc_unit_longitude(att_val.c_str())) { + found = true; + var = var_lon; + break; + } + } } if (found) { @@ -3430,33 +3464,51 @@ NcVar get_nc_var_lon(const NcFile *nc) { NcVar get_nc_var_time(const NcFile *nc) { NcVar var; bool found = false; + int max_dim_cnt = 0; + ConcatString att_val; + ConcatString coordinates_att; multimap mapVar = GET_NC_VARS_P(nc); static const char *method_name = "get_nc_var_time() "; - for (multimap::iterator it_var = mapVar.begin(); - it_var != mapVar.end(); ++it_var) { - ConcatString name = (*it_var).first; - //if (is_nc_name_time(name)) found = true; - if (get_var_standard_name(&(*it_var).second, name)) { - if (is_nc_name_time(name)) found = true; + for (auto &kv : mapVar) { + ConcatString name = kv.first; + if (!found && is_nc_name_time(name)) found = true; + if (get_var_standard_name(&kv.second, att_val)) { + if (is_nc_name_time(att_val)) found = true; mlog << Debug(7) << method_name << "checked variable \"" << name << "\" is_time: " << found << "\n"; } - if (!found && get_var_units(&(*it_var).second, name)) { - if (is_nc_unit_time(name.c_str())) { - if (get_nc_att_value(&(*it_var).second, axis_att_name, name)) { - if (is_nc_attr_time(name)) found = true; - } - else if (get_nc_att_value(&(*it_var).second, - coordinate_axis_type_att_name, name)) { - if (is_nc_attr_time(name)) found = true; - } + if (!found && get_var_units(&kv.second, att_val) + && is_nc_unit_time(att_val.c_str())) { + if (get_nc_att_value(&kv.second, axis_att_name, att_val)) { + if (is_nc_attr_time(att_val)) found = true; + } + else if (get_nc_att_value(&kv.second, + coordinate_axis_type_att_name, att_val)) { + if (is_nc_attr_time(att_val)) found = true; } } if (found) { - var = (*it_var).second; + var = kv.second; break; } + int dim_count = GET_NC_DIM_COUNT(kv.second); + if (dim_count > max_dim_cnt) { + max_dim_cnt = dim_count; + if (get_nc_att_value(&kv.second, coordinates_att_name, att_val)) coordinates_att = att_val; + } + } + + if (!found && !coordinates_att.empty()) { + StringArray coord_names = coordinates_att.split(" "); + for (int i=0; i< coord_names.n(); i++) { + NcVar var_time = get_nc_var((NcFile *)nc, coord_names[i].c_str()); + if (get_var_units(&var_time, att_val) && is_nc_unit_time(att_val.c_str())) { + found = true; + var = var_time; + break; + } + } } if (found) { @@ -3494,10 +3546,8 @@ NcFile *open_ncfile(const char * nc_name, bool write) { // Implement the old API var->num_vals() int get_data_size(NcVar *var) { - int dimCount = 0; int data_size = 1; - - dimCount = var->getDimCount(); + int dimCount = var->getDimCount(); for (int i=0; igetDim(i).getSize(); } diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 2b067ffdf4..de7d284fc1 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -41,6 +41,7 @@ #include "vx_regrid.h" #include "vx_util.h" #include "vx_statistics.h" +#include "var_info_nc_cf.h" #include "nc_obs_util.h" #include "nc_point_obs_in.h" @@ -170,6 +171,7 @@ static void set_gaussian_dx(const StringArray &); static void set_gaussian_radius(const StringArray &); static unixtime compute_unixtime(NcVar *time_var, unixtime var_value); +void clear_cell_mapping(IntArray *cell_mapping); static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, NcVar var_lat, NcVar var_lon, bool *skip_times); static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, @@ -390,7 +392,7 @@ static void process_data_file() { if (compress_level < 0) compress_level = config.nc_compression(); // Get the gridded file type from config string, if present - ftype = parse_conf_file_type(&config); + ftype = parse_conf_file_type(&conf_info.conf); // Open the input file mlog << Debug(1) << "Reading data file: " << InputFilename << "\n"; @@ -422,7 +424,6 @@ static void process_data_file() { // Get the obs type before opening NetCDF obs_type = get_obs_type(nc_in); goes_data = (obs_type == TYPE_GOES || obs_type == TYPE_GOES_ADP); - if (obs_type == TYPE_NCCF) setenv(nc_att_met_point_nccf, "yes", 1); // Read the input data file @@ -943,8 +944,9 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI } if (cellMapping) { - for (idx=0; idx<(nx*ny); idx++) cellMapping[idx].clear(); + clear_cell_mapping(cellMapping); delete [] cellMapping; + cellMapping = (IntArray *) nullptr; } cellMapping = new IntArray[nx * ny]; if( get_grid_mapping(to_grid, cellMapping, var_index_array, @@ -1139,6 +1141,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI } // end for i if (cellMapping) { + clear_cell_mapping(cellMapping); delete [] cellMapping; cellMapping = (IntArray *) nullptr; } @@ -1237,8 +1240,58 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, int from_size = fr_grid.nx() * fr_grid.ny(); static const char *method_name = "process_point_nccf_file() -> "; - NcVar var_lat = get_nc_var_lat(nc_in); - NcVar var_lon = get_nc_var_lon(nc_in); + NcVar var_lat; + NcVar var_lon; + bool user_defined_latlon = false; + ConcatString lat_vname = conf_info.get_var_name(conf_key_lat_vname); + ConcatString lon_vname = conf_info.get_var_name(conf_key_lon_vname); + + if (lat_vname != conf_key_lat_vname && lon_vname != conf_key_lon_vname) { + if (lat_vname != conf_key_lat_vname && has_var(nc_in, lat_vname.c_str())) { + var_lat = get_nc_var(nc_in, lat_vname.c_str()); + } + if (lon_vname != conf_key_lon_vname && has_var(nc_in, lon_vname.c_str())) { + var_lon = get_nc_var(nc_in, lon_vname.c_str()); + } + if (IS_INVALID_NC(var_lat)) { + mlog << Error << "\n" << method_name + << "can not find the latitude variable (" << lat_vname + << ") from the config file (" << config_filename << ").\n\n"; + exit(1); + } + else if (IS_INVALID_NC(var_lon)) { + mlog << Error << "\n" << method_name + << "can not find the longitude variable (" << lon_vname + << ") from the config file (" << config_filename << ").\n\n"; + exit(1); + } + else user_defined_latlon = true; + } + // Find lat/lon variables from the coordinates attribue + if (0 < FieldSA.n() && !user_defined_latlon) { + ConcatString coordinates_value; + VarInfoNcCF var_info = VarInfoNcCF(*(VarInfoNcCF *)vinfo); + // Initialize + var_info.clear(); + // Populate the VarInfo object using the config string + config.read_string(FieldSA[0].c_str()); + var_info.set_dict(config); + NcVar var_data = get_nc_var(nc_in, var_info.name().c_str()); + if (get_nc_att_value(&var_data, coordinates_att_name, coordinates_value)) { + StringArray sa = coordinates_value.split(" "); + ConcatString units; + for (int idx=0; idxset_dict(config); + NcVar var_data = get_nc_var(nc_in, vinfo->name().c_str()); + ConcatString coordinates_value; + if (!user_defined_latlon && get_nc_att_value(&var_data, coordinates_att_name, coordinates_value)) { + StringArray sa = coordinates_value.split(" "); + int count = sa.n_elements(); + if (count >= 2) { + bool match_lat = false; + bool match_lon = false; + for (int idx=0; idx= 2) { @@ -1334,7 +1425,6 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, write_nc(to_dp, to_grid, vinfo, vname.c_str()); NcVar to_var = get_nc_var(nc_out, vname.c_str()); - NcVar var_data = get_nc_var(nc_in, vinfo->name().c_str()); bool has_prob_thresh = !prob_cat_thresh.check(bad_data_double); if (has_prob_thresh || do_gaussian_filter) { @@ -1374,8 +1464,15 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, } } + if (nullptr != var_cell_mapping) { + clear_cell_mapping(var_cell_mapping); + delete [] var_cell_mapping; + var_cell_mapping = nullptr; + } + } // end for i + clear_cell_mapping(cellMapping); delete [] cellMapping; cellMapping = (IntArray *) nullptr; if( 0 < filtered_by_time ) { @@ -1397,7 +1494,7 @@ static void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, Grid to_grid, IntArray *cellMapping) { int to_cell_cnt = 0; - clock_t start_clock = clock(); + clock_t start_clock = clock(); Grid fr_grid = fr_mtddf->grid(); static const char *method_name = "regrid_nc_variable() -> "; @@ -1801,6 +1898,7 @@ static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, } delete nc_adp; nc_adp = nullptr; + clear_cell_mapping(cellMapping); delete [] cellMapping; cellMapping = (IntArray *) nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; @@ -1866,6 +1964,14 @@ GOES_QC compute_adp_qc_flag(int adp_qc, int shift_bits) { } +//////////////////////////////////////////////////////////////////////// + +void clear_cell_mapping(IntArray *cell_mapping) { + if (nullptr != cell_mapping) { + for (int idx=0; idxn(); idx++) cell_mapping[idx].clear(); + } +} + //////////////////////////////////////////////////////////////////////// static unixtime compute_unixtime(NcVar *time_var, unixtime var_value) { @@ -2838,7 +2944,7 @@ static bool has_lat_lon_vars(const NcFile *nc) { << " has_lat_var: " << has_lat_var << ", has_lon_var: " << has_lon_var << ", has_time_var: " << has_time_var << "\n"; - return (has_lat_var && has_lon_var && has_time_var); + return (has_lat_var && has_lon_var); } //////////////////////////////////////////////////////////////////////// From dcd500ad37ed92121834320bf0e6dc27d51be522 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Wed, 10 Jul 2024 11:08:58 -0600 Subject: [PATCH 095/114] Feature 2932 v12.0.0-beta5 (#2933) * Per #2932, updating version and release notes * Per #2932, updating date on release notes * Per #2932, fixed formatting and links * Update release-notes.rst * Update release-notes.rst Removing inline backticks since they do not format the way I expected, especially when put inside bolded release notes. --------- Co-authored-by: John Halley Gotway --- docs/Users_Guide/release-notes.rst | 34 ++++++++++++++++++++++++++++++ docs/conf.py | 4 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/Users_Guide/release-notes.rst b/docs/Users_Guide/release-notes.rst index c8f2fb0f2c..8bf26a49a4 100644 --- a/docs/Users_Guide/release-notes.rst +++ b/docs/Users_Guide/release-notes.rst @@ -9,6 +9,40 @@ When applicable, release notes are followed by the GitHub issue number which des enhancement, or new feature (`MET GitHub issues `_). Important issues are listed **in bold** for emphasis. +MET Version 12.0.0-beta5 Release Notes (20240710) +------------------------------------------------- + + .. dropdown:: Repository, build, and test + + * Reimplement and enhance the Perl-based (unit.pl) unit test control script in Python (`#2717 `_). + * Update compilation script and configuration files as needed for supported platforms (`#2753 `_). + * Update tag used for the release checksum action (`#2929 `_). + + .. dropdown:: Bugfixes + + * Bugfix (METbaseimage): Fix the environment to correct the ncdump runtime linker error (`METbaseimage#24 `_). + * Bugfix: Fix the Grid-Stat configuration file to support the MET_SEEPS_GRID_CLIMO_NAME option (`#2601 `_). + * **Bugfix: Fix TC-RMW to correct the tangential and radial wind computations** (`#2841 `_). + * Bugfix: Fix Ensemble-Stat's handling of climo data when verifying ensemble-derived probabilities (`#2856 `_). + * **Bugfix: Fix Point2Grid's handling of the -qc option for ADP input files** (`#2867 `_). + * Bugfix: Bugfix: Fix Stat-Analysis errors for jobs using the -dump_row option and the -line_type option with VCNT, RPS, DMAP, or SSIDX (`#2888 `_). + * Bugfix: Fix inconsistent handling of point observation valid times processed through Python embedding (`#2897 `_). + + .. dropdown:: Enhancements + + * **Add new wind direction verification statistics for RMSE, Bias, and MAE** (`#2395 `_). + * Document UGRID configuration options added to Point-Stat and Grid-Stat (`#2748 `_). + * **Add new -ugrid_config command line option for unstructured grid inputs to Grid-Stat and Point-Stat** (`#2842 `_). + * Enhance Point2Grid to support modified quality control settings for smoke/dust AOD data in GOES-16/17 as of April 16, 2024 (`#2853 `_). + * **Enhance Point2Grid to support a wider variety of input tripolar datasets** (`#2857 `_). + * Test NOAA Unstructured grids in MET-12.0.0 (`#2860 `_). + * Enhance Ensemble-Stat and Gen-Ens-Prod to omit warning messages for the MISSING keyword (`#2870 `_). + * Refine Point-Stat Warning message about fcst/obs level mismatch (`#2873 `_). + * Add new Python functionality to convert MET NetCDF observation data to a Pandas DataFrame (`#2877 `_). + * Enhance PCP-Combine to allow missing data (`#2883 `_). + * Enhance TC-Stat to support the -set_hdr job command option (`#2911 `_). + * Refine ERROR messages written by PB2NC (`#2912 `_). + MET Version 12.0.0-beta4 Release Notes (20240417) ------------------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index 3a135308ab..f6ffb456ad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,11 +20,11 @@ project = 'MET' author = 'UCAR/NCAR, NOAA, CSU/CIRA, and CU/CIRES' author_list = 'Prestopnik, J., H. Soh, L. Goodrich, B. Brown, R. Bullock, J. Halley Gotway, K. Newman, J. Opatz, T. Jensen' -version = '12.0.0-beta4' +version = '12.0.0-beta5' verinfo = version release = f'{version}' release_year = '2024' -release_date = f'{release_year}-04-17' +release_date = f'{release_year}-07-10' copyright = f'{release_year}, {author}' # -- General configuration --------------------------------------------------- From bcc86781d87b99b01e45968446d5954e9e38a7b2 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Thu, 11 Jul 2024 10:59:01 -0600 Subject: [PATCH 096/114] Feature fix release notes (#2934) * Fixing up release notes * Update release-notes.rst --------- Co-authored-by: John Halley Gotway --- docs/Users_Guide/release-notes.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/Users_Guide/release-notes.rst b/docs/Users_Guide/release-notes.rst index 8bf26a49a4..95c6c7233b 100644 --- a/docs/Users_Guide/release-notes.rst +++ b/docs/Users_Guide/release-notes.rst @@ -22,26 +22,26 @@ MET Version 12.0.0-beta5 Release Notes (20240710) * Bugfix (METbaseimage): Fix the environment to correct the ncdump runtime linker error (`METbaseimage#24 `_). * Bugfix: Fix the Grid-Stat configuration file to support the MET_SEEPS_GRID_CLIMO_NAME option (`#2601 `_). - * **Bugfix: Fix TC-RMW to correct the tangential and radial wind computations** (`#2841 `_). + * **Bugfix: Fix TC-RMW to correct the tangential and radial wind computations** (`#2841 `_). * Bugfix: Fix Ensemble-Stat's handling of climo data when verifying ensemble-derived probabilities (`#2856 `_). * **Bugfix: Fix Point2Grid's handling of the -qc option for ADP input files** (`#2867 `_). - * Bugfix: Bugfix: Fix Stat-Analysis errors for jobs using the -dump_row option and the -line_type option with VCNT, RPS, DMAP, or SSIDX (`#2888 `_). + * Bugfix: Fix Stat-Analysis errors for jobs using the -dump_row option and the -line_type option with VCNT, RPS, DMAP, or SSIDX (`#2888 `_). * Bugfix: Fix inconsistent handling of point observation valid times processed through Python embedding (`#2897 `_). .. dropdown:: Enhancements * **Add new wind direction verification statistics for RMSE, Bias, and MAE** (`#2395 `_). - * Document UGRID configuration options added to Point-Stat and Grid-Stat (`#2748 `_). + * Document UGRID configuration options added to Point-Stat and Grid-Stat (`#2748 `_ + * Refine Point-Stat Warning message about fcst/obs level mismatch (`#2795 `_). * **Add new -ugrid_config command line option for unstructured grid inputs to Grid-Stat and Point-Stat** (`#2842 `_). * Enhance Point2Grid to support modified quality control settings for smoke/dust AOD data in GOES-16/17 as of April 16, 2024 (`#2853 `_). * **Enhance Point2Grid to support a wider variety of input tripolar datasets** (`#2857 `_). * Test NOAA Unstructured grids in MET-12.0.0 (`#2860 `_). * Enhance Ensemble-Stat and Gen-Ens-Prod to omit warning messages for the MISSING keyword (`#2870 `_). - * Refine Point-Stat Warning message about fcst/obs level mismatch (`#2873 `_). - * Add new Python functionality to convert MET NetCDF observation data to a Pandas DataFrame (`#2877 `_). + * Add new Python functionality to convert MET NetCDF observation data to a Pandas DataFrame (`#2781 `_). * Enhance PCP-Combine to allow missing data (`#2883 `_). * Enhance TC-Stat to support the -set_hdr job command option (`#2911 `_). - * Refine ERROR messages written by PB2NC (`#2912 `_). + * Refine ERROR messages written by PB2NC (`#2912 `_). MET Version 12.0.0-beta4 Release Notes (20240417) ------------------------------------------------- From 101c0747be1d3e7613d5155fdcf3f9d42f292437 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 23 Jul 2024 11:23:38 -0600 Subject: [PATCH 097/114] Per dtcenter/METplus#2643 discussion, add more detail about the budget interpolation method. --- docs/Users_Guide/config_options.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index 5a92571886..b0d5110287 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -765,7 +765,18 @@ using the following entries: * NEAREST for the nearest grid point (width = 1) * BUDGET for the mass-conserving budget interpolation - + + * The budget interpolation method is often used for precipitation + in order to roughly conserve global averages. However it is + computationally intensive and relatively slow. To compute the + interpolated value for each point of the target grid, a higher + resolution 5x5 mesh with 0.2 grid box spacing is centered on + the point and bilinear interpolation is performed for each + of those 25 lat/lon locations. The budget interpolation value + is computed as the average of those 25 bilinear interpolation + values, assuming enough valid data is present to meet the + "vld_thresh" threshold. + * FORCE to compare gridded data directly with no interpolation as long as the grid x and y dimensions match. From c593187703a99c92551aeca27663795270a8a8fd Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 30 Jul 2024 13:38:04 -0600 Subject: [PATCH 098/114] Feature #2924 fcst climo, PR 1 of 2 (#2939) * Per #2924, Update the MPR and ORANK output line types to just write duplicate existing climo values, update the header tables and MPR/ORANK documentation tables. * Per #2924, update get_n_orank_columns() logic * Per #2924, update the Stat-Analysis parsing logic to parse the new MPR and ORANK climatology columns. * Per #2924, making some changes to the vx_statistics library to store climo data... but more work to come. Committing this first set of changes that are incomplete but do compile. * Per #2924, this big set of changes does compile but make test produces a segfault for ensemble-stat * Per #2924, fix return value for is_keeper_obs() * Per #2924, move fcst_info/obs_info into the VxPairBase pointer. * Per #2924, update Ensemble-Stat to set the VxPairBase::fcst_info pointer * Per #2924 udpate handling of fcst_info and obs_info pointers in Ensemble-Stat * Per #2924, update the GSI tools to handle the new fcst climo columns. * Per #2924, add backward compatibility logic so that when old climo column names are requested, the new ones are used. * Per #2924, print a DEBUG(2) log message if old column names are used. * Per #2924, switch the unit tests to reference the updated MPR column names rather than the old ones. * Per #2924, working progress. Not fully compiling yet * Per #2924, another round of changes. Removing MPR:FCST_CLIMO_CDF output column. This compiles but not sure if it actually runs yet * Per #2924, work in progress * Per #2924, work in progress. Almost compiling again. * Per #2924, get it compiling * Per #2924, add back in support for SCP and CDP which are interpreted as SOCP and OCDP, resp * Per #2924, update docs about SCP and CDP threshold types * Per #2924, minor whitespace changes * Per #2924, fix an uninitialized pointer bug by defining/calling SeepsClimoGrid::init_from_scratch() member function. The constructor had been calling clear() to delete pointers that weren't properly initialized to nullptr. Also, simplify some map processing logic. * Per #2924, rename SeepsAggScore from seeps to seeps_agg for clarity and to avoid conflicts in member function implementations. * Per #2924, fix seeps compilation error in Point-Stat * Per #2924, fix bug in the boolean logic for handling the do_climo_cdp NetCDF output option. * Per #2924, add missing exit statement. * Per #2924, tweak threshold.h * Per #2924, define one perc_thresh_info entry for each enumerated PercThreshType value * Per #2924, simplify the logic for handling percentile threshold types and print a log message once when the old versions are still used. * Per #2924, update the string comparison return value logic * Per #2924, fix the perc thresh string parsing logic by calling ConcatString::startswith() * Per #2924, switch all instances of CDP to OCDP. Gen-Ens-Prod was writing NetCDF files with OCDP in the output variable names, but Grid-Stat was requesting that the wrong variable name be read. So the unit tests failed. * Per #2924, add more doc details * Per #2924, update default config file to indicate when climo_mean and climo_stdev can be set seperately in the fcst and obs dictionaries. * Per #2924, update the MET tools to parse climo_mean and climo_stdev separately from the fcst and obs dictionaries. * Per #2924, backing out new/modified columns to minimize reg test diffs * Per #2924, one more section to be commented out later. * Per #2924, replace several calls to strncmp() with ConcatString::startswith() to simplify the code * Per #2924, strip out some more references to OBS_CLIMO_... in the unit tests. * Per #2924, delete accidental file * Per #2924 fix broken XML comments * Per #2924, fix comments * Per #2924, address SonarQube findings * Per #2924, tweak a Point-Stat and Grid-Stat unit test config file to make the output more comparable to develop. * Per #2924, fix bug in the logic of PairDataPoint and PairDataEnsemble, when looping over the 3-dim array do not return when checking the climo and fcst values. Instead we need to continue to the next loop iteration. * Per #2924, address more SonarQube code smells to reduce the overall number in MET for this PR. * Per #2924, correct the logic for parsing climo data from MPR lines. * Per #2924, cleanup grid_stat.cc source code by making calls to DataPlane::is_empty() and Grid::nxy(). * Per #2924, remove unneeded ==0 --- data/config/EnsembleStatConfig_default | 8 +- data/config/GenEnsProdConfig_default | 5 +- data/config/GridStatConfig_default | 8 +- data/config/PointStatConfig_default | 8 +- data/config/SeriesAnalysisConfig_default | 11 +- docs/Users_Guide/config_options.rst | 149 +- docs/Users_Guide/ensemble-stat.rst | 28 +- docs/Users_Guide/gen-ens-prod.rst | 6 +- docs/Users_Guide/grid-stat.rst | 2 +- docs/Users_Guide/point-stat.rst | 18 +- internal/test_unit/config/GenEnsProdConfig | 6 +- .../test_unit/config/GridStatConfig_climo_WMO | 18 +- .../config/GridStatConfig_gen_ens_prod | 8 +- .../config/GridStatConfig_mpr_thresh | 14 + .../config/PointStatConfig_climo_WMO | 18 +- .../config/PointStatConfig_mpr_thresh | 12 + .../config/SeriesAnalysisConfig_climo | 4 +- internal/test_unit/hdr/met_12_0.hdr | 2 +- .../test_unit/xml/unit_climatology_1.5deg.xml | 10 +- src/basic/vx_config/config.tab.cc | 22 +- src/basic/vx_config/config.tab.yy | 22 +- src/basic/vx_config/config_constants.h | 14 +- src/basic/vx_config/my_config_scanner.cc | 51 +- src/basic/vx_config/threshold.cc | 364 ++-- src/basic/vx_config/threshold.h | 235 +- src/basic/vx_log/logger.cc | 5 +- src/basic/vx_util/CircularTemplate.cc | 38 +- src/basic/vx_util/GridPoint.cc | 1 - src/basic/vx_util/data_plane.cc | 2 +- src/basic/vx_util/data_plane_util.cc | 74 +- src/basic/vx_util/data_plane_util.h | 4 +- src/basic/vx_util/interp_util.cc | 12 +- src/basic/vx_util/interp_util.h | 28 +- src/basic/vx_util/memory.cc | 4 +- src/basic/vx_util/polyline.cc | 4 +- src/basic/vx_util/stat_column_defs.h | 54 +- src/basic/vx_util/thresh_array.cc | 89 +- src/basic/vx_util/thresh_array.h | 14 +- src/libcode/vx_analysis_util/stat_job.cc | 21 +- src/libcode/vx_analysis_util/stat_job.h | 1 + src/libcode/vx_analysis_util/stat_line.cc | 50 + src/libcode/vx_data2d/var_info.h | 2 +- .../vx_data2d_nc_wrf/var_info_nc_wrf.cc | 2 +- .../vx_data2d_python/grid_from_python_dict.cc | 2 +- src/libcode/vx_grid/goes_grid.cc | 4 +- src/libcode/vx_grid/laea_grid.cc | 2 +- src/libcode/vx_seeps/seeps.cc | 52 +- src/libcode/vx_seeps/seeps.h | 2 + src/libcode/vx_shapedata/mode_conf_info.cc | 29 +- src/libcode/vx_shapedata/node.cc | 6 +- src/libcode/vx_stat_out/stat_columns.cc | 60 +- src/libcode/vx_statistics/compute_stats.cc | 166 +- src/libcode/vx_statistics/ens_stats.cc | 18 +- src/libcode/vx_statistics/met_stats.cc | 86 +- src/libcode/vx_statistics/met_stats.h | 6 +- src/libcode/vx_statistics/pair_base.cc | 1912 ++++++++++++++--- src/libcode/vx_statistics/pair_base.h | 293 ++- .../vx_statistics/pair_data_ensemble.cc | 1067 +++------ .../vx_statistics/pair_data_ensemble.h | 112 +- src/libcode/vx_statistics/pair_data_point.cc | 1663 +++----------- src/libcode/vx_statistics/pair_data_point.h | 177 +- .../vx_summary/summary_calc_percentile.cc | 8 +- src/libcode/vx_tc_util/atcf_prob_line.cc | 2 +- src/tools/core/ensemble_stat/ensemble_stat.cc | 291 +-- .../ensemble_stat/ensemble_stat_conf_info.cc | 43 +- src/tools/core/grid_stat/grid_stat.cc | 537 +++-- .../core/grid_stat/grid_stat_conf_info.cc | 22 +- src/tools/core/point_stat/point_stat.cc | 435 ++-- src/tools/core/point_stat/point_stat.h | 5 +- .../core/point_stat/point_stat_conf_info.cc | 28 +- .../core/series_analysis/series_analysis.cc | 81 +- .../core/stat_analysis/aggr_stat_line.cc | 170 +- .../core/stat_analysis/parse_stat_line.cc | 54 +- .../core/stat_analysis/parse_stat_line.h | 8 +- .../core/stat_analysis/stat_analysis_job.cc | 3 +- .../wavelet_stat/wavelet_stat_conf_info.cc | 4 +- src/tools/dev_utils/met_nc_file.cc | 2 +- src/tools/other/ascii2nc/airnow_locations.cc | 18 +- .../other/ascii2nc/ascii2nc_conf_info.cc | 2 +- src/tools/other/ascii2nc/little_r_handler.cc | 20 +- src/tools/other/ascii2nc/met_handler.cc | 26 +- src/tools/other/ascii2nc/ndbc_locations.cc | 14 +- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 25 +- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 7 +- src/tools/other/grid_diag/grid_diag.cc | 24 +- src/tools/other/gsi_tools/gsid2mpr.cc | 26 +- src/tools/other/gsi_tools/gsidens2orank.cc | 33 +- .../other/madis2nc/madis2nc_conf_info.cc | 2 +- .../modis_regrid/data_plane_to_netcdf.cc | 30 +- src/tools/tc_utils/tc_diag/python_tc_diag.cc | 4 +- 90 files changed, 4710 insertions(+), 4319 deletions(-) diff --git a/data/config/EnsembleStatConfig_default b/data/config/EnsembleStatConfig_default index 57f1984807..c496dd3507 100644 --- a/data/config/EnsembleStatConfig_default +++ b/data/config/EnsembleStatConfig_default @@ -130,7 +130,8 @@ ens_phist_bin_size = 0.05; //////////////////////////////////////////////////////////////////////////////// // -// Climatology data +// Climatology mean data +// May be set separately in the "fcst" and "obs" dictionaries // climo_mean = { @@ -149,12 +150,17 @@ climo_mean = { hour_interval = 6; } +// +// Climatology standard deviation data +// May be set separately in the "fcst" and "obs" dictionaries +// climo_stdev = climo_mean; climo_stdev = { file_name = []; } // +// Climatology distribution settings // May be set separately in each "obs.field" entry // climo_cdf = { diff --git a/data/config/GenEnsProdConfig_default b/data/config/GenEnsProdConfig_default index e2cb994bba..c650ec8b24 100644 --- a/data/config/GenEnsProdConfig_default +++ b/data/config/GenEnsProdConfig_default @@ -95,7 +95,7 @@ nmep_smooth = { //////////////////////////////////////////////////////////////////////////////// // -// Climatology data +// Climatology mean data // climo_mean = { @@ -114,6 +114,9 @@ climo_mean = { hour_interval = 6; } +// +// Climatology standard deviation data +// climo_stdev = climo_mean; climo_stdev = { file_name = []; diff --git a/data/config/GridStatConfig_default b/data/config/GridStatConfig_default index 4bec5ecf4b..4a0c7dce44 100644 --- a/data/config/GridStatConfig_default +++ b/data/config/GridStatConfig_default @@ -75,7 +75,8 @@ obs = fcst; //////////////////////////////////////////////////////////////////////////////// // -// Climatology data +// Climatology mean data +// May be set separately in the "fcst" and "obs" dictionaries // climo_mean = { @@ -94,12 +95,17 @@ climo_mean = { hour_interval = 6; } +// +// Climatology standard deviation data +// May be set separately in the "fcst" and "obs" dictionaries +// climo_stdev = climo_mean; climo_stdev = { file_name = []; } // +// Climatology distribution settings // May be set separately in each "obs.field" entry // climo_cdf = { diff --git a/data/config/PointStatConfig_default b/data/config/PointStatConfig_default index d4b277c6a3..266c251e59 100644 --- a/data/config/PointStatConfig_default +++ b/data/config/PointStatConfig_default @@ -118,7 +118,8 @@ message_type_group_map = [ //////////////////////////////////////////////////////////////////////////////// // -// Climatology data +// Climatology mean data +// May be set separately in the "fcst" and "obs" dictionaries // climo_mean = { @@ -137,12 +138,17 @@ climo_mean = { hour_interval = 6; } +// +// Climatology standard deviation data +// May be set separately in the "fcst" and "obs" dictionaries +// climo_stdev = climo_mean; climo_stdev = { file_name = []; } // +// Climatology distribution settings // May be set separately in each "obs.field" entry // climo_cdf = { diff --git a/data/config/SeriesAnalysisConfig_default b/data/config/SeriesAnalysisConfig_default index 2b0cdfa53e..8f76139011 100644 --- a/data/config/SeriesAnalysisConfig_default +++ b/data/config/SeriesAnalysisConfig_default @@ -61,7 +61,8 @@ obs = fcst; //////////////////////////////////////////////////////////////////////////////// // -// Climatology data +// Climatology mean data +// May be set separately in the "fcst" and "obs" dictionaries // climo_mean = { @@ -80,11 +81,19 @@ climo_mean = { hour_interval = 6; } +// +// Climatology standard deviation data +// May be set separately in the "fcst" and "obs" dictionaries +// climo_stdev = climo_mean; climo_stdev = { file_name = []; } +// +// Climatology distribution settings +// May be set separately in each "obs.field" entry +// climo_cdf = { cdf_bins = 1; center_bins = FALSE; diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index b0d5110287..de538bd7cb 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -60,8 +60,8 @@ The configuration file language supports the following data types: * Percentile Thresholds: * A threshold type (<, <=, ==, !=, >=, or >), followed by a percentile - type description (SFP, SOP, SCP, USP, CDP, or FBIAS), followed by a - numeric value, typically between 0 and 100. + type description (SFP, SOP, SFCP, SOCP, USP, FCDP, OCDP, or FBIAS), + followed by a numeric value, typically between 0 and 100. * Note that the two letter threshold type abbreviations (lt, le, eq, ne, ge, gt) are not supported for percentile thresholds. @@ -93,8 +93,14 @@ The configuration file language supports the following data types: * "SOP" for a percentile of the sample observation values. e.g. ">SOP75" means greater than the 75-th observation percentile. - * "SCP" for a percentile of the sample climatology values. - e.g. ">SCP90" means greater than the 90-th climatology percentile. + * "SFCP" for a percentile of the sample forecast climatology values. + e.g. ">SFCP90" means greater than the 90-th forecast climatology + percentile. + + * "SOCP" for a percentile of the sample observation climatology values. + e.g. ">SOCP90" means greater than the 90-th observation climatology + percentile. For backward compatibility, the "SCP" threshold type + is processed the same as "SOCP". * "USP" for a user-specified percentile threshold. e.g. " 0.0. - * "CDP" for climatological distribution percentile thresholds. - These thresholds require that the climatological mean and standard - deviation be defined using the climo_mean and climo_stdev config file - options, respectively. The categorical (cat_thresh), conditional - (cnt_thresh), or wind speed (wind_thresh) thresholds are defined - relative to the climatological distribution at each point. Therefore, - the actual numeric threshold applied can change for each point. - e.g. ">CDP50" means greater than the 50-th percentile of the + * "FCDP" for forecast climatological distribution percentile thresholds. + These thresholds require that the forecast climatological mean and + standard deviation be defined using the "climo_mean" and "climo_stdev" + config file options, respectively. The categorical (cat_thresh), + conditional (cnt_thresh), or wind speed (wind_thresh) thresholds can + be defined relative to the climatological distribution at each point. + Therefore, the actual numeric threshold applied can change for each point. + e.g. ">FCDP50" means greater than the 50-th percentile of the climatological distribution for each point. - - * When percentile thresholds of type SFP, SOP, SCP, or CDP are requested - for continuous filtering thresholds (cnt_thresh), wind speed thresholds - (wind_thresh), or observation filtering thresholds (obs_thresh in - ensemble_stat), the following special logic is applied. Percentile + + * "OCDP" for observation climatological distribution percentile thresholds. + The "OCDP" threshold logic matches the "FCDP" logic described above. + However these thresholds are defined using the observation climatological + mean and standard deviation rather than the forecast climatological data. + For backward compatibility, the "CDP" threshold type is processed the + same as "OCDP". + + * When percentile thresholds of type SFP, SOP, SFCP, SOCP, FCDP, or OCDP are + requested for continuous filtering thresholds (cnt_thresh), wind speed + thresholds (wind_thresh), or observation filtering thresholds (obs_thresh + in ensemble_stat), the following special logic is applied. Percentile thresholds of type equality are automatically converted to percentile bins which span the values from 0 to 100. - For example, "==CDP25" is automatically expanded to 4 percentile bins: - >=CDP0&&=CDP25&&=CDP50&&=CDP75&&<=CDP100 + For example, "==OCDP25" is automatically expanded to 4 percentile bins: + >=OCDP0&&=OCDP25&&=OCDP50&&=OCDP75&&<=OCDP100 - * When sample percentile thresholds of type SFP, SOP, SCP, or FBIAS are - requested, MET recomputes the actual percentile that the threshold + * When sample percentile thresholds of type SFP, SOP, SFCP, SOCP, or FBIAS + are requested, MET recomputes the actual percentile that the threshold represents. If the requested percentile and actual percentile differ by more than 5%, a warning message is printed. This may occur when the sample size is small or the data values are not truly continuous. - * When percentile thresholds of type SFP, SOP, SCP, or USP are used, the - actual threshold value is appended to the FCST_THRESH and OBS_THRESH + * When percentile thresholds of type SFP, SOP, SFCP, SOCP, or USP are used, + the actual threshold value is appended to the FCST_THRESH and OBS_THRESH output columns. For example, if the 90-th percentile of the current set of forecast values is 3.5, then the requested threshold "<=SFP90" is written to the output as "<=SFP90(3.5)". - + * When parsing FCST_THRESH and OBS_THRESH columns, the Stat-Analysis tool ignores the actual percentile values listed in parentheses. - + +.. note:: + + Prior to MET version 12.0.0, forecast climatological inputs were not + supported. The observation climatological inputs were used to process + threshold types named "SCP" and "CDP". + + For backward compatibility, the "SCP" threshold type is processed the same + as "SOCP" and "CDP" the same as "OCDP". + + Users are encouraged to replace the deprecated "SCP" and "CDP" threshold + types with the updated "SOCP" and "OCDP" types, respectively. + * Piecewise-Linear Function (currently used only by MODE): * A list of (x, y) points enclosed in parenthesis (). @@ -1448,8 +1473,11 @@ climo_mean ---------- The "climo_mean" dictionary specifies climatology mean data to be read by the -Grid-Stat, Point-Stat, Ensemble-Stat, and Series-Analysis tools. It consists -of several entires defining the climatology file names and fields to be used. +Grid-Stat, Point-Stat, Ensemble-Stat, and Series-Analysis tools. It can be +set inside the "fcst" and "obs" dictionaries to specify separate forecast and +observation climatology data or once at the top-level configuration file +context to use the same data for both. It consists of several entries defining +the climatology file names and fields to be used. * The "file_names" entry specifies one or more file names containing the gridded climatology data to be used. @@ -1506,19 +1534,22 @@ climo_stdev The "climo_stdev" dictionary specifies climatology standard deviation data to be read by the Grid-Stat, Point-Stat, Ensemble-Stat, and Series-Analysis -tools. The "climo_mean" and "climo_stdev" data define the climatological -distribution for each grid point, assuming normality. These climatological -distributions are used in two ways: +tools. It can be set inside the "fcst" and "obs" dictionaries to specify +separate forecast and observation climatology data or once at the top-level +configuration file context to use the same data for both. The "climo_mean" and +"climo_stdev" data define the climatological distribution for each grid point, +assuming normality. These climatological distributions are used in two ways: (1) - To define climatological distribution percentile (CDP) thresholds which - can be used as categorical (cat_thresh), continuous (cnt_thresh), or wind - speed (wind_thresh) thresholds. + To define climatological distribution percentiles thresholds (FCDP and + OCDP) which can be used as categorical (cat_thresh), continuous (cnt_thresh), + or wind speed (wind_thresh) thresholds. (2) To subset matched pairs into climatological bins based on where the - observation value falls within the climatological distribution. See the - "climo_cdf" dictionary. + observation value falls within the observation climatological distribution. + See the "climo_cdf" dictionary. Note that only the observation climatology + data is used for this purpose, not the forecast climatology data. This dictionary is identical to the "climo_mean" dictionary described above but points to files containing climatological standard deviation values @@ -1535,11 +1566,12 @@ over the "climo_mean" setting and then updating the "file_name" entry. climo_cdf --------- -The "climo_cdf" dictionary specifies how the the climatological mean -("climo_mean") and standard deviation ("climo_stdev") data are used to +The "climo_cdf" dictionary specifies how the the observation climatological +mean ("climo_mean") and standard deviation ("climo_stdev") data are used to evaluate model performance relative to where the observation value falls -within the climatological distribution. This dictionary consists of the -following entries: +within the observation climatological distribution. It can be set inside the +"obs" dictionary or at the top-level configuration file context. This +dictionary consists of the following entries: (1) The "cdf_bins" entry defines the climatological bins either as an integer @@ -1553,11 +1585,11 @@ following entries: (4) The "direct_prob" entry may be set to TRUE or FALSE. -MET uses the climatological mean and standard deviation to construct a normal -PDF at each observation location. The total area under the PDF is 1, and the -climatological CDF value is computed as the area of the PDF to the left of -the observation value. Since the CDF is a value between 0 and 1, the CDF -bins must span that same range. +MET uses the observation climatological mean and standard deviation to +construct a normal PDF at each observation location. The total area under the +PDF is 1, and the climatological CDF value is computed as the area of the PDF +to the left of the observation value. Since the CDF is a value between 0 and 1, +the CDF bins must span that same range. When "cdf_bins" is set to an array of floats, they explicitly define the climatological bins. The array must begin with 0.0 and end with 1.0. @@ -1601,20 +1633,21 @@ all pairs into a single climatological bin. climate_data ------------ - -When specifying climatology data for probability forecasts, either supply a -probabilistic "climo_mean" field or non-probabilistic "climo_mean" and -"climo_stdev" fields from which a normal approximation of the climatological -probabilities should be derived. -When "climo_mean" is set to a probability field with a range of [0, 1] and -"climo_stdev" is unset, the MET tools use the "climo_mean" probability values -directly to compute Brier Skill Score (BSS). +When specifying observation climatology data to evaluate probability +forecasts, either supply a probabilistic observation "climo_mean" field or +non-probabilistic "climo_mean" and "climo_stdev" fields from which a normal +approximation of the observation climatological probabilities should be +derived. -When "climo_mean" and "climo_stdev" are both set to non-probability fields, -the MET tools use the mean, standard deviation, and observation event -threshold to derive a normal approximation of the climatological -probabilities. +When the observation "climo_mean" is set to a probability field with a range +of [0, 1] and "climo_stdev" is unset, the MET tools use the "climo_mean" +probability values directly to compute Brier Skill Score (BSS). + +When the observation "climo_mean" and "climo_stdev" are both set to +non-probability fields, the MET tools use the mean, standard deviation, and +observation event threshold to derive a normal approximation of the +observation climatological probabilities. The "direct_prob" option controls the derivation logic. When "direct_prob" is true, the climatological probability is computed directly from the @@ -1697,7 +1730,7 @@ Point-Stat and Ensemble-Stat, the reference time is the forecast valid time. mask --- - + The "mask" entry is a dictionary that specifies the verification masking regions to be used when computing statistics. Each mask defines a geographic extent, and any matched pairs falling inside that area will be @@ -3759,7 +3792,7 @@ obs_prepbufr_map Default mapping for PREPBUFR. Replace input BUFR variable names with GRIB abbreviations in the output. This default map is appended to obs_bufr_map. This should not typically be overridden. This default mapping provides -backward-compatibility for earlier versions of MET which wrote GRIB +backward compatibility for earlier versions of MET which wrote GRIB abbreviations to the output. .. code-block:: none diff --git a/docs/Users_Guide/ensemble-stat.rst b/docs/Users_Guide/ensemble-stat.rst index dd221dd1d2..dc0fe8c248 100644 --- a/docs/Users_Guide/ensemble-stat.rst +++ b/docs/Users_Guide/ensemble-stat.rst @@ -856,30 +856,36 @@ The format of the STAT and ASCII output of the Ensemble-Stat tool are described * - 37 - ENS_i - Value of the ith ensemble member (repeated) - * - Last-7 + * - Last-9 - OBS_QC - Quality control string for the observation - * - Last-6 + * - Last-8 - ENS_MEAN - The unperturbed ensemble mean value - * - Last-5 - - CLIMO_MEAN - - Climatological mean value (named CLIMO prior to met-10.0.0) - * - Last-4 + * - Last-7 + - OBS_CLIMO_MEAN + - Observation climatological mean value (named CLIMO_MEAN prior to met-12.0.0) + * - Last-6 - SPREAD - The spread (standard deviation) of the unperturbed ensemble member values - * - Last-3 + * - Last-5 - ENS_MEAN _OERR - The PERTURBED ensemble mean (e.g. with Observation Error). - * - Last-2 + * - Last-4 - SPREAD_OERR - The spread (standard deviation) of the PERTURBED ensemble member values (e.g. with Observation Error). - * - Last-1 + * - Last-3 - SPREAD_PLUS_OERR - The square root of the sum of the unperturbed ensemble variance and the observation error variance. + * - Last-2 + - OBS_CLIMO_STDEV + - Observation climatological standard deviation value (named CLIMO_STDEV prior to met-12.0.0) + * - Last-1 + - FCST_CLIMO_MEAN + - Forecast climatological mean value * - Last - - CLIMO_STDEV - - Climatological standard deviation value + - FCST_CLIMO_STDEV + - Forecast climatological standard deviation value .. role:: raw-html(raw) :format: html diff --git a/docs/Users_Guide/gen-ens-prod.rst b/docs/Users_Guide/gen-ens-prod.rst index 57da0849cb..7f6d68c6c7 100644 --- a/docs/Users_Guide/gen-ens-prod.rst +++ b/docs/Users_Guide/gen-ens-prod.rst @@ -30,7 +30,9 @@ The Gen-Ens-Prod tool writes the gridded relative frequencies, NEP, and NMEP fie Climatology Data ---------------- -The ensemble relative frequencies derived by Gen-Ens-Prod are computed by applying threshold(s) to the input ensemble member data. Those thresholds can be simple and remain constant over the entire domain (e.g. >0) or can be defined relative to the climatological distribution at each grid point (e.g. >CDP90, for exceeding the 90-th percentile of climatology). When using climatological distribution percentile (CDP) thresholds, the climatological mean and standard deviation must be provided in the configuration file. +The ensemble relative frequencies derived by Gen-Ens-Prod are computed by applying threshold(s) to the input ensemble member data. Those thresholds can be simple and remain constant over the entire domain (e.g. >0) or can be defined relative to the climatological distribution at each grid point (e.g. >OCDP90, for exceeding the 90-th percentile of the observation climatology data provided). + +To use climatological distribution percentile thresholds, users must specify the climatological mean ("climo_mean") and standard deviation ("climo_stdev") entries in the configuration file. With forecast climatology inputs, use forecast climatology distribution percentile thresholds (e.g. >FCDP90). With observation climatology inputs, use observation climatological distribution percentile thresholds instead (e.g. >OCDP90). However, Gen-Ens-Prod cannot actually determine the input climatology data source and both "FCDP" and "OCDP" threshold types will work. Practical Information ===================== @@ -295,7 +297,7 @@ The **ensemble_flag** specifies which derived ensemble fields should be calculat 13. Climatology mean (**climo_mean**) and standard deviation (**climo_stdev**) data regridded to the model domain -14. Climatological Distribution Percentile field for each CDP threshold specified +14. Climatological Distribution Percentile field for each FCDP or OCDP threshold specified gen_ens_prod Output ------------------- diff --git a/docs/Users_Guide/grid-stat.rst b/docs/Users_Guide/grid-stat.rst index 051178cfb1..cac539e497 100644 --- a/docs/Users_Guide/grid-stat.rst +++ b/docs/Users_Guide/grid-stat.rst @@ -451,7 +451,7 @@ _____________________ The **nc_pairs_flag** entry may either be set to a boolean value or a dictionary specifying which fields should be written. Setting it to TRUE indicates the output NetCDF matched pairs file should be created with all available output fields, while setting all to FALSE disables its creation. This is done regardless of if **output_flag** dictionary indicates any statistics should be computed. The **latlon, raw**, and **diff** entries control the creation of output variables for the latitude and longitude, the forecast and observed fields after they have been modified by any user-defined regridding, censoring, and conversion, and the forecast minus observation difference fields, respectively. The **climo, weight**, and **nbrhd** entries control the creation of output variables for the climatological mean and standard deviation fields, the grid area weights applied, and the fractional coverage fields computed for neighborhood verification methods. Setting these entries to TRUE indicates that they should be written, while setting them to FALSE disables their creation. -Setting the **climo_cdp** entry to TRUE enables the creation of an output variable for each climatological distribution percentile (CDP) threshold requested in the configuration file. Note that enabling **nbrhd** output may lead to very large output files. The **gradient** entry controls the creation of output variables for the FCST and OBS gradients in the grid-x and grid-y directions. The **distance_map** entry controls the creation of output variables for the FCST and OBS distance maps for each categorical threshold. The **apply_mask** entry controls whether to create the FCST, OBS, and DIFF output variables for all defined masking regions. Setting this to TRUE will create the FCST, OBS, and DIFF output variables for all defined masking regions. Setting this to FALSE will create the FCST, OBS, and DIFF output variables for only the FULL verification domain. +Setting the **climo_cdp** entry to TRUE enables the creation of an output variable for each climatological distribution percentile (FCDP or OCDP) threshold requested in the configuration file. Note that enabling **nbrhd** output may lead to very large output files. The **gradient** entry controls the creation of output variables for the FCST and OBS gradients in the grid-x and grid-y directions. The **distance_map** entry controls the creation of output variables for the FCST and OBS distance maps for each categorical threshold. The **apply_mask** entry controls whether to create the FCST, OBS, and DIFF output variables for all defined masking regions. Setting this to TRUE will create the FCST, OBS, and DIFF output variables for all defined masking regions. Setting this to FALSE will create the FCST, OBS, and DIFF output variables for only the FULL verification domain. ______________________ diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index 0f42d54129..6c9849511e 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -1499,14 +1499,20 @@ The first set of header columns are common to all of the output files generated - OBS_QC - Quality control flag for observation * - 35 - - CLIMO_MEAN - - Climatological mean value + - OBS_CLIMO_MEAN + - Observation climatological mean value (named CLIMO_MEAN prior to met-12.0.0) * - 36 - - CLIMO_STDEV - - Climatological standard deviation value + - OBS_CLIMO_STDEV + - Observation climatological standard deviation value (named CLIMO_STDEV prior to met-12.0.0) * - 37 - - CLIMO_CDF - - Climatological cumulative distribution function value + - OBS_CLIMO_CDF + - Observation climatological cumulative distribution function value (named CLIMO_CDF prior to met-12.0.0) + * - 38 + - FCST_CLIMO_MEAN + - Forecast climatological mean value + * - 39 + - FCST_CLIMO_STDEV + - Forecast climatological standard deviation value .. _table_PS_format_info_SEEPS_MPR: diff --git a/internal/test_unit/config/GenEnsProdConfig b/internal/test_unit/config/GenEnsProdConfig index 9a565c2fb4..813272dc14 100644 --- a/internal/test_unit/config/GenEnsProdConfig +++ b/internal/test_unit/config/GenEnsProdConfig @@ -60,17 +60,17 @@ ens = { { name = "UGRD"; level = [ "Z10" ]; - cat_thresh = [ CDP75 ]; + cat_thresh = [ >OCDP75 ]; }, { name = "WIND"; level = [ "Z10" ]; - cat_thresh = [ >=CDP25&&<=CDP75 ]; + cat_thresh = [ >=OCDP25&&<=OCDP75 ]; } ]; } diff --git a/internal/test_unit/config/GridStatConfig_climo_WMO b/internal/test_unit/config/GridStatConfig_climo_WMO index 58f184cde0..739d122295 100644 --- a/internal/test_unit/config/GridStatConfig_climo_WMO +++ b/internal/test_unit/config/GridStatConfig_climo_WMO @@ -64,25 +64,25 @@ fcst = { { name = "UGRD"; level = [ "P500" ]; }, { name = "VGRD"; level = [ "P500" ]; }, { name = "WIND"; level = [ "P500" ]; }, - { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; } + { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; } ]; } obs = { - cnt_thresh = [ NA, =CDP50, ==CDP25 ]; + cnt_thresh = [ NA, =OCDP50, ==OCDP25 ]; field = [ { name = "TMP"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, { name = "UGRD"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, { name = "VGRD"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, { name = "WIND"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, - { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; } + { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; } ]; } diff --git a/internal/test_unit/config/GridStatConfig_gen_ens_prod b/internal/test_unit/config/GridStatConfig_gen_ens_prod index 8893c2d5ff..015ef3e946 100644 --- a/internal/test_unit/config/GridStatConfig_gen_ens_prod +++ b/internal/test_unit/config/GridStatConfig_gen_ens_prod @@ -66,9 +66,9 @@ fcst = { prob = TRUE; field = [ - { name = "UGRD_Z10_ENS_FREQ_ltCDP25"; }, - { name = "UGRD_Z10_ENS_NEP_ltCDP25_NBRHD25"; }, - { name = "UGRD_Z10_ENS_NMEP_ltCDP25_NBRHD25_GAUSSIAN1"; } + { name = "UGRD_Z10_ENS_FREQ_ltOCDP25"; }, + { name = "UGRD_Z10_ENS_NEP_ltOCDP25_NBRHD25"; }, + { name = "UGRD_Z10_ENS_NMEP_ltOCDP25_NBRHD25_GAUSSIAN1"; } ]; } @@ -76,7 +76,7 @@ obs = { name = "UGRD"; level = "Z10"; - cat_thresh = =0.25&&<=0.75 ]; +// desc = "OBS_CLIMO_CDF_IQR"; +// nc_pairs_var_suffix = desc; +// } { mpr_column = [ "ABS(OBS-CLIMO_MEAN)" ]; mpr_thresh = [ <=5 ]; @@ -91,6 +104,7 @@ fcst = { desc = "CLIMO_CDF_IQR"; nc_pairs_var_suffix = desc; } +// MET #2924 End replace ]; } obs = fcst; diff --git a/internal/test_unit/config/PointStatConfig_climo_WMO b/internal/test_unit/config/PointStatConfig_climo_WMO index 1ddc8deb1e..01c3f9b3de 100644 --- a/internal/test_unit/config/PointStatConfig_climo_WMO +++ b/internal/test_unit/config/PointStatConfig_climo_WMO @@ -55,25 +55,25 @@ fcst = { { name = "UGRD"; level = [ "P500" ]; }, { name = "VGRD"; level = [ "P500" ]; }, { name = "WIND"; level = [ "P500" ]; }, - { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; } + { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; } ]; } obs = { - cnt_thresh = [ NA, =CDP50, ==CDP25 ]; + cnt_thresh = [ NA, =OCDP50, ==OCDP25 ]; field = [ { name = "TMP"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, { name = "UGRD"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, { name = "VGRD"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, { name = "WIND"; level = [ "P500" ]; cnt_thresh = [ NA ]; wind_thresh = [ NA ]; }, - { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; }, - { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >CDP90 ]; } + { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; }, + { name = "WIND"; level = [ "P850" ]; cat_thresh = [ >OCDP90 ]; } ]; } diff --git a/internal/test_unit/config/PointStatConfig_mpr_thresh b/internal/test_unit/config/PointStatConfig_mpr_thresh index 5740d4907a..e0d54b9219 100644 --- a/internal/test_unit/config/PointStatConfig_mpr_thresh +++ b/internal/test_unit/config/PointStatConfig_mpr_thresh @@ -68,6 +68,17 @@ fcst = { mpr_thresh = [ <=5 ]; desc = "ABS_OBS_FCST_DIFF"; }, +// MET #2924 Replace this section +// { +// mpr_column = [ "ABS(OBS-OBS_CLIMO_MEAN)" ]; +// mpr_thresh = [ <=5 ]; +// desc = "ABS_OBS_CLIMO_MEAN_DIFF"; +// }, +// { +// mpr_column = [ "OBS_CLIMO_CDF" ]; +// mpr_thresh = [ >=0.25&&<=0.75 ]; +// desc = "OBS_CLIMO_CDF_IQR"; +// } { mpr_column = [ "ABS(OBS-CLIMO_MEAN)" ]; mpr_thresh = [ <=5 ]; @@ -78,6 +89,7 @@ fcst = { mpr_thresh = [ >=0.25&&<=0.75 ]; desc = "CLIMO_CDF_IQR"; } +// MET #2924 End replace ]; } obs = fcst; diff --git a/internal/test_unit/config/SeriesAnalysisConfig_climo b/internal/test_unit/config/SeriesAnalysisConfig_climo index 196c38dafa..3728482541 100644 --- a/internal/test_unit/config/SeriesAnalysisConfig_climo +++ b/internal/test_unit/config/SeriesAnalysisConfig_climo @@ -37,7 +37,7 @@ regrid = { censor_thresh = []; censor_val = []; -cat_thresh = [ >CDP25, >CDP50, >CDP75 ]; +cat_thresh = [ >OCDP25, >OCDP50, >OCDP75 ]; cnt_thresh = [ NA ]; cnt_logic = UNION; @@ -50,7 +50,7 @@ fcst = { ]; } obs = { - cnt_thresh = [ NA, >CDP25&&OCDP25&& \ -lookin &OUTPUT_DIR;/climatology_1.5deg/point_stat_WMO_CLIMO_1.5DEG_120000L_20120409_120000V.stat \ - -job aggregate_stat -line_type MPR -out_line_type CTC -fcst_lev P850 -interp_mthd NEAREST -by FCST_VAR -out_thresh '>CDP90' \ + -job aggregate_stat -line_type MPR -out_line_type CTC -fcst_lev P850 -interp_mthd NEAREST -by FCST_VAR -out_thresh '>OCDP90' \ -out_stat &OUTPUT_DIR;/climatology_1.5deg/stat_analysis_WMO_1.5DEG_MPR_to_CTC_out.stat @@ -82,11 +82,19 @@ OUTPUT_DIR &OUTPUT_DIR;/climatology_1.5deg + \ -lookin &OUTPUT_DIR;/climatology_1.5deg/point_stat_WMO_CLIMO_1.5DEG_120000L_20120409_120000V.stat \ -job filter -line_type MPR -column_thresh CLIMO_CDF 'lt0.1||gt0.9' \ -dump_row &OUTPUT_DIR;/climatology_1.5deg/stat_analysis_WMO_1.5DEG_FILTER_CDF_dump.stat + &OUTPUT_DIR;/climatology_1.5deg/stat_analysis_WMO_1.5DEG_FILTER_CDF_dump.stat diff --git a/src/basic/vx_config/config.tab.cc b/src/basic/vx_config/config.tab.cc index 61513c670b..69427413b0 100644 --- a/src/basic/vx_config/config.tab.cc +++ b/src/basic/vx_config/config.tab.cc @@ -3229,11 +3229,10 @@ Simple_Node * s = new Simple_Node; s->op = op; -if ( (info.perc_index < 0) || (info.perc_index >= n_perc_thresh_infos) ) { +if ( info.ptype == no_perc_thresh_type ) { - mlog << Error - << "\ndo_simple_perc_thresh() -> bad perc_index ... " - << (info.perc_index) << "\n\n"; + mlog << Error << "\ndo_simple_perc_thresh() -> " + << "bad percentile threshold type\n\n"; exit ( 1 ); @@ -3243,7 +3242,7 @@ s->T = bad_data_double; s->PT = info.value; -s->Ptype = perc_thresh_info[info.perc_index].type; +s->Ptype = info.ptype; // // sanity check @@ -3274,7 +3273,7 @@ if ( s->Ptype == perc_thresh_freq_bias && s->PT <= 0 ) { if ( op >= 0 ) { ConcatString cs; - cs << perc_thresh_info[info.perc_index].short_name; + cs << perc_thresh_info_map.at(info.ptype).short_name; cs << info.value; fix_float(cs); @@ -3303,11 +3302,10 @@ Simple_Node * s = new Simple_Node; s->op = op; -if ( (info.perc_index < 0) || (info.perc_index >= n_perc_thresh_infos) ) { +if ( info.ptype == no_perc_thresh_type ) { - mlog << Error - << "\ndo_compound_perc_thresh() -> bad perc_index ... " - << (info.perc_index) << "\n\n"; + mlog << Error << "\ndo_compound_perc_thresh() -> " + << "bad percentile threshold type\n\n"; exit ( 1 ); @@ -3318,7 +3316,7 @@ else s->T = num.d; s->PT = info.value; -s->Ptype = perc_thresh_info[info.perc_index].type; +s->Ptype = info.ptype; // // sanity check @@ -3349,7 +3347,7 @@ if ( s->Ptype == perc_thresh_freq_bias && !is_eq(s->PT, 1.0) ) { if ( op >= 0 ) { ConcatString cs; - cs << perc_thresh_info[info.perc_index].short_name; + cs << perc_thresh_info_map.at(info.ptype).short_name; cs << info.value; fix_float(cs); cs << "(" << number_string << ")"; diff --git a/src/basic/vx_config/config.tab.yy b/src/basic/vx_config/config.tab.yy index dabe56d786..cab56d64af 100644 --- a/src/basic/vx_config/config.tab.yy +++ b/src/basic/vx_config/config.tab.yy @@ -1623,11 +1623,10 @@ Simple_Node * s = new Simple_Node; s->op = op; -if ( (info.perc_index < 0) || (info.perc_index >= n_perc_thresh_infos) ) { +if ( info.ptype == no_perc_thresh_type ) { - mlog << Error - << "\ndo_simple_perc_thresh() -> bad perc_index ... " - << (info.perc_index) << "\n\n"; + mlog << Error << "\ndo_simple_perc_thresh() -> " + << "bad percentile threshold type\n\n"; exit ( 1 ); @@ -1637,7 +1636,7 @@ s->T = bad_data_double; s->PT = info.value; -s->Ptype = perc_thresh_info[info.perc_index].type; +s->Ptype = info.ptype; // // sanity check @@ -1668,7 +1667,7 @@ if ( s->Ptype == perc_thresh_freq_bias && s->PT <= 0 ) { if ( op >= 0 ) { ConcatString cs; - cs << perc_thresh_info[info.perc_index].short_name; + cs << perc_thresh_info_map.at(info.ptype).short_name; cs << info.value; fix_float(cs); @@ -1697,11 +1696,10 @@ Simple_Node * s = new Simple_Node; s->op = op; -if ( (info.perc_index < 0) || (info.perc_index >= n_perc_thresh_infos) ) { +if ( info.ptype == no_perc_thresh_type ) { - mlog << Error - << "\ndo_compound_perc_thresh() -> bad perc_index ... " - << (info.perc_index) << "\n\n"; + mlog << Error << "\ndo_compound_perc_thresh() -> " + << "bad percentile threshold type\n\n"; exit ( 1 ); @@ -1712,7 +1710,7 @@ else s->T = num.d; s->PT = info.value; -s->Ptype = perc_thresh_info[info.perc_index].type; +s->Ptype = info.ptype; // // sanity check @@ -1743,7 +1741,7 @@ if ( s->Ptype == perc_thresh_freq_bias && !is_eq(s->PT, 1.0) ) { if ( op >= 0 ) { ConcatString cs; - cs << perc_thresh_info[info.perc_index].short_name; + cs << perc_thresh_info_map.at(info.ptype).short_name; cs << info.value; fix_float(cs); cs << "(" << number_string << ")"; diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index d7f2453689..e1a18aeb1a 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -723,10 +723,18 @@ static const char conf_key_is_wind_direction[] = "is_wind_direction"; static const char conf_key_is_prob[] = "is_prob"; // -// Climatology parameter key names +// Climatology data parameter key names +// +static const char conf_key_climo_mean_field[] = "climo_mean.field"; +static const char conf_key_fcst_climo_mean_field[] = "fcst.climo_mean.field"; +static const char conf_key_obs_climo_mean_field[] = "obs.climo_mean.field"; +static const char conf_key_climo_stdev_field[] = "climo_stdev.field"; +static const char conf_key_fcst_climo_stdev_field[] = "fcst.climo_stdev.field"; +static const char conf_key_obs_climo_stdev_field[] = "obs.climo_stdev.field"; + +// +// Climatology distribution parameter key names // -static const char conf_key_climo_mean_field[] = "climo_mean.field"; -static const char conf_key_climo_stdev_field[] = "climo_stdev.field"; static const char conf_key_climo_cdf[] = "climo_cdf"; static const char conf_key_cdf_bins[] = "cdf_bins"; static const char conf_key_center_bins[] = "center_bins"; diff --git a/src/basic/vx_config/my_config_scanner.cc b/src/basic/vx_config/my_config_scanner.cc index 13e41a196c..25a5cec234 100644 --- a/src/basic/vx_config/my_config_scanner.cc +++ b/src/basic/vx_config/my_config_scanner.cc @@ -514,7 +514,7 @@ int do_id() { -int j, k; +int j; const char *method_name = "do_id() -> "; Column += m_strlen(configtext); @@ -618,15 +618,7 @@ for (j=0; j " << "unable to parse string \"" << configtext << "\"\n\n"; @@ -1475,10 +1436,6 @@ if ( index < 0 ) { } -configlval.pc_info.perc_index = index; -configlval.pc_info.value = value; - - return SIMPLE_PERC_THRESH; } diff --git a/src/basic/vx_config/threshold.cc b/src/basic/vx_config/threshold.cc index 2bf216e084..bfff7a0089 100644 --- a/src/basic/vx_config/threshold.cc +++ b/src/basic/vx_config/threshold.cc @@ -36,6 +36,12 @@ extern ThreshNode * result; extern bool test_mode; +extern const std::string scp_perc_thresh_type_str("SCP"); + +extern const std::string cdp_perc_thresh_type_str("CDP"); + +static bool print_climo_perc_thresh_log_message = true; + //////////////////////////////////////////////////////////////////////// @@ -49,6 +55,92 @@ return ( t == thresh_le || t == thresh_ge || t == thresh_eq ); } +//////////////////////////////////////////////////////////////////////// + + +bool is_climo_dist_type(PercThreshType t) + +{ + +return ( t == perc_thresh_fcst_climo_dist || + t == perc_thresh_obs_climo_dist ); + +} + + +//////////////////////////////////////////////////////////////////////// + + +bool parse_perc_thresh(const char *str, PC_info *info) + +{ + +bool match = false; + +if ( perc_thresh_info_map.empty() ) return false; + +ConcatString search_cs(str); + +for (auto const& x : perc_thresh_info_map) { + + if ( search_cs.startswith(x.second.short_name.c_str()) && + is_number(str + x.second.short_name.size()) ) { + + if ( info ) { + + info->ptype = x.first; + + info->value = atof(str + x.second.short_name.size()); + + } + + match = true; + + break; + + } + +} + + // + // MET #2924: For backward compatibility support SCP and CDP + // threshold types + // + +if ( !match && + (search_cs.startswith(scp_perc_thresh_type_str.c_str()) || + search_cs.startswith(cdp_perc_thresh_type_str.c_str())) ) { + + if ( print_climo_perc_thresh_log_message ) { + + mlog << Debug(2) << R"(Please replace the deprecated "SCP" and "CDP" )" + << R"(threshold types with "SOCP" and "OCDP", respectively, in the ")" + << str << R"(" threshold string.\n)"; + + print_climo_perc_thresh_log_message = false; + + } + + ConcatString cs; + + if ( search_cs.startswith(scp_perc_thresh_type_str.c_str()) ) { + cs << perc_thresh_info_map.at(perc_thresh_sample_obs_climo).short_name; + cs << str + scp_perc_thresh_type_str.size(); + } + else { + cs << perc_thresh_info_map.at(perc_thresh_obs_climo_dist).short_name; + cs << str + cdp_perc_thresh_type_str.size(); + } + + return parse_perc_thresh(cs.c_str(), info); + +} + +return match; + +} + + //////////////////////////////////////////////////////////////////////// @@ -119,27 +211,15 @@ if ( right_child ) { delete right_child; right_child = nullptr; } //////////////////////////////////////////////////////////////////////// -bool Or_Node::check(double x) const +bool Or_Node::check(double x, const ClimoPntInfo *cpi) const { -return check(x, bad_data_double, bad_data_double); - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool Or_Node::check(double x, double cmn, double csd) const - -{ - -const bool tf_left = left_child->check(x, cmn, csd); +const bool tf_left = left_child->check(x, cpi); if ( tf_left ) return true; -const bool tf_right = right_child->check(x, cmn, csd); +const bool tf_right = right_child->check(x, cpi); return tf_right; @@ -168,13 +248,13 @@ return n; //////////////////////////////////////////////////////////////////////// -double Or_Node::climo_prob() const +double Or_Node::obs_climo_prob() const { if ( !left_child || !right_child ) { - mlog << Error << "\nOr_Node::climo_prob() -> " + mlog << Error << "\nOr_Node::obs_climo_prob() -> " << "node not populated!\n\n"; exit ( 1 ); @@ -182,8 +262,8 @@ if ( !left_child || !right_child ) { } double prob = bad_data_double; -double prob_left = left_child->climo_prob(); -double prob_right = right_child->climo_prob(); +double prob_left = left_child->obs_climo_prob(); +double prob_right = right_child->obs_climo_prob(); if ( !is_bad_data(prob_left) && !is_bad_data(prob_right) ) { @@ -220,21 +300,8 @@ return ( left_child->need_perc() || right_child->need_perc() ); //////////////////////////////////////////////////////////////////////// -void Or_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr) - -{ - -set_perc(fptr, optr, cptr, 0, 0); - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void Or_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr, +void Or_Node::set_perc(const NumArray *fptr, const NumArray *optr, + const NumArray *fcptr, const NumArray *ocptr, const SingleThresh *fthr, const SingleThresh *othr) { @@ -248,8 +315,8 @@ if ( !left_child || !right_child ) { } - left_child->set_perc(fptr, optr, cptr, fthr, othr); -right_child->set_perc(fptr, optr, cptr, fthr, othr); + left_child->set_perc(fptr, optr, fcptr, ocptr, fthr, othr); +right_child->set_perc(fptr, optr, fcptr, ocptr, fthr, othr); return; @@ -340,27 +407,15 @@ if ( right_child ) { delete right_child; right_child = nullptr; } //////////////////////////////////////////////////////////////////////// -bool And_Node::check(double x) const - -{ - -return check(x, bad_data_double, bad_data_double); - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool And_Node::check(double x, double cmn, double csd) const +bool And_Node::check(double x, const ClimoPntInfo *cpi) const { -const bool tf_left = left_child->check(x, cmn, csd); +const bool tf_left = left_child->check(x, cpi); if ( ! tf_left ) return false; -const bool tf_right = right_child->check(x, cmn, csd); +const bool tf_right = right_child->check(x, cpi); return ( tf_left && tf_right ); @@ -389,13 +444,13 @@ return n; //////////////////////////////////////////////////////////////////////// -double And_Node::climo_prob() const +double And_Node::obs_climo_prob() const { if ( !left_child || !right_child ) { - mlog << Error << "\nAnd_Node::climo_prob() -> " + mlog << Error << "\nAnd_Node::obs_climo_prob() -> " << "node not populated!\n\n"; exit ( 1 ); @@ -403,8 +458,8 @@ if ( !left_child || !right_child ) { } double prob = bad_data_double; -double prob_left = left_child->climo_prob(); -double prob_right = right_child->climo_prob(); +double prob_left = left_child->obs_climo_prob(); +double prob_right = right_child->obs_climo_prob(); // // For opposing inequalities, compute the difference in percentiles @@ -459,21 +514,8 @@ return ( left_child->need_perc() || right_child->need_perc() ); //////////////////////////////////////////////////////////////////////// -void And_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr) - -{ - -set_perc(fptr, optr, cptr, 0, 0); - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void And_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr, +void And_Node::set_perc(const NumArray *fptr, const NumArray *optr, + const NumArray *fcptr, const NumArray *ocptr, const SingleThresh *fthr, const SingleThresh *othr) { @@ -487,8 +529,8 @@ if ( !left_child || !right_child ) { } - left_child->set_perc(fptr, optr, cptr, fthr, othr); -right_child->set_perc(fptr, optr, cptr, fthr, othr); + left_child->set_perc(fptr, optr, fcptr, ocptr, fthr, othr); +right_child->set_perc(fptr, optr, fcptr, ocptr, fthr, othr); return; @@ -578,23 +620,11 @@ if ( child ) { delete child; child = nullptr; } //////////////////////////////////////////////////////////////////////// -bool Not_Node::check(double x) const - -{ - -return check(x, bad_data_double, bad_data_double); - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool Not_Node::check(double x, double cmn, double csd) const +bool Not_Node::check(double x, const ClimoPntInfo *cpi) const { -const bool tf = child->check(x, cmn, csd); +const bool tf = child->check(x, cpi); return !tf; @@ -622,12 +652,12 @@ return n; //////////////////////////////////////////////////////////////////////// -double Not_Node::climo_prob() const +double Not_Node::obs_climo_prob() const { double prob = bad_data_double; -double prob_child = child->climo_prob(); +double prob_child = child->obs_climo_prob(); if ( !is_bad_data(prob_child) ) prob = 1.0 - prob_child; @@ -660,23 +690,11 @@ return child->need_perc(); //////////////////////////////////////////////////////////////////////// -void Not_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr) - -{ - -set_perc(fptr, optr, cptr, 0, 0); - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void Not_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr, +void Not_Node::set_perc(const NumArray *fptr, const NumArray *optr, + const NumArray *fcptr, const NumArray *ocptr, const SingleThresh *fthr, const SingleThresh *othr) + { if ( !child ) { @@ -688,7 +706,7 @@ if ( !child ) { } -child->set_perc(fptr, optr, cptr, fthr, othr); +child->set_perc(fptr, optr, fcptr, ocptr, fthr, othr); return; @@ -780,35 +798,44 @@ Simple_Node::~Simple_Node() //////////////////////////////////////////////////////////////////////// -bool Simple_Node::check(double x) const +bool Simple_Node::check(double x, const ClimoPntInfo *cpi) const { -return check(x, bad_data_double, bad_data_double); +if ( op == thresh_na ) return true; -} +double tval; + // + // check climo distribution percentile thresholds + // -//////////////////////////////////////////////////////////////////////// +if ( is_climo_dist_type(Ptype) ) { + + // + // check the pointer + // + if(!cpi) { -bool Simple_Node::check(double x, double cmn, double csd) const + mlog << Error << "\nSimple_Node::check(double, const ClimoPntInfo *) const -> " + << "climatological distribution percentile threshold type requested " + << "with no ClimoPntInfo provided!\n\n"; -{ + exit ( 1 ); -if ( op == thresh_na ) return true; + } -double tval; + double cmn = (Ptype == perc_thresh_fcst_climo_dist ? cpi->fcmn : cpi->ocmn); + double csd = (Ptype == perc_thresh_fcst_climo_dist ? cpi->fcsd : cpi->ocsd); // - // check climo distribution percentile thresholds + // check the climo data // -if ( Ptype == perc_thresh_climo_dist ) { - if(is_bad_data(cmn) || is_bad_data(csd)) { - mlog << Error << "\nSimple_Node::check(double, double, double) const -> " + mlog << Error << "\nSimple_Node::check(double, const ClimoPntInfo *) const -> " << "climatological distribution percentile threshold \"" << s << "\" requested with invalid mean (" << cmn << ") or standard deviation (" << csd << ").\n\n"; @@ -832,7 +859,7 @@ else { if ( Ptype != no_perc_thresh_type && is_bad_data(tval) ) { - mlog << Error << "\nSimple_Node::check(double, double, double) const -> " + mlog << Error << "\nSimple_Node::check(double, const ClimoPntInfo *) const -> " << "percentile threshold \"" << s << "\" used before it was set.\n\n"; @@ -856,7 +883,7 @@ switch ( op ) { case thresh_ne: tf = !eq; break; default: - mlog << Error << "\nSimple_Node::check(double, double, double) const -> " + mlog << Error << "\nSimple_Node::check(double, const ClimoPntInfo *) const -> " << "bad op ... " << op << "\n\n"; exit ( 1 ); @@ -914,24 +941,12 @@ return; } -//////////////////////////////////////////////////////////////////////// - - -void Simple_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr) - -{ - -set_perc(fptr, optr, cptr, 0, 0); - -return; - -} - //////////////////////////////////////////////////////////////////////// -void Simple_Node::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr, +void Simple_Node::set_perc(const NumArray *fptr, const NumArray *optr, + const NumArray *fcptr, const NumArray *ocptr, const SingleThresh *fthr, const SingleThresh *othr) { @@ -946,9 +961,10 @@ bool fbias_fcst = false; // handle sample percentile types // - if ( Ptype == perc_thresh_sample_fcst ) ptr = fptr; -else if ( Ptype == perc_thresh_sample_obs ) ptr = optr; -else if ( Ptype == perc_thresh_sample_climo ) ptr = cptr; + if ( Ptype == perc_thresh_sample_fcst ) ptr = fptr; +else if ( Ptype == perc_thresh_sample_obs ) ptr = optr; +else if ( Ptype == perc_thresh_sample_fcst_climo ) ptr = fcptr; +else if ( Ptype == perc_thresh_sample_obs_climo ) ptr = ocptr; // // handle bias-correction type @@ -960,7 +976,7 @@ else if ( Ptype == perc_thresh_freq_bias ) { mlog << Error << "\nSimple_Node::set_perc() -> " << "not enough information provided to define the " - << perc_thresh_info[Ptype].long_name + << perc_thresh_info_map.at(Ptype).long_name << " threshold \"" << s << "\".\n\n"; exit ( 1 ); @@ -1013,7 +1029,7 @@ else if ( Ptype == perc_thresh_freq_bias ) { mlog << Error << "\nSimple_Node::set_perc() -> " << "unsupported options for computing the " - << perc_thresh_info[Ptype].long_name + << perc_thresh_info_map.at(Ptype).long_name << " threshold \"" << s << "\".\n\n"; exit ( 1 ); @@ -1028,7 +1044,7 @@ else if ( Ptype == perc_thresh_freq_bias ) { mlog << Error << "\nSimple_Node::set_perc() -> " << "unable to compute the percentile for the " - << perc_thresh_info[Ptype].long_name + << perc_thresh_info_map.at(Ptype).long_name << " threshold \"" << s << "\".\n\n"; exit ( 1 ); @@ -1051,7 +1067,7 @@ else { if ( !ptr ) { mlog << Error << "\nSimple_Node::set_perc() -> " - << perc_thresh_info[Ptype].long_name + << perc_thresh_info_map.at(Ptype).long_name << " threshold \"" << s << "\" requested but no data provided.\n\n"; @@ -1086,7 +1102,7 @@ else { if ( data.n() == 0 ) { mlog << Error << "\nSimple_Node::set_perc() -> " - << "can't compute " << perc_thresh_info[Ptype].long_name + << "can't compute " << perc_thresh_info_map.at(Ptype).long_name << " threshold \"" << s << "\" because no valid data was provided.\n\n"; @@ -1216,15 +1232,15 @@ return; //////////////////////////////////////////////////////////////////////// -double Simple_Node::climo_prob() const +double Simple_Node::obs_climo_prob() const { double prob = bad_data_double; -if ( Ptype == perc_thresh_climo_dist ) { +if ( Ptype == perc_thresh_obs_climo_dist ) { - // Climo probability varies based on the threshold type + // Observation climo probability varies based on the threshold type switch ( op ) { case thresh_lt: @@ -1251,9 +1267,9 @@ if ( Ptype == perc_thresh_climo_dist ) { default: - mlog << Error << "\nSimple_Node::climo_prob() -> " - << "cannot convert climatological distribution percentile " - << "threshold to a probability!\n\n"; + mlog << Error << "\nSimple_Node::obs_climo_prob() -> " + << "cannot convert observation climatological distribution " + << "percentile threshold to a probability!\n\n"; exit ( 1 ); @@ -1272,9 +1288,10 @@ bool Simple_Node::need_perc() const { -return ( Ptype == perc_thresh_sample_fcst || - Ptype == perc_thresh_sample_obs || - Ptype == perc_thresh_sample_climo || +return ( Ptype == perc_thresh_sample_fcst || + Ptype == perc_thresh_sample_obs || + Ptype == perc_thresh_sample_fcst_climo || + Ptype == perc_thresh_sample_obs_climo || Ptype == perc_thresh_freq_bias ); } @@ -1496,17 +1513,16 @@ return; //////////////////////////////////////////////////////////////////////// -void SingleThresh::set(double pt, ThreshType ind, int perc_index, double t) +void SingleThresh::set(double pt, ThreshType ind, PercThreshType ptype, double t) { clear(); -if ( (perc_index < 0) || (perc_index >= n_perc_thresh_infos) ) { +if ( ptype == no_perc_thresh_type ) { - mlog << Error - << "\nSingleThresh::set(double pt, ThreshType ind, int perc_index, double t) -> " - << "bad perc_index ... " << perc_index << "\n\n"; + mlog << Error << "\nSingleThresh::set(double, ThreshType, PercThreshType, double) -> " + << "bad percentile threshold type\n\n"; exit ( 1 ); @@ -1515,12 +1531,12 @@ if ( (perc_index < 0) || (perc_index >= n_perc_thresh_infos) ) { Simple_Node * a = new Simple_Node; ConcatString cs; -cs << perc_thresh_info[perc_index].short_name << pt; +cs << perc_thresh_info_map.at(ptype).short_name << pt; if( !is_bad_data(t) ) cs << "(" << t << ")"; a->T = t; a->op = ind; -a->Ptype = perc_thresh_info[perc_index].type; +a->Ptype = ptype; a->PT = pt; a->s << thresh_type_str[ind] << cs; a->abbr_s << thresh_abbr_str[ind] << cs; @@ -1656,27 +1672,15 @@ return false; //////////////////////////////////////////////////////////////////////// -void SingleThresh::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr) - -{ - -set_perc(fptr, optr, cptr, 0, 0); - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void SingleThresh::set_perc(const NumArray *fptr, const NumArray *optr, const NumArray *cptr, +void SingleThresh::set_perc(const NumArray *fptr, const NumArray *optr, + const NumArray *fcptr, const NumArray *ocptr, const SingleThresh *fthr, const SingleThresh *othr) + { if ( node ) { - node->set_perc(fptr, optr, cptr, fthr, othr); + node->set_perc(fptr, optr, fcptr, ocptr, fthr, othr); } @@ -1796,23 +1800,11 @@ return; //////////////////////////////////////////////////////////////////////// -bool SingleThresh::check(double x) const - -{ - -return check(x, bad_data_double, bad_data_double); - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool SingleThresh::check(double x, double cmn, double csd) const +bool SingleThresh::check(double x, const ClimoPntInfo *cpi) const { -return ( node ? node->check(x, cmn, csd) : true ); +return ( node ? node->check(x, cpi) : true ); } diff --git a/src/basic/vx_config/threshold.h b/src/basic/vx_config/threshold.h index 0f39bd3413..c879cfe3c7 100644 --- a/src/basic/vx_config/threshold.h +++ b/src/basic/vx_config/threshold.h @@ -13,6 +13,7 @@ //////////////////////////////////////////////////////////////////////// #include +#include #include #include "concat_string.h" @@ -22,7 +23,6 @@ //////////////////////////////////////////////////////////////////////// - // // Enumeration of thresholding operations // @@ -39,7 +39,6 @@ enum ThreshType { thresh_complex = -2, no_thresh_type = -1 - }; static const int n_thresh_type = 7; @@ -55,82 +54,71 @@ static const char thresh_default_sep[] = ","; extern bool is_inclusive(ThreshType); - //////////////////////////////////////////////////////////////////////// - // // Enumeration of percentile threshold types // enum PercThreshType { - - perc_thresh_user_specified = 0, - perc_thresh_sample_fcst = 1, - perc_thresh_sample_obs = 2, - perc_thresh_sample_climo = 3, - perc_thresh_climo_dist = 4, - perc_thresh_freq_bias = 5, + perc_thresh_user_specified = 0, + perc_thresh_sample_fcst = 1, + perc_thresh_sample_obs = 2, + perc_thresh_sample_fcst_climo = 3, + perc_thresh_sample_obs_climo = 4, + perc_thresh_fcst_climo_dist = 5, + perc_thresh_obs_climo_dist = 6, + perc_thresh_freq_bias = 7, no_perc_thresh_type = -1 - }; - -static const int n_perc_thresh_type = 7; - +extern bool is_climo_dist_type(PercThreshType); struct PercThreshInfo { - - const PercThreshType type; - - const char * const short_name; - - const int short_name_length; - - const char * const long_name; - + const std::string short_name; + const std::string long_name; }; - -static const PercThreshInfo perc_thresh_info [] = { - - { perc_thresh_user_specified, "USP", 3, "USER_SPECIFIED_PERC" }, - - { perc_thresh_sample_fcst, "SFP", 3, "SAMPLE_FCST_PERC" }, - - { perc_thresh_sample_obs, "SOP", 3, "SAMPLE_OBS_PERC" }, - - { perc_thresh_sample_climo, "SCP", 3, "SAMPLE_CLIMO_PERC" }, - - { perc_thresh_climo_dist, "CDP", 3, "CLIMO_DIST_PERC" }, - - { perc_thresh_freq_bias, "FBIAS", 5, "FREQ_BIAS_PERC" }, - +static const std::map perc_thresh_info_map = { + { perc_thresh_user_specified, { "USP", "USER_SPECIFIED_PERC" } }, + { perc_thresh_sample_fcst, { "SFP", "SAMPLE_FCST_PERC" } }, + { perc_thresh_sample_obs, { "SOP", "SAMPLE_OBS_PERC" } }, + { perc_thresh_sample_fcst_climo, { "SFCP", "SAMPLE_FCST_CLIMO_PERC" } }, + { perc_thresh_sample_obs_climo, { "SOCP", "SAMPLE_OBS_CLIMO_PERC" } }, + { perc_thresh_fcst_climo_dist, { "FCDP", "CLIMO_FCST_DIST_PERC" } }, + { perc_thresh_obs_climo_dist, { "OCDP", "CLIMO_OBS_DIST_PERC" } }, + { perc_thresh_freq_bias, { "FBIAS", "FREQ_BIAS_PERC" } }, }; -static const int n_perc_thresh_infos = sizeof(perc_thresh_info)/sizeof(*perc_thresh_info); - static const int perc_thresh_default_precision = 0; static const double perc_thresh_default_tol = 0.05; - struct PC_info { + PercThreshType ptype; + double value; +}; - int perc_index; +extern bool parse_perc_thresh(const char *str, PC_info *info = nullptr); - double value; +struct ClimoPntInfo { + ClimoPntInfo() { clear(); } + ClimoPntInfo(double a, double b, double c, double d) : + fcmn(a), fcsd(b), ocmn(c), ocsd(d) {} + void set(double a, double b, double c, double d) { fcmn = a; fcsd = b; ocmn = c; ocsd = d; } + void clear() { fcmn = fcsd = ocmn = ocsd = bad_data_double; } + double fcmn; + double fcsd; + double ocmn; + double ocsd; }; - //////////////////////////////////////////////////////////////////////// - class SingleThresh; class Simple_Node; - //////////////////////////////////////////////////////////////////////// class ThreshNode { @@ -144,8 +132,7 @@ class ThreshNode { ThreshNode(); virtual ~ThreshNode(); - virtual bool check(double) const = 0; - virtual bool check(double, double, double) const = 0; + virtual bool check(double, const ClimoPntInfo *cpi = nullptr) const = 0; virtual ThreshNode * copy() const = 0; @@ -157,14 +144,14 @@ class ThreshNode { virtual double pvalue() const = 0; - virtual double climo_prob() const = 0; + virtual double obs_climo_prob() const = 0; virtual bool need_perc() const = 0; - virtual void set_perc(const NumArray *, const NumArray *, const NumArray *) = 0; - - virtual void set_perc(const NumArray *, const NumArray *, const NumArray *, - const SingleThresh *, const SingleThresh *) = 0; + virtual void set_perc(const NumArray *, const NumArray *, + const NumArray *, const NumArray *, + const SingleThresh *fthr = nullptr, + const SingleThresh *othr = nullptr) = 0; virtual void multiply_by(const double) = 0; @@ -186,31 +173,30 @@ class Or_Node : public ThreshNode { Or_Node(); ~Or_Node(); - bool check(double) const; - bool check(double, double, double) const; + bool check(double, const ClimoPntInfo *cpi = nullptr) const override; - ThreshNode * copy() const; + ThreshNode * copy() const override; - ThreshType type() const; + ThreshType type() const override; - double value() const; + double value() const override; - PercThreshType ptype() const; + PercThreshType ptype() const override; - double pvalue() const; + double pvalue() const override; - double climo_prob() const; + double obs_climo_prob() const override; - bool need_perc() const; + bool need_perc() const override; - void set_perc(const NumArray *, const NumArray *, const NumArray *); + void set_perc(const NumArray *, const NumArray *, + const NumArray *, const NumArray *, + const SingleThresh *fthr = nullptr, + const SingleThresh *othr = nullptr) override; - void set_perc(const NumArray *, const NumArray *, const NumArray *, - const SingleThresh *, const SingleThresh *); + void multiply_by(const double) override; - void multiply_by(const double); - - void get_simple_nodes(std::vector &) const; + void get_simple_nodes(std::vector &) const override; ThreshNode * left_child; ThreshNode * right_child; @@ -237,31 +223,30 @@ class And_Node : public ThreshNode { And_Node(); ~And_Node(); - bool check(double) const; - bool check(double, double, double) const; - - ThreshType type() const; + bool check(double, const ClimoPntInfo *cpi = nullptr) const override; - double value() const; + ThreshType type() const override; - PercThreshType ptype() const; + double value() const override; - double pvalue() const; + PercThreshType ptype() const override; - double climo_prob() const; + double pvalue() const override; - bool need_perc() const; + double obs_climo_prob() const override; - void set_perc(const NumArray *, const NumArray *, const NumArray *); + bool need_perc() const override; - void set_perc(const NumArray *, const NumArray *, const NumArray *, - const SingleThresh *, const SingleThresh *); + void set_perc(const NumArray *, const NumArray *, + const NumArray *, const NumArray *, + const SingleThresh *fthr = nullptr, + const SingleThresh *othr = nullptr) override; - void multiply_by(const double); + void multiply_by(const double) override; - void get_simple_nodes(std::vector &) const; + void get_simple_nodes(std::vector &) const override; - ThreshNode * copy() const; + ThreshNode * copy() const override; ThreshNode * left_child; ThreshNode * right_child; @@ -288,31 +273,30 @@ class Not_Node : public ThreshNode { Not_Node(); ~Not_Node(); - bool check(double) const; - bool check(double, double, double) const; + bool check(double, const ClimoPntInfo *cpi = nullptr) const override; - ThreshType type() const; + ThreshType type() const override; - double value() const; + double value() const override; - PercThreshType ptype() const; + PercThreshType ptype() const override; - double pvalue() const; + double pvalue() const override; - double climo_prob() const; + double obs_climo_prob() const override; - bool need_perc() const; + bool need_perc() const override; - void set_perc(const NumArray *, const NumArray *, const NumArray *); + void set_perc(const NumArray *, const NumArray *, + const NumArray *, const NumArray *, + const SingleThresh *fthr = nullptr, + const SingleThresh *othr = nullptr) override; - void set_perc(const NumArray *, const NumArray *, const NumArray *, - const SingleThresh *, const SingleThresh *); + void multiply_by(const double) override; - void multiply_by(const double); + void get_simple_nodes(std::vector &) const override; - void get_simple_nodes(std::vector &) const; - - ThreshNode * copy() const; + ThreshNode * copy() const override; ThreshNode * child; @@ -354,39 +338,38 @@ class Simple_Node : public ThreshNode { void set_na(); - void set_perc(const NumArray *, const NumArray *, const NumArray *); - - void set_perc(const NumArray *, const NumArray *, const NumArray *, - const SingleThresh *, const SingleThresh *); + void set_perc(const NumArray *, const NumArray *, + const NumArray *, const NumArray *, + const SingleThresh *fthr = nullptr, + const SingleThresh *othr = nullptr) override; // // get stuff // - ThreshType type() const; + ThreshType type() const override; - double value() const; + double value() const override; - PercThreshType ptype() const; + PercThreshType ptype() const override; - double pvalue() const; + double pvalue() const override; - double climo_prob() const; + double obs_climo_prob() const override; - bool need_perc() const; + bool need_perc() const override; - void get_simple_nodes(std::vector &) const; + void get_simple_nodes(std::vector &) const override; // // do stuff // - ThreshNode * copy() const; + ThreshNode * copy() const override; - bool check(double) const; - bool check(double, double, double) const; + bool check(double, const ClimoPntInfo *cpi = nullptr) const override; - void multiply_by(const double); + void multiply_by(const double) override; }; @@ -430,14 +413,15 @@ class SingleThresh { void clear(); void set(double t, ThreshType); - void set(double pt, ThreshType, int perc_index, double t = bad_data_double); + void set(double pt, ThreshType, PercThreshType, double t = bad_data_double); void set(const ThreshNode *); void set(const char *); bool need_perc() const; - void set_perc(const NumArray *, const NumArray *, const NumArray *); - void set_perc(const NumArray *, const NumArray *, const NumArray *, - const SingleThresh *, const SingleThresh *); + void set_perc(const NumArray *, const NumArray *, + const NumArray *, const NumArray *, + const SingleThresh *fthr = nullptr, + const SingleThresh *othr = nullptr); void set_na(); @@ -445,7 +429,7 @@ class SingleThresh { double get_value() const; PercThreshType get_ptype() const; double get_pvalue() const; - double get_climo_prob() const; + double get_obs_climo_prob() const; void get_simple_nodes(std::vector &) const; void multiply_by(const double); @@ -453,8 +437,7 @@ class SingleThresh { ConcatString get_str(int precision = thresh_default_precision) const; ConcatString get_abbr_str(int precision = thresh_default_precision) const; - bool check(double) const; - bool check(double, double, double) const; + bool check(double, const ClimoPntInfo *cpi = nullptr) const; }; @@ -462,11 +445,11 @@ class SingleThresh { //////////////////////////////////////////////////////////////////////// -inline ThreshType SingleThresh::get_type() const { return ( node ? node->type() : thresh_na ); } -inline double SingleThresh::get_value() const { return ( node ? node->value() : bad_data_double ); } -inline PercThreshType SingleThresh::get_ptype() const { return ( node ? node->ptype() : no_perc_thresh_type ); } -inline double SingleThresh::get_pvalue() const { return ( node ? node->pvalue() : bad_data_double ); } -inline double SingleThresh::get_climo_prob() const { return ( node ? node->climo_prob() : bad_data_double ); } +inline ThreshType SingleThresh::get_type() const { return ( node ? node->type() : thresh_na ); } +inline double SingleThresh::get_value() const { return ( node ? node->value() : bad_data_double ); } +inline PercThreshType SingleThresh::get_ptype() const { return ( node ? node->ptype() : no_perc_thresh_type ); } +inline double SingleThresh::get_pvalue() const { return ( node ? node->pvalue() : bad_data_double ); } +inline double SingleThresh::get_obs_climo_prob() const { return ( node ? node->obs_climo_prob() : bad_data_double ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/logger.cc b/src/basic/vx_log/logger.cc index 8535cca6e4..c3d6ee1b48 100644 --- a/src/basic/vx_log/logger.cc +++ b/src/basic/vx_log/logger.cc @@ -627,7 +627,6 @@ Logger & Logger::operator<<(const string s) // // put the next character into the ConcatString msg // - // tmp[0] = s[i]; msg.add(s[i]); if (s[i] == '\n') @@ -636,7 +635,7 @@ Logger & Logger::operator<<(const string s) // this was a newline, so // put msg into the StringArray messages // - messages.add((string)msg); + messages.add((string)msg); // // clear msg, and continue checking s @@ -655,7 +654,7 @@ Logger & Logger::operator<<(const string s) { if (s[s.length() - 1] != '\n') { - messages.add((string)msg); + messages.add((string)msg); msg.clear(); } diff --git a/src/basic/vx_util/CircularTemplate.cc b/src/basic/vx_util/CircularTemplate.cc index 593b1eedec..4fb91c1f85 100644 --- a/src/basic/vx_util/CircularTemplate.cc +++ b/src/basic/vx_util/CircularTemplate.cc @@ -41,12 +41,12 @@ CircularTemplate::CircularTemplate(const int width, bool wrap_lon) : _wrapLon = wrap_lon; - // width of 2 is not supported - if (width == 2) { + // width of 2 is not supported + if (width == 2) { mlog << Error << "\nCircularTemplate::CircularTemplate() -> " << "unsupported width of " << width << " for circles.\n\n"; - exit(1); - } + exit(1); + } bool evenWidth = ((width % 2) == 0); @@ -59,9 +59,9 @@ CircularTemplate::CircularTemplate(const int width, bool wrap_lon) : // offset is within the circle. double radius = (width-1)/2.0; - + // Create the offsets list. - + // Need to increase the area we look at if the width is even, because // some valid offset points will actually be farther from the reference point // than the radius, because the reference point is offset from the true @@ -71,31 +71,31 @@ CircularTemplate::CircularTemplate(const int width, bool wrap_lon) : if(evenWidth) maxOffset++; int minOffset = static_cast(floor(-1 * radius)); - + for(int y = minOffset; y <= maxOffset; y++) { for(int x = minOffset; x <= maxOffset; x++) { double double_x = (double)x; double double_y = (double)y; - if(evenWidth) { + if(evenWidth) { // if width is even, the reference point is actually shifted 1/2 a grid spacing down and to the left, // from the true center of the circle. - // - // so when we calculate distance, we need to subtract .5 so that the distance reflects the distance from the center - // of the circle, instead of the distance from the reference. - // - // for example - a circle with width == 4. The reference point is the lower left corner of the center square. - // the point directly below that is at (0,-1), but it's actually (-.5, -1.5) from the center of the circle. - // - // another example - same circle. The point directly to the right of the reference point is (1,0), but it's - // actually (.5,-.5) from the center. - + // + // so when we calculate distance, we need to subtract .5 so that the distance reflects the distance from the center + // of the circle, instead of the distance from the reference. + // + // for example - a circle with width == 4. The reference point is the lower left corner of the center square. + // the point directly below that is at (0,-1), but it's actually (-.5, -1.5) from the center of the circle. + // + // another example - same circle. The point directly to the right of the reference point is (1,0), but it's + // actually (.5,-.5) from the center. + double_x -= 0.5; double_y -= 0.5; } double distance= sqrt((double_x * double_x) + (double_y * double_y)); - if(distance <= radius) _addOffset(x, y); + if(distance <= radius) _addOffset(x, y); } // end for x } // end for y diff --git a/src/basic/vx_util/GridPoint.cc b/src/basic/vx_util/GridPoint.cc index 8ddd5f31b9..009cf86bf4 100644 --- a/src/basic/vx_util/GridPoint.cc +++ b/src/basic/vx_util/GridPoint.cc @@ -64,7 +64,6 @@ GridPoint::~GridPoint(void) void GridPoint::rotate(const double angle) { - //const double M_PI = 3.14159265358979323846; double angle_rad = angle * M_PI / 180.0; double cosa = cos(angle_rad); double sina = sin(angle_rad); diff --git a/src/basic/vx_util/data_plane.cc b/src/basic/vx_util/data_plane.cc index 2aa218b6a0..e3edf3d0cf 100644 --- a/src/basic/vx_util/data_plane.cc +++ b/src/basic/vx_util/data_plane.cc @@ -518,7 +518,7 @@ void DataPlane::censor(const ThreshArray &censor_thresh, for(i=0; iis_empty() && !csd->is_empty()) use_climo = true; - } + if(fcmn && !fcmn->is_empty() && + fcsd && !fcsd->is_empty() && + ocmn && !ocmn->is_empty() && + ocsd && !ocsd->is_empty()) use_climo = true; // Check climatology dimensions if(use_climo) { // Check dimensions - if(cmn->nx() != dp.nx() || cmn->ny() != dp.ny()) { + if(fcmn->nx() != dp.nx() || fcmn->ny() != dp.ny()) { + mlog << Error << "\nfractional_coverage() -> " + << "forecast climatology mean dimension (" + << fcmn->nx() << ", " << fcmn->ny() + << ") does not match the data dimenion (" + << dp.nx() << ", " << dp.ny() << ")!\n\n"; + exit(1); + } + if(fcsd->nx() != dp.nx() || fcsd->ny() != dp.ny()) { + mlog << Error << "\nfractional_coverage() -> " + << "forecast climatology standard deviation dimension (" + << fcsd->nx() << ", " << fcsd->ny() + << ") does not match the data dimenion (" + << dp.nx() << ", " << dp.ny() << ")!\n\n"; + exit(1); + } + if(ocmn->nx() != dp.nx() || ocmn->ny() != dp.ny()) { mlog << Error << "\nfractional_coverage() -> " - << "climatology mean dimension (" - << cmn->nx() << ", " << cmn->ny() + << "observation climatology mean dimension (" + << ocmn->nx() << ", " << ocmn->ny() << ") does not match the data dimenion (" << dp.nx() << ", " << dp.ny() << ")!\n\n"; exit(1); } - if(csd->nx() != dp.nx() || csd->ny() != dp.ny()) { + if(ocsd->nx() != dp.nx() || ocsd->ny() != dp.ny()) { mlog << Error << "\nfractional_coverage() -> " - << "climatology standard deviation dimension (" - << csd->nx() << ", " << csd->ny() + << "observation climatology standard deviation dimension (" + << ocsd->nx() << ", " << ocsd->ny() << ") does not match the data dimenion (" << dp.nx() << ", " << dp.ny() << ")!\n\n"; exit(1); @@ -255,7 +274,7 @@ void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, #pragma omp parallel default(none) \ shared(mlog, dp, frac_dp, shape, width, wrap_lon, t) \ - shared(use_climo, cmn, csd, vld_t, bad) \ + shared(use_climo, fcmn, fcsd, ocmn, ocsd, vld_t, bad)\ private(x, y, n_vld, n_thr, gp, v) { @@ -293,9 +312,14 @@ void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, gp = gt->getNextInGrid()) { if(is_bad_data(v = dp.get(gp->x, gp->y))) continue; n_vld++; - if(t.check(v, - (use_climo ? cmn->get(gp->x, gp->y) : bad), - (use_climo ? csd->get(gp->x, gp->y) : bad))) n_thr++; + ClimoPntInfo cpi; + if(use_climo) { + cpi.set(fcmn->get(gp->x, gp->y), + fcsd->get(gp->x, gp->y), + ocmn->get(gp->x, gp->y), + ocsd->get(gp->x, gp->y)); + } + if(t.check(v, &cpi)) n_thr++; } } // Subtract off the bottom edge, shift up, and add the top. @@ -307,9 +331,14 @@ void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, gp = gt->getNextInBotEdge()) { if(is_bad_data(v = dp.get(gp->x, gp->y))) continue; n_vld--; - if(t.check(v, - (use_climo ? cmn->get(gp->x, gp->y) : bad), - (use_climo ? csd->get(gp->x, gp->y) : bad))) n_thr--; + ClimoPntInfo cpi; + if(use_climo) { + cpi.set(fcmn->get(gp->x, gp->y), + fcsd->get(gp->x, gp->y), + ocmn->get(gp->x, gp->y), + ocsd->get(gp->x, gp->y)); + } + if(t.check(v, &cpi)) n_thr--; } // Increment Y @@ -321,9 +350,14 @@ void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, gp = gt->getNextInTopEdge()) { if(is_bad_data(v = dp.get(gp->x, gp->y))) continue; n_vld++; - if(t.check(v, - (use_climo ? cmn->get(gp->x, gp->y) : bad), - (use_climo ? csd->get(gp->x, gp->y) : bad))) n_thr++; + ClimoPntInfo cpi; + if(use_climo) { + cpi.set(fcmn->get(gp->x, gp->y), + fcsd->get(gp->x, gp->y), + ocmn->get(gp->x, gp->y), + ocsd->get(gp->x, gp->y)); + } + if(t.check(v, &cpi)) n_thr++; } } diff --git a/src/basic/vx_util/data_plane_util.h b/src/basic/vx_util/data_plane_util.h index 7f0b9b27a7..0cb74224ad 100644 --- a/src/basic/vx_util/data_plane_util.h +++ b/src/basic/vx_util/data_plane_util.h @@ -53,7 +53,9 @@ extern DataPlane smooth_field(const DataPlane &dp, extern void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, int width, GridTemplateFactory::GridTemplates shape, bool wrap_lon, SingleThresh t, - const DataPlane *cmn, const DataPlane *csd, double vld_t); + const DataPlane *fcmn, const DataPlane *fcsd, + const DataPlane *ocmn, const DataPlane *ocsd, + double vld_t); extern void apply_mask(const DataPlane &, const MaskPlane &, NumArray &); extern void apply_mask(DataPlane &, const MaskPlane &); diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index b5cb88c412..4bf797c2c6 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -704,7 +704,7 @@ double interp_geog_match(const DataPlane &dp, const GridTemplate >, //////////////////////////////////////////////////////////////////////// double interp_nbrhd(const DataPlane &dp, const GridTemplate >, int x, int y, - double t, const SingleThresh *st, double cmn, double csd, + double t, const SingleThresh *st, const ClimoPntInfo *cpi, const MaskPlane *mp) { int count, count_thr; @@ -723,7 +723,7 @@ double interp_nbrhd(const DataPlane &dp, const GridTemplate >, int x, int y, if(is_bad_data(data)) continue; count++; - if(st->check(data, cmn, csd)) count_thr++; + if(st->check(data, cpi)) count_thr++; } // Check whether enough valid grid points were found @@ -1099,8 +1099,8 @@ double compute_horz_interp(const DataPlane &dp, const GridTemplateFactory::GridTemplates shape, bool wrap_lon, double interp_thresh, const SingleThresh *cat_thresh) { - return compute_horz_interp(dp, obs_x, obs_y, obs_v, bad_data_double, - bad_data_double, mthd, width, shape, wrap_lon, + return compute_horz_interp(dp, obs_x, obs_y, obs_v, nullptr, + mthd, width, shape, wrap_lon, interp_thresh, cat_thresh); } @@ -1108,7 +1108,7 @@ double compute_horz_interp(const DataPlane &dp, double compute_horz_interp(const DataPlane &dp, double obs_x, double obs_y, - double obs_v, double cmn, double csd, + double obs_v, const ClimoPntInfo *cpi, const InterpMthd mthd, const int width, const GridTemplateFactory::GridTemplates shape, bool wrap_lon, double interp_thresh, @@ -1157,7 +1157,7 @@ double compute_horz_interp(const DataPlane &dp, case InterpMthd::Nbrhd: // Neighborhood fractional coverage v = interp_nbrhd(dp, *gt, x, y, - interp_thresh, cat_thresh, cmn, csd); + interp_thresh, cat_thresh, cpi); break; case InterpMthd::Bilin: // Bilinear interpolation diff --git a/src/basic/vx_util/interp_util.h b/src/basic/vx_util/interp_util.h index e8f30975de..9e5561eb63 100644 --- a/src/basic/vx_util/interp_util.h +++ b/src/basic/vx_util/interp_util.h @@ -64,10 +64,10 @@ extern NumArray interp_points (const DataPlane &dp, const GridTemplate >, dou // GridTemplate version takes center x/y extern NumArray interp_points (const DataPlane &dp, const GridTemplate >, int x, int y); -extern double interp_min (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = 0); -extern double interp_max (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = 0); -extern double interp_median (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = 0); -extern double interp_uw_mean (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = 0); +extern double interp_min (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = nullptr); +extern double interp_max (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = nullptr); +extern double interp_median (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = nullptr); +extern double interp_uw_mean (const DataPlane &dp, const GridTemplate >, int x, int y, double t, const MaskPlane *mp = nullptr); // Non-GridTemplate version takes lower-left corner x/y extern double interp_min_ll (const DataPlane &dp, int x_ll, int y_ll, int w, double t); @@ -76,19 +76,19 @@ extern double interp_median_ll (const DataPlane &dp, int x_ll, int y_ll, int extern double interp_uw_mean_ll (const DataPlane &dp, int x_ll, int y_ll, int w, double t); // GridTemplate version takes center x/y -extern double interp_dw_mean (const DataPlane &, const GridTemplate >, double obs_x, double obs_y, int i_pow, double t, const MaskPlane *mp = 0); -extern double interp_ls_fit (const DataPlane &, const GridTemplate >, double obs_x, double obs_y, double t, const MaskPlane *mp = 0); +extern double interp_dw_mean (const DataPlane &, const GridTemplate >, double obs_x, double obs_y, int i_pow, double t, const MaskPlane *mp = nullptr); +extern double interp_ls_fit (const DataPlane &, const GridTemplate >, double obs_x, double obs_y, double t, const MaskPlane *mp = nullptr); extern void interp_gaussian_dp(DataPlane &, const GaussianInfo &, double t); extern double interp_gaussian (const DataPlane &, const DataPlane &, double obs_x, double obs_y, int max_r, double t); -extern double interp_geog_match(const DataPlane &, const GridTemplate >, double obs_x, double obs_y, double obs_v, const MaskPlane *mp = 0); +extern double interp_geog_match(const DataPlane &, const GridTemplate >, double obs_x, double obs_y, double obs_v, const MaskPlane *mp = nullptr); extern double interp_nbrhd (const DataPlane &, const GridTemplate >, int x, int y, double t, const SingleThresh *, - double cmn, double csd, const MaskPlane *mp = 0); -extern double interp_bilin (const DataPlane &, bool wrap_lon, double obs_x, double obs_y, const MaskPlane *mp = 0); -extern double interp_xy (const DataPlane &, bool wrap_lon, int x, int y, const MaskPlane *mp = 0); + const ClimoPntInfo *, const MaskPlane *mp = nullptr); +extern double interp_bilin (const DataPlane &, bool wrap_lon, double obs_x, double obs_y, const MaskPlane *mp = nullptr); +extern double interp_xy (const DataPlane &, bool wrap_lon, int x, int y, const MaskPlane *mp = nullptr); -extern double interp_best (const DataPlane &dp, const GridTemplate >, int x, int y, double obs_v, double t, const MaskPlane *mp = 0); +extern double interp_best (const DataPlane &dp, const GridTemplate >, int x, int y, double obs_v, double t, const MaskPlane *mp = nullptr); extern void get_xy_ll (double x, double y, int w, int h, int &x_ll, int &y_ll); @@ -115,15 +115,15 @@ extern double compute_horz_interp(const DataPlane &dp, const InterpMthd mthd, const int width, const GridTemplateFactory::GridTemplates shape, bool wrap_lon, double interp_thresh, - const SingleThresh *cat_thresh = 0); + const SingleThresh *cat_thresh = nullptr); extern double compute_horz_interp(const DataPlane &dp, double obs_x, double obs_y, - double obs_v, double cmn, double csd, + double obs_v, const ClimoPntInfo *, const InterpMthd mthd, const int width, const GridTemplateFactory::GridTemplates shape, bool wrap_lon, double interp_thresh, - const SingleThresh *cat_thresh = 0); + const SingleThresh *cat_thresh = nullptr); extern double compute_vert_pinterp(double, double, double, double, double); extern double compute_vert_zinterp(double, double, double, double, double); diff --git a/src/basic/vx_util/memory.cc b/src/basic/vx_util/memory.cc index 621b3be0bb..297902685b 100644 --- a/src/basic/vx_util/memory.cc +++ b/src/basic/vx_util/memory.cc @@ -1,4 +1,4 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +/// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2024 // ** University Corporation for Atmospheric Research (UCAR) // ** National Center for Atmospheric Research (NCAR) @@ -33,7 +33,7 @@ void oom() { void oom_grib2() { mlog << Error << "\nOut of memory reading GRIB2 data! Exiting!\n" - << "Check that MET and the GRIB2C library were compiled " + << "Check that MET and the GRIB2C library were compiled " << "consistently, either with or without the -D__64BIT__ " << "flag.\n\n"; exit(1); diff --git a/src/basic/vx_util/polyline.cc b/src/basic/vx_util/polyline.cc index 5d96776544..03c38ae00e 100644 --- a/src/basic/vx_util/polyline.cc +++ b/src/basic/vx_util/polyline.cc @@ -190,7 +190,7 @@ void Polyline::extend_points(int n) { if(!u || !v) { mlog << Error << "\nPolyline::extend_points(int) -> " - << "memory allocation error 1" << "\n\n"; + << "memory allocation error 1" << "\n\n"; exit(1); } @@ -303,7 +303,7 @@ double Polyline::angle() const { if(n_points < 3) { mlog << Error << "\nPolyline::angle() -> " - << "not enough points!\n\n"; + << "not enough points!\n\n"; exit(1); } diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index 9a92cf0970..5ae3a64b1a 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -197,13 +197,26 @@ static const char * const eclv_columns [] = { "N_PNT", "CL_", "VALUE_" }; +/* MET #2924 Replace this change static const char * const mpr_columns [] = { - "TOTAL", "INDEX", "OBS_SID", - "OBS_LAT", "OBS_LON", "OBS_LVL", - "OBS_ELV", "FCST", "OBS", - "OBS_QC", "CLIMO_MEAN", "CLIMO_STDEV", - "CLIMO_CDF" + "TOTAL", "INDEX", "OBS_SID", + "OBS_LAT", "OBS_LON", "OBS_LVL", + "OBS_ELV", "FCST", "OBS", + "OBS_QC", + "OBS_CLIMO_MEAN", "OBS_CLIMO_STDEV", "OBS_CLIMO_CDF", + "FCST_CLIMO_MEAN", "FCST_CLIMO_STDEV" }; +*/ + +static const char * const mpr_columns [] = { + "TOTAL", "INDEX", "OBS_SID", + "OBS_LAT", "OBS_LON", "OBS_LVL", + "OBS_ELV", "FCST", "OBS", + "OBS_QC", + "CLIMO_MEAN", "CLIMO_STDEV", "CLIMO_CDF" +}; + +// MET #2924 End replace static const char * const nbrctc_columns [] = { "TOTAL", "FY_OY", "FY_ON", @@ -295,15 +308,30 @@ static const char * const phist_columns [] = { "BIN_" }; +/* MET #2924 Replace this section static const char * const orank_columns [] = { - "TOTAL", "INDEX", "OBS_SID", - "OBS_LAT", "OBS_LON", "OBS_LVL", - "OBS_ELV", "OBS", "PIT", - "RANK", "N_ENS_VLD", "N_ENS", - "ENS_", "OBS_QC", "ENS_MEAN", - "CLIMO_MEAN", "SPREAD", "ENS_MEAN_OERR", - "SPREAD_OERR", "SPREAD_PLUS_OERR", "CLIMO_STDEV" + "TOTAL", "INDEX", "OBS_SID", + "OBS_LAT", "OBS_LON", "OBS_LVL", + "OBS_ELV", "OBS", "PIT", + "RANK", "N_ENS_VLD", "N_ENS", + "ENS_", "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" }; +*/ + +static const char * const orank_columns [] = { + "TOTAL", "INDEX", "OBS_SID", + "OBS_LAT", "OBS_LON", "OBS_LVL", + "OBS_ELV", "OBS", "PIT", + "RANK", "N_ENS_VLD", "N_ENS", + "ENS_", "OBS_QC", "ENS_MEAN", + "CLIMO_MEAN", "SPREAD", "ENS_MEAN_OERR", + "SPREAD_OERR", "SPREAD_PLUS_OERR", "CLIMO_STDEV" +}; + +// MET #2924 End replace static const char * const ssvar_columns [] = { "TOTAL", "N_BIN", "BIN_i", @@ -456,7 +484,7 @@ inline int get_n_eclv_columns (int n) { return(4 + 2*n); } // inline int get_n_rhist_columns (int n) { return(2 + n); } // n = N_RANK inline int get_n_phist_columns (int n) { return(3 + n); } // n = N_BINS inline int get_n_relp_columns (int n) { return(2 + n); } // n = N_ENS -inline int get_n_orank_columns (int n) { return(20 + n); } // n = N_ENS +inline int get_n_orank_columns (int n) { return(22 + n); } // n = N_ENS //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index 4a0b421ae1..993857678f 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -291,9 +291,9 @@ void ThreshArray::parse_thresh_str(const char *thresh_str) { //////////////////////////////////////////////////////////////////////// int ThreshArray::has(const SingleThresh &st) const { - int index, status; + int index; - status = has(st, index); + int status = has(st, index); return status; } @@ -301,13 +301,12 @@ int ThreshArray::has(const SingleThresh &st) const { //////////////////////////////////////////////////////////////////////// int ThreshArray::has(const SingleThresh &st, int & index) const { - int j; index = -1; if(Nelements == 0) return 0; - for(j=0; j t[i+1].get_value() || t[i].get_type() != t[i+1].get_type() || @@ -386,34 +382,29 @@ void ThreshArray::check_bin_thresh() const { //////////////////////////////////////////////////////////////////////// -int ThreshArray::check_bins(double v) const { - return check_bins(v, bad_data_double, bad_data_double); -} - -//////////////////////////////////////////////////////////////////////// - -int ThreshArray::check_bins(double v, double mn, double sd) const { +int ThreshArray::check_bins(double v, const ClimoPntInfo *cpi) const { int i, bin; // Check for bad data or no thresholds if(is_bad_data(v) || Nelements == 0) return bad_data_int; - // For < and <=, check thresholds left to right. - if(t[0].get_type() == thresh_lt || t[0].get_type() == thresh_le) { + // For < and <=, check thresholds left to right + if(t[0].get_type() == thresh_lt || + t[0].get_type() == thresh_le) { for(i=0, bin=-1; i and >=, check thresholds right to left. + // For > and >=, check thresholds right to left else { for(i=Nelements-1, bin=-1; i>=0; i--) { - if(t[i].check(v, mn, sd)) { + if(t[i].check(v, cpi)) { bin = i+1; break; } @@ -421,26 +412,19 @@ int ThreshArray::check_bins(double v, double mn, double sd) const { if(bin == -1) bin = 0; } - // The bin value returned is 1-based, not 0-based. + // The bin value returned is 1-based, not 0-based return bin; } //////////////////////////////////////////////////////////////////////// -bool ThreshArray::check_dbl(double v) const { - return check_dbl(v, bad_data_double, bad_data_double); -} - -//////////////////////////////////////////////////////////////////////// - -bool ThreshArray::check_dbl(double v, double mn, double sd) const { - int i; +bool ThreshArray::check_dbl(double v, const ClimoPntInfo *cpi) const { // // Check if the value satisifes all the thresholds in the array // - for(i=0; ithresh()[i]), &(oarr->thresh()[i])); + t[i].set_perc(fptr, optr, fcptr, ocptr, + &(farr->thresh()[i]), + &(oarr->thresh()[i])); } return; @@ -755,11 +741,13 @@ ThreshArray process_perc_thresh_bins(const ThreshArray &ta_in) { for(i=0; i=100) { @@ -810,11 +798,11 @@ ThreshArray process_rps_cdp_thresh(const ThreshArray &ta) { SingleThresh st; ThreshArray ta_out; - // Check for evenly-spaced CDP thresholds + // Check for evenly-spaced OCDP thresholds for(int i=0; i #include #include +#include #include #include #include @@ -34,6 +35,32 @@ using namespace std; +//////////////////////////////////////////////////////////////////////// + + + // + // MET #2924 Rename climatology column names + // + +static const map mpr_rename_map = { + { "CLIMO_MEAN", "OBS_CLIMO_MEAN" }, + { "CLIMO_STDEV", "OBS_CLIMO_STDEV" }, + { "CLIMO_CDF", "OBS_CLIMO_CDF" } +}; + +static const map orank_rename_map = { + { "CLIMO_MEAN", "OBS_CLIMO_MEAN" }, + { "CLIMO_STDEV", "OBS_CLIMO_STDEV" } +}; + +static const map< STATLineType, map > stat_lty_rename_map = { + { STATLineType::mpr, mpr_rename_map }, + { STATLineType::orank, orank_rename_map } +}; + +static StringArray print_stat_rename_message; + + //////////////////////////////////////////////////////////////////////// @@ -444,6 +471,29 @@ if ( is_bad_data(offset) ) { if ( !get_file()->header().has(col_str, offset) ) offset = bad_data_int; } + // + // If not found, check renamed columns for backward compatibility + // + +if ( is_bad_data(offset) ) { + + string s(col_str); + + if ( stat_lty_rename_map.count(Type) && + stat_lty_rename_map.at(Type).count(s) ) { + if ( !print_stat_rename_message.has(s) ) { + mlog << Debug(2) << "The \"" << s << "\" column in the " + << statlinetype_to_string(Type) + << " line type has been renamed as \"" + << (stat_lty_rename_map.at(Type)).at(s) + << "\". Please switch to using MET" + << met_version << " column names.\n"; + print_stat_rename_message.add(s); + } + return ( get_item((stat_lty_rename_map.at(Type)).at(s).c_str()) ); + } +} + // // Return bad data string for no match // diff --git a/src/libcode/vx_data2d/var_info.h b/src/libcode/vx_data2d/var_info.h index 0d8717f416..3271376816 100644 --- a/src/libcode/vx_data2d/var_info.h +++ b/src/libcode/vx_data2d/var_info.h @@ -278,7 +278,7 @@ class EnsVarInfo { private: std::vector inputs; // Vector of InputInfo - VarInfo * ctrl_info; // Field info for control member + VarInfo * ctrl_info; // Field info for control member public: EnsVarInfo(); diff --git a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc index 6beba9a08d..edb45079e6 100644 --- a/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/var_info_nc_wrf.cc @@ -239,7 +239,7 @@ void VarInfoNcWrf::set_magic(const ConcatString &nstr, const ConcatString &lstr) level_value = unix_time; as_offset = false; } - else if (is_number(ptr2)) { + else if (is_number(ptr2)) { if (as_offset) level = atoi(ptr2); else { level = vx_data2d_dim_by_value; diff --git a/src/libcode/vx_data2d_python/grid_from_python_dict.cc b/src/libcode/vx_data2d_python/grid_from_python_dict.cc index c1b07c779c..fa69bd9d8e 100644 --- a/src/libcode/vx_data2d_python/grid_from_python_dict.cc +++ b/src/libcode/vx_data2d_python/grid_from_python_dict.cc @@ -527,7 +527,7 @@ else { if ( ! pointdata_from_np_array(np, &vals) ) { mlog << Error << "\nlookup_python_num_array() -> " - << "can't parse values for \"" << key << "\" from python \"" + << "can't parse values for \"" << key << "\" from python \"" << Py_TYPE(obj)->tp_name << "\" object.\n"; } diff --git a/src/libcode/vx_grid/goes_grid.cc b/src/libcode/vx_grid/goes_grid.cc index c00babc717..296dc27a11 100644 --- a/src/libcode/vx_grid/goes_grid.cc +++ b/src/libcode/vx_grid/goes_grid.cc @@ -431,13 +431,13 @@ void GoesImagerData::compute_lat_lon() mlog << Error << method_name << " index=" << index << " too big than " << buf_len << "\n"; else { - if (std::isnan(lat_rad)) lat = bad_data_float; + if (std::isnan(lat_rad)) lat = bad_data_float; else { lat = lat_rad * deg_per_rad; if (lat > lat_max) {lat_max = lat; idx_lat_max = index; } if (lat < lat_min) {lat_min = lat; idx_lat_min = index; } } - if (std::isnan(lon_rad)) lon = bad_data_float; + if (std::isnan(lon_rad)) lon = bad_data_float; else { lon = lon_of_projection_origin - (lon_rad * deg_per_rad); if (lon > lon_max) {lon_max = lon; idx_lon_max = index; } diff --git a/src/libcode/vx_grid/laea_grid.cc b/src/libcode/vx_grid/laea_grid.cc index 6d59f25f6e..b14ddf159a 100644 --- a/src/libcode/vx_grid/laea_grid.cc +++ b/src/libcode/vx_grid/laea_grid.cc @@ -455,7 +455,7 @@ v = new double [n]; if ( !u || !v ) { mlog << Error << "\nLaeaGrid::xy_closedpolyline_area() -> " - << "memory allocation error\n\n"; + << "memory allocation error\n\n"; exit ( 1 ); diff --git a/src/libcode/vx_seeps/seeps.cc b/src/libcode/vx_seeps/seeps.cc index c3114acffc..4204f59370 100644 --- a/src/libcode/vx_seeps/seeps.cc +++ b/src/libcode/vx_seeps/seeps.cc @@ -64,34 +64,23 @@ void release_seeps_climo() { //////////////////////////////////////////////////////////////////////// SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour) { - bool not_found = true; - SeepsClimoGrid *seeps_climo_grid = nullptr; - for (map::iterator it=seeps_climo_grid_map_00.begin(); - it!=seeps_climo_grid_map_00.end(); ++it) { - if (it->first == month) { - not_found = false; - seeps_climo_grid = (SeepsClimoGrid *)it->second; - break; - } - } - if (not_found) { - seeps_climo_grid = new SeepsClimoGrid(month, hour, seeps_grid_climo_name); - seeps_climo_grid_map_00[month] = seeps_climo_grid; + if (seeps_climo_grid_map_00.count(month) == 0) { + seeps_climo_grid_map_00[month] = nullptr; + seeps_climo_grid_map_00[month] = new SeepsClimoGrid(month, hour, seeps_grid_climo_name); } - return seeps_climo_grid; + + return seeps_climo_grid_map_00[month]; } //////////////////////////////////////////////////////////////////////// void release_seeps_climo_grid(int month, int hour) { - for (map::iterator it=seeps_climo_grid_map_00.begin(); - it!=seeps_climo_grid_map_00.end(); ++it) { - if (it->first == month) { - delete it->second; - seeps_climo_grid_map_00.erase(it); - break; - } + + if (seeps_climo_grid_map_00.count(month) > 0) { + delete seeps_climo_grid_map_00[month]; + seeps_climo_grid_map_00[month] = nullptr; + seeps_climo_grid_map_00.erase(month); } } @@ -103,10 +92,8 @@ double weighted_average(double v1, double w1, double v2, double w2) { v1 * w1 + v2 * w2); } - //////////////////////////////////////////////////////////////////////// - void SeepsAggScore::clear() { n_obs = 0; @@ -166,7 +153,6 @@ SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { return *this; } - //////////////////////////////////////////////////////////////////////// SeepsClimoBase::SeepsClimoBase(ConcatString seeps_climo_name) : climo_file_name{seeps_climo_name} { @@ -657,22 +643,14 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { } - - //////////////////////////////////////////////////////////////////////// - SeepsClimoGrid::SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name) : month{month}, hour{hour}, SeepsClimoBase{seeps_climo_name} { - - clear(); - p1_buf = p2_buf = t1_buf = t2_buf = nullptr; - s12_buf = s13_buf = s21_buf = s23_buf = s31_buf = s32_buf = nullptr; - + init_from_scratch(); ConcatString seeps_name = get_climo_filename(); if (file_exists(seeps_name.c_str())) read_seeps_scores(seeps_name); - } //////////////////////////////////////////////////////////////////////// @@ -683,6 +661,14 @@ SeepsClimoGrid::~SeepsClimoGrid() { //////////////////////////////////////////////////////////////////////// +void SeepsClimoGrid::init_from_scratch() { + p1_buf = p2_buf = t1_buf = t2_buf = nullptr; + s12_buf = s13_buf = s21_buf = s23_buf = s31_buf = s32_buf = nullptr; + clear(); +} + +//////////////////////////////////////////////////////////////////////// + void SeepsClimoGrid::clear() { SeepsClimoBase::clear(); if (nullptr != p1_buf) { delete [] p1_buf; p1_buf = nullptr; } diff --git a/src/libcode/vx_seeps/seeps.h b/src/libcode/vx_seeps/seeps.h index 208275e7cd..808acefa3e 100644 --- a/src/libcode/vx_seeps/seeps.h +++ b/src/libcode/vx_seeps/seeps.h @@ -230,6 +230,8 @@ class SeepsClimoGrid : public SeepsClimoBase { double *s31_buf; double *s32_buf; + void init_from_scratch(); + protected: void clear() override; ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_GRID_CLIMO_NAME; }; diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index 642db14034..080365c757 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -1192,19 +1192,23 @@ void ModeConfInfo::set_perc_thresh(const DataPlane &f_dp, // // Compute percentiles // - Fcst->conv_thresh_array.set_perc(&fsort, &osort, (NumArray *) 0, + Fcst->conv_thresh_array.set_perc(&fsort, &osort, + nullptr, nullptr, &(Fcst->conv_thresh_array), &(Obs->conv_thresh_array)); - Obs->conv_thresh_array.set_perc(&fsort, &osort, (NumArray *) 0, + Obs->conv_thresh_array.set_perc(&fsort, &osort, + nullptr, nullptr, &(Fcst->conv_thresh_array), &(Obs->conv_thresh_array)); - Fcst->merge_thresh_array.set_perc(&fsort, &osort, (NumArray *) 0, + Fcst->merge_thresh_array.set_perc(&fsort, &osort, + nullptr, nullptr, &(Fcst->merge_thresh_array), &(Obs->merge_thresh_array)); - Obs->merge_thresh_array.set_perc(&fsort, &osort, (NumArray *) 0, + Obs->merge_thresh_array.set_perc(&fsort, &osort, + nullptr, nullptr, &(Fcst->merge_thresh_array), &(Obs->merge_thresh_array)); @@ -1253,10 +1257,12 @@ void ModeConfInfo::set_perc_thresh(const DataPlane &dp) // // Compute percentiles by hacking in the same input as if its two // - F->conv_thresh_array.set_perc(&sort, &sort, (NumArray *) 0, + F->conv_thresh_array.set_perc(&sort, &sort, + nullptr, nullptr, &(F->conv_thresh_array), &(F->conv_thresh_array)); - F->merge_thresh_array.set_perc(&sort, &sort, (NumArray *) 0, + F->merge_thresh_array.set_perc(&sort, &sort, + nullptr, nullptr, &(F->merge_thresh_array), &(F->merge_thresh_array)); return; @@ -1789,14 +1795,17 @@ PercThreshType ModeConfInfo::perctype(const Mode_Field_Info &f) const if (f.conv_thresh_array.n() > 0) { pc = f.conv_thresh_array[0].get_ptype(); } - if (pm == perc_thresh_sample_climo || pc == perc_thresh_sample_climo) { + if (pm == perc_thresh_sample_fcst_climo || pm == perc_thresh_sample_obs_climo || + pc == perc_thresh_sample_fcst_climo || pc == perc_thresh_sample_obs_climo) { mlog << Error << "\nModeConfInfo::perctype()\n" - << " Thresholding with 'SCP' in an input not implemented for multivariate mode\n\n"; + << " Thresholding with 'SFCP' or 'SOCP' in an input not implemented " + << "for multivariate mode\n\n"; exit ( 1 ); } - if (pm == perc_thresh_climo_dist || pc == perc_thresh_climo_dist) { + if (is_climo_dist_type(pm) || is_climo_dist_type(pc)) { mlog << Error << "\nModeConfInfo::perctype()\n" - << " Thresholding with 'CDP' in an input not implemented for multivariate mode\n\n"; + << " Thresholding with 'CDP', 'FCDP', or 'OCDP' in an " + << "input not implemented for multivariate mode\n\n"; exit ( 1 ); } if (pm == perc_thresh_freq_bias || diff --git a/src/libcode/vx_shapedata/node.cc b/src/libcode/vx_shapedata/node.cc index 329bd9f961..a0ac3397e3 100644 --- a/src/libcode/vx_shapedata/node.cc +++ b/src/libcode/vx_shapedata/node.cc @@ -213,8 +213,8 @@ Node *Node::get_child(int n) const { if( n >= (children_count = n_children()) ) { mlog << Error << "\nNode::get_child(int) -> " - << "attempting to access child number " << n << " when only " - << children_count << " exist\n\n"; + << "attempting to access child number " << n << " when only " + << children_count << " exist\n\n"; exit(1); } @@ -295,7 +295,7 @@ double Node::angle() const { if(p.n_points < 3 && n_children() == 0) { mlog << Error << "\nNode::angle() -> " - << "not enough points!\n\n"; + << "not enough points!\n\n"; exit(1); } diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 0bd1c9393a..330a74d827 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -488,6 +488,10 @@ void write_orank_header_row(int hdr_flag, int n_ens, AsciiTable &at, at.set_entry(r, c+17+n_ens, (string)orank_columns[18]); at.set_entry(r, c+18+n_ens, (string)orank_columns[19]); at.set_entry(r, c+19+n_ens, (string)orank_columns[20]); + /* MET #2924 Uncomment this section + at.set_entry(r, c+20+n_ens, (string)orank_columns[21]); + at.set_entry(r, c+21+n_ens, (string)orank_columns[22]); + */ return; } @@ -4076,11 +4080,12 @@ void write_mpr_cols(const PairDataPoint *pd_ptr, int i, // // Matched Pairs (MPR) // Dump out the MPR line: - // TOTAL, INDEX, OBS_SID, - // OBS_LAT, OBS_LON, OBS_LVL, - // OBS_ELV, FCST, OBS, - // OBS_QC, CLIMO_MEAN, CLIMO_STDEV, - // CLIMO_CDF + // TOTAL, INDEX, OBS_SID, + // OBS_LAT, OBS_LON, OBS_LVL, + // OBS_ELV, FCST, OBS, + // OBS_QC, + // OBS_CLIMO_MEAN, OBS_CLIMO_STDEV, OBS_CLIMO_CDF, + // FCST_CLIMO_MEAN, FCST_CLIMO_STDEV // at.set_entry(r, c+0, // Total Number of Pairs pd_ptr->n_obs); @@ -4112,14 +4117,22 @@ void write_mpr_cols(const PairDataPoint *pd_ptr, int i, at.set_entry(r, c+9, // Observation Quality Control (string)pd_ptr->o_qc_sa[i]); - at.set_entry(r, c+10, // Climatological Mean Value - pd_ptr->cmn_na[i]); + at.set_entry(r, c+10, // Observation Climatological Mean Value + pd_ptr->ocmn_na[i]); - at.set_entry(r, c+11, // Climatological Standard Deviation Value - pd_ptr->csd_na[i]); + at.set_entry(r, c+11, // Observation Climatological Standard Deviation Value + pd_ptr->ocsd_na[i]); - at.set_entry(r, c+12, // Climatological CDF Value - pd_ptr->cdf_na[i]); + at.set_entry(r, c+12, // Observation Climatological CDF Value + pd_ptr->ocdf_na[i]); + +/* MET #2924 Uncomment this section + at.set_entry(r, c+13, // Forecast Climatological Mean Value + pd_ptr->fcmn_na[i]); + + at.set_entry(r, c+14, // Forecast Climatological Standard Deviation Value + pd_ptr->fcsd_na[i]); +*/ return; } @@ -4493,9 +4506,10 @@ void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, // OBS_ELV, OBS, PIT, // RANK, N_ENS_VLD, N_ENS, // [ENS_] (for each ensemble member) - // OBS_QC, ENS_MEAN, CLIMO_MEAN, - // SPREAD, ENS_MEAN_OERR, SPREAD_OERR, - // SPREAD_PLUS_OERR, CLIMO_STDEV + // 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 // at.set_entry(r, c+0, // Total Number of Pairs pd_ptr->n_obs); // Use n_obs instead of n_pair to include missing data @@ -4551,9 +4565,9 @@ void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, at.set_entry(r, c+13+pd_ptr->n_ens, pd_ptr->mn_na[i]); - // Climatology mean values + // Observation climatology mean values at.set_entry(r, c+14+pd_ptr->n_ens, - pd_ptr->cmn_na[i]); + pd_ptr->ocmn_na[i]); // Unperturbed ensemble spread values at.set_entry(r, c+15+pd_ptr->n_ens, @@ -4571,9 +4585,19 @@ void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, at.set_entry(r, c+18+pd_ptr->n_ens, square_root(pd_ptr->var_plus_oerr_na[i])); - // Climatology standard deviation values + // Observation climatology standard deviation values at.set_entry(r, c+19+pd_ptr->n_ens, - pd_ptr->csd_na[i]); + pd_ptr->ocsd_na[i]); + +/* MET #2924 Uncomment this section + // Forecast climatology mean values + at.set_entry(r, c+20+pd_ptr->n_ens, + pd_ptr->fcmn_na[i]); + + // Forecast climatology standard deviation values + at.set_entry(r, c+21+pd_ptr->n_ens, + pd_ptr->fcsd_na[i]); +*/ return; } diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index d775637dd3..40c4e82589 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -150,11 +150,10 @@ void compute_cntinfo(const PairDataPoint &pd, const NumArray &i_na, bool precip_flag, bool rank_flag, bool normal_ci_flag, CNTInfo &cnt_info) { int i, j, n; - double f, o, c, wgt, wgt_sum; + double f, o, fc, oc, wgt, wgt_sum; double f_bar, o_bar, ff_bar, oo_bar, fo_bar; double fa_bar, oa_bar, ffa_bar, ooa_bar, foa_bar; double err, err_bar, abs_err_bar, err_sq_bar, den; - bool cmn_flag; // // Allocate memory to store the differences @@ -176,7 +175,8 @@ void compute_cntinfo(const PairDataPoint &pd, const NumArray &i_na, // // Flag to process climo // - cmn_flag = set_climo_flag(pd.f_na, pd.cmn_na); + bool cmn_flag = set_climo_flag(pd.f_na, pd.fcmn_na) && + set_climo_flag(pd.f_na, pd.ocmn_na); // // Get the sum of the weights @@ -199,7 +199,8 @@ void compute_cntinfo(const PairDataPoint &pd, const NumArray &i_na, f = pd.f_na[j]; o = pd.o_na[j]; - c = (cmn_flag ? pd.cmn_na[j] : bad_data_double); + fc = (cmn_flag ? pd.fcmn_na[j] : bad_data_double); + oc = (cmn_flag ? pd.ocmn_na[j] : bad_data_double); wgt = pd.wgt_na[i]/wgt_sum; // @@ -207,7 +208,8 @@ void compute_cntinfo(const PairDataPoint &pd, const NumArray &i_na, // if(is_bad_data(f) || is_bad_data(o) || - (cmn_flag && is_bad_data(c))) continue; + (cmn_flag && is_bad_data(fc)) || + (cmn_flag && is_bad_data(oc))) continue; // // Compute the error @@ -226,11 +228,11 @@ void compute_cntinfo(const PairDataPoint &pd, const NumArray &i_na, n++; if(cmn_flag) { - fa_bar += wgt*(f-c); - oa_bar += wgt*(o-c); - foa_bar += wgt*(f-c)*(o-c); - ffa_bar += wgt*(f-c)*(f-c); - ooa_bar += wgt*(o-c)*(o-c); + fa_bar += wgt*(f-fc); + oa_bar += wgt*(o-oc); + foa_bar += wgt*(f-fc)*(o-oc); + ffa_bar += wgt*(f-fc)*(f-fc); + ooa_bar += wgt*(o-oc)*(o-oc); } } // end for i @@ -587,7 +589,9 @@ void compute_ctsinfo(const PairDataPoint &pd, const NumArray &i_na, // // Add this pair to the contingency table // - cts_info.add(pd.f_na[j], pd.o_na[j], pd.cmn_na[j], pd.csd_na[j]); + ClimoPntInfo cpi(pd.fcmn_na[j], pd.fcsd_na[j], + pd.ocmn_na[j], pd.ocsd_na[j]); + cts_info.add(pd.f_na[j], pd.o_na[j], &cpi); } // end for i @@ -684,7 +688,9 @@ void compute_mctsinfo(const PairDataPoint &pd, const NumArray &i_na, // // Add this pair to the contingency table // - mcts_info.add(pd.f_na[j], pd.o_na[j], pd.cmn_na[j], pd.csd_na[j]); + ClimoPntInfo cpi(pd.fcmn_na[j], pd.fcsd_na[j], + pd.ocmn_na[j], pd.ocsd_na[j]); + mcts_info.add(pd.f_na[j], pd.o_na[j], &cpi); } // end for i @@ -761,14 +767,14 @@ void compute_pctinfo(const PairDataPoint &pd, bool pstd_flag, n_pair = pd.f_na.n(); // Flag to process climo - cmn_flag = (set_climo_flag(pd.f_na, pd.cmn_na) || - (cprob_in && cprob_in->n() > 0)); + cmn_flag = (set_climo_flag(pd.f_na, pd.ocmn_na) || + (cprob_in && cprob_in->n() > 0)); // Use input climatological probabilities or derive them if(cmn_flag) { if(cprob_in) climo_prob = *cprob_in; else climo_prob = derive_climo_prob(pd.cdf_info_ptr, - pd.cmn_na, pd.csd_na, + pd.ocmn_na, pd.ocsd_na, pct_info.othresh); } @@ -797,10 +803,16 @@ void compute_pctinfo(const PairDataPoint &pd, bool pstd_flag, // for(i=0; in_obs = count; - seeps->mean_fcst = fcst_sum / count; - seeps->mean_obs = obs_sum / count; - seeps->score = score_sum / count; + seeps_agg->n_obs = count; + seeps_agg->mean_fcst = fcst_sum / count; + seeps_agg->mean_obs = obs_sum / count; + seeps_agg->score = score_sum / count; weighted_score = 0.; for (int i=0; i count) density_cnt = count; @@ -1502,35 +1514,35 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps) { seeps_mprs.clear(); // The weight for s12 to s32 should come from climo file, but not available yet - seeps->pv1 = pvf[0] + pvf[3] + pvf[6]; // sum by column for obs - seeps->pv2 = pvf[1] + pvf[4] + pvf[7]; // sum by column for obs - seeps->pv3 = pvf[2] + pvf[5] + pvf[8]; // sum by column for obs - seeps->pf1 = pvf[0] + pvf[1] + pvf[2]; // sum by row for forecast - seeps->pf2 = pvf[3] + pvf[4] + pvf[5]; // sum by row for forecast - seeps->pf3 = pvf[6] + pvf[7] + pvf[8]; // sum by row for forecast - seeps->s12 = c12 * seeps->pf1 * seeps->pv2; - seeps->s13 = c13 * seeps->pf1 * seeps->pv3; - seeps->s21 = c21 * seeps->pf2 * seeps->pv1; - seeps->s23 = c23 * seeps->pf2 * seeps->pv3; - seeps->s31 = c31 * seeps->pf3 * seeps->pv1; - seeps->s32 = c32 * seeps->pf3 * seeps->pv2; - seeps->weighted_score = weighted_score; + seeps_agg->pv1 = pvf[0] + pvf[3] + pvf[6]; // sum by column for obs + seeps_agg->pv2 = pvf[1] + pvf[4] + pvf[7]; // sum by column for obs + seeps_agg->pv3 = pvf[2] + pvf[5] + pvf[8]; // sum by column for obs + seeps_agg->pf1 = pvf[0] + pvf[1] + pvf[2]; // sum by row for forecast + seeps_agg->pf2 = pvf[3] + pvf[4] + pvf[5]; // sum by row for forecast + seeps_agg->pf3 = pvf[6] + pvf[7] + pvf[8]; // sum by row for forecast + seeps_agg->s12 = c12 * seeps_agg->pf1 * seeps_agg->pv2; + seeps_agg->s13 = c13 * seeps_agg->pf1 * seeps_agg->pv3; + seeps_agg->s21 = c21 * seeps_agg->pf2 * seeps_agg->pv1; + seeps_agg->s23 = c23 * seeps_agg->pf2 * seeps_agg->pv3; + seeps_agg->s31 = c31 * seeps_agg->pf3 * seeps_agg->pv1; + seeps_agg->s32 = c32 * seeps_agg->pf3 * seeps_agg->pv2; + seeps_agg->weighted_score = weighted_score; mlog << Debug(7) << method_name - << "SEEPS score=" << seeps->score << " weighted_score=" << weighted_score - << " pv1=" << seeps->pv1 << " pv2=" << seeps->pv2 << " pv3=" << seeps->pv3 - << " pf1=" << seeps->pf1 << " pf2=" << seeps->pf2 << " pf3=" << seeps->pf3 << "\n"; + << "SEEPS score=" << seeps_agg->score << " weighted_score=" << weighted_score + << " pv1=" << seeps_agg->pv1 << " pv2=" << seeps_agg->pv2 << " pv3=" << seeps_agg->pv3 + << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 << "\n"; } else { mlog << Debug(5) << method_name << "no SEEPS_MPR available\n"; } - seeps->c12 = c12; - seeps->c13 = c13; - seeps->c21 = c21; - seeps->c23 = c23; - seeps->c31 = c31; - seeps->c32 = c32; + seeps_agg->c12 = c12; + seeps_agg->c13 = c13; + seeps_agg->c21 = c21; + seeps_agg->c23 = c23; + seeps_agg->c31 = c31; + seeps_agg->c32 = c32; if (count != (c12+c13+c21+c23+c31+c32+count_diagonal)){ mlog << Debug(6) << method_name @@ -1546,7 +1558,7 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps) { void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &obs_dp, DataPlane &seeps_dp, DataPlane &seeps_dp_fcat, - DataPlane &seeps_dp_ocat,SeepsAggScore *seeps, + DataPlane &seeps_dp_ocat, SeepsAggScore *seeps_agg, int month, int hour, const SingleThresh &seeps_p1_thresh, const ConcatString &seeps_climo_name) { int fcst_cat, obs_cat; @@ -1559,7 +1571,6 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob int c12, c13, c21, c23, c31, c32; double obs_sum, fcst_sum; double seeps_score, seeps_score_sum, seeps_score_partial_sum; - SeepsScore *seeps_mpr; static const char *method_name = "compute_aggregated_seeps_grid() -> "; seeps_dp.set_size(nx, ny); @@ -1568,8 +1579,7 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob obs_sum = fcst_sum = seeps_score_sum = 0.; seeps_count = count_diagonal = nan_count = bad_count = 0; c12 = c13 = c21 = c23 = c31 = c32 = 0; - - seeps->clear(); + seeps_agg->clear(); SeepsClimoGrid *seeps_climo = get_seeps_climo_grid(month, seeps_climo_name); seeps_climo->set_p1_thresh(seeps_p1_thresh); for (int i=0; iget_record(ix, iy, fcst_value, obs_value); + SeepsScore *seeps_mpr = seeps_climo->get_record(ix, iy, fcst_value, obs_value); if (seeps_mpr != nullptr) { fcst_cat = seeps_mpr->fcst_cat; obs_cat = seeps_mpr->obs_cat; @@ -1621,7 +1631,7 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob pvf_cnt[seeps_mpr->s_idx] += 1; } - delete seeps_mpr; + if(seeps_mpr) { delete seeps_mpr; seeps_mpr = nullptr; } } } seeps_dp.set(seeps_score, ix, iy); @@ -1632,41 +1642,41 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob } int cell_count = dp_size - nan_count - bad_count; if (cell_count > 0) { - seeps->weighted_score = seeps_score_sum/cell_count; + seeps_agg->weighted_score = seeps_score_sum/cell_count; for (int i=0; in_obs = seeps_count; - seeps->c12 = c12; - seeps->c13 = c13; - seeps->c21 = c21; - seeps->c23 = c23; - seeps->c31 = c31; - seeps->c32 = c32; + seeps_agg->n_obs = seeps_count; + seeps_agg->c12 = c12; + seeps_agg->c13 = c13; + seeps_agg->c21 = c21; + seeps_agg->c23 = c23; + seeps_agg->c31 = c31; + seeps_agg->c32 = c32; if (seeps_count > 0) { - seeps->mean_fcst = fcst_sum / seeps_count; - seeps->mean_obs = obs_sum / seeps_count; - - seeps->pv1 = pvf[0] + pvf[3] + pvf[6]; // sum by column for obs - seeps->pv2 = pvf[1] + pvf[4] + pvf[7]; // sum by column for obs - seeps->pv3 = pvf[2] + pvf[5] + pvf[8]; // sum by column for obs - seeps->pf1 = pvf[0] + pvf[1] + pvf[2]; // sum by row for forecast - seeps->pf2 = pvf[3] + pvf[4] + pvf[5]; // sum by row for forecast - seeps->pf3 = pvf[6] + pvf[7] + pvf[8]; // sum by row for forecast - seeps->s12 = c12 * seeps->pf1 * seeps->pv2; - seeps->s13 = c13 * seeps->pf1 * seeps->pv3; - seeps->s21 = c21 * seeps->pf2 * seeps->pv1; - seeps->s23 = c23 * seeps->pf2 * seeps->pv3; - seeps->s31 = c31 * seeps->pf3 * seeps->pv1; - seeps->s32 = c32 * seeps->pf3 * seeps->pv2; - seeps->score = seeps_score_sum / seeps_count; + seeps_agg->mean_fcst = fcst_sum / seeps_count; + seeps_agg->mean_obs = obs_sum / seeps_count; + + seeps_agg->pv1 = pvf[0] + pvf[3] + pvf[6]; // sum by column for obs + seeps_agg->pv2 = pvf[1] + pvf[4] + pvf[7]; // sum by column for obs + seeps_agg->pv3 = pvf[2] + pvf[5] + pvf[8]; // sum by column for obs + seeps_agg->pf1 = pvf[0] + pvf[1] + pvf[2]; // sum by row for forecast + seeps_agg->pf2 = pvf[3] + pvf[4] + pvf[5]; // sum by row for forecast + seeps_agg->pf3 = pvf[6] + pvf[7] + pvf[8]; // sum by row for forecast + seeps_agg->s12 = c12 * seeps_agg->pf1 * seeps_agg->pv2; + seeps_agg->s13 = c13 * seeps_agg->pf1 * seeps_agg->pv3; + seeps_agg->s21 = c21 * seeps_agg->pf2 * seeps_agg->pv1; + seeps_agg->s23 = c23 * seeps_agg->pf2 * seeps_agg->pv3; + seeps_agg->s31 = c31 * seeps_agg->pf3 * seeps_agg->pv1; + seeps_agg->s32 = c32 * seeps_agg->pf3 * seeps_agg->pv2; + seeps_agg->score = seeps_score_sum / seeps_count; } mlog << Debug(6) << method_name - << "SEEPS score=" << seeps->score << " weighted_score=" << seeps->weighted_score - << " pv1=" << seeps->pv1 << " pv2=" << seeps->pv2 << " pv3=" << seeps->pv3 - << " pf1=" << seeps->pf1 << " pf2=" << seeps->pf2 << " pf3=" << seeps->pf3 << "\n"; + << "SEEPS score=" << seeps_agg->score << " weighted_score=" << seeps_agg->weighted_score + << " pv1=" << seeps_agg->pv1 << " pv2=" << seeps_agg->pv2 << " pv3=" << seeps_agg->pv3 + << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 << "\n"; if(mlog.verbosity_level() >= detailed_debug_level) { char buffer[100]; ConcatString log_message; diff --git a/src/libcode/vx_statistics/ens_stats.cc b/src/libcode/vx_statistics/ens_stats.cc index 6483e68045..a9b475acff 100644 --- a/src/libcode/vx_statistics/ens_stats.cc +++ b/src/libcode/vx_statistics/ens_stats.cc @@ -518,7 +518,7 @@ void RPSInfo::set_prob_cat_thresh(const ThreshArray &ta) { //////////////////////////////////////////////////////////////////////// void RPSInfo::set_cdp_thresh(const ThreshArray &ta) { - fthresh = derive_cdp_thresh(ta); + fthresh = derive_ocdp_thresh(ta); } //////////////////////////////////////////////////////////////////////// @@ -546,8 +546,8 @@ void RPSInfo::set(const PairDataEnsemble &pd) { // Check RPS threshold formatting: monotonically increasing fthresh.check_bin_thresh(); - // Flag to process climo - cmn_flag = set_climo_flag(pd.o_na, pd.cmn_na); + // Flag to process observation climatology data + cmn_flag = set_climo_flag(pd.o_na, pd.ocmn_na); // Setup probability thresholds, equally spaced by ensemble size for(i=0; i<=n_prob; i++) p_thresh.add((double) i/n_prob); @@ -575,20 +575,24 @@ void RPSInfo::set(const PairDataEnsemble &pd) { // Derive climatological probabilities if(cmn_flag) climo_prob = derive_climo_prob(pd.cdf_info_ptr, - pd.cmn_na, pd.csd_na, + pd.ocmn_na, pd.ocsd_na, fthresh[i]); // Loop over the observations for(j=0; j " + // The o_na, ocmn_na, and ocsd_na have already been populated + if(o_na.n() != ocmn_na.n() || o_na.n() != ocsd_na.n()) { + mlog << Error << "\nPairBase::compute_climo_cdf() -> " << "the observation, climo mean, and climo stdev arrays " << "must all have the same length (" << o_na.n() << ").\n\n"; exit(1); } - cdf_na.extend(o_na.n()); + ocdf_na.extend(o_na.n()); for(i=0; i= n_obs) { mlog << Error << "\nPairBase::set_point_obs() -> " @@ -512,7 +545,7 @@ void PairBase::set_point_obs(int i_obs, const char *sid, elv_na.set(i_obs, elv); o_na.set(i_obs, o); o_qc_sa.set(i_obs, qc); - set_climo(i_obs, o, cmn, csd); + set_climo(i_obs, o, cpi); return; } @@ -626,7 +659,7 @@ ob_val_t PairBase::compute_percentile(string obs_key, int perc) { //////////////////////////////////////////////////////////////////////// -void PairBase::print_obs_summary(){ +void PairBase::print_obs_summary() const { if(!IsPointVx) return; @@ -637,7 +670,7 @@ void PairBase::print_obs_summary(){ // iterate over ordered list map keys in the station id map for(int i=0; i= 0 && fabs(dist) < dist_abv) { - dist_abv = fabs(dist); - i_abv = i; - } - } + init_from_scratch(); - // Check if the observation is above the forecast range - if(is_eq(dist_blw, 1.0e30) && !is_eq(dist_abv, 1.0e30)) { + assign(vx_pb); +} - // Set the index below to the index above and perform no vertical - // interpolation - i_blw = i_abv; - } - // Check if the observation is below the forecast range - else if(!is_eq(dist_blw, 1.0e30) && is_eq(dist_abv, 1.0e30)) { +//////////////////////////////////////////////////////////////////////// - // Set the index above to the index below and perform no vertical - // interpolation - i_abv = i_blw; - } - // Check if an error occurred - else if(is_eq(dist_blw, 1.0e30) && is_eq(dist_abv, 1.0e30)) { +VxPairBase & VxPairBase::operator=(const VxPairBase &vx_pb) { - mlog << Error << "\nfind_vert_lvl() -> " - << "could not find a level above and/or below the " - << "observation level of " << obs_lvl << ".\n\n"; - exit(1); - } + if(this == &vx_pb) return *this; + + assign(vx_pb); + + return *this; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::init_from_scratch() { + + fcst_info = (VarInfo *) nullptr; + obs_info = (VarInfo *) nullptr; + + fclm_info = (VarInfo *) nullptr; + oclm_info = (VarInfo *) nullptr; + + clear(); return; } //////////////////////////////////////////////////////////////////////// -double compute_interp(const DataPlaneArray &dpa, - const double obs_x, const double obs_y, - const double obs_v, const double cmn, const double csd, - const InterpMthd method, const int width, - const GridTemplateFactory::GridTemplates shape, - const bool wrap_lon, - const double thresh, - const bool spfh_flag, const LevelType lvl_typ, - const double to_lvl, const int i_blw, const int i_abv, - const SingleThresh *cat_thresh) { - double v, v_blw, v_abv, t; +void VxPairBase::clear() { - // Check for no data - if(dpa.n_planes() == 0) return bad_data_double; + if(fcst_info) { delete fcst_info; fcst_info = (VarInfo *) nullptr; } + if(obs_info) { delete obs_info; obs_info = (VarInfo *) nullptr; } - v_blw = compute_horz_interp(dpa[i_blw], obs_x, obs_y, obs_v, cmn, csd, - method, width, shape, wrap_lon, - thresh, cat_thresh); + if(fclm_info) { delete fclm_info; fclm_info = (VarInfo *) nullptr; } + if(oclm_info) { delete oclm_info; oclm_info = (VarInfo *) nullptr; } - if(i_blw == i_abv) { - v = v_blw; - } - else { - v_abv = compute_horz_interp(dpa[i_abv], obs_x, obs_y, obs_v, cmn, csd, - method, width, shape, wrap_lon, - thresh, cat_thresh); + desc.clear(); - // Check for bad data prior to vertical interpolation - if(is_bad_data(v_blw) || is_bad_data(v_abv)) { - return bad_data_double; - } + interp_thresh = 0; - // If verifying specific humidity, do vertical interpolation in - // the natural log of q - if(spfh_flag) { - t = compute_vert_pinterp(log(v_blw), dpa.lower(i_blw), - log(v_abv), dpa.lower(i_abv), - to_lvl); - v = exp(t); - } - // Vertically interpolate to the observation pressure level - else if(lvl_typ == LevelType_Pres) { - v = compute_vert_pinterp(v_blw, dpa.lower(i_blw), - v_abv, dpa.lower(i_abv), - to_lvl); - } - // Vertically interpolate to the observation height - else { - v = compute_vert_zinterp(v_blw, dpa.lower(i_blw), - v_abv, dpa.lower(i_abv), - to_lvl); - } - } + fcst_dpa.clear(); + fcmn_dpa.clear(); + fcsd_dpa.clear(); + ocmn_dpa.clear(); + ocsd_dpa.clear(); - return v; -} + sid_inc_filt.clear(); + sid_exc_filt.clear(); + obs_qty_inc_filt.clear(); + obs_qty_exc_filt.clear(); + + mpr_column.clear(); + mpr_thresh.clear(); + + fcst_ut = (unixtime) 0; + beg_ut = (unixtime) 0; + end_ut = (unixtime) 0; + + msg_typ_sfc.clear(); + msg_typ_lnd.clear(); + msg_typ_wtr.clear(); + + sfc_info.clear(); + + n_msg_typ = 0; + n_mask = 0; + n_interp = 0; + n_vx = 0; + + pb_ptr.clear(); + + n_try = 0; + rej_sid = 0; + rej_var = 0; + rej_vld = 0; + rej_obs = 0; + rej_grd = 0; + rej_lvl = 0; + rej_topo = 0; + rej_qty = 0; + + rej_typ.clear(); + rej_mask.clear(); + rej_fcst.clear(); + rej_cmn.clear(); + rej_csd.clear(); + rej_mpr.clear(); + rej_dup.clear(); + return; +} //////////////////////////////////////////////////////////////////////// -void get_interp_points(const DataPlaneArray &dpa, - const double obs_x, const double obs_y, - const InterpMthd method, const int width, - const GridTemplateFactory::GridTemplates shape, - const bool wrap_lon, - const double thresh, const bool spfh_flag, - const LevelType lvl_typ, const double to_lvl, - const int i_blw, const int i_abv, - NumArray &interp_pnts) { +void VxPairBase::assign(const VxPairBase &vx_pb) { - // Initialize - interp_pnts.erase(); + clear(); - // Check for no data - if(dpa.n_planes() == 0) return; + set_fcst_info(vx_pb.fcst_info); + set_obs_info(vx_pb.obs_info); - double v; - int i, n_vld; - NumArray pts_blw, pts_abv; - GridTemplateFactory gtf; - const GridTemplate* gt = gtf.buildGT(shape, width, wrap_lon); + set_fcst_climo_info(vx_pb.fclm_info); + set_obs_climo_info(vx_pb.oclm_info); - // Get interpolation points below the observation - pts_blw = interp_points(dpa[i_blw], *gt, obs_x, obs_y); + desc = vx_pb.desc; - // For multiple levels, get interpolation points above - if(i_blw != i_abv) { - pts_abv = interp_points(dpa[i_abv], *gt, obs_x, obs_y); + interp_thresh = vx_pb.interp_thresh; - if(pts_abv.n() != pts_blw.n()) { - mlog << Error << "\nget_interp_points() -> " - << "the number of interpolation points above (" - << pts_abv.n() << ") and below (" << pts_blw.n() - << ") should match!\n\n"; - exit(1); - } - } + fcst_dpa = vx_pb.fcst_dpa; + fcmn_dpa = vx_pb.fcmn_dpa; + fcsd_dpa = vx_pb.fcsd_dpa; + ocmn_dpa = vx_pb.ocmn_dpa; + ocsd_dpa = vx_pb.ocsd_dpa; - // Interpolate each point vertically - for(i=0, n_vld=0; isize()) < thresh) { - interp_pnts.erase(); - } + sfc_info = vx_pb.sfc_info; - if ( gt ) { delete gt; gt = (const GridTemplate *) nullptr; } + set_size(vx_pb.n_msg_typ, vx_pb.n_mask, vx_pb.n_interp); + + pb_ptr = vx_pb.pb_ptr; + + n_try = vx_pb.n_try; + rej_typ = vx_pb.rej_typ; + rej_mask = vx_pb.rej_mask; + rej_fcst = vx_pb.rej_fcst; + rej_cmn = vx_pb.rej_cmn; + rej_csd = vx_pb.rej_csd; + rej_mpr = vx_pb.rej_mpr; + rej_dup = vx_pb.rej_dup; + rej_typ = vx_pb.rej_typ; + rej_mask = vx_pb.rej_mask; + rej_fcst = vx_pb.rej_fcst; + rej_cmn = vx_pb.rej_cmn; + rej_csd = vx_pb.rej_csd; + rej_mpr = vx_pb.rej_mpr; + rej_dup = vx_pb.rej_dup; return; } //////////////////////////////////////////////////////////////////////// -bool set_climo_flag(const NumArray &f_na, const NumArray &c_na) { +void VxPairBase::copy_var_info(const VarInfo *info, VarInfo *©) { + VarInfoFactory f; - // The climo values must have non-zero, consistent length and - // cannot all be bad data - if(c_na.n() != f_na.n() || c_na.n() < 1 || is_bad_data(c_na.max())) { - return false; - } + // Deallocate, if necessary + if(copy) { delete copy; copy = (VarInfo *) nullptr; } - return true; + // Perform a deep copy + copy = f.new_var_info(info->file_type()); + *copy = *info; + + return; } //////////////////////////////////////////////////////////////////////// -void derive_climo_vals(const ClimoCDFInfo *cdf_info_ptr, - double m, double s, - NumArray &climo_vals) { +int VxPairBase::three_to_one(int i_msg_typ, int i_mask, int i_interp) const { - // Initialize - climo_vals.erase(); + int n = (i_interp * n_mask + i_mask)*n_msg_typ + i_msg_typ; - // Check for no work to do - if(!cdf_info_ptr) return; + if(n < 0 || n >= n_vx) { + mlog << Error << "\nVxPairBase::three_to_one() -> " + << "range check error for n (" << n << " < 0 or n >= " << n_vx + << ") for i_msg_typ (" << i_msg_typ << "), i_mask (" + << i_mask << "), i_interp (" << i_interp << "), and n_msg_typ (" + << n_msg_typ << "), n_mask (" << n_mask << "), n_interp (" + << n_interp << ")!\n\n"; + exit(1); + } - // cdf_info_ptr->cdf_ta starts with >=0.0 and ends with >=1.0. - // The number of bins is the number of thresholds minus 1. + return n; +} - // Check for bad mean value - if(is_bad_data(m) || cdf_info_ptr->cdf_ta.n() < 2) { - return; - } - // Single climo bin - else if(cdf_info_ptr->cdf_ta.n() == 2) { - climo_vals.add(m); - } - // Check for bad standard deviation value - else if(is_bad_data(s)) { - return; - } - // Extract climo distribution values - else { +//////////////////////////////////////////////////////////////////////// - // Skip the first and last thresholds - for(int i=1; icdf_ta.n()-1; i++) { - climo_vals.add( - normal_cdf_inv(cdf_info_ptr->cdf_ta[i].get_value(), m, s)); - } - } +void VxPairBase::set_fcst_info(const VarInfo *info) { + + copy_var_info(info, fcst_info); return; } //////////////////////////////////////////////////////////////////////// -NumArray derive_climo_prob(const ClimoCDFInfo *cdf_info_ptr, - const NumArray &mn_na, const NumArray &sd_na, - const SingleThresh &othresh) { - int i, n_mn, n_sd; - NumArray climo_prob, climo_vals; - double prob; +void VxPairBase::set_obs_info(const VarInfo *info) { - // Number of valid climo mean and standard deviation - n_mn = mn_na.n_valid(); - n_sd = sd_na.n_valid(); + copy_var_info(info, obs_info); - // Check for constant climo probability - if(!is_bad_data(prob = othresh.get_climo_prob())) { + return; +} - mlog << Debug(4) - << "For threshold " << othresh.get_str() - << ", using a constant climatological probability value of " - << prob << ".\n"; +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_fcst_climo_info(const VarInfo *info) { + + copy_var_info(info, fclm_info); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_climo_info(const VarInfo *info) { + + copy_var_info(info, oclm_info); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_desc(const char *s) { + + desc = s; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_interp_thresh(double t) { + + interp_thresh = t; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_fcst_dpa(const DataPlaneArray &dpa) { + + fcst_dpa = dpa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_fcst_climo_mn_dpa(const DataPlaneArray &dpa) { + + fcmn_dpa = dpa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_fcst_climo_sd_dpa(const DataPlaneArray &dpa) { + + fcsd_dpa = dpa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_climo_mn_dpa(const DataPlaneArray &dpa) { + + ocmn_dpa = dpa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_climo_sd_dpa(const DataPlaneArray &dpa) { + + ocsd_dpa = dpa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_fcst_ut(const unixtime ut) { + + fcst_ut = ut; + + // Set for all PairBase instances, used for duplicate logic + for(auto &x : pb_ptr) x->set_fcst_ut(ut); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_beg_ut(const unixtime ut) { + + beg_ut = ut; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_end_ut(const unixtime ut) { + + end_ut = ut; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_sid_inc_filt(const StringArray &sa) { + + sid_inc_filt = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_sid_exc_filt(const StringArray &sa) { + + sid_exc_filt = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_qty_inc_filt(const StringArray &sa) { + + obs_qty_inc_filt = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_qty_exc_filt(const StringArray &sa) { + + obs_qty_exc_filt = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_size(int types, int masks, int interps) { + + // Store the dimensions for the PairBase array + n_msg_typ = types; + n_mask = masks; + n_interp = interps; + n_vx = types * masks * interps; + + // Resize the PairBase pointer vector + pb_ptr.resize(n_vx); + + // Initialize 3-D rejection count vectors + vector rej_counts(n_vx, 0); + rej_typ = rej_counts; + rej_mask = rej_counts; + rej_fcst = rej_counts; + rej_cmn = rej_counts; + rej_csd = rej_counts; + rej_mpr = rej_counts; + rej_dup = rej_counts; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_msg_typ(int i_msg_typ, const char *name) { + + for(int i_mask=0; i_maskset_msg_typ(name); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_msg_typ_vals(int i_msg_typ, const StringArray &sa) { + + for(int i_mask=0; i_maskset_msg_typ_vals(sa); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_mask_area(int i_mask, const char *name, + MaskPlane *mp_ptr) { + + for(int i_msg_typ=0; i_msg_typset_mask_name(name); + pb_ptr[n]->set_mask_area_ptr(mp_ptr); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_mask_sid(int i_mask, const char *name, + StringArray *sid_ptr) { + + for(int i_msg_typ=0; i_msg_typset_mask_name(name); + pb_ptr[n]->set_mask_sid_ptr(sid_ptr); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_mask_llpnt(int i_mask, const char *name, + MaskLatLon *llpnt_ptr) { + + for(int i_msg_typ=0; i_msg_typset_mask_name(name); + pb_ptr[n]->set_mask_llpnt_ptr(llpnt_ptr); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_interp(int i_interp, + const char *interp_mthd_str, int width, + GridTemplateFactory::GridTemplates shape) { + + for(int i_msg_typ=0; i_msg_typset_interp_mthd(interp_mthd_str); + pb_ptr[n]->set_interp_wdth(width); + pb_ptr[n]->set_interp_shape(shape); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_interp(int i_interp, + InterpMthd mthd, int width, + GridTemplateFactory::GridTemplates shape) { + + for(int i_msg_typ=0; i_msg_typset_interp_mthd(mthd); + pb_ptr[n]->set_interp_wdth(width); + pb_ptr[n]->set_interp_shape(shape); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_mpr_thresh(const StringArray &sa, const ThreshArray &ta) { + + // Check for constant length + if(sa.n() != ta.n()) { + mlog << Error << "\nVxPairBase::set_mpr_thresh() -> " + << "the \"" << conf_key_mpr_column << "\" (" + << write_css(sa) << ") and \"" << conf_key_mpr_thresh + << "\" (" << write_css(ta) + << ") config file entries must have the same length!\n\n"; + exit(1); + } + + mpr_column = sa; + mpr_thresh = ta; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_climo_cdf_info_ptr(const ClimoCDFInfo *info) { + + for(auto &x : pb_ptr) x->set_climo_cdf_info_ptr(info); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_msg_typ_sfc(const StringArray &sa) { + + msg_typ_sfc = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_msg_typ_lnd(const StringArray &sa) { + + msg_typ_lnd = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_msg_typ_wtr(const StringArray &sa) { + + msg_typ_wtr = sa; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_sfc_info(const SurfaceInfo &si) { + + sfc_info = si; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +int VxPairBase::get_n_pair() const { + + if(n_vx == 0) { + mlog << Warning << "\nVxPairBase::get_n_pair() -> " + << "set_size() has not been called yet!\n\n"; + } + + int n = 0; + + for(auto &x : pb_ptr) n += x->n_obs; + + return n; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_duplicate_flag(DuplicateType duplicate_flag) { + + if(n_vx == 0) { + mlog << Warning << "\nVxPairBase::set_duplicate_flag() -> " + << "set_size() has not been called yet!\n\n"; + } + + for(auto &x : pb_ptr) x->set_check_unique(duplicate_flag == DuplicateType::Unique); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_summary(ObsSummary s) { + + if(n_vx == 0) { + mlog << Warning << "\nVxPairBase::set_obs_summary() -> " + << "set_size() has not been called yet!\n\n"; + } + + for(auto &x : pb_ptr) x->set_obs_summary(s); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::set_obs_perc_value(int percentile) { + + if(n_vx == 0) { + mlog << Warning << "\nVxPairBase::set_obs_perc_value() -> " + << "set_size() has not been called yet!\n\n"; + } + + for(auto &x : pb_ptr) x->set_obs_perc_value(percentile); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::print_obs_summary() const { + + if(n_vx == 0) { + mlog << Warning << "\nVxPairBase::print_obs_summary() -> " + << "set_size() has not been called yet!\n\n"; + } + + for(auto &x : pb_ptr) x->print_obs_summary(); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::calc_obs_summary() { + + if(n_vx == 0) { + mlog << Warning << "\nVxPairBase::calc_obs_summary() -> " + << "set_size() has not been called yet!\n\n"; + } + + for(auto &x : pb_ptr) x->calc_obs_summary(); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_sid( + const char *pnt_obs_str, const char *hdr_sid_str) { + bool keep = true; + + // Check the station ID inclusion and exclusion lists + if((sid_inc_filt.n() && !sid_inc_filt.has(hdr_sid_str)) || + (sid_exc_filt.n() && sid_exc_filt.has(hdr_sid_str))) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "station id:\n" + << pnt_obs_str << "\n"; + } + + rej_sid++; + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_var( + const char *pnt_obs_str, const char *var_name, int grib_code) { + bool keep = true; + + const auto obs_info_grib = (VarInfoGrib *) obs_info; + + // Check for matching variable name or GRIB code + if((var_name != nullptr) && (m_strlen(var_name) > 0)) { + + if(var_name != obs_info->name()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "variable name:\n" + << pnt_obs_str << "\n"; + } + + rej_var++; + keep = false; + } + } + else if(obs_info_grib && obs_info_grib->code() != nint(grib_code)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "GRIB code:\n" + << pnt_obs_str << "\n"; + } + + rej_var++; + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_qty( + const char *pnt_obs_str, const char *obs_qty) { + bool keep = true; + + // Check the observation quality include and exclude options + if((obs_qty_inc_filt.n() > 0 && !obs_qty_inc_filt.has(obs_qty)) || + (obs_qty_exc_filt.n() > 0 && obs_qty_exc_filt.has(obs_qty))) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "quality control string:\n" + << pnt_obs_str << "\n"; + } + + rej_qty++; + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_vld( + const char *pnt_obs_str, unixtime hdr_ut) { + bool keep = true; + + // Check the observation valid time + if(hdr_ut < beg_ut || hdr_ut > end_ut) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "valid time:\n" + << pnt_obs_str << "\n"; + } + + rej_vld++; + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_obs( + const char *pnt_obs_str, double &obs_v) { + bool keep = true; + + // Apply observation processing logic + obs_v = pb_ptr[0]->process_obs(obs_info, obs_v); + + // Check whether the observation value contains valid data + if(is_bad_data(obs_v)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "with bad data value:\n" + << pnt_obs_str << "\n"; + } + + rej_obs++; + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_grd( + const char *pnt_obs_str, const Grid &gr, + double hdr_lat, double hdr_lon, + double &obs_x, double &obs_y) { + bool keep = true; + + // Convert the lat/lon value to x/y + gr.latlon_to_xy(hdr_lat, -1.0*hdr_lon, obs_x, obs_y); + int x = nint(obs_x); + int y = nint(obs_y); + + // Check if the observation's lat/lon is on the grid + if(((x < 0 || x >= gr.nx()) && !gr.wrap_lon()) || + y < 0 || y >= gr.ny()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "off the grid where (x, y) = (" << x << ", " << y + << ") and grid (nx, ny) = (" << gr.nx() << ", " << gr.ny() << "):\n" + << pnt_obs_str << "\n"; + } + + rej_grd++; + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_topo( + const char *pnt_obs_str, const Grid &gr, + double obs_x, double obs_y, + const char *hdr_typ_str, double hdr_elv) { + bool keep = true; + + // Check for a large topography difference + if(sfc_info.topo_ptr && msg_typ_sfc.reg_exp_match(hdr_typ_str)) { + + // Interpolate model topography to observation location + double topo = compute_horz_interp( + *sfc_info.topo_ptr, obs_x, obs_y, hdr_elv, + InterpMthd::Bilin, 2, + GridTemplateFactory::GridTemplates::Square, + gr.wrap_lon(), 1.0); + + // Skip bad topography values + if(is_bad_data(hdr_elv) || is_bad_data(topo)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "due to bad topography values where observation elevation = " + << hdr_elv << " and model topography = " << topo << ":\n" + << pnt_obs_str << "\n"; + } + + rej_topo++; + keep = false; + } + + // Check the topography difference threshold + else if(!sfc_info.topo_use_obs_thresh.check(topo - hdr_elv)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "due to topography difference where observation elevation (" + << hdr_elv << ") minus model topography (" << topo << ") = " + << topo - hdr_elv << " is not " + << sfc_info.topo_use_obs_thresh.get_str() << ":\n" + << pnt_obs_str << "\n"; + } + + rej_topo++; + keep = false; + } + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_lvl( + const char *pnt_obs_str, const char *hdr_typ_str, + double obs_lvl, double obs_hgt) { + bool keep = true; + + // For pressure levels, check if the observation pressure level + // falls in the requested range. + if(obs_info->level().type() == LevelType_Pres) { + + if(obs_lvl < obs_info->level().lower() || + obs_lvl > obs_info->level().upper()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "pressure level value:\n" + << pnt_obs_str << "\n"; + } + + rej_lvl++; + keep = false; + } + } + // For accumulations, check if the observation accumulation interval + // matches the requested interval. + else if(obs_info->level().type() == LevelType_Accum) { + + if(obs_lvl < obs_info->level().lower() || + obs_lvl > obs_info->level().upper()) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "accumulation interval:\n" + << pnt_obs_str << "\n"; + } + + rej_lvl++; + keep = false; + } + } + // For all other level types (VertLevel, RecNumber, NoLevel), + // check for a surface message type or if the observation height + // falls within the requested range. + else { + + if(!msg_typ_sfc.reg_exp_match(hdr_typ_str) && + (obs_hgt < obs_info->level().lower() || + obs_hgt > obs_info->level().upper())) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "level value:\n" + << pnt_obs_str << "\n"; + } + + rej_lvl++; + keep = false; + } + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_typ( + const char *pnt_obs_str, int i_msg_typ, + const char *hdr_typ_str) { + bool keep = true; + + int n = three_to_one(i_msg_typ, 0, 0); + + // Check for a matching message type + if(!pb_ptr[n]->msg_typ_vals.has(hdr_typ_str)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "message type:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_typ, i_msg_typ); + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_mask( + const char *pnt_obs_str, int i_msg_typ, int i_mask, int x, int y, + const char *hdr_sid_str, double hdr_lat, double hdr_lon) { + bool keep = true; + + int n = three_to_one(i_msg_typ, i_mask, 0); + + // Check for the obs falling within the masking region + if( pb_ptr[n]->mask_area_ptr != nullptr && + !pb_ptr[n]->mask_area_ptr->s_is_on(x, y)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on spatial masking region:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_mask, i_msg_typ, i_mask); + keep = false; + } + // Otherwise, check for the masking SID list + else if( pb_ptr[n]->mask_sid_ptr != nullptr && + !pb_ptr[n]->mask_sid_ptr->has(hdr_sid_str)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on masking station id list:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_mask, i_msg_typ, i_mask); + keep = false; + } + // Otherwise, check observation lat/lon thresholds + else if( pb_ptr[n]->mask_llpnt_ptr != nullptr && + (!pb_ptr[n]->mask_llpnt_ptr->lat_thresh.check(hdr_lat) || + !pb_ptr[n]->mask_llpnt_ptr->lon_thresh.check(hdr_lon))) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on latitude/longitude thesholds:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_mask, i_msg_typ, i_mask); + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_climo( + const char *pnt_obs_str, + int i_msg_typ, int i_mask, int i_interp, + const Grid &gr, double obs_x, double obs_y, + double obs_v, double obs_lvl, double obs_hgt, + ClimoPntInfo &cpi) { + bool keep = true; + + int n = three_to_one(i_msg_typ, i_mask, i_interp); + + bool spfh_flag = fcst_info->is_specific_humidity() && + obs_info->is_specific_humidity(); + + // Compute the interpolated forecast value using the + // observation pressure level or height + double to_lvl = (fcst_info->level().type() == LevelType_Pres ? + obs_lvl : obs_hgt); + int lvl_blw, lvl_abv; + + // Initialize + cpi.clear(); + + // Forecast climatology mean + if(keep && fcmn_dpa.n_planes() > 0) { + + find_vert_lvl(fcmn_dpa, to_lvl, lvl_blw, lvl_abv); + + cpi.fcmn = compute_interp(fcmn_dpa, obs_x, obs_y, obs_v, nullptr, + pb_ptr[n]->interp_mthd, pb_ptr[n]->interp_wdth, + pb_ptr[n]->interp_shape, gr.wrap_lon(), + interp_thresh, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv); + + // Check for bad data + if(is_bad_data(cpi.fcmn)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on bad forecast climatological mean value:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_cmn, i_msg_typ, i_mask, i_interp); + keep = false; + } + } + + // Observation climatology mean + if(keep && ocmn_dpa.n_planes() > 0) { + + find_vert_lvl(ocmn_dpa, to_lvl, lvl_blw, lvl_abv); + + cpi.ocmn = compute_interp(ocmn_dpa, obs_x, obs_y, obs_v, nullptr, + pb_ptr[n]->interp_mthd, pb_ptr[n]->interp_wdth, + pb_ptr[n]->interp_shape, gr.wrap_lon(), + interp_thresh, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv); + + // Check for bad data + if(is_bad_data(cpi.ocmn)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on bad observation climatological mean value:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_cmn, i_msg_typ, i_mask, i_interp); + keep = false; + } + } + + // Check for valid interpolation options + if((fcsd_dpa.n_planes() > 0 || + ocsd_dpa.n_planes() > 0) && + (pb_ptr[n]->interp_mthd == InterpMthd::Min || + pb_ptr[n]->interp_mthd == InterpMthd::Max || + pb_ptr[n]->interp_mthd == InterpMthd::Median || + pb_ptr[n]->interp_mthd == InterpMthd::Best)) { + mlog << Warning << "\nVxPairBase::add_point_obs() -> " + << "applying the " << interpmthd_to_string(pb_ptr[n]->interp_mthd) + << " interpolation method to climatological spread " + << "may cause unexpected results.\n\n"; + } + + // Forecast climatology spread + if(keep && fcsd_dpa.n_planes() > 0) { + + find_vert_lvl(fcsd_dpa, to_lvl, lvl_blw, lvl_abv); + + cpi.fcsd = compute_interp(fcsd_dpa, obs_x, obs_y, obs_v, nullptr, + pb_ptr[n]->interp_mthd, pb_ptr[n]->interp_wdth, + pb_ptr[n]->interp_shape, gr.wrap_lon(), + interp_thresh, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv); + + // Check for bad data + if(is_bad_data(cpi.fcsd)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on bad forecast climatological spread value:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_csd, i_msg_typ, i_mask, i_interp); + keep = false; + } + } + + // Observation climatology spread + if(keep && ocsd_dpa.n_planes() > 0) { + + find_vert_lvl(ocsd_dpa, to_lvl, lvl_blw, lvl_abv); + + cpi.ocsd = compute_interp(ocsd_dpa, obs_x, obs_y, obs_v, nullptr, + pb_ptr[n]->interp_mthd, pb_ptr[n]->interp_wdth, + pb_ptr[n]->interp_shape, gr.wrap_lon(), + interp_thresh, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv); + + // Check for bad data + if(is_bad_data(cpi.ocsd)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on bad observation climatological spread value:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_csd, i_msg_typ, i_mask, i_interp); + keep = false; + } + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +bool VxPairBase::is_keeper_fcst( + const char *pnt_obs_str, + int i_msg_typ, int i_mask, int i_interp, + const char *hdr_typ_str, const Grid &gr, + double obs_x, double obs_y, double hdr_elv, + double obs_v, double obs_lvl, double obs_hgt, + const ClimoPntInfo &cpi, double &fcst_v) { + bool keep = true; + + int n = three_to_one(i_msg_typ, i_mask, i_interp); + + // For surface verification, apply land/sea and topo masks + if((sfc_info.land_ptr || sfc_info.topo_ptr) && + (msg_typ_sfc.reg_exp_match(hdr_typ_str))) { + + bool is_land = msg_typ_lnd.has(hdr_typ_str); + + // Check for a single forecast DataPlane + if(fcst_dpa.n_planes() != 1) { + mlog << Error << "\nVxPairBase::add_point_obs() -> " + << "unexpected number of forecast levels (" + << fcst_dpa.n_planes() + << ") for surface verification! Set \"land_mask.flag\" and " + << "\"topo_mask.flag\" to false to disable this check.\n\n"; + exit(1); + } + + fcst_v = compute_sfc_interp(fcst_dpa[0], obs_x, obs_y, hdr_elv, obs_v, + pb_ptr[n]->interp_mthd, pb_ptr[n]->interp_wdth, + pb_ptr[n]->interp_shape, gr.wrap_lon(), + interp_thresh, sfc_info, is_land); + } + // Otherwise, compute interpolated value + else { + + bool spfh_flag = fcst_info->is_specific_humidity() && + obs_info->is_specific_humidity(); + + // Compute the interpolated forecast value using the + // observation pressure level or height + double to_lvl = (fcst_info->level().type() == LevelType_Pres ? + obs_lvl : obs_hgt); + int lvl_blw, lvl_abv; + + find_vert_lvl(fcst_dpa, to_lvl, lvl_blw, lvl_abv); + + fcst_v = compute_interp(fcst_dpa, obs_x, obs_y, obs_v, &cpi, + pb_ptr[n]->interp_mthd, pb_ptr[n]->interp_wdth, + pb_ptr[n]->interp_shape, gr.wrap_lon(), + interp_thresh, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv); + } + + // Check for bad data + if(is_bad_data(fcst_v)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() << " versus " + << obs_info->magic_str() << ", skipping observation " + << "based on bad data in the " + << interpmthd_to_string(pb_ptr[n]->interp_mthd) << "(" + << pb_ptr[n]->interp_wdth * pb_ptr[n]->interp_wdth + << ") interpolated forecast value:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_fcst, i_msg_typ, i_mask, i_interp); + keep = false; + } + + return keep; +} + +//////////////////////////////////////////////////////////////////////// + +void VxPairBase::inc_count(vector &rej, int i_msg_typ) { + + for(int i_mask=0; i_mask &rej, int i_msg_typ, int i_mask) { + + for(int i_interp=0; i_interp &rej, int i_msg_typ, int i_mask, int i_interp) { + + rej[three_to_one(i_msg_typ, i_mask, i_interp)]++; + + return; +} + +//////////////////////////////////////////////////////////////////////// +// +// Begin miscellaneous utility functions +// +//////////////////////////////////////////////////////////////////////// + +void find_vert_lvl(const DataPlaneArray &dpa, const double obs_lvl, + int &i_blw, int &i_abv) { + int i; + double dist, dist_blw, dist_abv; + + // Initialize + i_blw = i_abv = bad_data_int; + + // Check for no data + if(dpa.n_planes() == 0) return; + + // Find the closest levels above and below the observation + dist_blw = dist_abv = 1.0e30; + for(i=0; i= 0 && fabs(dist) < dist_abv) { + dist_abv = fabs(dist); + i_abv = i; + } + } + + // Check if the observation is above the forecast range + if(is_eq(dist_blw, 1.0e30) && !is_eq(dist_abv, 1.0e30)) { + + // Set the index below to the index above and perform no vertical + // interpolation + i_blw = i_abv; + } + // Check if the observation is below the forecast range + else if(!is_eq(dist_blw, 1.0e30) && is_eq(dist_abv, 1.0e30)) { + + // Set the index above to the index below and perform no vertical + // interpolation + i_abv = i_blw; + } + // Check if an error occurred + else if(is_eq(dist_blw, 1.0e30) && is_eq(dist_abv, 1.0e30)) { + + mlog << Error << "\nfind_vert_lvl() -> " + << "could not find a level above and/or below the " + << "observation level of " << obs_lvl << ".\n\n"; + exit(1); + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +double compute_interp(const DataPlaneArray &dpa, + const double obs_x, const double obs_y, + const double obs_v, const ClimoPntInfo *cpi, + const InterpMthd method, const int width, + const GridTemplateFactory::GridTemplates shape, + const bool wrap_lon, + const double thresh, + const bool spfh_flag, const LevelType lvl_typ, + const double to_lvl, const int i_blw, const int i_abv, + const SingleThresh *cat_thresh) { + double v, v_blw, v_abv, t; + + // Check for no data + if(dpa.n_planes() == 0) return bad_data_double; + + v_blw = compute_horz_interp(dpa[i_blw], obs_x, obs_y, obs_v, cpi, + method, width, shape, wrap_lon, + thresh, cat_thresh); + + if(i_blw == i_abv) { + v = v_blw; + } + else { + v_abv = compute_horz_interp(dpa[i_abv], obs_x, obs_y, obs_v, cpi, + method, width, shape, wrap_lon, + thresh, cat_thresh); + + // Check for bad data prior to vertical interpolation + if(is_bad_data(v_blw) || is_bad_data(v_abv)) { + return bad_data_double; + } + + // If verifying specific humidity, do vertical interpolation in + // the natural log of q + if(spfh_flag) { + t = compute_vert_pinterp(log(v_blw), dpa.lower(i_blw), + log(v_abv), dpa.lower(i_abv), + to_lvl); + v = exp(t); + } + // Vertically interpolate to the observation pressure level + else if(lvl_typ == LevelType_Pres) { + v = compute_vert_pinterp(v_blw, dpa.lower(i_blw), + v_abv, dpa.lower(i_abv), + to_lvl); + } + // Vertically interpolate to the observation height + else { + v = compute_vert_zinterp(v_blw, dpa.lower(i_blw), + v_abv, dpa.lower(i_abv), + to_lvl); + } + } + + return v; +} + + +//////////////////////////////////////////////////////////////////////// + +void get_interp_points(const DataPlaneArray &dpa, + const double obs_x, const double obs_y, + const InterpMthd method, const int width, + const GridTemplateFactory::GridTemplates shape, + const bool wrap_lon, + const double thresh, const bool spfh_flag, + const LevelType lvl_typ, const double to_lvl, + const int i_blw, const int i_abv, + NumArray &interp_pnts) { + + // Initialize + interp_pnts.erase(); + + // Check for no data + if(dpa.n_planes() == 0) return; + + double v; + int i, n_vld; + NumArray pts_blw, pts_abv; + GridTemplateFactory gtf; + const GridTemplate* gt = gtf.buildGT(shape, width, wrap_lon); + + // Get interpolation points below the observation + pts_blw = interp_points(dpa[i_blw], *gt, obs_x, obs_y); + + // For multiple levels, get interpolation points above + if(i_blw != i_abv) { + pts_abv = interp_points(dpa[i_abv], *gt, obs_x, obs_y); + + if(pts_abv.n() != pts_blw.n()) { + mlog << Error << "\nget_interp_points() -> " + << "the number of interpolation points above (" + << pts_abv.n() << ") and below (" << pts_blw.n() + << ") should match!\n\n"; + exit(1); + } + } + + // Interpolate each point vertically + for(i=0, n_vld=0; isize()) < thresh) { + interp_pnts.erase(); + } + + if ( gt ) { delete gt; gt = (const GridTemplate *) nullptr; } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +bool set_climo_flag(const NumArray &f_na, const NumArray &c_na) { + + // The climo values must have non-zero, consistent length and + // cannot all be bad data + if(c_na.n() != f_na.n() || c_na.n() < 1 || is_bad_data(c_na.max())) { + return false; + } + + return true; +} + +//////////////////////////////////////////////////////////////////////// + +void derive_climo_vals(const ClimoCDFInfo *cdf_info_ptr, + double m, double s, + NumArray &climo_vals) { + + // Initialize + climo_vals.erase(); + + // Check for no work to do + if(!cdf_info_ptr) return; + + // cdf_info_ptr->cdf_ta starts with >=0.0 and ends with >=1.0. + // The number of bins is the number of thresholds minus 1. + + // Check for bad mean value + if(is_bad_data(m) || cdf_info_ptr->cdf_ta.n() < 2) { + return; + } + // Single climo bin + else if(cdf_info_ptr->cdf_ta.n() == 2) { + climo_vals.add(m); + } + // Check for bad standard deviation value + else if(is_bad_data(s)) { + return; + } + // Extract climo distribution values + else { + + // Skip the first and last thresholds + for(int i=1; icdf_ta.n()-1; i++) { + climo_vals.add( + normal_cdf_inv(cdf_info_ptr->cdf_ta[i].get_value(), m, s)); + } + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +NumArray derive_climo_prob(const ClimoCDFInfo *cdf_info_ptr, + const NumArray &mn_na, const NumArray &sd_na, + const SingleThresh &othresh) { + int i, n_mn, n_sd; + NumArray climo_prob, climo_vals; + double prob; + + // Number of valid climo mean and standard deviation + n_mn = mn_na.n_valid(); + n_sd = sd_na.n_valid(); + + // Check for constant climo probability + prob = othresh.get_obs_climo_prob(); + if(!is_bad_data(prob)) { + + mlog << Debug(4) + << "For threshold " << othresh.get_str() + << ", using a constant climatological probability value of " + << prob << ".\n"; climo_prob.add_const(prob, n_mn); } @@ -1206,3 +2558,33 @@ double derive_prob(const NumArray &na, const SingleThresh &st) { } //////////////////////////////////////////////////////////////////////// + +// Write the point observation in the MET point format for logging +ConcatString point_obs_to_string(const float *hdr_arr, const char *hdr_typ_str, + const char *hdr_sid_str, unixtime hdr_ut, + const char *obs_qty, const float *obs_arr, + const char *var_name) { + ConcatString obs_cs, name; + + if((var_name != nullptr) && (0 < m_strlen(var_name))) name << var_name; + else name << nint(obs_arr[1]); + + // + // Write the 11-column MET point format: + // Message_Type Station_ID Valid_Time(YYYYMMDD_HHMMSS) + // Lat(Deg North) Lon(Deg East) Elevation(msl) + // Var_Name(or GRIB_Code) Level Height(msl or agl) + // QC_String Observation_Value + // + obs_cs << " " + << hdr_typ_str << " " << hdr_sid_str << " " + << unix_to_yyyymmdd_hhmmss(hdr_ut) << " " + << hdr_arr[0] << " " << -1.0*hdr_arr[1] << " " + << hdr_arr[2] << " " << name << " " + << obs_arr[2] << " " << obs_arr[3] << " " + << obs_qty << " " << obs_arr[4]; + + return obs_cs; +} + +//////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_base.h b/src/libcode/vx_statistics/pair_base.h index b0881ae34e..af92385f5c 100644 --- a/src/libcode/vx_statistics/pair_base.h +++ b/src/libcode/vx_statistics/pair_base.h @@ -18,27 +18,39 @@ #include "vx_util.h" #include "vx_data2d.h" +#include "vx_data2d_grib.h" + +//////////////////////////////////////////////////////////////////////// + +static const int REJECT_DEBUG_LEVEL = 9; + +//////////////////////////////////////////////////////////////////////// struct ob_val_t { - unixtime ut; - double val; - std::string qc; + unixtime ut; + double val; + std::string qc; }; struct station_values_t { - std::string sid; - double lat; - double lon; - double x; - double y; - double wgt; - unixtime ut; - double lvl; - double elv; - double cmn; - double csd; - double summary_val; - std::vector obs; + + void clear(); + + std::string sid; + double lat; + double lon; + double x; + double y; + double wgt; + unixtime ut; + double lvl; + double elv; + double fcmn; + double fcsd; + double ocmn; + double ocsd; + double summary_val; + std::vector obs; }; //////////////////////////////////////////////////////////////////////// @@ -91,9 +103,11 @@ class PairBase { NumArray wgt_na; // Weight [n_obs] // Point and Grid Climatology Information - NumArray cmn_na; // Climatology mean [n_obs] - NumArray csd_na; // Climatology standard deviation [n_obs] - NumArray cdf_na; // Climatology cumulative distribution function [n_obs] + NumArray fcmn_na; // Forecast climatology mean [n_obs] + NumArray fcsd_na; // Forecast climatology standard deviation [n_obs] + NumArray ocmn_na; // Observation climatology mean [n_obs] + NumArray ocsd_na; // Observation climatology standard deviation [n_obs] + NumArray ocdf_na; // Observation climatology cumulative distribution function [n_obs] // Point Observation Information StringArray sid_sa; // Station ID [n_obs] @@ -156,24 +170,25 @@ class PairBase { bool add_point_obs(const char *, double, double, double, double, unixtime, double, double, double, const char *, - double, double, double); + const ClimoPntInfo &, double); void set_point_obs(int, const char *, double, double, double, double, unixtime, double, double, double, - const char *, double, double, double); + const char *, const ClimoPntInfo &, double); - void add_grid_obs(double, double, double, double); + void add_grid_obs(double, const ClimoPntInfo &, double); - void add_grid_obs(double, double, double, - double, double, double); - - void add_climo(double, double, double); - void set_climo(int, double, double, double); - void add_climo_cdf(); + void add_grid_obs(double, double, double, const ClimoPntInfo &, double); - double process_obs(VarInfo *, double); + void add_climo(double, const ClimoPntInfo &); - void print_obs_summary(); + void set_climo(int, double, const ClimoPntInfo &); + + void compute_climo_cdf(); + + double process_obs(const VarInfo *, double) const; + + void print_obs_summary() const; void calc_obs_summary(); @@ -183,6 +198,215 @@ class PairBase { inline bool PairBase::is_point_vx() const { return IsPointVx; } +//////////////////////////////////////////////////////////////////////// +// +// Base class for verification tasks +// +//////////////////////////////////////////////////////////////////////// + +class VxPairBase { + + protected: + + void init_from_scratch(); + void assign(const VxPairBase &); + void copy_var_info(const VarInfo *info, VarInfo *©); + + public: + + VxPairBase(); + ~VxPairBase(); + VxPairBase(const VxPairBase &); + VxPairBase & operator=(const VxPairBase &); + + ////////////////////////////////////////////////////////////////// + // + // Information about the fields to be compared + // + ////////////////////////////////////////////////////////////////// + + VarInfo *fcst_info; // Forecast field, allocated by VarInfoFactory + VarInfo *obs_info; // Observation field, allocated by VarInfoFactory + + VarInfo *fclm_info; // Forecast climatology field, allocated by VarInfoFactory + VarInfo *oclm_info; // Observation climatology field, allocated by VarInfoFactory + + ConcatString desc; // User description from config file + + double interp_thresh; // Threshold between 0 and 1 used when + // interpolating the forecasts to the + // observation location. + + ////////////////////////////////////////////////////////////////// + // + // Forecast and climatology fields falling between the requested + // levels. Store the fields in a data plane array. + // + ////////////////////////////////////////////////////////////////// + + DataPlaneArray fcst_dpa; // Forecast data plane array + DataPlaneArray fcmn_dpa; // Forecast climatology mean data plane array + DataPlaneArray fcsd_dpa; // Forecast climatology standard deviation data plane array + DataPlaneArray ocmn_dpa; // Observation climatology mean data plane array + DataPlaneArray ocsd_dpa; // Observation climatology standard deviation data plane array + + ////////////////////////////////////////////////////////////////// + + unixtime fcst_ut; // Forecast valid time + unixtime beg_ut; // Beginning of valid time window + unixtime end_ut; // End of valid time window + + ////////////////////////////////////////////////////////////////// + + StringArray sid_inc_filt; // Station ID inclusion list + StringArray sid_exc_filt; // Station ID exclusion list + StringArray obs_qty_inc_filt; // Observation quality include markers + StringArray obs_qty_exc_filt; // Observation quality exclude markers + + ////////////////////////////////////////////////////////////////// + + StringArray mpr_column; // Names of MPR columns or diffs of columns + ThreshArray mpr_thresh; // Filtering thresholds for the MPR columns + + ////////////////////////////////////////////////////////////////// + + StringArray msg_typ_sfc; // List of surface message types + StringArray msg_typ_lnd; // List of surface land message types + StringArray msg_typ_wtr; // List of surface water message types + + SurfaceInfo sfc_info; // Land/sea mask and topography info + + ////////////////////////////////////////////////////////////////// + + int n_msg_typ; // Number of verifying message types + + int n_mask; // Total number of masking regions + // of masking DataPlane fields or SIDs + + int n_interp; // Number of interpolation techniques + + int n_vx; // n_msg_typ * n_mask * n_interp + + ////////////////////////////////////////////////////////////////// + + // 3-Dim vector of PairBase pointers [n_msg_typ][n_mask][n_interp] + std::vector pb_ptr; + + // Counts for observation rejection reason codes + int n_try; // Number of observations processed + int rej_sid; // Reject based on SID inclusion and exclusion lists + int rej_var; // Reject based on observation variable name + int rej_vld; // Reject based on valid time + int rej_obs; // Reject observation bad data + int rej_grd; // Reject based on location + int rej_topo; // Reject based on topography + int rej_lvl; // Reject based on vertical level + int rej_qty; // Reject based on obs quality + + // 3-Dim vectors for observation rejection reason codes [n_msg_typ][n_mask][n_interp] + std::vector rej_typ; // Reject based on message type + std::vector rej_mask; // Reject based on masking region + std::vector rej_fcst; // Reject forecast bad data + std::vector rej_cmn; // Reject fcst or obs climo mean bad data + std::vector rej_csd; // Reject fcst or obs climo stdev bad data + std::vector rej_mpr; // Reject based on MPR filtering logic + std::vector rej_dup; // Reject based on duplicates logic + + ////////////////////////////////////////////////////////////////// + + void clear(); + + int three_to_one(int, int, int) const; + + void set_fcst_info(const VarInfo *); + void set_obs_info(const VarInfo *); + + void set_fcst_climo_info(const VarInfo *); + void set_obs_climo_info(const VarInfo *); + + void set_desc(const char *); + + void set_interp_thresh(double); + + void set_fcst_dpa(const DataPlaneArray &); + void set_fcst_climo_mn_dpa(const DataPlaneArray &); + void set_fcst_climo_sd_dpa(const DataPlaneArray &); + void set_obs_climo_mn_dpa(const DataPlaneArray &); + void set_obs_climo_sd_dpa(const DataPlaneArray &); + + void set_fcst_ut(const unixtime); + void set_beg_ut(const unixtime); + void set_end_ut(const unixtime); + + void set_sid_inc_filt(const StringArray &); + void set_sid_exc_filt(const StringArray &); + void set_obs_qty_inc_filt(const StringArray &); + void set_obs_qty_exc_filt(const StringArray &); + + // Call set_size before set_msg_typ, set_mask_area, and set_interp + void set_size(int, int, int); + + void set_msg_typ(int, const char *); + void set_msg_typ_vals(int, const StringArray &); + void set_mask_area(int, const char *, MaskPlane *); + void set_mask_sid(int, const char *, StringArray *); + void set_mask_llpnt(int, const char *, MaskLatLon *); + + void set_interp(int i_interp, const char *interp_mthd_str, int width, + GridTemplateFactory::GridTemplates shape); + void set_interp(int i_interp, InterpMthd mthd, + int width, GridTemplateFactory::GridTemplates shape); + + void set_mpr_thresh(const StringArray &, const ThreshArray &); + + void set_climo_cdf_info_ptr(const ClimoCDFInfo *); + + void set_msg_typ_sfc(const StringArray &); + void set_msg_typ_lnd(const StringArray &); + void set_msg_typ_wtr(const StringArray &); + + void set_sfc_info(const SurfaceInfo &); + + int get_n_pair() const; + + void set_duplicate_flag(DuplicateType duplicate_flag); + void set_obs_summary(ObsSummary obs_summary); + void set_obs_perc_value(int percentile); + + void print_obs_summary() const; + void calc_obs_summary(); + + bool is_keeper_sid(const char *, const char *); + bool is_keeper_var(const char *, const char *, int); + bool is_keeper_qty(const char *, const char *); + bool is_keeper_vld(const char *, unixtime); + bool is_keeper_obs(const char *, double &); + bool is_keeper_grd(const char *, const Grid &, + double, double, + double &, double &); + bool is_keeper_topo(const char *, const Grid &, + double, double, + const char *, double); + bool is_keeper_lvl(const char *, const char *, double, double); + bool is_keeper_typ(const char *, int, const char *); + bool is_keeper_mask(const char *, int, int, int, int, + const char *, double, double); + bool is_keeper_climo(const char *, int, int, int, + const Grid &gr, double, double, + double, double, double, + ClimoPntInfo &); + bool is_keeper_fcst(const char *, int, int, int, + const char *, const Grid &gr, + double, double, double, + double, double, double, + const ClimoPntInfo &, double &); + + // Member functions for incrementing the counts + void inc_count(std::vector &, int); + void inc_count(std::vector &, int, int); + void inc_count(std::vector &, int, int, int); +}; + //////////////////////////////////////////////////////////////////////// // // Miscellanous utility functions @@ -194,7 +418,7 @@ extern void find_vert_lvl(const DataPlaneArray &, const double, extern double compute_interp(const DataPlaneArray &dpa, const double obs_x, const double obs_y, - const double obs_v, const double cmn, const double csd, + const double obs_v, const ClimoPntInfo *cpi, const InterpMthd method, const int width, const GridTemplateFactory::GridTemplates shape, const bool wrap_lon, @@ -224,6 +448,13 @@ extern NumArray derive_climo_prob(const ClimoCDFInfo *, extern double derive_prob(const NumArray &, const SingleThresh &); +// Write the point observation in the MET point format for logging +extern ConcatString point_obs_to_string( + const float *hdr_arr, const char *hdr_typ_str, + const char *hdr_sid_str, unixtime hdr_ut, + const char *obs_qty, const float *obs_arr, + const char *var_name); + //////////////////////////////////////////////////////////////////////// #endif // __PAIR_BASE_H__ diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index 2cf41de138..af9f80de15 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -32,7 +31,6 @@ using namespace std; - //////////////////////////////////////////////////////////////////////// // // Code for class PairDataEnsemble @@ -233,9 +231,11 @@ void PairDataEnsemble::assign(const PairDataEnsemble &pd) { cdf_info_ptr = pd.cdf_info_ptr; - cmn_na = pd.cmn_na; - csd_na = pd.csd_na; - cdf_na = pd.cdf_na; + fcmn_na = pd.fcmn_na; + fcsd_na = pd.fcsd_na; + ocmn_na = pd.ocmn_na; + ocsd_na = pd.ocsd_na; + ocdf_na = pd.ocdf_na; // PairDataEnsemble v_na = pd.v_na; @@ -380,24 +380,27 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { // Check if the ranks have already been computed if(r_na.n() == o_na.n()) return; - // Print the climo data being used - bool cmn_flag = set_climo_flag(o_na, cmn_na); - bool csd_flag = set_climo_flag(o_na, csd_na); + // Print the observation climo data being used + bool ocmn_flag = set_climo_flag(o_na, ocmn_na); + bool ocsd_flag = set_climo_flag(o_na, ocsd_na); - if(cmn_flag && cdf_info_ptr && cdf_info_ptr->cdf_ta.n() == 2) { + if(ocmn_flag && cdf_info_ptr && cdf_info_ptr->cdf_ta.n() == 2) { mlog << Debug(3) << "Computing ensemble statistics relative to the " - << "climatological mean.\n"; + << "observation climatological mean.\n"; } - else if(cmn_flag && csd_flag && cdf_info_ptr && cdf_info_ptr->cdf_ta.n() > 2) { + else if(ocmn_flag && + ocsd_flag && + cdf_info_ptr && + cdf_info_ptr->cdf_ta.n() > 2) { mlog << Debug(3) << "Computing ensemble statistics relative to a " << cdf_info_ptr->cdf_ta.n() - 2 - << "-member climatological ensemble.\n"; + << "-member observation climatological ensemble.\n"; } else { mlog << Debug(3) - << "No reference climatology data provided.\n"; + << "No reference observation climatology data provided.\n"; } // Compute the rank for each observation @@ -533,8 +536,8 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { r_na.add(nint(dest_na[0])); } - // Derive ensemble from climo mean and standard deviation - derive_climo_vals(cdf_info_ptr, cmn_na[i], csd_na[i], cur_clm); + // Derive ensemble from observation climo mean and standard deviation + derive_climo_vals(cdf_info_ptr, ocmn_na[i], ocsd_na[i], cur_clm); // Store empirical CRPS stats // For crps_emp use temporary, local variable so we can use it @@ -552,7 +555,7 @@ void PairDataEnsemble::compute_pair_vals(const gsl_rng *rng_ptr) { // Store Gaussian CRPS stats crps_gaus_na.add(compute_crps_gaus(o_na[i], mean, stdev)); - crpscl_gaus_na.add(compute_crps_gaus(o_na[i], cmn_na[i], csd_na[i])); + crpscl_gaus_na.add(compute_crps_gaus(o_na[i], ocmn_na[i], ocsd_na[i])); ign_na.add(compute_ens_ign(o_na[i], mean, stdev)); pit_na.add(compute_ens_pit(o_na[i], mean, stdev)); @@ -783,10 +786,7 @@ void PairDataEnsemble::compute_ssvar() { // Sort the bins set sorted_bins; - for( ssvar_bin_map::iterator map_it = bins.begin(); - map_it != bins.end(); map_it++ ){ - sorted_bins.insert( (*map_it).first ); - } + for(auto &x : bins) sorted_bins.insert(x.first); // Report the number of bins built int n_bin = sorted_bins.size(); @@ -876,26 +876,33 @@ PairDataEnsemble PairDataEnsemble::subset_pairs_obs_thresh(const SingleThresh &o pd.obs_error_flag = obs_error_flag; pd.cdf_info_ptr = cdf_info_ptr; - bool cmn_flag = set_climo_flag(o_na, cmn_na); - bool csd_flag = set_climo_flag(o_na, csd_na); - bool wgt_flag = set_climo_flag(o_na, wgt_na); + bool fcmn_flag = set_climo_flag(o_na, fcmn_na); + bool fcsd_flag = set_climo_flag(o_na, fcsd_na); + bool ocmn_flag = set_climo_flag(o_na, ocmn_na); + bool ocsd_flag = set_climo_flag(o_na, ocsd_na); + bool wgt_flag = set_climo_flag(o_na, wgt_na); // Loop over the pairs for(i=0; ifile_type()); - *climo_info = *info; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_obs_info(VarInfo *info) { - VarInfoFactory f; - - // Deallocate, if necessary - if(obs_info) { delete obs_info; obs_info = (VarInfo *) nullptr; } - - // Perform a deep copy - obs_info = f.new_var_info(info->file_type()); - *obs_info = *info; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_desc(const char *s) { - - desc = s; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_interp_thresh(double t) { - - interp_thresh = t; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_msg_typ_sfc(const StringArray &sa) { - - msg_typ_sfc = sa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_fcst_dpa(const DataPlaneArray &dpa) { - - fcst_dpa = dpa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_climo_mn_dpa(const DataPlaneArray &dpa) { - - climo_mn_dpa = dpa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_climo_sd_dpa(const DataPlaneArray &dpa) { - - climo_sd_dpa = dpa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_fcst_ut(const unixtime ut) { - - fcst_ut = ut; - - // set the fcst_ut for all PairBase instances, used for duplicate logic - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_fcst_ut(ut); - } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_beg_ut(const unixtime ut) { - - beg_ut = ut; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_end_ut(const unixtime ut) { + ens_info = new EnsVarInfo(*info); - end_ut = ut; + // Set the base pointer + if(!fcst_info) set_fcst_info(ens_info->get_var_info()); return; } //////////////////////////////////////////////////////////////////////// -void VxPairDataEnsemble::set_sid_inc_filt(const StringArray sa) { - - sid_inc_filt = sa; - - return; -} +void VxPairDataEnsemble::set_size(int types, int masks, int interps) { -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_sid_exc_filt(const StringArray sa) { - - sid_exc_filt = sa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_obs_qty_inc_filt(const StringArray q) { - - obs_qty_inc_filt = q; - - return; -} - -//////////////////////////////////////////////////////////////////////// + VxPairBase::set_size(types, masks, interps); -void VxPairDataEnsemble::set_obs_qty_exc_filt(const StringArray q) { + // Resize the PairDataPoint vector + pd.resize(n_vx); - obs_qty_exc_filt = q; + // Set PairBase pointers to the PairDataEnsemble objects + for(int i=0; i " + << "set_size() has not been called yet!\n\n"; } - return; -} - -//////////////////////////////////////////////////////////////////////// + for(auto it = pd.begin(); it != pd.end(); it++) { -void VxPairDataEnsemble::set_msg_typ(int i_msg_typ, const char *name) { - - for(int i=0; iinterp_mthd == InterpMthd::HiRA) { + GridTemplateFactory gtf; + GridTemplate* gt = gtf.buildGT(it->interp_shape, + it->interp_wdth, + false); + it->set_ens_size(n*gt->size()); } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_msg_typ_vals(int i_msg_typ, const StringArray &sa) { - - for(int i=0; iset_ens_size(n); } } @@ -1313,150 +1108,57 @@ void VxPairDataEnsemble::set_msg_typ_vals(int i_msg_typ, const StringArray &sa) //////////////////////////////////////////////////////////////////////// -void VxPairDataEnsemble::set_mask_area(int i_mask, const char *name, - MaskPlane *mp_ptr) { +void VxPairDataEnsemble::set_ssvar_bin_size(double ssvar_bin_size) { - for(int i=0; i " + << "set_size() has not been called yet!\n\n"; } - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_mask_sid(int i_mask, const char *name, - StringArray *sid_ptr) { - - for(int i=0; i " + << "set_size() has not been called yet!\n\n"; } - return; -} - - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_interp(int i_interp, - const char *interp_mthd_str, - int width, GridTemplateFactory::GridTemplates shape) { - - for(int i=0; isize()); - } - else { - pd[i][j][k].set_ens_size(n); - } - } - } + if(n_vx == 0) { + mlog << Warning << "\nVxPairDataEnsemble::set_ctrl_index() -> " + << "set_size() has not been called yet!\n\n"; } - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_climo_cdf_info_ptr(const ClimoCDFInfo *info) { - - for(int i=0; i " + << "set_size() has not been called yet!\n\n"; } - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_phist_bin_size(double phist_bin_size) { - - for(int i=0; ifile_type() != FileType_Gb1) { @@ -1489,104 +1184,49 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, // Create VarInfoGrib pointer VarInfoGrib *obs_info_grib = (VarInfoGrib *) obs_info; - // Check the station ID inclusion and exclusion lists - if((sid_inc_filt.n() && !sid_inc_filt.has(hdr_sid_str)) || - (sid_exc_filt.n() && sid_exc_filt.has(hdr_sid_str))) return; + // Increment the number of tries count + n_try++; - // Check whether the observation variable name matches (rej_var) - if ((var_name != 0) && (0 < m_strlen(var_name))) { - if ( var_name != obs_info->name() ) { - return; - } - } - else if(obs_info_grib->code() != nint(obs_arr[1])) { - return; + // Point observation summary string for rejection log messages + ConcatString pnt_obs_str; + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + pnt_obs_str = point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name); } - - // Check the observation quality include and exclude options - if((obs_qty_inc_filt.n() > 0 && !obs_qty_inc_filt.has(obs_qty)) || - (obs_qty_exc_filt.n() > 0 && obs_qty_exc_filt.has(obs_qty))) { - return; - } - - // Check whether the observation time falls within the valid time - // window - if(hdr_ut < beg_ut || hdr_ut > end_ut) return; - hdr_lat = hdr_arr[0]; - hdr_lon = hdr_arr[1]; + // Check the station ID + if(!is_keeper_sid(pnt_obs_str.c_str(), hdr_sid_str)) return; - obs_lvl = obs_arr[2]; - obs_hgt = obs_arr[3]; + // Check observation variable + if(!is_keeper_var(pnt_obs_str.c_str(), var_name, nint(obs_arr[1]))) return; - // Apply observation processing logic - obs_v = pd[0][0][0].process_obs(obs_info, obs_arr[4]); + // Check observation quality + if(!is_keeper_qty(pnt_obs_str.c_str(), obs_qty)) return; - // Check whether the observation value contains valid data - if(is_bad_data(obs_v)) return; + // Check valid time + if(!is_keeper_vld(pnt_obs_str.c_str(), hdr_ut)) return; - // Convert the lat/lon value to x/y - gr.latlon_to_xy(hdr_lat, -1.0*hdr_lon, obs_x, obs_y); - x = nint(obs_x); - y = nint(obs_y); + // Check observation value + double obs_v = obs_arr[4]; + if(!is_keeper_obs(pnt_obs_str.c_str(), obs_v)) return; - // Check if the observation's lat/lon is on the grid - if(((x < 0 || x >= gr.nx()) && !gr.wrap_lon()) || - y < 0 || y >= gr.ny()) return; + // Check location + double hdr_lat = hdr_arr[0]; + double hdr_lon = hdr_arr[1]; + double obs_x, obs_y; + if(!is_keeper_grd(pnt_obs_str.c_str(), gr, hdr_lat, hdr_lon, obs_x, obs_y)) return; - // For pressure levels, check if the observation pressure level - // falls in the requested range. - if(obs_info_grib->level().type() == LevelType_Pres) { + // TODO: Add topography filtering to Ensemble-Stat - if(obs_lvl < obs_info_grib->level().lower() || - obs_lvl > obs_info_grib->level().upper()) return; - } - // For accumulations, check if the observation accumulation interval - // matches the requested interval. - else if(obs_info_grib->level().type() == LevelType_Accum) { - - if(obs_lvl < obs_info_grib->level().lower() || - obs_lvl > obs_info_grib->level().upper()) return; - } - // For all other level types (VertLevel, RecNumber, NoLevel), - // check for a surface message type or if the observation height - // falls within the requested range. - else { + // Check topo + double hdr_elv = hdr_arr[2]; + if(!is_keeper_topo(pnt_obs_str.c_str(), gr, obs_x, obs_y, + hdr_typ_str, hdr_elv)) return; - if(!msg_typ_sfc.reg_exp_match(hdr_typ_str) && - (obs_hgt < obs_info_grib->level().lower() || - obs_hgt > obs_info_grib->level().upper())) { - return; - } - } - - // For a single climatology mean field - if(climo_mn_dpa.n_planes() == 1) { - cmn_lvl_blw = 0; - cmn_lvl_abv = 0; - } - // For multiple climatology mean fields, find the levels above and - // below the observation point. - else { - // Interpolate using the observation pressure level or height - to_lvl = (fcst_info->get_var_info()->level().type() == LevelType_Pres ? - obs_lvl : obs_hgt); - find_vert_lvl(climo_mn_dpa, to_lvl, cmn_lvl_blw, cmn_lvl_abv); - } - - // For a single climatology standard deviation field - if(climo_sd_dpa.n_planes() == 1) { - csd_lvl_blw = 0; - csd_lvl_abv = 0; - } - // For multiple climatology standard deviation fields, find the - // levels above and below the observation point. - else { - // Interpolate using the observation pressure level or height - to_lvl = (fcst_info->get_var_info()->level().type() == LevelType_Pres ? - obs_lvl : obs_hgt); - find_vert_lvl(climo_sd_dpa, to_lvl, csd_lvl_blw, csd_lvl_abv); - } + // Check level + double obs_lvl = obs_arr[2]; + double obs_hgt = obs_arr[3]; + if(!is_keeper_lvl(pnt_obs_str.c_str(), hdr_typ_str, obs_lvl, obs_hgt)) return; // When verifying a vertical level forecast against a surface message type, // set the observation level value to bad data so that it's not used in the @@ -1596,11 +1236,12 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, obs_lvl = bad_data_double; } - // Set flag for specific humidity - bool spfh_flag = fcst_info->get_var_info()->is_specific_humidity() && - obs_info->is_specific_humidity(); + // Set flags + bool spfh_flag = fcst_info->is_specific_humidity() && + obs_info->is_specific_humidity(); // Store pointer to ObsErrorEntry + ObsErrorEntry *oerr_ptr = (ObsErrorEntry *) nullptr; if(obs_error_info->flag) { // Use config file setting, if specified @@ -1637,96 +1278,58 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, FieldType::Obs, oerr_ptr, obs_v); } - // Look through all of the PairData objects to see if the observation - // should be added. + // Loop through the message types + for(int i_msg_typ=0; i_msg_typs_is_on(x, y)) continue; - } - // Otherwise, check for the obs Station ID's presence in the - // masking SID list - else if(pd[i][j][0].mask_sid_ptr != (StringArray *) 0) { - if(!pd[i][j][0].mask_sid_ptr->has(hdr_sid_str)) continue; - } - // Otherwise, check observation Lat/Lon thresholds - else if(pd[i][j][0].mask_llpnt_ptr != (MaskLatLon *) 0) { - if(!pd[i][j][0].mask_llpnt_ptr->lat_thresh.check(hdr_lat) || - !pd[i][j][0].mask_llpnt_ptr->lon_thresh.check(hdr_lon)) { - continue; - } - } + // Loop through the masking regions + for(int i_mask=0; i_maskget_var_info()->level().type() == LevelType_Pres ? - obs_lvl : obs_hgt); - - // Compute the interpolated climatology mean - cmn_v = compute_interp(climo_mn_dpa, obs_x, obs_y, obs_v, - bad_data_double, bad_data_double, - pd[0][0][k].interp_mthd, pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, gr.wrap_lon(), - interp_thresh, spfh_flag, - fcst_info->get_var_info()->level().type(), - to_lvl, cmn_lvl_blw, cmn_lvl_abv); - - // Check for bad data - if(climo_mn_dpa.n_planes() > 0 && is_bad_data(cmn_v)) { - continue; - } + // Check masking region + if(!is_keeper_mask(pnt_obs_str.c_str(), i_msg_typ, i_mask, x, y, + hdr_sid_str, hdr_lat, hdr_lon)) continue; - // Check for valid interpolation options - if(climo_sd_dpa.n_planes() > 0 && - (pd[0][0][k].interp_mthd == InterpMthd::Min || - pd[0][0][k].interp_mthd == InterpMthd::Max || - pd[0][0][k].interp_mthd == InterpMthd::Median || - pd[0][0][k].interp_mthd == InterpMthd::Best)) { - mlog << Warning << "\nVxPairDataEnsemble::add_point_obs() -> " - << "applying the " - << interpmthd_to_string(pd[0][0][k].interp_mthd) - << " interpolation method to climatological spread " - << "may cause unexpected results.\n\n"; - } + // Loop through the interpolation methods + for(int i_interp=0; i_interpget_var_info()->level().type(), - to_lvl, csd_lvl_blw, csd_lvl_abv); - - // Check for bad data - if(climo_sd_dpa.n_planes() > 0 && is_bad_data(csd_v)) { - continue; - } + // Check climatology values + ClimoPntInfo cpi; + if(!is_keeper_climo(pnt_obs_str.c_str(), i_msg_typ, i_mask, i_interp, + gr, obs_x, obs_y, obs_v, obs_lvl, obs_hgt, + cpi)) continue; // Compute weight for current point - wgt_v = (wgt_dp == (DataPlane *) 0 ? - default_grid_weight : wgt_dp->get(x, y)); + double wgt_v = (wgt_dp == nullptr ? + default_grid_weight : + wgt_dp->get(x, y)); // Add the observation value // Weight is from the nearest grid point - pd[i][j][k].add_point_obs(hdr_sid_str, hdr_lat, hdr_lon, - obs_x, obs_y, hdr_ut, obs_lvl, obs_hgt, - obs_v, obs_qty, cmn_v, csd_v, wgt_v); - pd[i][j][k].add_obs_error_entry(oerr_ptr); + int n = three_to_one(i_msg_typ, i_mask, i_interp); + if(!pd[n].add_point_obs(hdr_sid_str, hdr_lat, hdr_lon, + obs_x, obs_y, hdr_ut, obs_lvl, obs_hgt, + obs_v, obs_qty, cpi, wgt_v)) { + + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + mlog << Debug(REJECT_DEBUG_LEVEL) + << "For " << fcst_info->magic_str() + << " versus " << obs_info->magic_str() + << ", skipping observation since it is a duplicate:\n" + << pnt_obs_str << "\n"; + } + + inc_count(rej_dup, i_msg_typ, i_mask, i_interp); + continue; + } + + // Store the observation error pointer + pd[n].add_obs_error_entry(oerr_ptr); + } // end for k } // end for j } // end for i @@ -1737,254 +1340,120 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, //////////////////////////////////////////////////////////////////////// void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { - int i, j, k, l, m; - int f_lvl_blw, f_lvl_abv, i_mem; - double to_lvl, fcst_v; - NumArray fcst_na; // Set flag for specific humidity - bool spfh_flag = fcst_info->get_var_info()->is_specific_humidity() && - obs_info->is_specific_humidity(); + bool spfh_flag = fcst_info->is_specific_humidity() && + obs_info->is_specific_humidity(); // Loop through all the PairDataEnsemble objects and interpolate - for(i=0; i " - << "the \"" << interpmthd_to_string(pd[0][0][k].interp_mthd) - << "\" interpolation method only applies when verifying a " - << "single level, not " << fcst_dpa.n_planes() - << " levels.\n\n"; - continue; - } - - // Process each of the observations - for(l=0; lget_var_info()->level().type() == LevelType_Pres ? - pd[i][j][k].lvl_na[l] : pd[i][j][k].elv_na[l]); - - // For a single forecast field - if(fcst_dpa.n_planes() == 1) { - f_lvl_blw = 0; - f_lvl_abv = 0; - } - // For multiple forecast fields, find the levels above - // and below the observation point. - else { - find_vert_lvl(fcst_dpa, to_lvl, f_lvl_blw, f_lvl_abv); - } - - // Extract the HiRA neighborhood of values - if(pd[0][0][k].interp_mthd == InterpMthd::HiRA) { - - // For HiRA, set the ensemble mean to bad data - if(mn) { - fcst_na.erase(); - fcst_na.add(bad_data_double); - } - // Otherwise, retrieve all the neighborhood values - // using a valid threshold of 0 - else { - get_interp_points(fcst_dpa, - pd[i][j][k].x_na[l], - pd[i][j][k].y_na[l], - pd[0][0][k].interp_mthd, - pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, - gr.wrap_lon(), - 0, spfh_flag, - fcst_info->get_var_info()->level().type(), - to_lvl, f_lvl_blw, f_lvl_abv, - fcst_na); - } - } - // Otherwise, get a single interpolated ensemble value - else { - fcst_na.add(compute_interp(fcst_dpa, - pd[i][j][k].x_na[l], - pd[i][j][k].y_na[l], - pd[i][j][k].o_na[l], - pd[i][j][k].cmn_na[l], - pd[i][j][k].csd_na[l], - pd[0][0][k].interp_mthd, - pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, - gr.wrap_lon(), - interp_thresh, spfh_flag, - fcst_info->get_var_info()->level().type(), - to_lvl, f_lvl_blw, f_lvl_abv)); - } - - // Store the single ensemble value or HiRA neighborhood - for(m=0; mflag) { - fcst_v = add_obs_error_inc( - obs_error_info->rng_ptr, FieldType::Fcst, - pd[i][j][k].obs_error_entry[l], - pd[i][j][k].o_na[l], fcst_na[m]); - } - else { - fcst_v = fcst_na[m]; - } - - // Determine index of ensemble member - i_mem = member * fcst_na.n() + m; - - // Store perturbed ensemble member value - pd[i][j][k].add_ens(i_mem, fcst_v); - } - - } // end for m - fcst_na - } // end for l - n_obs - } // end for k - n_interp - } // end for j - n_mask - } // end for i - n_msg_typ - - return; -} - -//////////////////////////////////////////////////////////////////////// - -int VxPairDataEnsemble::get_n_pair() const { - int n, i, j, k; - - for(i=0, n=0; iinterp_mthd == InterpMthd::HiRA && + fcst_dpa.n_planes() != 1 ) { + + mlog << Warning << "\nVxPairDataEnsemble::add_ens() -> " + << "the \"" << interpmthd_to_string(it->interp_mthd) + << "\" interpolation method only applies when verifying a " + << "single level, not " << fcst_dpa.n_planes() + << " levels.\n\n"; + continue; } - } - return; -} + // Process each of the observations + NumArray fcst_na; + for(int i_obs=0; i_obsn_obs; i_obs++) { -//////////////////////////////////////////////////////////////////////// + // Initialize + fcst_na.erase(); -void VxPairDataEnsemble::set_obs_summary(ObsSummary s) { + // Interpolate using the observation pressure level or height + double to_lvl = (fcst_info->level().type() == LevelType_Pres ? + it->lvl_na[i_obs] : it->elv_na[i_obs]); + int lvl_blw, lvl_abv; - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_obs_summary(s); + // For a single forecast field + if(fcst_dpa.n_planes() == 1) { + lvl_blw = 0; + lvl_abv = 0; } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::set_obs_perc_value(int percentile) { - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_obs_perc_value(percentile); + // For multiple forecast fields, find the levels above + // and below the observation point. + else { + find_vert_lvl(fcst_dpa, to_lvl, lvl_blw, lvl_abv); } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// -void VxPairDataEnsemble::print_obs_summary() { + // Extract the HiRA neighborhood of values + if(it->interp_mthd == InterpMthd::HiRA) { - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].print_obs_summary(); + // For HiRA, set the ensemble mean to bad data + if(mn) { + fcst_na.erase(); + fcst_na.add(bad_data_double); + } + // Otherwise, retrieve all the neighborhood values + // using a valid threshold of 0 + else { + get_interp_points(fcst_dpa, + it->x_na[i_obs], it->y_na[i_obs], + it->interp_mthd, it->interp_wdth, it->interp_shape, + gr.wrap_lon(), 0, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv, + fcst_na); + } } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataEnsemble::calc_obs_summary() { - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].calc_obs_summary(); + // Otherwise, get a single interpolated ensemble value + else { + ClimoPntInfo cpi(it->fcmn_na[i_obs], it->fcsd_na[i_obs], + it->ocmn_na[i_obs], it->ocsd_na[i_obs]); + + fcst_na.add(compute_interp(fcst_dpa, + it->x_na[i_obs], it->y_na[i_obs], it->o_na[i_obs], &cpi, + it->interp_mthd, it->interp_wdth, it->interp_shape, + gr.wrap_lon(), interp_thresh, spfh_flag, + fcst_info->level().type(), + to_lvl, lvl_blw, lvl_abv)); } - } - } - - return; -} -//////////////////////////////////////////////////////////////////////// + // Store the single ensemble value or HiRA neighborhood + for(int i_fcst=0; i_fcstmn_na.add(fcst_na[i_fcst]); + } + // Store the ensemble member values + else { - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].ctrl_index = index; - } - } - } + // Track unperturbed ensemble variance sums + // Exclude the control member from the variance + if(member != it->ctrl_index) { + it->add_ens_var_sums(i_obs, fcst_na[i_fcst]); + } - return; -} + // Apply observation error perturbation, if requested + double fcst_v; + if(obs_error_info->flag) { + fcst_v = add_obs_error_inc( + obs_error_info->rng_ptr, FieldType::Fcst, + it->obs_error_entry[i_obs], + it->o_na[i_obs], fcst_na[i_fcst]); + } + else { + fcst_v = fcst_na[i_fcst]; + } -//////////////////////////////////////////////////////////////////////// + // Determine index of ensemble member + int i_mem = member * fcst_na.n() + i_fcst; -void VxPairDataEnsemble::set_skip_const(bool tf) { + // Store perturbed ensemble member value + it->add_ens(i_mem, fcst_v); + } - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].skip_const = tf; - } - } - } + } // end for i_fcst + } // end for i_obs + } // end for PairDataEnsemble iterator return; } diff --git a/src/libcode/vx_statistics/pair_data_ensemble.h b/src/libcode/vx_statistics/pair_data_ensemble.h index 9be2eec3c8..f621c23abf 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.h +++ b/src/libcode/vx_statistics/pair_data_ensemble.h @@ -164,12 +164,11 @@ class PairDataEnsemble : public PairBase { //////////////////////////////////////////////////////////////////////// // -// Class to store a variety of PairDataEnsemble objects for each -// verification task +// Class to store PairDataEnsemble objects for ensemble verification // //////////////////////////////////////////////////////////////////////// -class VxPairDataEnsemble { +class VxPairDataEnsemble : public VxPairBase { private: @@ -189,130 +188,37 @@ class VxPairDataEnsemble { // ////////////////////////////////////////////////////////////////// - EnsVarInfo *fcst_info; // Forecast field, allocated by EnsVarInfo - VarInfo *climo_info; // Climatology field, allocated by VarInfoFactory - VarInfo *obs_info; // Observation field, allocated by VarInfoFactory - - ConcatString desc; // User description from config file - - double interp_thresh; // Threshold between 0 and 1 used when - // interpolating the forecasts to the - // observation location. - - StringArray msg_typ_sfc; // List of surface message types - - ////////////////////////////////////////////////////////////////// - // - // Forecast and climotology fields falling between the requested - // levels. Store the fields in a data plane array. - // - ////////////////////////////////////////////////////////////////// - - DataPlaneArray fcst_dpa; // Forecast data plane array - DataPlaneArray climo_mn_dpa; // Climatology mean data plane array - DataPlaneArray climo_sd_dpa; // Climatology standard deviation data plane array - - ////////////////////////////////////////////////////////////////// - - unixtime fcst_ut; // Ensemble valid time - unixtime beg_ut; // Beginning of valid time window - unixtime end_ut; // End of valid time window + EnsVarInfo *ens_info; // Ensemble data, allocated by EnsVarInfo ////////////////////////////////////////////////////////////////// - StringArray sid_inc_filt; // Station ID inclusion list - StringArray sid_exc_filt; // Station ID exclusion list - StringArray obs_qty_inc_filt; // Observation quality include markers - StringArray obs_qty_exc_filt; // Observation quality exclude markers - - ////////////////////////////////////////////////////////////////// - ObsErrorInfo *obs_error_info; // Pointer for observation error // Not allocated ////////////////////////////////////////////////////////////////// - int n_msg_typ; // Number of verifying message types - - int n_mask; // Total number of masking regions - // of masking DataPlane fields or SIDs - - int n_interp; // Number of interpolation techniques - - ////////////////////////////////////////////////////////////////// - - PairDataEnsemble ***pd; // 3-Dim Array of PairDataEnsemble objects - // as [n_msg_typ][n_mask][n_interp] + // 3-Dim vector of PairDataEnsemble objects [n_msg_typ][n_mask][n_interp] + std::vector pd; ////////////////////////////////////////////////////////////////// void clear(); - void set_fcst_info(EnsVarInfo *); - void set_climo_info(VarInfo *); - void set_obs_info(VarInfo *); - - void set_desc(const char *); - - void set_interp_thresh(double); - void set_msg_typ_sfc(const StringArray &); - - void set_fcst_dpa(const DataPlaneArray &); - void set_climo_mn_dpa(const DataPlaneArray &); - void set_climo_sd_dpa(const DataPlaneArray &); - - void set_fcst_ut(const unixtime); - void set_beg_ut(const unixtime); - void set_end_ut(const unixtime); - - void set_sid_inc_filt(const StringArray); - void set_sid_exc_filt(const StringArray); - void set_obs_qty_inc_filt(const StringArray); - void set_obs_qty_exc_filt(const StringArray); - - // Call set_pd_size before set_msg_typ, set_mask_area, and set_interp - void set_pd_size(int, int, int); - - void set_msg_typ(int, const char *); - void set_msg_typ_vals(int, const StringArray &); - void set_mask_area(int, const char *, MaskPlane *); - void set_mask_sid(int, const char *, StringArray *); - void set_mask_llpnt(int, const char *, MaskLatLon *); - - void set_interp(int i_interp, const char *interp_mthd_str, int width, - GridTemplateFactory::GridTemplates shape); - void set_interp(int i_interp, InterpMthd mthd, int width, - GridTemplateFactory::GridTemplates shape); + void set_ens_info(const EnsVarInfo *); + void set_size(int, int, int); // Call set_ens_size before add_ens void set_ens_size(int n); - void set_climo_cdf_info_ptr(const ClimoCDFInfo *); - void set_ssvar_bin_size(double); void set_phist_bin_size(double); + void set_ctrl_index(int); + void set_skip_const(bool); void add_point_obs(float *, int *, const char *, const char *, unixtime, const char *, float *, Grid &, const char * = 0, const DataPlane * = 0); - void add_ens(int, bool mn, Grid &); - - int get_n_pair() const; - - void set_duplicate_flag(DuplicateType duplicate_flag); - - void set_obs_summary(ObsSummary obs_summary); - - void set_obs_perc_value(int percentile); - - void print_obs_summary(); - - void calc_obs_summary(); - - void set_ctrl_index(int); - - void set_skip_const(bool); }; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 5088c22564..0d29dda9ed 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -29,8 +29,6 @@ using namespace std; -static const int REJECT_DEBUG_LEVEL = 9; - //////////////////////////////////////////////////////////////////////// // // Code for class PairDataPoint @@ -71,9 +69,8 @@ PairDataPoint & PairDataPoint::operator=(const PairDataPoint &pd) { void PairDataPoint::init_from_scratch() { - seeps_mpr.clear(); - seeps.clear(); seeps_climo = nullptr; + clear(); return; @@ -87,10 +84,13 @@ void PairDataPoint::clear() { f_na.clear(); for (int idx=0; idxset_p1_thresh(p1_thresh); - else mlog << Warning << "\nPairDataPoint::set_seeps_thresh() ignored t1_threshold." - << " Load SEEPS climo first\n\n"; + else mlog << Warning << "\nPairDataPoint::set_seeps_thresh() -> " + << "ignored t1_threshold. Load SEEPS climo first\n\n"; } //////////////////////////////////////////////////////////////////////// @@ -226,8 +236,8 @@ void PairDataPoint::set_point_pair(int i_obs, const char *sid, double x, double y, unixtime ut, double lvl, double elv, double f, double o, const char *qc, - double cmn, double csd, double wgt, - SeepsScore *seeps) { + const ClimoPntInfo &cpi, + double wgt, const SeepsScore *seeps) { if(i_obs < 0 || i_obs >= n_obs) { mlog << Error << "\nPairDataPoint::set_point_pair() -> " @@ -237,7 +247,7 @@ void PairDataPoint::set_point_pair(int i_obs, const char *sid, } set_point_obs(i_obs, sid, lat, lon, x, y, ut, lvl, elv, - o, qc, cmn, csd, wgt); + o, qc, cpi, wgt); f_na.set(i_obs, f); *seeps_mpr[i_obs] = *seeps; @@ -248,9 +258,10 @@ void PairDataPoint::set_point_pair(int i_obs, const char *sid, //////////////////////////////////////////////////////////////////////// bool PairDataPoint::add_grid_pair(double f, double o, - double cmn, double csd, double wgt) { + const ClimoPntInfo &cpi, + double wgt) { - add_grid_obs(o, cmn, csd, wgt); + add_grid_obs(o, cpi, wgt); f_na.add(f); seeps_mpr.push_back(nullptr); @@ -261,13 +272,16 @@ bool PairDataPoint::add_grid_pair(double f, double o, //////////////////////////////////////////////////////////////////////// bool PairDataPoint::add_grid_pair(const NumArray &f_in, const NumArray &o_in, - const NumArray &cmn_in, const NumArray &csd_in, + const NumArray &fcmn_in, const NumArray &fcsd_in, + const NumArray &ocmn_in, const NumArray &ocsd_in, const NumArray &wgt_in) { // Check for constant length - if(o_in.n() != f_in.n() || - o_in.n() != cmn_in.n() || - o_in.n() != csd_in.n() || + if(o_in.n() != f_in.n() || + o_in.n() != fcmn_in.n() || + o_in.n() != fcsd_in.n() || + o_in.n() != ocmn_in.n() || + o_in.n() != ocsd_in.n() || o_in.n() != wgt_in.n()) { mlog << Error << "\nPairDataPoint::add_grid_pair() -> " << "arrays must all have the same length!\n\n"; @@ -282,7 +296,8 @@ bool PairDataPoint::add_grid_pair(const NumArray &f_in, const NumArray &o_in, wgt_na.add(wgt_in); for(int i=0; ifile_type()); - *fcst_info = *info; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_climo_info(VarInfo *info) { - VarInfoFactory f; - - // Deallocate, if necessary - if(climo_info) { delete climo_info; climo_info = (VarInfo *) nullptr; } - - // Perform a deep copy - climo_info = f.new_var_info(info->file_type()); - *climo_info = *info; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_obs_info(VarInfoGrib *info) { - - // Deallocate, if necessary - if(obs_info) { delete obs_info; obs_info = (VarInfoGrib *) nullptr; } - - // Perform a deep copy - obs_info = new VarInfoGrib; - *obs_info = *info; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_desc(const char *s) { - - desc = s; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_interp_thresh(double t) { - - interp_thresh = t; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_fcst_dpa(const DataPlaneArray &dpa) { - - fcst_dpa = dpa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_climo_mn_dpa(const DataPlaneArray &dpa) { - - climo_mn_dpa = dpa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_climo_sd_dpa(const DataPlaneArray &dpa) { - - climo_sd_dpa = dpa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_fcst_ut(const unixtime ut) { - - fcst_ut = ut; - - // set the fcst_ut for all PairBase instances, used for duplicate logic - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_fcst_ut(ut); - } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_beg_ut(const unixtime ut) { - - beg_ut = ut; - - return; -} - -//////////////////////////////////////////////////////////////////////// + VxPairBase::assign(vx_pd); -void VxPairDataPoint::set_end_ut(const unixtime ut) { + set_size(vx_pd.n_msg_typ, vx_pd.n_mask, vx_pd.n_interp); - end_ut = ut; + pd = vx_pd.pd; return; } //////////////////////////////////////////////////////////////////////// -void VxPairDataPoint::set_sid_inc_filt(const StringArray &sa) { - - sid_inc_filt = sa; +void VxPairDataPoint::set_size(int types, int masks, int interps) { - return; -} - -//////////////////////////////////////////////////////////////////////// + VxPairBase::set_size(types, masks, interps); -void VxPairDataPoint::set_sid_exc_filt(const StringArray &sa) { + // Resize the PairDataPoint vector + pd.resize(n_vx); - sid_exc_filt = sa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_obs_qty_inc_filt(const StringArray &sa) { - - obs_qty_inc_filt = sa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_obs_qty_exc_filt(const StringArray &sa) { - - obs_qty_exc_filt = sa; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_pd_size(int types, int masks, int interps) { - int i, j, k; - - // Store the dimensions for the PairDataPoint array - n_msg_typ = types; - n_mask = masks; - n_interp = interps; - - // Allocate space for the PairDataPoint array - pd = new PairDataPoint ** [n_msg_typ]; - rej_typ = new int ** [n_msg_typ]; - rej_mask = new int ** [n_msg_typ]; - rej_fcst = new int ** [n_msg_typ]; - rej_cmn = new int ** [n_msg_typ]; - rej_csd = new int ** [n_msg_typ]; - rej_mpr = new int ** [n_msg_typ]; - rej_dup = new int ** [n_msg_typ]; - - for(i=0; i " - << "the \"" << conf_key_mpr_column << "\" (" - << write_css(sa) << ") and \"" << conf_key_mpr_thresh - << "\" (" << write_css(ta) - << ") config file entries must have the same length!\n\n"; - exit(1); - } - - mpr_column = sa; - mpr_thresh = ta; - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_climo_cdf_info_ptr(const ClimoCDFInfo *info) { - - for(int i=0; i= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation station id:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_sid++; - return; + // Point observation summary string for rejection log messages + ConcatString pnt_obs_str; + if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { + pnt_obs_str = point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, + hdr_ut, obs_qty, obs_arr, var_name); } - // Check whether the GRIB code for the observation matches - // the specified code - if((var_name != 0) && (0 < strlen(var_name))) { - if(var_name != obs_info->name()) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation variable name:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } + // Check the station ID + if(!is_keeper_sid(pnt_obs_str.c_str(), hdr_sid_str)) return; - rej_var++; - return; - } - } - else if(obs_info->code() != nint(obs_arr[1])) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation variable GRIB code:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } + // Check observation variable + if(!is_keeper_var(pnt_obs_str.c_str(), var_name, nint(obs_arr[1]))) return; - rej_var++; - return; - } + // Check observation quality + if(!is_keeper_qty(pnt_obs_str.c_str(), obs_qty)) return; - // Check the observation quality include and exclude options - if((obs_qty_inc_filt.n() > 0 && !obs_qty_inc_filt.has(obs_qty)) || - (obs_qty_exc_filt.n() > 0 && obs_qty_exc_filt.has(obs_qty))) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation quality control string:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } + // Check valid time + if(!is_keeper_vld(pnt_obs_str.c_str(), hdr_ut)) return; - rej_qty++; - return; - } + // Check observation value + double obs_v = obs_arr[4]; + if(!is_keeper_obs(pnt_obs_str.c_str(), obs_v)) return; - // Check whether the observation time falls within the valid time - // window - if(hdr_ut < beg_ut || hdr_ut > end_ut) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation valid time:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } + // Check location + double hdr_lat = hdr_arr[0]; + double hdr_lon = hdr_arr[1]; + double obs_x, obs_y; + if(!is_keeper_grd(pnt_obs_str.c_str(), gr, hdr_lat, hdr_lon, obs_x, obs_y)) return; - rej_vld++; - return; - } + // Check topo + double hdr_elv = hdr_arr[2]; + if(!is_keeper_topo(pnt_obs_str.c_str(), gr, obs_x, obs_y, + hdr_typ_str, hdr_elv)) return; + // Check level + double obs_lvl = obs_arr[2]; + double obs_hgt = obs_arr[3]; + if(!is_keeper_lvl(pnt_obs_str.c_str(), hdr_typ_str, obs_lvl, obs_hgt)) return; + + // Set flags + bool spfh_flag = fcst_info->is_specific_humidity() && + obs_info->is_specific_humidity(); bool precip_flag = fcst_info->is_precipitation() && obs_info->is_precipitation(); int precip_interval = bad_data_int; - if (precip_flag) { - if (wgt_dp) precip_interval = wgt_dp->accum(); + if(precip_flag) { + if(wgt_dp) precip_interval = wgt_dp->accum(); else precip_interval = fcst_dpa[0].accum(); } - hdr_lat = hdr_arr[0]; - hdr_lon = hdr_arr[1]; - hdr_elv = hdr_arr[2]; - - obs_lvl = obs_arr[2]; - obs_hgt = obs_arr[3]; - - // Apply observation processing logic - obs_v = pd[0][0][0].process_obs(obs_info, obs_arr[4]); - - // Check whether the observation value contains valid data - if(is_bad_data(obs_v)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation with bad data value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_obs++; - return; - } - - // Convert the lat/lon value to x/y - gr.latlon_to_xy(hdr_lat, -1.0*hdr_lon, obs_x, obs_y); - x = nint(obs_x); - y = nint(obs_y); - - // Check if the observation's lat/lon is on the grid - if(((x < 0 || x >= gr.nx()) && !gr.wrap_lon()) || - y < 0 || y >= gr.ny()) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation off the grid where (x, y) = (" - << x << ", " << y << ") and grid (nx, ny) = (" << gr.nx() - << ", " << gr.ny() << "):\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_grd++; - return; - } - - // Check for a large topography difference - if(sfc_info.topo_ptr && msg_typ_sfc.reg_exp_match(hdr_typ_str)) { - - // Interpolate model topography to observation location - double topo = compute_horz_interp( - *sfc_info.topo_ptr, obs_x, obs_y, hdr_elv, - InterpMthd::Bilin, 2, - GridTemplateFactory::GridTemplates::Square, - gr.wrap_lon(), 1.0); - - // Skip bad topography values - if(is_bad_data(hdr_elv) || is_bad_data(topo)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to bad topography values " - << "where observation elevation = " << hdr_elv - << " and model topography = " << topo << ":\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_topo++; - return; - } - - // Check the topography difference threshold - if(!sfc_info.topo_use_obs_thresh.check(topo - hdr_elv)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to topography difference " - << "where observation elevation (" << hdr_elv - << ") minus model topography (" << topo << ") = " - << topo - hdr_elv << " is not " - << sfc_info.topo_use_obs_thresh.get_str() << ":\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_topo++; - return; - } - } - - // For pressure levels, check if the observation pressure level - // falls in the requested range. - if(obs_info->level().type() == LevelType_Pres) { - - if(obs_lvl < obs_info->level().lower() || - obs_lvl > obs_info->level().upper()) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation pressure level value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_lvl++; - return; - } - } - // For accumulations, check if the observation accumulation interval - // matches the requested interval. - else if(obs_info->level().type() == LevelType_Accum) { - - if(obs_lvl < obs_info->level().lower() || - obs_lvl > obs_info->level().upper()) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation accumulation interval:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_lvl++; - return; - } - } - // For all other level types (VertLevel, RecNumber, NoLevel), - // check for a surface message type or if the observation height - // falls within the requested range. - else { - - if(!msg_typ_sfc.reg_exp_match(hdr_typ_str) && - (obs_hgt < obs_info->level().lower() || - obs_hgt > obs_info->level().upper())) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation level value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - rej_lvl++; - return; - } - } - - // For a single forecast field - if(fcst_dpa.n_planes() == 1) { - f_lvl_blw = 0; - f_lvl_abv = 0; - } - // For multiple forecast fields, find the levels above and below - // the observation point. - else { - // Interpolate using the observation pressure level or height - to_lvl = (fcst_info->level().type() == LevelType_Pres ? - obs_lvl : obs_hgt); - find_vert_lvl(fcst_dpa, to_lvl, f_lvl_blw, f_lvl_abv); - } - - // For a single climatology mean field - if(climo_mn_dpa.n_planes() == 1) { - cmn_lvl_blw = 0; - cmn_lvl_abv = 0; - } - // For multiple climatology mean fields, find the levels above and - // below the observation point. - else { - // Interpolate using the observation pressure level or height - to_lvl = (fcst_info->level().type() == LevelType_Pres ? - obs_lvl : obs_hgt); - find_vert_lvl(climo_mn_dpa, to_lvl, cmn_lvl_blw, cmn_lvl_abv); - } - - // For a single climatology standard deviation field - if(climo_sd_dpa.n_planes() == 1) { - csd_lvl_blw = 0; - csd_lvl_abv = 0; - } - // For multiple climatology standard deviation fields, find the - // levels above and below the observation point. - else { - // Interpolate using the observation pressure level or height - to_lvl = (fcst_info->level().type() == LevelType_Pres ? - obs_lvl : obs_hgt); - find_vert_lvl(climo_sd_dpa, to_lvl, csd_lvl_blw, csd_lvl_abv); - } + bool has_seeps = false; + SeepsScore *seeps = nullptr; // When verifying a vertical level forecast against a surface message // type, set the observation level value to bad data so that it's not @@ -1307,367 +565,108 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, obs_lvl = bad_data_double; } - // Set flag for specific humidity - bool spfh_flag = fcst_info->is_specific_humidity() && - obs_info->is_specific_humidity(); - - // Look through all of the PairDataPoint objects to see if the - // observation should be added. - - bool has_seeps = false; - SeepsScore *seeps = 0; - - // Check the message types - for(i=0; i= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation message type:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - inc_count(rej_typ, i); - continue; - } - - // Check the masking areas and points - for(j=0; js_is_on(x, y)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation based on spatial masking region:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - inc_count(rej_mask, i, j); - continue; - } - } - // Otherwise, check for the obs Station ID's presence in the - // masking SID list - else if(pd[i][j][0].mask_sid_ptr != (StringArray *) 0) { - if(!pd[i][j][0].mask_sid_ptr->has(hdr_sid_str)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation based on masking station id list:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - inc_count(rej_mask, i, j); - continue; - } - } - // Otherwise, check observation lat/lon thresholds - else if(pd[i][j][0].mask_llpnt_ptr != (MaskLatLon *) 0) { - if(!pd[i][j][0].mask_llpnt_ptr->lat_thresh.check(hdr_lat) || - !pd[i][j][0].mask_llpnt_ptr->lon_thresh.check(hdr_lon)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation based on latitude/longitude thesholds:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - inc_count(rej_mask, i, j); - continue; - } - } - - // Compute the interpolated values - for(k=0; klevel().type() == LevelType_Pres ? - obs_lvl : obs_hgt); + // Check message type + if(!is_keeper_typ(pnt_obs_str.c_str(), i_msg_typ, hdr_typ_str)) continue; - // Compute the interpolated climatology mean - cmn_v = compute_interp(climo_mn_dpa, obs_x, obs_y, obs_v, - bad_data_double, bad_data_double, - pd[0][0][k].interp_mthd, pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, gr.wrap_lon(), - interp_thresh, spfh_flag, - fcst_info->level().type(), - to_lvl, cmn_lvl_blw, cmn_lvl_abv); + int x = nint(obs_x); + int y = nint(obs_y); - // Check for bad data - if(climo_mn_dpa.n_planes() > 0 && is_bad_data(cmn_v)) { + // Loop through the masking regions + for(int i_mask=0; i_mask= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation based on bad climatological mean value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } + // Check masking region + if(!is_keeper_mask(pnt_obs_str.c_str(), i_msg_typ, i_mask, x, y, + hdr_sid_str, hdr_lat, hdr_lon)) continue; - inc_count(rej_cmn, i, j, k); - continue; - } - - // Check for valid interpolation options - if(climo_sd_dpa.n_planes() > 0 && - (pd[0][0][k].interp_mthd == InterpMthd::Min || - pd[0][0][k].interp_mthd == InterpMthd::Max || - pd[0][0][k].interp_mthd == InterpMthd::Median || - pd[0][0][k].interp_mthd == InterpMthd::Best)) { - mlog << Warning << "\nVxPairDataPoint::add_point_obs() -> " - << "applying the " - << interpmthd_to_string(pd[0][0][k].interp_mthd) - << " interpolation method to climatological spread " - << "may cause unexpected results.\n\n"; - } - - // Compute the interpolated climatology standard deviation - csd_v = compute_interp(climo_sd_dpa, obs_x, obs_y, obs_v, - bad_data_double, bad_data_double, - pd[0][0][k].interp_mthd, pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, gr.wrap_lon(), - interp_thresh, spfh_flag, - fcst_info->level().type(), - to_lvl, csd_lvl_blw, csd_lvl_abv); - - // Check for bad data - if(climo_sd_dpa.n_planes() > 0 && is_bad_data(csd_v)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation based on bad climatological standard deviation value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - inc_count(rej_csd, i, j, k); - continue; - } + // Loop through the interpolation methods + for(int i_interp=0; i_interp " - << "unexpected number of forecast levels (" - << fcst_dpa.n_planes() - << ") for surface verification! Set \"land_mask.flag\" and " - << "\"topo_mask.flag\" to false to disable this check.\n\n"; - exit(1); - } - - fcst_v = compute_sfc_interp(fcst_dpa[0], obs_x, obs_y, hdr_elv, obs_v, - pd[0][0][k].interp_mthd, pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, gr.wrap_lon(), - interp_thresh, sfc_info, is_land); - } - // Otherwise, compute interpolated value - else { - fcst_v = compute_interp(fcst_dpa, obs_x, obs_y, obs_v, cmn_v, csd_v, - pd[0][0][k].interp_mthd, pd[0][0][k].interp_wdth, - pd[0][0][k].interp_shape, gr.wrap_lon(), - interp_thresh, spfh_flag, - fcst_info->level().type(), - to_lvl, f_lvl_blw, f_lvl_abv); - } - - if(is_bad_data(fcst_v)) { - - if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { - mlog << Debug(REJECT_DEBUG_LEVEL) - << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation based due to bad data in the " - << interpmthd_to_string(pd[0][0][k].interp_mthd) << "(" - << pd[0][0][k].interp_wdth * pd[0][0][k].interp_wdth - << ") interpolated forecast value:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; - } - - inc_count(rej_fcst, i, j, k); - continue; - } + // Check forecast values + double fcst_v; + if(!is_keeper_fcst(pnt_obs_str.c_str(), + i_msg_typ, i_mask, i_interp, + hdr_typ_str, gr, + obs_x, obs_y, hdr_elv, + obs_v, obs_lvl, obs_hgt, + cpi, fcst_v)) continue; // Check matched pair filtering options - if(!check_mpr_thresh(fcst_v, obs_v, cmn_v, csd_v, + ConcatString reason_cs; + if(!check_mpr_thresh(fcst_v, obs_v, cpi, mpr_column, mpr_thresh, &reason_cs)) { if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { mlog << Debug(REJECT_DEBUG_LEVEL) << "For " << fcst_info->magic_str() << " versus " - << obs_info->magic_str() - << ", skipping observation due to matched pair filter since " + << obs_info->magic_str() << ", skipping observation" + << "due to matched pair filter since " << reason_cs << ":\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + << pnt_obs_str << "\n"; } - inc_count(rej_mpr, i, j, k); + inc_count(rej_mpr, i_msg_typ, i_mask, i_interp); continue; } // Compute weight for current point - wgt_v = (wgt_dp == (DataPlane *) 0 ? - default_grid_weight : wgt_dp->get(x, y)); + double wgt_v = (wgt_dp == nullptr ? + default_grid_weight : + wgt_dp->get(x, y)); // Add the forecast, climatological, and observation data // Weight is from the nearest grid point - if(!pd[i][j][k].add_point_pair(hdr_sid_str, - hdr_lat, hdr_lon, obs_x, obs_y, hdr_ut, obs_lvl, - obs_hgt, fcst_v, obs_v, obs_qty, cmn_v, csd_v, - wgt_v)) { + int n = three_to_one(i_msg_typ, i_mask, i_interp); + if(!pd[n].add_point_pair(hdr_sid_str, + hdr_lat, hdr_lon, obs_x, obs_y, hdr_ut, obs_lvl, + obs_hgt, fcst_v, obs_v, obs_qty, cpi, wgt_v)) { if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { mlog << Debug(REJECT_DEBUG_LEVEL) << "For " << fcst_info->magic_str() << " versus " << obs_info->magic_str() << ", skipping observation since it is a duplicate:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + << pnt_obs_str << "\n"; } - inc_count(rej_dup, i, j, k); + inc_count(rej_dup, i_msg_typ, i_mask, i_interp); + continue; } - seeps = 0; + + // Compute seeps if (precip_flag && precip_interval == 24*60*60) { // 24 hour precip only - seeps = pd[i][j][k].compute_seeps(hdr_sid_str, fcst_v, obs_v, hdr_ut); + seeps = pd[n].compute_seeps(hdr_sid_str, fcst_v, obs_v, hdr_ut); + } + else { + seeps = nullptr; } - pd[i][j][k].set_seeps_score(seeps); - if (seeps) delete seeps; + pd[n].set_seeps_score(seeps); + if (seeps) { delete seeps; seeps = nullptr; } if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { mlog << Debug(REJECT_DEBUG_LEVEL) << "For " << fcst_info->magic_str() << " versus " << obs_info->magic_str() << ", for observation type " - << pd[i][0][0].msg_typ << ", over region " - << pd[0][j][0].mask_name << ", for interpolation method " - << interpmthd_to_string(pd[0][0][k].interp_mthd) << "(" - << pd[0][0][k].interp_wdth * pd[0][0][k].interp_wdth + << pd[n].msg_typ << ", over region " + << pd[n].mask_name << ", for interpolation method " + << interpmthd_to_string(pd[n].interp_mthd) << "(" + << pd[n].interp_wdth * pd[n].interp_wdth << "), using observation:\n" - << point_obs_to_string(hdr_arr, hdr_typ_str, hdr_sid_str, - hdr_ut, obs_qty, obs_arr, var_name) - << "\n"; + << pnt_obs_str << "\n"; } - } // end for k - } // end for j - } // end for i - - return; -} - -//////////////////////////////////////////////////////////////////////// - -int VxPairDataPoint::get_n_pair() const { - int n, i, j, k; - - if(n_msg_typ == 0 || n_mask == 0 || n_interp == 0) { - mlog << Warning << "\nVxPairDataPoint::get_n_pair() -> " - << "set_pd_size() has not been called yet!\n\n"; - } - - for(i=0, n=0; i " - << "set_pd_size() has not been called yet!\n\n"; - } - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType::Unique); - } - } - } - -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_obs_summary(ObsSummary s) { - - if(n_msg_typ == 0 || n_mask == 0 || n_interp == 0) { - mlog << Warning << "\nVxPairDataPoint::set_obs_summary() -> " - << "set_pd_size() has not been called yet!\n\n"; - } - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_obs_summary(s); - } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::set_obs_perc_value(int percentile) { - - if(n_msg_typ == 0 || n_mask == 0 || n_interp == 0) { - mlog << Warning << "\nVxPairDataPoint::set_obs_perc_value() -> " - << "set_pd_size() has not been called yet!\n\n"; - } - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_obs_perc_value(percentile); - } - } - } + } // end for i_interp + } // end for i_mask + } // end for i_msg_typ return; } @@ -1675,98 +674,27 @@ void VxPairDataPoint::set_obs_perc_value(int percentile) { //////////////////////////////////////////////////////////////////////// void VxPairDataPoint::load_seeps_climo(const ConcatString &seeps_climo_name) { - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].load_seeps_climo(seeps_climo_name); - } - } - } -} - -//////////////////////////////////////////////////////////////////////// -void VxPairDataPoint::set_seeps_thresh(const SingleThresh &p1_thresh) { - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_seeps_thresh(p1_thresh); - } - } + if(n_vx == 0) { + mlog << Warning << "\nVxPairDataPoint::load_seeps_climo() -> " + << "set_size() has not been called yet!\n\n"; } -} -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::print_obs_summary() { - - if(n_msg_typ == 0 || n_mask == 0 || n_interp == 0) { - mlog << Warning << "\nVxPairDataPoint::print_obs_summary() -> " - << "set_pd_size() has not been called yet!\n\n"; - } - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].print_obs_summary(); - } - } - } + for(auto &x : pd) x.load_seeps_climo(seeps_climo_name); return; } //////////////////////////////////////////////////////////////////////// -void VxPairDataPoint::calc_obs_summary() { - - if(n_msg_typ == 0 || n_mask == 0 || n_interp == 0) { - mlog << Warning << "\nVxPairDataPoint::calc_obs_summary() -> " - << "set_pd_size() has not been called yet!\n\n"; - } - - for(int i=0; i < n_msg_typ; i++){ - for(int j=0; j < n_mask; j++){ - for(int k=0; k < n_interp; k++){ - pd[i][j][k].calc_obs_summary(); - } - } - } - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::inc_count(int ***&rej, int i) { - int j, k; - - for(j=0; j " + << "set_size() has not been called yet!\n\n"; } - return; -} - -//////////////////////////////////////////////////////////////////////// - -void VxPairDataPoint::inc_count(int ***&rej, int i, int j, int k) { - - rej[i][j][k]++; + for(auto &x : pd) x.set_seeps_thresh(p1_thresh); return; } @@ -1777,12 +705,12 @@ void VxPairDataPoint::inc_count(int ***&rej, int i, int j, int k) { // //////////////////////////////////////////////////////////////////////// -bool check_fo_thresh(double f, double o, double cmn, double csd, +bool check_fo_thresh(double f, double o, const ClimoPntInfo &cpi, const SingleThresh &ft, const SingleThresh &ot, const SetLogic type) { bool status = true; - bool fcheck = ft.check(f, cmn, csd); - bool ocheck = ot.check(o, cmn, csd); + bool fcheck = ft.check(f, &cpi); + bool ocheck = ot.check(o, &cpi); SetLogic t = type; // If either of the thresholds is NA, reset the logic to intersection @@ -1815,7 +743,7 @@ bool check_fo_thresh(double f, double o, double cmn, double csd, //////////////////////////////////////////////////////////////////////// -bool check_mpr_thresh(double f, double o, double cmn, double csd, +bool check_mpr_thresh(double f, double o, const ClimoPntInfo &cpi, const StringArray &col_sa, const ThreshArray &col_ta, ConcatString *reason_ptr) { // Initialize @@ -1829,10 +757,9 @@ bool check_mpr_thresh(double f, double o, double cmn, double csd, StringArray sa; ConcatString cs; double v, v_cur; - int i, j; // Loop over all the column filter names - for(i=0; i 1) { // Loop through the columns - for(j=1; j " << "unsupported matched pair column name requested in \"" @@ -1914,7 +854,8 @@ double get_mpr_column_value(double f, double o, double cmn, double csd, //////////////////////////////////////////////////////////////////////// void apply_mpr_thresh_mask(DataPlane &fcst_dp, DataPlane &obs_dp, - DataPlane &cmn_dp, DataPlane &csd_dp, + DataPlane &fcmn_dp, DataPlane &fcsd_dp, + DataPlane &ocmn_dp, DataPlane &ocsd_dp, const StringArray &col_sa, const ThreshArray &col_ta) { // Check for no work to be done @@ -1932,33 +873,43 @@ void apply_mpr_thresh_mask(DataPlane &fcst_dp, DataPlane &obs_dp, int nxy = fcst_dp.nx() * fcst_dp.ny(); int n_skip = 0; - bool cmn_flag = !(cmn_dp.is_empty()); - bool csd_flag = !(csd_dp.is_empty()); + bool fcmn_flag = !(fcmn_dp.is_empty()); + bool fcsd_flag = !(fcsd_dp.is_empty()); + bool ocmn_flag = !(ocmn_dp.is_empty()); + bool ocsd_flag = !(ocsd_dp.is_empty()); // Loop over the pairs for(int i=0; i seeps_mpr; - SeepsAggScore seeps; + SeepsAggScore seeps_agg; ////////////////////////////////////////////////////////////////// @@ -58,19 +58,21 @@ class PairDataPoint : public PairBase { bool add_point_pair(const char *, double, double, double, double, unixtime, double, double, double, double, - const char *, double, double, double); + const char *, const ClimoPntInfo &, double); void load_seeps_climo(const ConcatString &seeps_climo_name); void set_seeps_thresh(const SingleThresh &p1_thresh); void set_seeps_score(SeepsScore *, int index=-1); void set_point_pair(int, const char *, double, double, double, double, unixtime, double, double, double, double, - const char *, double, double, double, SeepsScore *); + const char *, const ClimoPntInfo &, + double, const SeepsScore *); - bool add_grid_pair(double, double, double, double, double); + bool add_grid_pair(double, double, const ClimoPntInfo &, double); bool add_grid_pair(const NumArray &f_in, const NumArray &o_in, - const NumArray &cmn_in, const NumArray &csd_in, + const NumArray &fcmn_in, const NumArray &fcsd_in, + const NumArray &ocmn_in, const NumArray &ocsd_in, const NumArray &w_in); PairDataPoint subset_pairs_cnt_thresh(const SingleThresh &ft, @@ -82,12 +84,11 @@ class PairDataPoint : public PairBase { //////////////////////////////////////////////////////////////////////// // -// Class to store a variety of PairDataPoint objects for each -// verification task +// Class to store PairDataPoint objects for point verification // //////////////////////////////////////////////////////////////////////// -class VxPairDataPoint { +class VxPairDataPoint : public VxPairBase { private: @@ -107,159 +108,21 @@ class VxPairDataPoint { // ////////////////////////////////////////////////////////////////// - VarInfo *fcst_info; // Forecast field, allocated by VarInfoFactory - VarInfo *climo_info; // Climatology field, allocated by VarInfoFactory - VarInfoGrib *obs_info; // Observation field, allocated by VarInfoFactory - - ConcatString desc; // User description from config file - - double interp_thresh; // Threshold between 0 and 1 used when - // interpolating the forecasts to the - // observation location. - - ////////////////////////////////////////////////////////////////// - // - // Forecast and climatology fields falling between the requested - // levels. Store the fields in a data plane array. - // - ////////////////////////////////////////////////////////////////// - - DataPlaneArray fcst_dpa; // Forecast data plane array - DataPlaneArray climo_mn_dpa; // Climatology mean data plane array - DataPlaneArray climo_sd_dpa; // Climatology standard deviation data plane array - - ////////////////////////////////////////////////////////////////// - - unixtime fcst_ut; // Forecast valid time - unixtime beg_ut; // Beginning of valid time window - unixtime end_ut; // End of valid time window - - ////////////////////////////////////////////////////////////////// - - StringArray sid_inc_filt; // Station ID inclusion list - StringArray sid_exc_filt; // Station ID exclusion list - StringArray obs_qty_inc_filt; // Observation quality include markers - StringArray obs_qty_exc_filt; // Observation quality exclude markers - - ////////////////////////////////////////////////////////////////// - - StringArray mpr_column; // Names of MPR columns or diffs of columns - ThreshArray mpr_thresh; // Filtering thresholds for the MPR columns - - ////////////////////////////////////////////////////////////////// - - StringArray msg_typ_sfc; // List of surface message types - StringArray msg_typ_lnd; // List of surface land message types - StringArray msg_typ_wtr; // List of surface water message types - - SurfaceInfo sfc_info; // Land/sea mask and topography info - - ////////////////////////////////////////////////////////////////// - - int n_msg_typ; // Number of verifying message types - - int n_mask; // Total number of masking regions - // of masking DataPlane fields or SIDs - - int n_interp; // Number of interpolation techniques - - ////////////////////////////////////////////////////////////////// - - PairDataPoint ***pd; // 3-Dim Array of PairDataPoint objects - // as [n_msg_typ][n_mask][n_interp] - - // Counts for observation rejection reason codes - int n_try; // Number of observations processed - int rej_sid; // Reject based on SID inclusion and exclusion lists - int rej_var; // Reject based on observation variable name - int rej_vld; // Reject based on valid time - int rej_obs; // Reject observation bad data - int rej_grd; // Reject based on location - int rej_topo; // Reject based on topography - int rej_lvl; // Reject based on vertical level - int rej_qty; // Reject based on obs quality - - // 3-Dim Arrays for observation rejection reason codes - int ***rej_typ; // Reject based on message type - int ***rej_mask; // Reject based on masking region - int ***rej_fcst; // Reject forecast bad data - int ***rej_cmn; // Reject climo mean bad data - int ***rej_csd; // Reject climo stdev bad data - int ***rej_mpr; // Reject based on MPR filtering logic - int ***rej_dup; // Reject based on duplicates logic + // 3-Dim vector of PairDataPoint objects [n_msg_typ][n_mask][n_interp] + std::vector pd; ////////////////////////////////////////////////////////////////// void clear(); - void set_fcst_info(VarInfo *); - void set_climo_info(VarInfo *); - void set_obs_info(VarInfoGrib *); - - void set_desc(const char *); - - void set_interp_thresh(double); - - void set_fcst_dpa(const DataPlaneArray &); - void set_climo_mn_dpa(const DataPlaneArray &); - void set_climo_sd_dpa(const DataPlaneArray &); - - void set_fcst_ut(const unixtime); - void set_beg_ut(const unixtime); - void set_end_ut(const unixtime); - - void set_sid_inc_filt(const StringArray &); - void set_sid_exc_filt(const StringArray &); - void set_obs_qty_inc_filt(const StringArray &); - void set_obs_qty_exc_filt(const StringArray &); - - // Call set_pd_size before set_msg_typ, set_mask_area, and set_interp - void set_pd_size(int, int, int); - - void set_msg_typ(int, const char *); - void set_msg_typ_vals(int, const StringArray &); - void set_mask_area(int, const char *, MaskPlane *); - void set_mask_sid(int, const char *, StringArray *); - void set_mask_llpnt(int, const char *, MaskLatLon *); - - void set_interp(int i_interp, const char *interp_mthd_str, int width, - GridTemplateFactory::GridTemplates shape); - void set_interp(int i_interp, InterpMthd mthd, - int width, GridTemplateFactory::GridTemplates shape); - - void set_mpr_thresh(const StringArray &, const ThreshArray &); + void set_size(int, int, int); void load_seeps_climo(const ConcatString &seeps_climo_name); void set_seeps_thresh(const SingleThresh &p1_thresh); - void set_climo_cdf_info_ptr(const ClimoCDFInfo *); - - void set_msg_typ_sfc(const StringArray &); - void set_msg_typ_lnd(const StringArray &); - void set_msg_typ_wtr(const StringArray &); - - void set_sfc_info(const SurfaceInfo &); - void add_point_obs(float *, const char *, const char *, unixtime, const char *, float *, Grid &, const char * = 0, const DataPlane * = 0); - - int get_n_pair() const; - - void set_duplicate_flag(DuplicateType duplicate_flag); - - void set_obs_summary(ObsSummary obs_summary); - - void set_obs_perc_value(int percentile); - - void print_obs_summary(); - - void calc_obs_summary(); - - // Member functions for incrementing the counts - void inc_count(int ***&, int); - void inc_count(int ***&, int, int); - void inc_count(int ***&, int, int, int); }; @@ -269,18 +132,19 @@ class VxPairDataPoint { // //////////////////////////////////////////////////////////////////////// -extern bool check_fo_thresh(double, double, double, double, +extern bool check_fo_thresh(double, double, const ClimoPntInfo &, const SingleThresh &, const SingleThresh &, const SetLogic); -extern bool check_mpr_thresh(double, double, double, double, +extern bool check_mpr_thresh(double, double, const ClimoPntInfo &, const StringArray &, const ThreshArray &, ConcatString * = 0); -extern double get_mpr_column_value(double, double, double, double, +extern double get_mpr_column_value(double, double, const ClimoPntInfo &, const char *); extern void apply_mpr_thresh_mask(DataPlane &, DataPlane &, + DataPlane &, DataPlane &, DataPlane &, DataPlane &, const StringArray &, const ThreshArray &); @@ -304,13 +168,6 @@ extern void subset_wind_pairs(const PairDataPoint &, extern PairDataPoint subset_climo_cdf_bin(const PairDataPoint &, const ThreshArray &, int i_bin); -// Write the point observation in the MET point format for logging -extern ConcatString point_obs_to_string( - float *hdr_arr, const char *hdr_typ_str, - const char *hdr_sid_str, unixtime hdr_ut, - const char *obs_qty, float *obs_arr, - const char *var_name); - //////////////////////////////////////////////////////////////////////// #endif // __PAIR_DATA_POINT_H__ diff --git a/src/libcode/vx_summary/summary_calc_percentile.cc b/src/libcode/vx_summary/summary_calc_percentile.cc index d55ace753d..5ac813944f 100644 --- a/src/libcode/vx_summary/summary_calc_percentile.cc +++ b/src/libcode/vx_summary/summary_calc_percentile.cc @@ -40,15 +40,15 @@ SummaryCalcPercentile::SummaryCalcPercentile(const string &type_string) : !isdigit(type_string[2])) { mlog << Error << "\nSummaryCalcPercentile::SummaryCalcPercentile() -> " - << "invalid percentile type \"" << type_string - << "\" specified in configuration file.\n\n"; + << "invalid percentile type \"" << type_string + << "\" specified in configuration file.\n\n"; exit(1); } - + // Pull the desired percentile from the string _percentile = atof(type_string.substr(1,2).c_str()) / 100.0; - + // Construct the type string ConcatString type_buffer; diff --git a/src/libcode/vx_tc_util/atcf_prob_line.cc b/src/libcode/vx_tc_util/atcf_prob_line.cc index 8b320eb912..8a140997ae 100644 --- a/src/libcode/vx_tc_util/atcf_prob_line.cc +++ b/src/libcode/vx_tc_util/atcf_prob_line.cc @@ -148,7 +148,7 @@ int ATCFProbLine::read_line(LineDataFile * ldf) { status = 0; continue; } - } + } return 1; } diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index cab5405f19..3dedd76ef5 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -75,6 +75,7 @@ // 042 04/29/24 Halley Gotway MET #2870 Ignore MISSING keyword. // 043 04/29/24 Halley Gotway MET #2795 Move level mismatch warning. // 044 06/17/24 Halley Gotway MET #2856 Reinitialize climo_cdf pointer +// 045 07/05/24 Halley Gotway MET #2924 Support forecast climatology. // //////////////////////////////////////////////////////////////////////// @@ -130,6 +131,7 @@ static void process_grid_scores (int, const DataPlane *, const DataPlane *, const DataPlane &, const DataPlane &, const DataPlane &, const DataPlane &, + const DataPlane &, const DataPlane &, const DataPlane &, const MaskPlane &, ObsErrorEntry *, PairDataEnsemble &); @@ -486,7 +488,7 @@ void process_grid(const Grid &fcst_grid) { // Parse regridding logic RegridInfo ri; - ri = conf_info.vx_opt[0].vx_pd.fcst_info->get_var_info()->regrid(); + ri = conf_info.vx_opt[0].vx_pd.ens_info->get_var_info()->regrid(); // Read gridded observation data, if necessary if(ri.field == FieldType::Obs) { @@ -552,15 +554,15 @@ void process_n_vld() { // Loop through the verification fields to be processed for(i_var=0; i_varinputs_n(); + n_ens_inputs = conf_info.vx_opt[i_var].vx_pd.ens_info->inputs_n(); // Loop through the forecast inputs for(i_ens=n_vld=0; i_ensget_file(i_ens); - var_info = conf_info.vx_opt[i_var].vx_pd.fcst_info->get_var_info(i_ens); - j = conf_info.vx_opt[i_var].vx_pd.fcst_info->get_file_index(i_ens); + fcst_file = conf_info.vx_opt[i_var].vx_pd.ens_info->get_file(i_ens); + var_info = conf_info.vx_opt[i_var].vx_pd.ens_info->get_var_info(i_ens); + j = conf_info.vx_opt[i_var].vx_pd.ens_info->get_file_index(i_ens); // Check for valid file if(!ens_file_vld[j]) continue; @@ -592,7 +594,7 @@ void process_n_vld() { << n_vld << " of " << n_ens_inputs << " (" << (double) n_vld/n_ens_inputs << ")" << " forecast fields found for \"" - << conf_info.vx_opt[i_var].vx_pd.fcst_info->get_var_info()->magic_str() + << conf_info.vx_opt[i_var].vx_pd.fcst_info->magic_str() << "\" does not meet the threshold specified by \"" << conf_key_fcst_ens_thresh << "\" (" << conf_info.vld_ens_thresh << ") in the configuration file.\n\n"; @@ -755,7 +757,8 @@ void process_point_vx() { int i, j, i_file, n_miss; unixtime beg_ut, end_ut; DataPlaneArray fcst_dpa, emn_dpa; - DataPlaneArray cmn_dpa, csd_dpa; + DataPlaneArray fcmn_dpa, fcsd_dpa; + DataPlaneArray ocmn_dpa, ocsd_dpa; // Loop through each of the fields to be verified for(i=0; iget_var_info()->magic_str() << ".\n"; + << "For " << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() << ", found " + << fcmn_dpa.n_planes() << " forecast climatology mean and " + << fcsd_dpa.n_planes() << " standard deviation level(s), and " + << ocmn_dpa.n_planes() << " observation climatology mean and " + << ocsd_dpa.n_planes() << " standard deviation level(s).\n"; // Store climatology information - conf_info.vx_opt[i].vx_pd.set_climo_mn_dpa(cmn_dpa); - conf_info.vx_opt[i].vx_pd.set_climo_sd_dpa(csd_dpa); + conf_info.vx_opt[i].vx_pd.set_fcst_climo_mn_dpa(fcmn_dpa); + conf_info.vx_opt[i].vx_pd.set_fcst_climo_sd_dpa(fcsd_dpa); + conf_info.vx_opt[i].vx_pd.set_obs_climo_mn_dpa(ocmn_dpa); + conf_info.vx_opt[i].vx_pd.set_obs_climo_sd_dpa(ocsd_dpa); } // Process each point observation NetCDF file @@ -809,17 +823,18 @@ void process_point_vx() { // Loop through each of the fields to be verified for(i=0; iget_var_info(); - VarInfo *obs_info = conf_info.vx_opt[i].vx_pd.obs_info; + EnsVarInfo *ens_info = conf_info.vx_opt[i].vx_pd.ens_info; + VarInfo *fcst_info = ens_info->get_var_info(); + VarInfo *obs_info = conf_info.vx_opt[i].vx_pd.obs_info; bool print_level_mismatch_warning = true; // Initialize emn_dpa.clear(); // Loop through the ensemble inputs - for(j=0, n_miss=0; jinputs_n(); j++) { + for(j=0, n_miss=0; jinputs_n(); j++) { - i_file = conf_info.vx_opt[i].vx_pd.fcst_info->get_file_index(j); + i_file = ens_info->get_file_index(j); // If the current forecast file is valid, process it if(!ens_file_vld[i_file]) { @@ -886,7 +901,7 @@ void process_point_vx() { mlog << Debug(2) << "Computing the ensemble mean from the members.\n"; - int n = conf_info.vx_opt[i].vx_pd.fcst_info->inputs_n() - n_miss; + int n = ens_info->inputs_n() - n_miss; if(n <= 0) { mlog << Error << "\nprocess_point_vx() -> " @@ -1099,13 +1114,13 @@ bool process_point_ens(int i_vx, int i_ens, DataPlaneArray &fcst_dpa) { fcst_dpa.clear(); // Get file based on current vx and ensemble index - ConcatString ens_file = conf_info.vx_opt[i_vx].vx_pd.fcst_info->get_file(i_ens); + ConcatString ens_file = conf_info.vx_opt[i_vx].vx_pd.ens_info->get_file(i_ens); mlog << Debug(2) << "\n" << sep_str << "\n\n" << "Processing ensemble member file: " << ens_file << (i_ens == ctrl_file_index ? " (control)\n" : "\n"); - VarInfo *info = conf_info.vx_opt[i_vx].vx_pd.fcst_info->get_var_info(i_ens); + VarInfo *info = conf_info.vx_opt[i_vx].vx_pd.ens_info->get_var_info(i_ens); // Read the gridded data from the input forecast file bool status = get_data_plane_array(ens_file.c_str(), info->file_type(), info, @@ -1143,28 +1158,31 @@ void process_point_scores() { // requested, and write the output. for(i=0; iget_var_info(); + VarInfo *obs_info = conf_info.vx_opt[i].vx_pd.obs_info; + // Set the description shc.set_desc(conf_info.vx_opt[i].vx_pd.desc.c_str()); // Store the forecast variable name - shc.set_fcst_var(conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->name_attr()); + shc.set_fcst_var(fcst_info->name_attr()); // Store the forecast variable units - shc.set_fcst_units(conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->units_attr()); + shc.set_fcst_units(fcst_info->units_attr()); // Set the forecast level name - shc.set_fcst_lev(conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->level_attr().c_str()); + shc.set_fcst_lev(fcst_info->level_attr().c_str()); // Store the observation variable name - shc.set_obs_var(conf_info.vx_opt[i].vx_pd.obs_info->name_attr()); + shc.set_obs_var(obs_info->name_attr()); // Store the observation variable units - cs = conf_info.vx_opt[i].vx_pd.obs_info->units_attr(); + cs = obs_info->units_attr(); if(cs.empty()) cs = na_string; shc.set_obs_units(cs); // Set the observation level name - shc.set_obs_lev(conf_info.vx_opt[i].vx_pd.obs_info->level_attr().c_str()); + shc.set_obs_lev(obs_info->level_attr().c_str()); // Set the observation lead time shc.set_obs_lead_sec(0); @@ -1195,13 +1213,13 @@ void process_point_scores() { shc.set_interp_wdth(conf_info.vx_opt[i].interp_info.width[l]); } - pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][l]; + int n = conf_info.vx_opt[i].vx_pd.three_to_one(j, k, l); + + pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[n]; mlog << Debug(2) << "Processing point verification " - << conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->magic_str() - << " versus " - << conf_info.vx_opt[i].vx_pd.obs_info->magic_str() + << fcst_info->magic_str() << " versus " << obs_info->magic_str() << ", for observation type " << pd_ptr->msg_typ << ", over region " << pd_ptr->mask_name << ", for interpolation method " @@ -1238,7 +1256,7 @@ void process_grid_vx() { DataPlane *fcst_dp = (DataPlane *) nullptr; DataPlane *fraw_dp = (DataPlane *) nullptr; DataPlane obs_dp, oraw_dp; - DataPlane emn_dp, cmn_dp, csd_dp; + DataPlane emn_dp, fcmn_dp, fcsd_dp, ocmn_dp, ocsd_dp; PairDataEnsemble pd_all, pd; ObsErrorEntry *oerr_ptr = (ObsErrorEntry *) nullptr; VarInfo * var_info; @@ -1251,13 +1269,16 @@ void process_grid_vx() { shc.set_obtype(conf_info.obtype.c_str()); // Allocate space to store the forecast fields - int num_dp = conf_info.vx_opt[0].vx_pd.fcst_info->inputs_n(); + int num_dp = conf_info.vx_opt[0].vx_pd.ens_info->inputs_n(); fcst_dp = new DataPlane [num_dp]; fraw_dp = new DataPlane [num_dp]; // Loop through each of the fields to be verified for(i=0; iget_var_info(); + VarInfo *obs_info = conf_info.vx_opt[i].vx_pd.obs_info; + // Initialize emn_dp.clear(); @@ -1272,13 +1293,13 @@ void process_grid_vx() { shc.set_desc(conf_info.vx_opt[i].vx_pd.desc.c_str()); // Set the forecast variable name - shc.set_fcst_var(conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->name_attr()); + shc.set_fcst_var(fcst_info->name_attr()); // Store the forecast variable units - shc.set_fcst_units(conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->units_attr()); + shc.set_fcst_units(fcst_info->units_attr()); // Set the forecast level name - shc.set_fcst_lev(conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->level_attr().c_str()); + shc.set_fcst_lev(fcst_info->level_attr().c_str()); // Set the ObsErrorEntry pointer if(conf_info.vx_opt[i].obs_error.flag) { @@ -1295,12 +1316,12 @@ void process_grid_vx() { // Check for table entries for this variable and message type if(!obs_error_table.has( - conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), + obs_info->name().c_str(), conf_info.obtype.c_str())) { mlog << Warning << "\nprocess_grid_vx() -> " << "Disabling observation error logic since the " << "obs error table contains no entry for OBS_VAR(" - << conf_info.vx_opt[i].vx_pd.obs_info->name() + << obs_info->name() << ") and MESSAGE_TYPE(" << conf_info.obtype << ").\nSpecify a custom obs error table using the " << "MET_OBS_ERROR_TABLE environment variable.\n\n"; @@ -1310,7 +1331,7 @@ void process_grid_vx() { // Do a lookup for this variable and message type oerr_ptr = obs_error_table.lookup( - conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), + obs_info->name().c_str(), conf_info.obtype.c_str()); // If match was found and includes a value range setting, @@ -1333,14 +1354,14 @@ void process_grid_vx() { } // Loop through each of the input ensemble files/variables - for(j=0, n_miss=0; j < conf_info.vx_opt[i].vx_pd.fcst_info->inputs_n(); j++) { + for(j=0, n_miss=0; j < conf_info.vx_opt[i].vx_pd.ens_info->inputs_n(); j++) { // Initialize fcst_dp[j].clear(); - i_file = conf_info.vx_opt[i].vx_pd.fcst_info->get_file_index(j); - var_info = conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info(j); - fcst_file = conf_info.vx_opt[i].vx_pd.fcst_info->get_file(j); + i_file = conf_info.vx_opt[i].vx_pd.ens_info->get_file_index(j); + var_info = conf_info.vx_opt[i].vx_pd.ens_info->get_var_info(j); + fcst_file = conf_info.vx_opt[i].vx_pd.ens_info->get_file(j); // If the current ensemble file is valid, read the field if(ens_file_vld[i_file]) { @@ -1369,7 +1390,7 @@ void process_grid_vx() { mlog << Debug(2) << "Processing ensemble mean file: " << ens_mean_file << "\n"; - VarInfo *info = conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info(); + VarInfo *info = conf_info.vx_opt[i].vx_pd.ens_info->get_var_info(); // Read the gridded data from the mean file found = get_data_plane(ens_mean_file.c_str(), FileType_None, @@ -1388,7 +1409,7 @@ void process_grid_vx() { mlog << Debug(2) << "Computing the ensemble mean from the members.\n"; - int n = conf_info.vx_opt[i].vx_pd.fcst_info->inputs_n() - n_miss; + int n = conf_info.vx_opt[i].vx_pd.ens_info->inputs_n() - n_miss; if(n <= 0) { mlog << Error << "\nprocess_grid_vx() -> " @@ -1400,19 +1421,29 @@ void process_grid_vx() { emn_dp /= (double) n; } - // Read climatology data - cmn_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_mean_field, false), - i, ens_valid_ut, grid); - csd_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_stdev_field, false), - i, ens_valid_ut, grid); + // Read forecast climatology data + fcmn_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), + i, ens_valid_ut, grid); + fcsd_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), + i, ens_valid_ut, grid); + + // Read observation climatology data + ocmn_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), + i, ens_valid_ut, grid); + ocsd_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), + i, ens_valid_ut, grid); mlog << Debug(3) - << "Found " << (cmn_dp.nx() == 0 ? 0 : 1) - << " climatology mean field(s) and " << (csd_dp.nx() == 0 ? 0 : 1) - << " climatology standard deviation field(s) for forecast " - << conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->magic_str() << ".\n"; + << "For " << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() << ", found " + << (fcmn_dp.nx() == 0 ? 0 : 1) << " forecast climatology mean and " + << (fcsd_dp.nx() == 0 ? 0 : 1) << " standard deviation field(s), and " + << (ocmn_dp.nx() == 0 ? 0 : 1) << " observation climatology mean and " + << (ocsd_dp.nx() == 0 ? 0 : 1) << " standard deviation field(s).\n"; + // If requested in the config file, create a NetCDF file to store // the verification matched pairs @@ -1447,13 +1478,13 @@ void process_grid_vx() { } // Set the observation variable name - shc.set_obs_var(conf_info.vx_opt[i].vx_pd.obs_info->name_attr()); + shc.set_obs_var(obs_info->name_attr()); // Store the observation variable units - shc.set_obs_units(conf_info.vx_opt[i].vx_pd.obs_info->units_attr()); + shc.set_obs_units(obs_info->units_attr()); // Set the observation level name - shc.set_obs_lev(conf_info.vx_opt[i].vx_pd.obs_info->level_attr().c_str()); + shc.set_obs_lev(obs_info->level_attr().c_str()); // Set the observation lead time shc.set_obs_lead_sec(obs_dp.lead()); @@ -1513,12 +1544,12 @@ void process_grid_vx() { << "gridded observation data.\n"; obs_dp = add_obs_error_bc(conf_info.rng_ptr, FieldType::Obs, oerr_ptr, oraw_dp, oraw_dp, - conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), + obs_info->name().c_str(), conf_info.obtype.c_str()); } // Loop through the ensemble members - for(k=0; k < conf_info.vx_opt[i].vx_pd.fcst_info->inputs_n(); k++) { + for(k=0; k < conf_info.vx_opt[i].vx_pd.ens_info->inputs_n(); k++) { // Smooth the forecast field, if requested if(field == FieldType::Fcst || field == FieldType::Both) { @@ -1538,7 +1569,7 @@ void process_grid_vx() { << "ensemble member " << k+1 << ".\n"; fcst_dp[k] = add_obs_error_inc(conf_info.rng_ptr, FieldType::Fcst, oerr_ptr, fraw_dp[k], oraw_dp, - conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), + obs_info->name().c_str(), conf_info.obtype.c_str()); } } // end for k @@ -1556,22 +1587,22 @@ void process_grid_vx() { pd_all.clear(); pd_all.set_ens_size(n_vx_vld[i]); pd_all.set_climo_cdf_info_ptr(&conf_info.vx_opt[i].cdf_info); - pd_all.ctrl_index = conf_info.vx_opt[i].vx_pd.pd[0][0][0].ctrl_index; - pd_all.skip_const = conf_info.vx_opt[i].vx_pd.pd[0][0][0].skip_const; + pd_all.ctrl_index = conf_info.vx_opt[i].vx_pd.pd[0].ctrl_index; + pd_all.skip_const = conf_info.vx_opt[i].vx_pd.pd[0].skip_const; // Apply the current mask to the fields and compute the pairs process_grid_scores(i, fcst_dp, fraw_dp, obs_dp, oraw_dp, - emn_dp, cmn_dp, csd_dp, + emn_dp, + fcmn_dp, fcsd_dp, + ocmn_dp, ocsd_dp, mask_mp, oerr_ptr, pd_all); mlog << Debug(2) << "Processing gridded verification " - << conf_info.vx_opt[i].vx_pd.fcst_info->get_var_info()->magic_str() - << " versus " - << conf_info.vx_opt[i].vx_pd.obs_info->magic_str() + << fcst_info->magic_str() << " versus " << obs_info->magic_str() << ", for observation type " << shc.get_obtype() << ", over region " << shc.get_mask() << ", for interpolation method " @@ -1615,23 +1646,28 @@ void process_grid_vx() { void process_grid_scores(int i_vx, const DataPlane *fcst_dp, const DataPlane *fraw_dp, const DataPlane &obs_dp, const DataPlane &oraw_dp, - const DataPlane &emn_dp, const DataPlane &cmn_dp, - const DataPlane &csd_dp, const MaskPlane &mask_mp, + const DataPlane &emn_dp, + const DataPlane &fcmn_dp, const DataPlane &fcsd_dp, + const DataPlane &ocmn_dp, const DataPlane &ocsd_dp, + const MaskPlane &mask_mp, ObsErrorEntry *oerr_ptr, PairDataEnsemble &pd) { int i, j, x, y, n_miss; - double cmn, csd; ObsErrorEntry *e = (ObsErrorEntry *) nullptr; // Allocate memory in one big chunk based on grid size pd.extend(nxy); // Climatology flags - bool emn_flag = (emn_dp.nx() == obs_dp.nx() && - emn_dp.ny() == obs_dp.ny()); - bool cmn_flag = (cmn_dp.nx() == obs_dp.nx() && - cmn_dp.ny() == obs_dp.ny()); - bool csd_flag = (csd_dp.nx() == obs_dp.nx() && - csd_dp.ny() == obs_dp.ny()); + bool emn_flag = (emn_dp.nx() == obs_dp.nx() && + emn_dp.ny() == obs_dp.ny()); + bool fcmn_flag = (fcmn_dp.nx() == obs_dp.nx() && + fcmn_dp.ny() == obs_dp.ny()); + bool fcsd_flag = (fcsd_dp.nx() == obs_dp.nx() && + fcsd_dp.ny() == obs_dp.ny()); + bool ocmn_flag = (ocmn_dp.nx() == obs_dp.nx() && + ocmn_dp.ny() == obs_dp.ny()); + bool ocsd_flag = (ocsd_dp.nx() == obs_dp.nx() && + ocsd_dp.ny() == obs_dp.ny()); // Loop through the observation field for(x=0; xinputs_n(); j++) { + for(j=0,n_miss=0; j < conf_info.vx_opt[i_vx].vx_pd.ens_info->inputs_n(); j++) { // Skip missing data if(fcst_dp[j].nx() == 0 || fcst_dp[j].ny() == 0) { @@ -1742,17 +1781,17 @@ void do_rps(const EnsembleStatVxOpt &vx_opt, rps_info.othresh = othresh; rps_info.set_prob_cat_thresh(vx_opt.fcat_ta); - // If prob_cat_thresh is empty and climo data is available, - // use climo_cdf thresholds instead + // If prob_cat_thresh is empty and observation climo + // data is available, use climo_cdf thresholds instead if(rps_info.fthresh.n() == 0 && - pd_ptr->cmn_na.n_valid() > 0 && - pd_ptr->csd_na.n_valid() > 0 && + pd_ptr->ocmn_na.n_valid() > 0 && + pd_ptr->ocsd_na.n_valid() > 0 && vx_opt.cdf_info.cdf_ta.n() > 0) { rps_info.set_cdp_thresh(vx_opt.cdf_info.cdf_ta); } // Compute ensemble RPS statistics from pre-computed binned probabilities - if(vx_opt.vx_pd.fcst_info->get_var_info()->is_prob()) { + if(vx_opt.vx_pd.ens_info->get_var_info()->is_prob()) { rps_info.set_climo_bin_prob(*pd_ptr, vx_opt.ocat_ta); } // Compute ensemble RPS statistics from ensemble member values @@ -1833,7 +1872,7 @@ void setup_txt_files() { // Compute the number of PHIST bins for(i=n_phist_bin=0; i n_phist_bin ? n : n_phist_bin); } @@ -2059,7 +2098,7 @@ void write_txt_files(const EnsembleStatVxOpt &vx_opt, PairDataEnsemble pd; // Check for probabilistic input - bool is_prob = vx_opt.vx_pd.fcst_info->get_var_info()->is_prob(); + bool is_prob = vx_opt.vx_pd.ens_info->get_var_info()->is_prob(); // Process each observation filtering threshold for(i=0; i 0) { @@ -2134,7 +2173,7 @@ void write_txt_files(const EnsembleStatVxOpt &vx_opt, if(!is_prob && vx_opt.output_flag[i_ssvar] != STATOutputType::None) { - pd.ssvar_bin_size = vx_opt.vx_pd.pd[0][0][0].ssvar_bin_size; + pd.ssvar_bin_size = vx_opt.vx_pd.pd[0].ssvar_bin_size; pd.compute_ssvar(); // Make sure there are bins to process @@ -2196,17 +2235,15 @@ void write_txt_files(const EnsembleStatVxOpt &vx_opt, void do_pct(const EnsembleStatVxOpt &vx_opt, const PairDataEnsemble &pd_ens) { - // Flag to indicate the presence of valid climo data - bool have_climo = (pd_ens.cmn_na.n_valid() > 0 && - pd_ens.csd_na.n_valid() > 0); - // If forecast probability thresholds were specified, use them. if(vx_opt.fcat_ta.n() > 0) { do_pct_cat_thresh(vx_opt, pd_ens); } // Otherwise, if climo data is available and bins were requested, // use climo_cdf thresholds instead. - else if(have_climo && vx_opt.cdf_info.cdf_ta.n() > 0) { + else if(pd_ens.ocmn_na.n_valid() > 0 && + pd_ens.ocsd_na.n_valid() > 0 && + vx_opt.cdf_info.cdf_ta.n() > 0) { do_pct_cdp_thresh(vx_opt, pd_ens); } @@ -2232,7 +2269,8 @@ void do_pct_cat_thresh(const EnsembleStatVxOpt &vx_opt, pd_pnt.extend(pd_ens.n_obs); // Determine the number of climo CDF bins - n_bin = (pd_ens.cmn_na.n_valid() > 0 && pd_ens.csd_na.n_valid() > 0 ? + n_bin = (pd_ens.ocmn_na.n_valid() > 0 && + pd_ens.ocsd_na.n_valid() > 0 ? vx_opt.get_n_cdf_bin() : 1); if(n_bin > 1) { @@ -2266,21 +2304,22 @@ void do_pct_cat_thresh(const EnsembleStatVxOpt &vx_opt, // Initialize counts n_vld = n_evt = 0; + // Store climo data + ClimoPntInfo cpi(pd_ens.fcmn_na[i_obs], pd_ens.fcsd_na[i_obs], + pd_ens.ocmn_na[i_obs], pd_ens.ocsd_na[i_obs]); + // Derive the ensemble probability for(i_ens=0; i_ens 0 || (double) (n_vld/pd_ens.n_ens) >= conf_info.vld_data_thresh) { pd_pnt.add_grid_pair((double) n_evt/n_vld, pd_ens.o_na[i_obs], - pd_ens.cmn_na[i_obs], pd_ens.csd_na[i_obs], - pd_ens.wgt_na[i_obs]); + cpi, pd_ens.wgt_na[i_obs]); } } // end for i_obs @@ -2332,18 +2371,19 @@ void do_pct_cdp_thresh(const EnsembleStatVxOpt &vx_opt, int n_vld, n_evt, n_bin; PCTInfo *pct_info = (PCTInfo *) nullptr; PairDataPoint pd_pnt, pd; - ThreshArray cdp_thresh; + ThreshArray ocdp_thresh; // Derive a PairDataPoint object from the PairDataEnsemble input pd_pnt.extend(pd_ens.n_obs); // Derive the climo distribution percentile thresholds - cdp_thresh = derive_cdp_thresh(vx_opt.cdf_info.cdf_ta); - n_bin = cdp_thresh.n(); + ocdp_thresh = derive_ocdp_thresh(vx_opt.cdf_info.cdf_ta); + n_bin = ocdp_thresh.n(); mlog << Debug(2) - << "Computing Probabilistic Statistics for " << cdp_thresh.n() - << " climatological distribution percentile thresholds.\n"; + << "Computing Probabilistic Statistics for " + << ocdp_thresh.n() << " observation climatological " + << "distribution percentile thresholds.\n"; // Allocate memory pct_info = new PCTInfo [n_bin]; @@ -2353,7 +2393,7 @@ void do_pct_cdp_thresh(const EnsembleStatVxOpt &vx_opt, // Set the header columns shc.set_fcst_thresh(vx_opt.fpct_ta); - shc.set_obs_thresh(cdp_thresh[i_bin]); + shc.set_obs_thresh(ocdp_thresh[i_bin]); // Re-initialize pd_pnt.erase(); @@ -2365,21 +2405,22 @@ void do_pct_cdp_thresh(const EnsembleStatVxOpt &vx_opt, // Initialize counts n_vld = n_evt = 0; + // Store climo data + ClimoPntInfo cpi(pd_ens.fcmn_na[i_obs], pd_ens.fcsd_na[i_obs], + pd_ens.ocmn_na[i_obs], pd_ens.ocsd_na[i_obs]); + // Derive the ensemble probability for(i_ens=0; i_ens 0 || (double) (n_vld/pd_ens.n_ens) >= conf_info.vld_data_thresh) { pd_pnt.add_grid_pair((double) n_evt/n_vld, pd_ens.o_na[i_obs], - pd_ens.cmn_na[i_obs], pd_ens.csd_na[i_obs], - pd_ens.wgt_na[i_obs]); + cpi, pd_ens.wgt_na[i_obs]); } } // end for i_obs @@ -2389,7 +2430,7 @@ void do_pct_cdp_thresh(const EnsembleStatVxOpt &vx_opt, // Store thresholds pct_info[i_bin].fthresh = vx_opt.fpct_ta; - pct_info[i_bin].othresh = cdp_thresh[i_bin]; + pct_info[i_bin].othresh = ocdp_thresh[i_bin]; pct_info[i_bin].allocate_n_alpha(vx_opt.get_n_ci_alpha()); for(i=0; iget_var_info(), &nc_var, false, dp, + add_var_att_local(conf_info.vx_opt[i_vx].vx_pd.ens_info->get_var_info(), + &nc_var, false, dp, name_str.c_str(), long_name_str); // Write the data @@ -2696,7 +2738,8 @@ void write_orank_var_int(int i_vx, int i_interp, int i_mask, nc_var = add_var(nc_out, (string)var_name, ncInt, lat_dim, lon_dim); // Add the variable attributes - add_var_att_local(conf_info.vx_opt[i_vx].vx_pd.fcst_info->get_var_info(), &nc_var, true, dp, + add_var_att_local(conf_info.vx_opt[i_vx].vx_pd.ens_info->get_var_info(), + &nc_var, true, dp, name_str.c_str(), long_name_str); // Write the data diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 6f31073d20..d248124cbd 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -646,7 +646,7 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, clear(); // Allocate new EnsVarInfo object for fcst - vx_pd.fcst_info = new EnsVarInfo(); + vx_pd.ens_info = new EnsVarInfo(); // Loop over ensemble member IDs to substitute for(i=0; iadd_input(input_info); + vx_pd.ens_info->add_input(input_info); + + // Set the fcst_info, if needed + if(!vx_pd.fcst_info) vx_pd.set_fcst_info(next_var); // Add InputInfo to fcst info list for each ensemble file provided // set var_info to nullptr to note first VarInfo should be used @@ -672,7 +675,7 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, input_info.var_info = nullptr; input_info.file_index = j; input_info.file_list = ens_files; - vx_pd.fcst_info->add_input(input_info); + vx_pd.ens_info->add_input(input_info); } // end for j } // end for i @@ -691,11 +694,11 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, input_info.var_info = next_var; input_info.file_index = ens_files->n() - 1; input_info.file_list = ens_files; - vx_pd.fcst_info->add_input(input_info); + vx_pd.ens_info->add_input(input_info); } // Allocate new VarInfo object for obs - vx_pd.obs_info = info_factory.new_var_info(otype); + vx_pd.obs_info = info_factory.new_var_info(otype); // Set the VarInfo objects vx_pd.obs_info->set_dict(odict); @@ -704,14 +707,14 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, if(mlog.verbosity_level() >= 5) { mlog << Debug(5) << "Parsed forecast field:\n"; - vx_pd.fcst_info->get_var_info()->dump(cout); + vx_pd.ens_info->get_var_info()->dump(cout); mlog << Debug(5) << "Parsed observation field:\n"; vx_pd.obs_info->dump(cout); } // No support for wind direction - if(vx_pd.fcst_info->get_var_info()->is_wind_direction() || + if(vx_pd.ens_info->get_var_info()->is_wind_direction() || vx_pd.obs_info->is_wind_direction()) { mlog << Error << "\nEnsembleStatVxOpt::process_config() -> " << "wind direction may not be verified using grid_stat.\n\n"; @@ -783,7 +786,7 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, ocat_ta = odict.lookup_thresh_array(conf_key_prob_cat_thresh); // The number of thresholds must match for non-probability forecasts - if(!vx_pd.fcst_info->get_var_info()->is_prob() && + if(!vx_pd.ens_info->get_var_info()->is_prob() && fcat_ta.n() != ocat_ta.n()) { mlog << Error << "\nEnsembleStatVxOpt::process_config() -> " << "The number of forecast (" << write_css(fcat_ta) @@ -936,7 +939,7 @@ void EnsembleStatVxOpt::set_vx_pd(EnsembleStatConfInfo *conf_info, int ctrl_inde } // Define the dimensions - vx_pd.set_pd_size(n_msg_typ, n_mask, n_interp); + vx_pd.set_size(n_msg_typ, n_mask, n_interp); // Store the climo CDF info vx_pd.set_climo_cdf_info_ptr(&cdf_info); @@ -1014,21 +1017,23 @@ void EnsembleStatVxOpt::set_perc_thresh(const PairDataEnsemble *pd_ptr) { // // Sort the input arrays // - NumArray fsort; - for(int i=0; in_ens; i++) fsort.add(pd_ptr->e_na[i]); - NumArray osort = pd_ptr->o_na; - NumArray csort = pd_ptr->cmn_na; - fsort.sort_array(); - osort.sort_array(); - csort.sort_array(); + NumArray f_sort; + for(int i=0; in_ens; i++) f_sort.add(pd_ptr->e_na[i]); + NumArray o_sort = pd_ptr->o_na; + NumArray fcmn_sort = pd_ptr->fcmn_na; + NumArray ocmn_sort = pd_ptr->ocmn_na; + f_sort.sort_array(); + o_sort.sort_array(); + fcmn_sort.sort_array(); + ocmn_sort.sort_array(); // // Compute percentiles, passing the observation filtering // thresholds in for the fcst and obs slots. // - othr_ta.set_perc(&fsort, &osort, &csort, &othr_ta, &othr_ta); - fcat_ta.set_perc(&fsort, &osort, &csort, &fcat_ta, &ocat_ta); - ocat_ta.set_perc(&fsort, &osort, &csort, &fcat_ta, &ocat_ta); + othr_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &othr_ta, &othr_ta); + fcat_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcat_ta, &ocat_ta); + ocat_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcat_ta, &ocat_ta); return; } diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 56be2071cf..843344897c 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -109,9 +109,10 @@ // filtering options. // 052 05/28/21 Halley Gotway Add MCTS HSS_EC output. // 053 12/11/21 Halley Gotway MET #1991 Fix VCNT output. -// 054 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main -// 055 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files -// 056 01/29/24 Halley Gotway MET #2801 Configure time difference warnings +// 054 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. +// 055 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files. +// 056 01/29/24 Halley Gotway MET #2801 Configure time difference warnings. +// 057 07/05/24 Halley Gotway MET #2924 Support forecast climatology. // //////////////////////////////////////////////////////////////////////// @@ -168,6 +169,7 @@ static void get_mask_points(const GridStatVxOpt &, const MaskPlane &, const DataPlane *, const DataPlane *, const DataPlane *, const DataPlane *, const DataPlane *, + const DataPlane *, const DataPlane *, PairDataPoint &); static void do_cts (CTSInfo *&, int, const PairDataPoint *); @@ -672,8 +674,8 @@ void process_scores() { DataPlane fcst_dp_thresh, obs_dp_thresh; // Climatology mean and standard deviation - DataPlane cmn_dp, csd_dp; - DataPlane cmn_dp_smooth; + DataPlane fcmn_dp, fcsd_dp, ocmn_dp, ocsd_dp; + DataPlane fcmn_dp_smooth, ocmn_dp_smooth; // Paired forecast, observation, climatology, and weight values PairDataPoint pd; @@ -682,19 +684,20 @@ void process_scores() { PairDataPoint pd_thr; // Allocate memory in one big chunk based on grid size - pd.extend(grid.nx()*grid.ny()); + pd.extend(grid.nxy()); if(conf_info.output_flag[i_nbrctc] != STATOutputType::None || conf_info.output_flag[i_nbrcts] != STATOutputType::None || conf_info.output_flag[i_nbrcnt] != STATOutputType::None || conf_info.output_flag[i_dmap] != STATOutputType::None) { - pd_thr.extend(grid.nx()*grid.ny()); + pd_thr.extend(grid.nxy()); } // Objects to handle vector winds DataPlane fu_dp, ou_dp; DataPlane fu_dp_smooth, ou_dp_smooth; - DataPlane cmnu_dp, csdu_dp, cmnu_dp_smooth; + DataPlane fcmnu_dp, fcsdu_dp, fcmnu_dp_smooth; + DataPlane ocmnu_dp, ocsdu_dp, ocmnu_dp_smooth; PairDataPoint pd_u; DataPlane seeps_dp, seeps_dp_fcat, seeps_dp_ocat; @@ -784,23 +787,34 @@ void process_scores() { << ".\n\n"; } - // Read climatology data - cmn_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_mean_field, false), - i, fcst_dp.valid(), grid); - csd_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_stdev_field, false), - i, fcst_dp.valid(), grid); + // Read forecast climatology data + fcmn_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), + i, fcst_dp.valid(), grid); + fcsd_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), + i, fcst_dp.valid(), grid); + + // Read observation climatology data + ocmn_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), + i, fcst_dp.valid(), grid); + ocsd_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), + i, fcst_dp.valid(), grid); mlog << Debug(3) - << "Found " << (cmn_dp.nx() == 0 ? 0 : 1) - << " climatology mean and " << (csd_dp.nx() == 0 ? 0 : 1) - << " climatology standard deviation field(s) for forecast " - << conf_info.vx_opt[i].fcst_info->magic_str() << ".\n"; + << "For " << conf_info.vx_opt[i].fcst_info->magic_str() << ", found " + << (fcmn_dp.is_empty() ? 0 : 1) << " forecast climatology mean and " + << (fcsd_dp.is_empty() ? 0 : 1) << " standard deviation field(s), and " + << (ocmn_dp.is_empty() ? 0 : 1) << " observation climatology mean and " + << (ocsd_dp.is_empty() ? 0 : 1) << " standard deviation field(s).\n"; // Apply MPR threshold filters if(conf_info.vx_opt[i].mpr_sa.n() > 0) { - apply_mpr_thresh_mask(fcst_dp, obs_dp, cmn_dp, csd_dp, + apply_mpr_thresh_mask(fcst_dp, obs_dp, + fcmn_dp, fcsd_dp, + ocmn_dp, ocsd_dp, conf_info.vx_opt[i].mpr_sa, conf_info.vx_opt[i].mpr_ta); } @@ -879,22 +893,20 @@ void process_scores() { // Store the current mask mask_mp = conf_info.mask_map[conf_info.vx_opt[i].mask_name[k]]; - // Turn off the mask for missing data values + // Turn off the mask for any grid points containing bad data mask_bad_data(mask_mp, fcst_dp_smooth); mask_bad_data(mask_mp, obs_dp_smooth); - if(cmn_dp.nx() == fcst_dp_smooth.nx() && - cmn_dp.ny() == fcst_dp_smooth.ny()) { - mask_bad_data(mask_mp, cmn_dp); - } - if(csd_dp.nx() == fcst_dp_smooth.nx() && - csd_dp.ny() == fcst_dp_smooth.ny()) { - mask_bad_data(mask_mp, csd_dp); - } + if(!fcmn_dp.is_empty()) mask_bad_data(mask_mp, fcmn_dp); + if(!fcsd_dp.is_empty()) mask_bad_data(mask_mp, fcsd_dp); + if(!ocmn_dp.is_empty()) mask_bad_data(mask_mp, ocmn_dp); + if(!ocsd_dp.is_empty()) mask_bad_data(mask_mp, ocsd_dp); // Apply the current mask to the current fields get_mask_points(conf_info.vx_opt[i], mask_mp, &fcst_dp_smooth, &obs_dp_smooth, - &cmn_dp, &csd_dp, &wgt_dp, pd); + &fcmn_dp, &fcsd_dp, + &ocmn_dp, &ocsd_dp, + &wgt_dp, pd); // Set the mask name shc.set_mask(conf_info.vx_opt[i].mask_name[k].c_str()); @@ -1042,13 +1054,21 @@ void process_scores() { if(!read_data_plane(conf_info.vx_opt[ui].obs_info, ou_dp, obs_mtddf, obs_file)) continue; - // Read climatology data for UGRD - cmnu_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_mean_field, false), - ui, fcst_dp.valid(), grid); - csdu_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_stdev_field, false), - ui, fcst_dp.valid(), grid); + // Read the forecast climatology data for UGRD + fcmnu_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), + ui, fcst_dp.valid(), grid); + fcsdu_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), + ui, fcst_dp.valid(), grid); + + // Read the observation climatology data for UGRD + ocmnu_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), + ui, fcst_dp.valid(), grid); + ocsdu_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), + ui, fcst_dp.valid(), grid); // If requested in the config file, smooth the forecast // and climatology U-wind fields @@ -1080,7 +1100,9 @@ void process_scores() { // Apply the current mask to the U-wind fields get_mask_points(conf_info.vx_opt[i], mask_mp, &fu_dp_smooth, &ou_dp_smooth, - &cmnu_dp, &csdu_dp, &wgt_dp, pd_u); + &fcmnu_dp, &fcsdu_dp, + &ocmnu_dp, &ocsdu_dp, + &wgt_dp, pd_u); // Compute VL1L2 do_vl1l2(vl1l2_info, i, &pd_u, &pd); @@ -1153,23 +1175,65 @@ void process_scores() { } if(conf_info.vx_opt[i].nc_info.do_diff) { write_nc((string)"DIFF", subtract(fcst_dp_smooth, obs_dp_smooth), - i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + /* MET #2924 Replace this section + if(conf_info.vx_opt[i].nc_info.do_climo && + !fcmn_dp.is_empty()) { + write_nc((string)"FCST_CLIMO_MEAN", fcmn_dp, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + if(conf_info.vx_opt[i].nc_info.do_climo && + !fcsd_dp.is_empty()) { + write_nc((string)"FCST_CLIMO_STDEV", fcsd_dp, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + if(conf_info.vx_opt[i].nc_info.do_climo && + !ocmn_dp.is_empty()) { + write_nc((string)"OBS_CLIMO_MEAN", ocmn_dp, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + if(conf_info.vx_opt[i].nc_info.do_climo && + !ocsd_dp.is_empty()) { + write_nc((string)"OBS_CLIMO_STDEV", ocsd_dp, + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + if(conf_info.vx_opt[i].nc_info.do_climo && + !ocmn_dp.is_empty() && !ocsd_dp.is_empty()) { + write_nc((string)"OBS_CLIMO_CDF", normal_cdf(obs_dp, ocmn_dp, ocsd_dp), + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); } - if(conf_info.vx_opt[i].nc_info.do_climo && !cmn_dp.is_empty()) { - write_nc((string)"CLIMO_MEAN", cmn_dp, i, mthd, pnts, + */ + if(conf_info.vx_opt[i].nc_info.do_climo && + !ocmn_dp.is_empty()) { + write_nc((string)"CLIMO_MEAN", ocmn_dp, + i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); } - if(conf_info.vx_opt[i].nc_info.do_climo && !csd_dp.is_empty()) { - write_nc((string)"CLIMO_STDEV", csd_dp, i, mthd, pnts, + if(conf_info.vx_opt[i].nc_info.do_climo && + !ocsd_dp.is_empty()) { + write_nc((string)"CLIMO_STDEV", fcsd_dp, + i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); } - if(conf_info.vx_opt[i].nc_info.do_climo && !cmn_dp.is_empty() && !csd_dp.is_empty()) { - write_nc((string)"CLIMO_CDF", normal_cdf(obs_dp, cmn_dp, csd_dp), - i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); + if(conf_info.vx_opt[i].nc_info.do_climo && + !ocmn_dp.is_empty() && !ocsd_dp.is_empty()) { + write_nc((string)"CLIMO_CDF", normal_cdf(obs_dp, ocmn_dp, ocsd_dp), + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); } + // MET #2924 End replace // Write out the fields of requested climo distribution percentile threshold values - if(conf_info.vx_opt[i].nc_info.do_climo_cdp && !cmn_dp.is_empty() && !csd_dp.is_empty()) { + if(conf_info.vx_opt[i].nc_info.do_climo_cdp && + ((!fcmn_dp.is_empty() && !fcsd_dp.is_empty()) || + (!ocmn_dp.is_empty() && !ocsd_dp.is_empty()))) { // Construct one list of all thresholds ThreshArray ta; @@ -1185,36 +1249,59 @@ void process_scores() { // Process all CDP thresholds except 0 and 100 for(vector::iterator it = simp.begin(); it != simp.end(); it++) { - if(it->ptype() == perc_thresh_climo_dist && + /* MET #2924 Replace this section + if(it->ptype() == perc_thresh_fcst_climo_dist && !is_eq(it->pvalue(), 0.0) && !is_eq(it->pvalue(), 100.0)) { + cs << cs_erase << "FCST_CLIMO_CDP" << nint(it->pvalue()); + write_nc(cs, normal_cdf_inv(it->pvalue()/100.0, fcmn_dp, fcsd_dp), + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + else if(it->ptype() == perc_thresh_obs_climo_dist && + !is_eq(it->pvalue(), 0.0) && + !is_eq(it->pvalue(), 100.0)) { + cs << cs_erase << "OBS_CLIMO_CDP" << nint(it->pvalue()); + write_nc(cs, normal_cdf_inv(it->pvalue()/100.0, ocmn_dp, ocsd_dp), + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); + } + */ + if(it->ptype() == perc_thresh_obs_climo_dist && + !is_eq(it->pvalue(), 0.0) && + !is_eq(it->pvalue(), 100.0)) { cs << cs_erase << "CLIMO_CDP" << nint(it->pvalue()); - write_nc(cs, normal_cdf_inv(it->pvalue()/100.0, cmn_dp, csd_dp), - i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); + write_nc(cs, normal_cdf_inv(it->pvalue()/100.0, ocmn_dp, ocsd_dp), + i, mthd, pnts, + conf_info.vx_opt[i].interp_info.field); } + // MET #2924 End replace } // end for it } // Write out the fields of requested SEEPS - if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType::None - && conf_info.vx_opt[i].fcst_info->is_precipitation() - && conf_info.vx_opt[i].obs_info->is_precipitation()) { - SeepsAggScore seeps; + if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType::None && + conf_info.vx_opt[i].fcst_info->is_precipitation() && + conf_info.vx_opt[i].obs_info->is_precipitation()) { + SeepsAggScore seeps_agg; int month, day, year, hour, minute, second; 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, month, hour, + &seeps_agg, month, hour, conf_info.seeps_p1_thresh, conf_info.seeps_climo_name); - write_nc("SEEPS_MPR_SCORE", seeps_dp, i, mthd, pnts, + 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, + 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, + write_nc("SEEPS_MPR_OCAT", seeps_dp_ocat, + i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); - write_seeps_row(shc, &seeps, conf_info.output_flag[i_seeps], + 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]); } @@ -1225,8 +1312,8 @@ void process_scores() { // Allocate memory in one big chunk based on grid size DataPlane fgx_dp, fgy_dp, ogx_dp, ogy_dp; PairDataPoint pd_gx, pd_gy; - pd_gx.extend(grid.nx()*grid.ny()); - pd_gy.extend(grid.nx()*grid.ny()); + pd_gx.extend(grid.nxy()); + pd_gy.extend(grid.nxy()); // Loop over gradient Dx/Dy for(k=0; kwidth[j], nbrhd->shape, grid.wrap_lon(), conf_info.vx_opt[i].fcat_ta[k], - &cmn_dp, &csd_dp, + &fcmn_dp, &fcsd_dp, + &ocmn_dp, &ocsd_dp, nbrhd->vld_thresh); // Compute the binary threshold field @@ -1538,7 +1633,8 @@ void process_scores() { nbrhd->width[j], nbrhd->shape, grid.wrap_lon(), conf_info.vx_opt[i].ocat_ta[k], - &cmn_dp, &csd_dp, + &fcmn_dp, &fcsd_dp, + &ocmn_dp, &ocsd_dp, nbrhd->vld_thresh); // Compute the binary threshold field @@ -1565,7 +1661,7 @@ void process_scores() { } } - // Turn off the mask for bad forecast or observation values + // Turn off the mask for any grid points containing bad data mask_bad_data(mask_mp, fcst_dp_smooth); mask_bad_data(mask_mp, obs_dp_smooth); @@ -1583,14 +1679,18 @@ void process_scores() { // and thresholded fields get_mask_points(conf_info.vx_opt[i], mask_mp, &fcst_dp_smooth, &obs_dp_smooth, - 0, 0, &wgt_dp, pd); + nullptr, nullptr, nullptr, nullptr, + &wgt_dp, pd); get_mask_points(conf_info.vx_opt[i], mask_mp, &fcst_dp_thresh, &obs_dp_thresh, - 0, 0, 0, pd_thr); + nullptr, nullptr, nullptr, nullptr, + nullptr, pd_thr); // Store climatology values as bad data - pd.cmn_na.add_const(bad_data_double, pd.f_na.n()); - pd.csd_na.add_const(bad_data_double, pd.f_na.n()); + pd.fcmn_na.add_const(bad_data_double, pd.f_na.n()); + pd.fcsd_na.add_const(bad_data_double, pd.f_na.n()); + pd.ocmn_na.add_const(bad_data_double, pd.f_na.n()); + pd.ocsd_na.add_const(bad_data_double, pd.f_na.n()); mlog << Debug(2) << "Processing " << conf_info.vx_opt[i].fcst_info->magic_str() @@ -1691,15 +1791,16 @@ void process_scores() { for(j=0; jcmn_na.n_valid() > 0 && - pd_ptr->csd_na.n_valid() > 0 ? + // Determine the number of observation climo CDF bins + n_bin = (pd_ptr->ocmn_na.n_valid() > 0 && + pd_ptr->ocsd_na.n_valid() > 0 ? vx_opt.get_n_cdf_bin() : 1); if(n_bin > 1) { @@ -2310,8 +2459,9 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { mlog << Debug(2) << "Computing Probabilistic Statistics.\n"; - // Determine the number of climo CDF bins - n_bin = (pd_ptr->cmn_na.n_valid() > 0 && pd_ptr->csd_na.n_valid() > 0 ? + // Determine the number of observation climo CDF bins + n_bin = (pd_ptr->ocmn_na.n_valid() > 0 && + pd_ptr->ocsd_na.n_valid() > 0 ? vx_opt.get_n_cdf_bin() : 1); if(n_bin > 1) { @@ -2616,7 +2766,7 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, // Allocate memory float *data = (float *) nullptr; - data = new float [grid.nx()*grid.ny()]; + data = new float [grid.nxy()]; // Set the NetCDF compression level int deflate_level = compress_level; @@ -2665,12 +2815,94 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, << conf_info.vx_opt[i_vx].fcst_info->units_attr() << " and " << conf_info.vx_opt[i_vx].obs_info->units_attr(); } + else if(field_name == "FCST_CLIMO_MEAN") { + var_name << cs_erase << field_name << "_" + << obs_name << var_suffix << "_" << mask_str; + + // Append interpolation string for Fourier decomposition + if(interp_str.nonempty()) { + if(interp_str.startswith("_WV")) var_name << interp_str; + } + long_att << cs_erase + << "Forecast climatology mean for " + << fcst_long_name; + level_att = shc.get_fcst_lev(); + units_att = conf_info.vx_opt[i_vx].fcst_info->units_attr(); + } + else if(field_name == "FCST_CLIMO_STDEV") { + var_name << cs_erase << field_name << "_" + << obs_name << var_suffix << "_" << mask_str; + long_att << cs_erase + << "Forecast climatology standard deviation for " + << fcst_long_name; + level_att = shc.get_fcst_lev(); + units_att = conf_info.vx_opt[i_vx].fcst_info->units_attr(); + } + /* MET #2924 Replace this section + else if(field_name == "OBS_CLIMO_MEAN") { + var_name << cs_erase << field_name << "_" + << obs_name << var_suffix << "_" << mask_str; + + // Append interpolation string for Fourier decomposition + if(interp_str.nonempty()) { + if(interp_str.startswith("_WV")) var_name << interp_str; + } + long_att << cs_erase + << "Observation climatology mean for " + << obs_long_name; + level_att = shc.get_obs_lev(); + units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); + } + else if(field_name == "OBS_CLIMO_STDEV") { + var_name << cs_erase << field_name << "_" + << obs_name << var_suffix << "_" << mask_str; + long_att << cs_erase + << "Observation climatology standard deviation for " + << obs_long_name; + level_att = shc.get_obs_lev(); + units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); + } + else if(field_name == "OBS_CLIMO_CDF") { + var_name << cs_erase << field_name << "_" + << obs_name << var_suffix << "_" << mask_str; + long_att << cs_erase + << "Observation climatology cumulative distribution function for " + << obs_long_name; + level_att = shc.get_obs_lev(); + units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); + } + else if(field_name.startswith("FCST_CLIMO_CDP")) { + var_name << cs_erase + << field_name << "_" + << conf_info.vx_opt[i_vx].fcst_info->name_attr() << "_" + << conf_info.vx_opt[i_vx].fcst_info->level_attr() + << var_suffix << "_" << mask_str; + long_att << cs_erase + << "Forecast climatology distribution percentile thresholds for " + << fcst_long_name; + level_att = shc.get_fcst_lev(); + units_att = conf_info.vx_opt[i_vx].fcst_info->units_attr(); + } + else if(field_name.startswith("OBS_CLIMO_CDP")) { + var_name << cs_erase + << field_name << "_" + << conf_info.vx_opt[i_vx].obs_info->name_attr() << "_" + << conf_info.vx_opt[i_vx].obs_info->level_attr() + << var_suffix << "_" << mask_str; + long_att << cs_erase + << "Observation climatology distribution percentile thresholds for " + << obs_long_name; + level_att = shc.get_obs_lev(); + units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); + } + */ else if(field_name == "CLIMO_MEAN") { var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; + // Append interpolation string for Fourier decomposition if(interp_str.nonempty()) { - if(strncmp(interp_str.c_str(), "_WV", 3) == 0) var_name << interp_str; + if(interp_str.startswith("_WV")) var_name << interp_str; } long_att << cs_erase << "Climatology mean for " @@ -2696,7 +2928,7 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, level_att = shc.get_obs_lev(); units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); } - else if(strncmp(field_name.c_str(), "CLIMO_CDP", 9) == 0) { + else if(field_name.startswith("CLIMO_CDP")) { var_name << cs_erase << field_name << "_" << conf_info.vx_opt[i_vx].obs_info->name_attr() << "_" @@ -2708,6 +2940,7 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, level_att = shc.get_obs_lev(); units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); } + // MET #2924 end replace else if(check_reg_exp("FCST_XGRAD_", field_name.c_str()) || check_reg_exp("FCST_YGRAD_", field_name.c_str())) { var_name << cs_erase << field_name << "_" @@ -2762,7 +2995,7 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, level_att = shc.get_obs_lev(); units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); } - else if(strncmp(field_name.c_str(), "SEEPS_MPR", 9) == 0) { + else if(field_name.startswith("SEEPS_MPR")) { ConcatString seeps_desc; var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; @@ -2770,11 +3003,11 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, field_type == FieldType::Both) { var_name << interp_str; } - if(strncmp(field_name.c_str(), "SEEPS_MPR_SCORE", 15) == 0) + if(field_name.startswith("SEEPS_MPR_SCORE")) seeps_desc = "score"; - else if(strncmp(field_name.c_str(), "SEEPS_MPR_FCAT", 14) == 0) + else if(field_name.startswith("SEEPS_MPR_FCAT")) seeps_desc = "forecast category"; - else if(strncmp(field_name.c_str(), "SEEPS_MPR_OCAT", 14) == 0) + else if(field_name.startswith("SEEPS_MPR_OCAT")) seeps_desc = "observation category"; long_att << cs_erase << "SEEPS MPR " << seeps_desc << " for " @@ -2917,8 +3150,8 @@ void write_nbrhd_nc(const DataPlane &fcst_dp, const DataPlane &obs_dp, if(!fcst_flag && !obs_flag) return; // Allocate memory for the forecast and observation fields - fcst_data = new float [grid.nx()*grid.ny()]; - obs_data = new float [grid.nx()*grid.ny()]; + fcst_data = new float [grid.nxy()]; + obs_data = new float [grid.nxy()]; // Add the forecast variable if(fcst_flag) { 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 a2d64873b3..6ec2dd8f98 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -1031,20 +1031,22 @@ void GridStatVxOpt::set_perc_thresh(const PairDataPoint &pd) { // // Sort the input arrays // - NumArray fsort = pd.f_na; - NumArray osort = pd.o_na; - NumArray csort = pd.cmn_na; - fsort.sort_array(); - osort.sort_array(); - csort.sort_array(); + NumArray f_sort = pd.f_na; + NumArray o_sort = pd.o_na; + NumArray fcmn_sort = pd.fcmn_na; + NumArray ocmn_sort = pd.ocmn_na; + f_sort.sort_array(); + o_sort.sort_array(); + fcmn_sort.sort_array(); + ocmn_sort.sort_array(); // // Compute percentiles // - fcat_ta.set_perc(&fsort, &osort, &csort, &fcat_ta, &ocat_ta); - ocat_ta.set_perc(&fsort, &osort, &csort, &fcat_ta, &ocat_ta); - fcnt_ta.set_perc(&fsort, &osort, &csort, &fcnt_ta, &ocnt_ta); - ocnt_ta.set_perc(&fsort, &osort, &csort, &fcnt_ta, &ocnt_ta); + fcat_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcat_ta, &ocat_ta); + ocat_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcat_ta, &ocat_ta); + fcnt_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcnt_ta, &ocnt_ta); + ocnt_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcnt_ta, &ocnt_ta); return; } diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index edb59d8814..5532ea7e1d 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -100,10 +100,11 @@ // Added code for obs_qty_exc. // 049 12/11/21 Halley Gotway MET #1991 Fix VCNT output. // 050 02/11/22 Halley Gotway MET #2045 Fix HiRA output. -// 051 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main +// 051 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. // 052 09/29/22 Halley Gotway MET #2286 Refine GRIB1 table lookup logic. // 053 10/03/22 Prestopnik MET #2227 Remove using namespace netCDF from header files. // 054 04/29/24 Halley Gotway MET #2795 Move level mismatch warning. +// 055 07/05/24 Halley Gotway MET #2924 Support forecast climatology. // //////////////////////////////////////////////////////////////////////// @@ -600,7 +601,9 @@ void build_outfile_name(unixtime valid_ut, int lead_sec, void process_fcst_climo_files() { int j; int n_fcst; - DataPlaneArray fcst_dpa, cmn_dpa, csd_dpa; + DataPlaneArray fcst_dpa; + DataPlaneArray fcmn_dpa, fcsd_dpa; + DataPlaneArray ocmn_dpa, ocsd_dpa; unixtime file_ut, beg_ut, end_ut; // Loop through each of the fields to be verified and extract @@ -662,18 +665,28 @@ void process_fcst_climo_files() { } } // end for j - // Read climatology data - cmn_dpa = read_climo_data_plane_array( - conf_info.conf.lookup_array(conf_key_climo_mean_field, false), - i, fcst_dpa[0].valid(), grid); - csd_dpa = read_climo_data_plane_array( - conf_info.conf.lookup_array(conf_key_climo_stdev_field, false), - i, fcst_dpa[0].valid(), grid); + // Read forecast climatology data + fcmn_dpa = read_climo_data_plane_array( + conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), + i, fcst_dpa[0].valid(), grid); + fcsd_dpa = read_climo_data_plane_array( + conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), + i, fcst_dpa[0].valid(), grid); + + // Read observation climatology data + ocmn_dpa = read_climo_data_plane_array( + conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), + i, fcst_dpa[0].valid(), grid); + ocsd_dpa = read_climo_data_plane_array( + conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), + i, fcst_dpa[0].valid(), grid); // Store data for the current verification task conf_info.vx_opt[i].vx_pd.set_fcst_dpa(fcst_dpa); - conf_info.vx_opt[i].vx_pd.set_climo_mn_dpa(cmn_dpa); - conf_info.vx_opt[i].vx_pd.set_climo_sd_dpa(csd_dpa); + conf_info.vx_opt[i].vx_pd.set_fcst_climo_mn_dpa(fcmn_dpa); + conf_info.vx_opt[i].vx_pd.set_fcst_climo_sd_dpa(fcsd_dpa); + conf_info.vx_opt[i].vx_pd.set_obs_climo_mn_dpa(ocmn_dpa); + conf_info.vx_opt[i].vx_pd.set_obs_climo_sd_dpa(ocsd_dpa); // Get the valid time for the first field file_ut = fcst_dpa[0].valid(); @@ -697,10 +710,12 @@ void process_fcst_climo_files() { // Dump out the number of levels found mlog << Debug(2) - << "For " << fcst_info->magic_str() << " found " + << "For " << fcst_info->magic_str() << ", found " << n_fcst << " forecast levels, " - << cmn_dpa.n_planes() << " climatology mean levels, and " - << csd_dpa.n_planes() << " climatology standard deviation levels.\n"; + << fcmn_dpa.n_planes() << " forecast climatology mean and " + << fcsd_dpa.n_planes() << " standard deviation level(s), and " + << ocmn_dpa.n_planes() << " observation climatology mean and " + << ocsd_dpa.n_planes() << " standard deviation level(s).\n"; } // end for i @@ -944,7 +959,6 @@ void process_obs_file(int i_nc) { //////////////////////////////////////////////////////////////////////// void process_scores() { - int i, j, k, l, m; int n_cat, n_wind; ConcatString cs; @@ -969,75 +983,77 @@ void process_scores() { vl1l2_info = new VL1L2Info [n_wind]; // Compute scores for each PairData object and write output - for(i=0; iname_attr()); + shc.set_fcst_var(conf_info.vx_opt[i_vx].vx_pd.fcst_info->name_attr()); // Store the forecast variable units - shc.set_fcst_units(conf_info.vx_opt[i].vx_pd.fcst_info->units_attr()); + shc.set_fcst_units(conf_info.vx_opt[i_vx].vx_pd.fcst_info->units_attr()); // Set the forecast level name - shc.set_fcst_lev(conf_info.vx_opt[i].vx_pd.fcst_info->level_attr().c_str()); + shc.set_fcst_lev(conf_info.vx_opt[i_vx].vx_pd.fcst_info->level_attr().c_str()); // Store the observation variable name - shc.set_obs_var(conf_info.vx_opt[i].vx_pd.obs_info->name_attr()); + shc.set_obs_var(conf_info.vx_opt[i_vx].vx_pd.obs_info->name_attr()); // Store the observation variable units - cs = conf_info.vx_opt[i].vx_pd.obs_info->units_attr(); + cs = conf_info.vx_opt[i_vx].vx_pd.obs_info->units_attr(); if(cs.empty()) cs = na_string; shc.set_obs_units(cs); // Set the observation level name - shc.set_obs_lev(conf_info.vx_opt[i].vx_pd.obs_info->level_attr().c_str()); + shc.set_obs_lev(conf_info.vx_opt[i_vx].vx_pd.obs_info->level_attr().c_str()); // Set the forecast lead time - shc.set_fcst_lead_sec(conf_info.vx_opt[i].vx_pd.fcst_dpa[0].lead()); + shc.set_fcst_lead_sec(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa[0].lead()); // Set the forecast valid time - shc.set_fcst_valid_beg(conf_info.vx_opt[i].vx_pd.fcst_dpa[0].valid()); - shc.set_fcst_valid_end(conf_info.vx_opt[i].vx_pd.fcst_dpa[0].valid()); + shc.set_fcst_valid_beg(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa[0].valid()); + shc.set_fcst_valid_end(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa[0].valid()); // Set the observation lead time shc.set_obs_lead_sec(0); // Set the observation valid time - shc.set_obs_valid_beg(conf_info.vx_opt[i].vx_pd.beg_ut); - shc.set_obs_valid_end(conf_info.vx_opt[i].vx_pd.end_ut); + shc.set_obs_valid_beg(conf_info.vx_opt[i_vx].vx_pd.beg_ut); + shc.set_obs_valid_end(conf_info.vx_opt[i_vx].vx_pd.end_ut); // Loop through the message types - for(j=0; jmagic_str() + << conf_info.vx_opt[i_vx].vx_pd.fcst_info->magic_str() << " versus " - << conf_info.vx_opt[i].vx_pd.obs_info->magic_str() + << conf_info.vx_opt[i_vx].vx_pd.obs_info->magic_str() << ", for observation type " << pd_ptr->msg_typ << ", over region " << pd_ptr->mask_name << ", for interpolation method " @@ -1048,22 +1064,22 @@ void process_scores() { // List counts for reasons why observations were rejected cs << cs_erase << "Number of matched pairs = " << pd_ptr->n_obs << "\n" - << "Observations processed = " << conf_info.vx_opt[i].vx_pd.n_try << "\n" - << "Rejected: station id = " << conf_info.vx_opt[i].vx_pd.rej_sid << "\n" - << "Rejected: obs var name = " << conf_info.vx_opt[i].vx_pd.rej_var << "\n" - << "Rejected: valid time = " << conf_info.vx_opt[i].vx_pd.rej_vld << "\n" - << "Rejected: bad obs value = " << conf_info.vx_opt[i].vx_pd.rej_obs << "\n" - << "Rejected: off the grid = " << conf_info.vx_opt[i].vx_pd.rej_grd << "\n" - << "Rejected: topography = " << conf_info.vx_opt[i].vx_pd.rej_topo << "\n" - << "Rejected: level mismatch = " << conf_info.vx_opt[i].vx_pd.rej_lvl << "\n" - << "Rejected: quality marker = " << conf_info.vx_opt[i].vx_pd.rej_qty << "\n" - << "Rejected: message type = " << conf_info.vx_opt[i].vx_pd.rej_typ[j][k][l] << "\n" - << "Rejected: masking region = " << conf_info.vx_opt[i].vx_pd.rej_mask[j][k][l] << "\n" - << "Rejected: bad fcst value = " << conf_info.vx_opt[i].vx_pd.rej_fcst[j][k][l] << "\n" - << "Rejected: bad climo mean = " << conf_info.vx_opt[i].vx_pd.rej_cmn[j][k][l] << "\n" - << "Rejected: bad climo stdev = " << conf_info.vx_opt[i].vx_pd.rej_csd[j][k][l] << "\n" - << "Rejected: mpr filter = " << conf_info.vx_opt[i].vx_pd.rej_mpr[j][k][l] << "\n" - << "Rejected: duplicates = " << conf_info.vx_opt[i].vx_pd.rej_dup[j][k][l] << "\n"; + << "Observations processed = " << conf_info.vx_opt[i_vx].vx_pd.n_try << "\n" + << "Rejected: station id = " << conf_info.vx_opt[i_vx].vx_pd.rej_sid << "\n" + << "Rejected: obs var name = " << conf_info.vx_opt[i_vx].vx_pd.rej_var << "\n" + << "Rejected: valid time = " << conf_info.vx_opt[i_vx].vx_pd.rej_vld << "\n" + << "Rejected: bad obs value = " << conf_info.vx_opt[i_vx].vx_pd.rej_obs << "\n" + << "Rejected: off the grid = " << conf_info.vx_opt[i_vx].vx_pd.rej_grd << "\n" + << "Rejected: topography = " << conf_info.vx_opt[i_vx].vx_pd.rej_topo << "\n" + << "Rejected: level mismatch = " << conf_info.vx_opt[i_vx].vx_pd.rej_lvl << "\n" + << "Rejected: quality marker = " << conf_info.vx_opt[i_vx].vx_pd.rej_qty << "\n" + << "Rejected: message type = " << conf_info.vx_opt[i_vx].vx_pd.rej_typ[n] << "\n" + << "Rejected: masking region = " << conf_info.vx_opt[i_vx].vx_pd.rej_mask[n] << "\n" + << "Rejected: bad fcst value = " << conf_info.vx_opt[i_vx].vx_pd.rej_fcst[n] << "\n" + << "Rejected: bad climo mean = " << conf_info.vx_opt[i_vx].vx_pd.rej_cmn[n] << "\n" + << "Rejected: bad climo stdev = " << conf_info.vx_opt[i_vx].vx_pd.rej_csd[n] << "\n" + << "Rejected: mpr filter = " << conf_info.vx_opt[i_vx].vx_pd.rej_mpr[n] << "\n" + << "Rejected: duplicates = " << conf_info.vx_opt[i_vx].vx_pd.rej_dup[n] << "\n"; // Print report based on the number of matched pairs if(pd_ptr->n_obs > 0) { @@ -1076,88 +1092,88 @@ void process_scores() { } // Process percentile thresholds - conf_info.vx_opt[i].set_perc_thresh(pd_ptr); + conf_info.vx_opt[i_vx].set_perc_thresh(pd_ptr); // Write out the MPR lines - if(conf_info.vx_opt[i].output_flag[i_mpr] != STATOutputType::None) { + if(conf_info.vx_opt[i_vx].output_flag[i_mpr] != STATOutputType::None) { write_mpr_row(shc, pd_ptr, - conf_info.vx_opt[i].output_flag[i_mpr], + conf_info.vx_opt[i_vx].output_flag[i_mpr], stat_at, i_stat_row, txt_at[i_mpr], i_txt_row[i_mpr]); // Reset the observation valid time - shc.set_obs_valid_beg(conf_info.vx_opt[i].vx_pd.beg_ut); - shc.set_obs_valid_end(conf_info.vx_opt[i].vx_pd.end_ut); + shc.set_obs_valid_beg(conf_info.vx_opt[i_vx].vx_pd.beg_ut); + shc.set_obs_valid_end(conf_info.vx_opt[i_vx].vx_pd.end_ut); } // Write out the SEEPS MPR lines - if(conf_info.vx_opt[i].output_flag[i_seeps_mpr] != STATOutputType::None) { + if(conf_info.vx_opt[i_vx].output_flag[i_seeps_mpr] != STATOutputType::None) { write_seeps_mpr_row(shc, pd_ptr, - conf_info.vx_opt[i].output_flag[i_seeps_mpr], + conf_info.vx_opt[i_vx].output_flag[i_seeps_mpr], stat_at, i_stat_row, txt_at[i_seeps_mpr], i_txt_row[i_seeps_mpr]); // Reset the observation valid time - shc.set_obs_valid_beg(conf_info.vx_opt[i].vx_pd.beg_ut); - shc.set_obs_valid_end(conf_info.vx_opt[i].vx_pd.end_ut); + shc.set_obs_valid_beg(conf_info.vx_opt[i_vx].vx_pd.beg_ut); + shc.set_obs_valid_end(conf_info.vx_opt[i_vx].vx_pd.end_ut); } // Write out the SEEPS lines - if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType::None) { - compute_aggregated_seeps(pd_ptr, &pd_ptr->seeps); - write_seeps_row(shc, &pd_ptr->seeps, - conf_info.vx_opt[i].output_flag[i_seeps], + if(conf_info.vx_opt[i_vx].output_flag[i_seeps] != STATOutputType::None) { + compute_aggregated_seeps(pd_ptr, &pd_ptr->seeps_agg); + write_seeps_row(shc, &pd_ptr->seeps_agg, + conf_info.vx_opt[i_vx].output_flag[i_seeps], stat_at, i_stat_row, txt_at[i_seeps], i_txt_row[i_seeps]); } // Compute CTS scores - if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - conf_info.vx_opt[i].fcat_ta.n() > 0 && - (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { + if(!conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + conf_info.vx_opt[i_vx].fcat_ta.n() > 0 && + (conf_info.vx_opt[i_vx].output_flag[i_fho] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_ctc] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_eclv] != STATOutputType::None)) { // Initialize - for(m=0; mis_prob() && - conf_info.vx_opt[i].fcat_ta.n() > 1 && - (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None)) { + if(!conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + conf_info.vx_opt[i_vx].fcat_ta.n() > 1 && + (conf_info.vx_opt[i_vx].output_flag[i_mctc] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None)) { // Initialize mcts_info.clear(); // Compute MCTS Info - do_mcts(mcts_info, i, pd_ptr); + do_mcts(mcts_info, i_vx, pd_ptr); // Write out MCTC - if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None && + if(conf_info.vx_opt[i_vx].output_flag[i_mctc] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mctc_row(shc, mcts_info, - conf_info.vx_opt[i].output_flag[i_mctc], + conf_info.vx_opt[i_vx].output_flag[i_mctc], stat_at, i_stat_row, txt_at[i_mctc], i_txt_row[i_mctc]); } // Write out MCTS - if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None && + if(conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mcts_row(shc, mcts_info, - conf_info.vx_opt[i].output_flag[i_mcts], + conf_info.vx_opt[i_vx].output_flag[i_mcts], stat_at, i_stat_row, txt_at[i_mcts], i_txt_row[i_mcts]); } } // end Compute MCTS scores // Compute CNT, SL1L2, and SAL1L2 scores - if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { - do_cnt_sl1l2(conf_info.vx_opt[i], pd_ptr); + if(!conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + (conf_info.vx_opt[i_vx].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_sal1l2] != STATOutputType::None)) { + do_cnt_sl1l2(conf_info.vx_opt[i_vx], pd_ptr); } // Compute VL1L2 and VAL1L2 partial sums for UGRD and VGRD - if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - conf_info.vx_opt[i].vx_pd.fcst_info->is_v_wind() && - conf_info.vx_opt[i].vx_pd.fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { + if(!conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_v_wind() && + conf_info.vx_opt[i_vx].vx_pd.fcst_info->uv_index() >= 0 && + (conf_info.vx_opt[i_vx].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1220,19 +1236,19 @@ void process_scores() { shc.set_obs_var(ugrd_vgrd_abbr_str); // Initialize - for(m=0; muv_index(); + int u_vx = conf_info.vx_opt[i_vx].vx_pd.fcst_info->uv_index(); // Check to make sure message types, masking regions, // and interpolation methods match - if(conf_info.vx_opt[i].get_n_msg_typ() != - conf_info.vx_opt[ui].get_n_msg_typ() || - conf_info.vx_opt[i].get_n_mask() != - conf_info.vx_opt[ui].get_n_mask() || - conf_info.vx_opt[i].get_n_interp() != - conf_info.vx_opt[ui].get_n_interp()) { + if(conf_info.vx_opt[i_vx].get_n_msg_typ() != + conf_info.vx_opt[u_vx].get_n_msg_typ() || + conf_info.vx_opt[i_vx].get_n_mask() != + conf_info.vx_opt[u_vx].get_n_mask() || + conf_info.vx_opt[i_vx].get_n_interp() != + conf_info.vx_opt[u_vx].get_n_interp()) { mlog << Warning << "\nprocess_scores() -> " << "when computing VL1L2 and/or VAL1L2 vector " << "partial sums, the U and V components must " @@ -1243,106 +1259,110 @@ void process_scores() { } // Compute VL1L2 and VAL1L2 - do_vl1l2(vl1l2_info, i, - &conf_info.vx_opt[ui].vx_pd.pd[j][k][l], - &conf_info.vx_opt[i].vx_pd.pd[j][k][l]); + do_vl1l2(vl1l2_info, i_vx, + &conf_info.vx_opt[u_vx].vx_pd.pd[n], + &conf_info.vx_opt[i_vx].vx_pd.pd[n]); // Loop through all of the wind speed thresholds - for(m=0; m 0) { - write_vl1l2_row(shc, vl1l2_info[m], - conf_info.vx_opt[i].output_flag[i_vl1l2], + if(conf_info.vx_opt[i_vx].output_flag[i_vl1l2] != STATOutputType::None && + vl1l2_info[i_wind].vcount > 0) { + write_vl1l2_row(shc, vl1l2_info[i_wind], + conf_info.vx_opt[i_vx].output_flag[i_vl1l2], stat_at, i_stat_row, txt_at[i_vl1l2], i_txt_row[i_vl1l2]); } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && - vl1l2_info[m].vacount > 0) { - write_val1l2_row(shc, vl1l2_info[m], - conf_info.vx_opt[i].output_flag[i_val1l2], + if(conf_info.vx_opt[i_vx].output_flag[i_val1l2] != STATOutputType::None && + vl1l2_info[i_wind].vacount > 0) { + write_val1l2_row(shc, vl1l2_info[i_wind], + conf_info.vx_opt[i_vx].output_flag[i_val1l2], stat_at, i_stat_row, txt_at[i_val1l2], i_txt_row[i_val1l2]); } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && - vl1l2_info[m].vcount > 0) { - write_vcnt_row(shc, vl1l2_info[m], - conf_info.vx_opt[i].output_flag[i_vcnt], + if(conf_info.vx_opt[i_vx].output_flag[i_vcnt] != STATOutputType::None && + vl1l2_info[i_wind].vcount > 0) { + write_vcnt_row(shc, vl1l2_info[i_wind], + conf_info.vx_opt[i_vx].output_flag[i_vcnt], stat_at, i_stat_row, txt_at[i_vcnt], i_txt_row[i_vcnt]); } - } // end for m + } // end for i // Reset the forecast variable name - shc.set_fcst_var(conf_info.vx_opt[i].vx_pd.fcst_info->name_attr()); + shc.set_fcst_var(conf_info.vx_opt[i_vx].vx_pd.fcst_info->name_attr()); // Reset the observation variable name - shc.set_obs_var(conf_info.vx_opt[i].vx_pd.obs_info->name_attr()); + shc.set_obs_var(conf_info.vx_opt[i_vx].vx_pd.obs_info->name_attr()); } // end Compute VL1L2 and VAL1L2 // Compute PCT counts and scores - if(conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { - do_pct(conf_info.vx_opt[i], pd_ptr); + if(conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + (conf_info.vx_opt[i_vx].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_prc] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_eclv] != STATOutputType::None)) { + do_pct(conf_info.vx_opt[i_vx], pd_ptr); } // Reset the verification masking region - shc.set_mask(conf_info.vx_opt[i].mask_name[k].c_str()); + shc.set_mask(conf_info.vx_opt[i_vx].mask_name[i_mask].c_str()); - } // end for l + } // end for i_interp // Apply HiRA ensemble verification logic - if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - conf_info.vx_opt[i].hira_info.flag && - (conf_info.vx_opt[i].output_flag[i_ecnt] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_rps] != STATOutputType::None)) { + if(!conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + conf_info.vx_opt[i_vx].hira_info.flag && + (conf_info.vx_opt[i_vx].output_flag[i_ecnt] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_rps] != STATOutputType::None)) { + + int n = conf_info.vx_opt[i_vx].vx_pd.three_to_one(i_msg_typ, i_mask, 0); - pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][0]; + pd_ptr = &conf_info.vx_opt[i_vx].vx_pd.pd[n]; // Process percentile thresholds - conf_info.vx_opt[i].set_perc_thresh(pd_ptr); + conf_info.vx_opt[i_vx].set_perc_thresh(pd_ptr); // Appy HiRA verification and write ensemble output - do_hira_ens(i, pd_ptr); + do_hira_ens(i_vx, pd_ptr); } // end HiRA for ensembles // Apply HiRA probabilistic verification logic - if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - conf_info.vx_opt[i].hira_info.flag && - (conf_info.vx_opt[i].output_flag[i_mpr] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None)) { + if(!conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_prob() && + conf_info.vx_opt[i_vx].hira_info.flag && + (conf_info.vx_opt[i_vx].output_flag[i_mpr] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i_vx].output_flag[i_prc] != STATOutputType::None)) { - pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][0]; + int n = conf_info.vx_opt[i_vx].vx_pd.three_to_one(i_msg_typ, i_mask, 0); + + pd_ptr = &conf_info.vx_opt[i_vx].vx_pd.pd[n]; // Process percentile thresholds - conf_info.vx_opt[i].set_perc_thresh(pd_ptr); + conf_info.vx_opt[i_vx].set_perc_thresh(pd_ptr); // Apply HiRA verification and write probabilistic output - do_hira_prob(i, pd_ptr); + do_hira_prob(i_vx, pd_ptr); } // end HiRA for probabilities - } // end for k - } // end for j + } // end for i_mask + } // end for i_msg_typ - mlog << Debug(2) - << "\n" << sep_str << "\n\n"; - } // end for i + mlog << Debug(2) << "\n" << sep_str << "\n\n"; + + } // end for i_vx // Deallocate memory if(cts_info) { delete [] cts_info; cts_info = (CTSInfo *) nullptr; } @@ -1466,8 +1486,9 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { mlog << Debug(2) << "Computing Scalar Partial Sums and Continuous Statistics.\n"; - // Determine the number of climo CDF bins - n_bin = (pd_ptr->cmn_na.n_valid() > 0 && pd_ptr->csd_na.n_valid() > 0 ? + // Determine the number of observation climo CDF bins + n_bin = (pd_ptr->ocmn_na.n_valid() > 0 && + pd_ptr->ocsd_na.n_valid() > 0 ? vx_opt.get_n_cdf_bin() : 1); if(n_bin > 1) { @@ -1702,8 +1723,9 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { mlog << Debug(2) << "Computing Probabilistic Statistics.\n"; - // Determine the number of climo CDF bins - n_bin = (pd_ptr->cmn_na.n_valid() > 0 && pd_ptr->csd_na.n_valid() > 0 ? + // Determine the number of observation climo CDF bins + n_bin = (pd_ptr->ocmn_na.n_valid() > 0 && + pd_ptr->ocsd_na.n_valid() > 0 ? vx_opt.get_n_cdf_bin() : 1); if(n_bin > 1) { @@ -1868,9 +1890,17 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { // Check for values if(f_ens.n() == 0) continue; + // TODO: Add has_climo member function instead + // Skip points where climatology has been specified but is bad data - if(conf_info.vx_opt[i_vx].vx_pd.climo_mn_dpa.n_planes() > 0 && - is_bad_data(pd_ptr->cmn_na[j])) continue; + if((conf_info.vx_opt[i_vx].vx_pd.fcmn_dpa.n_planes() > 0 && + is_bad_data(pd_ptr->fcmn_na[j])) || + (conf_info.vx_opt[i_vx].vx_pd.ocmn_dpa.n_planes() > 0 && + is_bad_data(pd_ptr->ocmn_na[j]))) continue; + + // Store climo data + ClimoPntInfo cpi(pd_ptr->fcmn_na[j], pd_ptr->fcsd_na[j], + pd_ptr->ocmn_na[j], pd_ptr->ocsd_na[j]); // Store the observation value hira_pd.add_point_obs(pd_ptr->sid_sa[j].c_str(), @@ -1878,8 +1908,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { pd_ptr->x_na[j], pd_ptr->y_na[j], pd_ptr->vld_ta[j], pd_ptr->lvl_na[j], pd_ptr->elv_na[j], pd_ptr->o_na[j], pd_ptr->o_qc_sa[j].c_str(), - pd_ptr->cmn_na[j], pd_ptr->csd_na[j], - pd_ptr->wgt_na[j]); + cpi, pd_ptr->wgt_na[j]); // Store the ensemble mean and member values hira_pd.mn_na.add(f_ens.mean()); @@ -1946,9 +1975,9 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { // If prob_cat_thresh is empty, try to select other thresholds if(rps_info.fthresh.n() == 0) { - // Use climo data, if avaiable - if(hira_pd.cmn_na.n_valid() > 0 && - hira_pd.csd_na.n_valid() > 0 && + // Use observation climo data, if avaiable + if(hira_pd.ocmn_na.n_valid() > 0 && + hira_pd.ocsd_na.n_valid() > 0 && conf_info.vx_opt[i_vx].cdf_info.cdf_ta.n() > 0) { mlog << Debug(3) << "Resetting the empty HiRA \"" << conf_key_prob_cat_thresh << "\" thresholds to " @@ -1995,8 +2024,8 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { PairDataPoint hira_pd; int i, j, k, lvl_blw, lvl_abv; - double f_cov, cmn_cov; - NumArray cmn_cov_na; + double f_cov, ocmn_cov; + NumArray ocmn_cov_na; SingleThresh cat_thresh; PCTInfo pct_info; @@ -2023,20 +2052,23 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { // Initialize hira_pd.clear(); pct_info.clear(); - cmn_cov_na.erase(); + ocmn_cov_na.erase(); // Loop through matched pairs and replace the forecast value // with the HiRA fractional coverage. for(k=0; kn_obs; k++) { + // Store climo data + ClimoPntInfo cpi(pd_ptr->fcmn_na[k], pd_ptr->fcsd_na[k], + pd_ptr->ocmn_na[k], pd_ptr->ocsd_na[k]); + // Compute the fractional coverage forecast value using the // observation level value find_vert_lvl(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa, pd_ptr->lvl_na[k], lvl_blw, lvl_abv); f_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa, - pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], - pd_ptr->cmn_na[k], pd_ptr->csd_na[k], + pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], &cpi, InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, @@ -2046,25 +2078,25 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { // Check for bad data if(is_bad_data(f_cov)) continue; - // Compute the fractional coverage for the climatological mean - if(conf_info.vx_opt[i_vx].vx_pd.climo_mn_dpa.n_planes() > 0) { + // Compute the climatological event probability as the fractional + // coverage of the observation climatology mean field + if(conf_info.vx_opt[i_vx].vx_pd.ocmn_dpa.n_planes() > 0) { // Interpolate to the observation level - find_vert_lvl(conf_info.vx_opt[i_vx].vx_pd.climo_mn_dpa, + find_vert_lvl(conf_info.vx_opt[i_vx].vx_pd.ocmn_dpa, pd_ptr->lvl_na[k], lvl_blw, lvl_abv); - cmn_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.climo_mn_dpa, - pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], - pd_ptr->cmn_na[k], pd_ptr->csd_na[k], - InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], - conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), - conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, - conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), - pd_ptr->lvl_na[k], lvl_blw, lvl_abv, &cat_thresh); + ocmn_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.ocmn_dpa, + pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], &cpi, + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], + conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), + conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, + conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), + pd_ptr->lvl_na[k], lvl_blw, lvl_abv, &cat_thresh); // Check for bad data - if(is_bad_data(cmn_cov)) continue; - else cmn_cov_na.add(cmn_cov); + if(is_bad_data(ocmn_cov)) continue; + else ocmn_cov_na.add(ocmn_cov); } // Store the fractional coverage pair @@ -2073,8 +2105,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->vld_ta[k], pd_ptr->lvl_na[k], pd_ptr->elv_na[k], f_cov, pd_ptr->o_na[k], pd_ptr->o_qc_sa[k].c_str(), - pd_ptr->cmn_na[k], pd_ptr->csd_na[k], pd_ptr->wgt_na[k]); - + cpi, pd_ptr->wgt_na[k]); } // end for k mlog << Debug(2) @@ -2103,8 +2134,8 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(hira_pd, (STATOutputType::None!=conf_info.vx_opt[i_vx].output_flag[i_pstd]), - pct_info, &cmn_cov_na); + bool pstd_flag = conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType::None; + compute_pctinfo(hira_pd, pstd_flag, pct_info, &ocmn_cov_na); // Set the contents of the output threshold columns shc.set_fcst_thresh (conf_info.vx_opt[i_vx].fcat_ta[i]); diff --git a/src/tools/core/point_stat/point_stat.h b/src/tools/core/point_stat/point_stat.h index abe34d25ac..894a79559b 100644 --- a/src/tools/core/point_stat/point_stat.h +++ b/src/tools/core/point_stat/point_stat.h @@ -15,11 +15,8 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 11/11/08 Halley Gotway New -// 001 09/28/22 Prestopnik MET #2227 Remove namespace std and netCDF from header files +// 001 09/28/22 Prestopnik MET #2227 Remove namespace std and netCDF from header files. // -// -//////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////// #ifndef __POINT_STAT_H__ diff --git a/src/tools/core/point_stat/point_stat_conf_info.cc b/src/tools/core/point_stat/point_stat_conf_info.cc index 1f28857cdc..0f03bcb632 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.cc +++ b/src/tools/core/point_stat/point_stat_conf_info.cc @@ -841,8 +841,8 @@ void PointStatVxOpt::process_config(GrdFileType ftype, clear(); // Allocate new VarInfo objects - vx_pd.fcst_info = info_factory.new_var_info(ftype); - vx_pd.obs_info = new VarInfoGrib; + vx_pd.set_fcst_info(info_factory.new_var_info(ftype)); + vx_pd.set_obs_info(new VarInfoGrib); // Set the VarInfo objects vx_pd.fcst_info->set_dict(fdict); @@ -1077,7 +1077,7 @@ void PointStatVxOpt::set_vx_pd(PointStatConfInfo *conf_info) { } // Define the dimensions - vx_pd.set_pd_size(n_msg_typ, n_mask, n_interp); + vx_pd.set_size(n_msg_typ, n_mask, n_interp); // Store the MPR filter threshold vx_pd.set_mpr_thresh(mpr_sa, mpr_ta); @@ -1185,20 +1185,22 @@ void PointStatVxOpt::set_perc_thresh(const PairDataPoint *pd_ptr) { // // Sort the input arrays // - NumArray fsort = pd_ptr->f_na; - NumArray osort = pd_ptr->o_na; - NumArray csort = pd_ptr->cmn_na; - fsort.sort_array(); - osort.sort_array(); - csort.sort_array(); + NumArray f_sort = pd_ptr->f_na; + NumArray o_sort = pd_ptr->o_na; + NumArray fcmn_sort = pd_ptr->fcmn_na; + NumArray ocmn_sort = pd_ptr->ocmn_na; + f_sort.sort_array(); + o_sort.sort_array(); + fcmn_sort.sort_array(); + ocmn_sort.sort_array(); // // Compute percentiles // - fcat_ta.set_perc(&fsort, &osort, &csort, &fcat_ta, &ocat_ta); - ocat_ta.set_perc(&fsort, &osort, &csort, &fcat_ta, &ocat_ta); - fcnt_ta.set_perc(&fsort, &osort, &csort, &fcnt_ta, &ocnt_ta); - ocnt_ta.set_perc(&fsort, &osort, &csort, &fcnt_ta, &ocnt_ta); + fcat_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcat_ta, &ocat_ta); + ocat_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcat_ta, &ocat_ta); + fcnt_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcnt_ta, &ocnt_ta); + ocnt_ta.set_perc(&f_sort, &o_sort, &fcmn_sort, &ocmn_sort, &fcnt_ta, &ocnt_ta); return; } diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index ebbb43e27a..9373c0e040 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -32,9 +32,10 @@ // 011 05/28/21 Halley Gotway Add MCTS HSS_EC output. // 012 01/20/22 Halley Gotway MET #2003 Add PSTD BRIERCL output. // 013 05/25/22 Halley Gotway MET #2147 Add CTS HSS_EC output. -// 014 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main -// 015 10/03/22 Presotpnik MET #2227 Remove namespace netCDF from header files -// 016 01/29/24 Halley Gotway MET #2801 Configure time difference warnings +// 014 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. +// 015 10/03/22 Presotpnik MET #2227 Remove namespace netCDF from header files. +// 016 01/29/24 Halley Gotway MET #2801 Configure time difference warnings. +// 017 07/05/24 Halley Gotway MET #2924 Support forecast climatology. // //////////////////////////////////////////////////////////////////////// @@ -687,8 +688,8 @@ void process_scores() { const char *method_name = "process_scores() "; // Climatology mean and standard deviation - DataPlane cmn_dp, csd_dp; - bool cmn_flag, csd_flag; + DataPlane fcmn_dp, fcsd_dp; + DataPlane ocmn_dp, ocsd_dp; // Number of points skipped due to valid data threshold int n_skip_zero = 0; @@ -737,21 +738,34 @@ void process_scores() { } // Read climatology data for the current series entry - cmn_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_mean_field, false), - i_fcst, fcst_dp.valid(), grid); - csd_dp = read_climo_data_plane( - conf_info.conf.lookup_array(conf_key_climo_stdev_field, false), - i_fcst, fcst_dp.valid(), grid); - - cmn_flag = (cmn_dp.nx() == fcst_dp.nx() && cmn_dp.ny() == fcst_dp.ny()); - csd_flag = (csd_dp.nx() == fcst_dp.nx() && csd_dp.ny() == fcst_dp.ny()); + fcmn_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), + i_fcst, fcst_dp.valid(), grid); + fcsd_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), + i_fcst, fcst_dp.valid(), grid); + ocmn_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), + i_fcst, fcst_dp.valid(), grid); + ocsd_dp = read_climo_data_plane( + conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), + i_fcst, fcst_dp.valid(), grid); + + bool fcmn_flag = (fcmn_dp.nx() == fcst_dp.nx() && + fcmn_dp.ny() == fcst_dp.ny()); + bool fcsd_flag = (fcsd_dp.nx() == fcst_dp.nx() && + fcsd_dp.ny() == fcst_dp.ny()); + bool ocmn_flag = (ocmn_dp.nx() == fcst_dp.nx() && + ocmn_dp.ny() == fcst_dp.ny()); + bool ocsd_flag = (ocsd_dp.nx() == fcst_dp.nx() && + ocsd_dp.ny() == fcst_dp.ny()); mlog << Debug(3) - << "Found " << (cmn_flag ? 1 : 0) - << " climatology mean and " << (csd_flag ? 1 : 0) - << " climatology standard deviation field(s) for forecast " - << fcst_info->magic_str() << ".\n"; + << "For " << fcst_info->magic_str() << ", found " + << (fcmn_flag ? 0 : 1) << " forecast climatology mean and " + << (fcsd_flag ? 0 : 1) << " standard deviation field(s), and " + << (ocmn_flag ? 0 : 1) << " observation climatology mean and " + << (ocsd_flag ? 0 : 1) << " standard deviation field(s).\n"; // Setup the output NetCDF file on the first pass if(nc_out == (NcFile *) 0) setup_nc_file(fcst_info, obs_info); @@ -771,16 +785,21 @@ void process_scores() { DefaultTO.one_to_two(grid.nx(), grid.ny(), i_point+i, x, y); // Skip points outside the mask and bad data - if(!conf_info.mask_area(x, y) || - is_bad_data(fcst_dp(x, y)) || - is_bad_data(obs_dp(x,y)) || - (cmn_flag && is_bad_data(cmn_dp(x, y))) || - (csd_flag && is_bad_data(csd_dp(x, y)))) continue; - - pd_ptr[i].add_grid_pair(fcst_dp(x, y), obs_dp(x, y), - (cmn_flag ? cmn_dp(x, y) : bad_data_double), - (csd_flag ? csd_dp(x, y) : bad_data_double), - default_grid_weight); + if(!conf_info.mask_area(x, y) || + is_bad_data(fcst_dp(x, y)) || + is_bad_data(obs_dp(x,y)) || + (fcmn_flag && is_bad_data(fcmn_dp(x, y))) || + (fcsd_flag && is_bad_data(fcsd_dp(x, y))) || + (ocmn_flag && is_bad_data(ocmn_dp(x, y))) || + (ocsd_flag && is_bad_data(ocsd_dp(x, y)))) continue; + + // Store climo data + ClimoPntInfo cpi((fcmn_flag ? fcmn_dp(x, y) : bad_data_double), + (fcsd_flag ? fcsd_dp(x, y) : bad_data_double), + (ocmn_flag ? ocmn_dp(x, y) : bad_data_double), + (ocsd_flag ? ocsd_dp(x, y) : bad_data_double)); + + pd_ptr[i].add_grid_pair(fcst_dp(x, y), obs_dp(x, y), cpi, default_grid_weight); } // end for i @@ -860,8 +879,10 @@ void process_scores() { for(i=0; i #include #include @@ -1770,10 +1770,9 @@ void aggr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // // Append the unit vectors with no climatological values // - m[key].pd_u.add_grid_pair(uf, uo, bad_data_double, - bad_data_double, default_grid_weight); - m[key].pd_v.add_grid_pair(vf, vo, bad_data_double, - bad_data_double, default_grid_weight); + ClimoPntInfo cpi; + m[key].pd_u.add_grid_pair(uf, uo, cpi, default_grid_weight); + m[key].pd_v.add_grid_pair(vf, vo, cpi, default_grid_weight); // // Keep track of the unique header column entries @@ -1797,9 +1796,11 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, VL1L2Info v_info; MPRData cur; ConcatString hdr, key; - double uf, uo, ucmn, ucsd; - double vf, vo, vcmn, vcsd; - double fcst_wind, obs_wind, cmn_wind, csd_wind; + double uf, uo, ufcmn, ufcsd, uocmn, uocsd; + double vf, vo, vfcmn, vfcsd, vocmn, vocsd; + double fcst_wind, obs_wind; + double fcmn_wind, fcsd_wind; + double ocmn_wind, ocsd_wind; bool is_ugrd; int i; map::iterator it; @@ -1819,14 +1820,18 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, parse_mpr_line(line, cur); is_ugrd = (cur.fcst_var == ugrd_abbr_str); - uf = (is_ugrd ? cur.fcst : bad_data_double); - uo = (is_ugrd ? cur.obs : bad_data_double); - ucmn = (is_ugrd ? cur.climo_mean : bad_data_double); - ucsd = (is_ugrd ? cur.climo_stdev : bad_data_double); - vf = (is_ugrd ? bad_data_double : cur.fcst); - vo = (is_ugrd ? bad_data_double : cur.obs); - vcmn = (is_ugrd ? bad_data_double : cur.climo_mean); - vcsd = (is_ugrd ? bad_data_double : cur.climo_stdev); + uf = (is_ugrd ? cur.fcst : bad_data_double); + uo = (is_ugrd ? cur.obs : bad_data_double); + ufcmn = (is_ugrd ? cur.fcst_climo_mean : bad_data_double); + ufcsd = (is_ugrd ? cur.fcst_climo_stdev : bad_data_double); + uocmn = (is_ugrd ? cur.obs_climo_mean : bad_data_double); + uocsd = (is_ugrd ? cur.obs_climo_stdev : bad_data_double); + vf = (is_ugrd ? bad_data_double : cur.fcst); + vo = (is_ugrd ? bad_data_double : cur.obs); + vfcmn = (is_ugrd ? bad_data_double : cur.fcst_climo_mean); + vfcsd = (is_ugrd ? bad_data_double : cur.fcst_climo_stdev); + vocmn = (is_ugrd ? bad_data_double : cur.obs_climo_mean); + vocsd = (is_ugrd ? bad_data_double : cur.obs_climo_stdev); // // Build header string for matching UGRD and VGRD lines @@ -1880,10 +1885,10 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // Initialize values // aggr.hdr_sa.add(hdr); - aggr.pd_u.add_grid_pair(uf, uo, ucmn, ucsd, - default_grid_weight); - aggr.pd_v.add_grid_pair(vf, vo, vcmn, vcsd, - default_grid_weight); + ClimoPntInfo u_cpi(ufcmn, ufcsd, uocmn, uocsd); + ClimoPntInfo v_cpi(vfcmn, vfcsd, vocmn, vocsd); + aggr.pd_u.add_grid_pair(uf, uo, u_cpi, default_grid_weight); + aggr.pd_v.add_grid_pair(vf, vo, v_cpi, default_grid_weight); // // Add the new map entry @@ -1927,24 +1932,28 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // // Update the existing values // - if(!is_bad_data(uf)) m[key].pd_u.f_na.set(i, uf); - if(!is_bad_data(uo)) m[key].pd_u.o_na.set(i, uo); - if(!is_bad_data(ucmn)) m[key].pd_u.cmn_na.set(i, ucmn); - if(!is_bad_data(ucsd)) m[key].pd_u.csd_na.set(i, ucsd); - if(!is_bad_data(vf)) m[key].pd_v.f_na.set(i, vf); - if(!is_bad_data(vo)) m[key].pd_v.o_na.set(i, vo); - if(!is_bad_data(vcmn)) m[key].pd_v.cmn_na.set(i, vcmn); - if(!is_bad_data(vcsd)) m[key].pd_v.csd_na.set(i, vcsd); + if(!is_bad_data(uf)) m[key].pd_u.f_na.set(i, uf); + if(!is_bad_data(uo)) m[key].pd_u.o_na.set(i, uo); + if(!is_bad_data(ufcmn)) m[key].pd_u.fcmn_na.set(i, ufcmn); + if(!is_bad_data(ufcsd)) m[key].pd_u.fcsd_na.set(i, ufcsd); + if(!is_bad_data(uocmn)) m[key].pd_u.ocmn_na.set(i, uocmn); + if(!is_bad_data(uocsd)) m[key].pd_u.ocsd_na.set(i, uocsd); + if(!is_bad_data(vf)) m[key].pd_v.f_na.set(i, vf); + if(!is_bad_data(vo)) m[key].pd_v.o_na.set(i, vo); + if(!is_bad_data(vfcmn)) m[key].pd_v.fcmn_na.set(i, vfcmn); + if(!is_bad_data(vfcsd)) m[key].pd_v.fcsd_na.set(i, vfcsd); + if(!is_bad_data(vocmn)) m[key].pd_v.ocmn_na.set(i, vocmn); + if(!is_bad_data(vocsd)) m[key].pd_v.ocsd_na.set(i, vocsd); } // // Add data for a new header entry // else { m[key].hdr_sa.add(hdr); - m[key].pd_u.add_grid_pair(uf, uo, ucmn, ucsd, - default_grid_weight); - m[key].pd_v.add_grid_pair(vf, vo, vcmn, vcsd, - default_grid_weight); + ClimoPntInfo u_cpi(ufcmn, ufcsd, uocmn, uocsd); + ClimoPntInfo v_cpi(vfcmn, vfcsd, vocmn, vocsd); + m[key].pd_u.add_grid_pair(uf, uo, u_cpi, default_grid_weight); + m[key].pd_v.add_grid_pair(vf, vo, v_cpi, default_grid_weight); } } @@ -2011,18 +2020,25 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, job.out_obs_wind_thresh.get_type() != thresh_na) { // Compute wind speeds - fcst_wind = convert_u_v_to_wind(it->second.pd_u.f_na[i], - it->second.pd_v.f_na[i]); - obs_wind = convert_u_v_to_wind(it->second.pd_u.o_na[i], - it->second.pd_v.o_na[i]); - cmn_wind = convert_u_v_to_wind(it->second.pd_u.cmn_na[i], - it->second.pd_v.cmn_na[i]); - csd_wind = convert_u_v_to_wind(it->second.pd_u.csd_na[i], - it->second.pd_v.csd_na[i]); + fcst_wind = convert_u_v_to_wind(it->second.pd_u.f_na[i], + it->second.pd_v.f_na[i]); + obs_wind = convert_u_v_to_wind(it->second.pd_u.o_na[i], + it->second.pd_v.o_na[i]); + fcmn_wind = convert_u_v_to_wind(it->second.pd_u.fcmn_na[i], + it->second.pd_v.fcmn_na[i]); + fcsd_wind = convert_u_v_to_wind(it->second.pd_u.fcsd_na[i], + it->second.pd_v.fcsd_na[i]); + ocmn_wind = convert_u_v_to_wind(it->second.pd_u.ocmn_na[i], + it->second.pd_v.ocmn_na[i]); + ocsd_wind = convert_u_v_to_wind(it->second.pd_u.ocsd_na[i], + it->second.pd_v.ocsd_na[i]); + + // Store climo data + ClimoPntInfo cpi(fcmn_wind, fcsd_wind, ocmn_wind, ocsd_wind); // No climo mean and standard deviation in the input VL1L2 lines, // so just fill with bad data. - if(!check_fo_thresh(fcst_wind, obs_wind, cmn_wind, csd_wind, + if(!check_fo_thresh(fcst_wind, obs_wind, cpi, job.out_fcst_wind_thresh, job.out_obs_wind_thresh, job.out_wind_logic)) { mlog << Debug(4) << "aggr_mpr_wind_lines() -> " @@ -2076,15 +2092,14 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // // Convert to and append unit vectors // + ClimoPntInfo cpi; aggr.hdr_sa.add(it->second.hdr_sa[i]); convert_u_v_to_unit(it->second.pd_u.f_na[i], it->second.pd_v.f_na[i], uf, vf); convert_u_v_to_unit(it->second.pd_u.o_na[i], it->second.pd_v.o_na[i], uo, vo); - aggr.pd_u.add_grid_pair(uf, uo, bad_data_double, - bad_data_double, default_grid_weight); - aggr.pd_v.add_grid_pair(vf, vo, bad_data_double, - bad_data_double, default_grid_weight); + aggr.pd_u.add_grid_pair(uf, uo, cpi, default_grid_weight); + aggr.pd_v.add_grid_pair(vf, vo, cpi, default_grid_weight); } // @@ -2151,17 +2166,21 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, aggr.pd.f_na.clear(); aggr.pd.o_na.clear(); - aggr.pd.cmn_na.clear(); - aggr.pd.csd_na.clear(); - aggr.pd.cdf_na.clear(); + aggr.pd.fcmn_na.clear(); + aggr.pd.fcsd_na.clear(); + aggr.pd.ocmn_na.clear(); + aggr.pd.ocsd_na.clear(); + aggr.pd.ocdf_na.clear(); aggr.pd.wgt_na.clear(); aggr.pd.n_obs = 1; aggr.pd.f_na.add(cur.fcst); aggr.pd.o_na.add(cur.obs); - aggr.pd.cmn_na.add(cur.climo_mean); - aggr.pd.csd_na.add(cur.climo_stdev); - aggr.pd.cdf_na.add(cur.climo_cdf); + aggr.pd.fcmn_na.add(cur.fcst_climo_mean); + aggr.pd.fcsd_na.add(cur.fcst_climo_stdev); + aggr.pd.ocmn_na.add(cur.obs_climo_mean); + aggr.pd.ocsd_na.add(cur.obs_climo_stdev); + aggr.pd.ocdf_na.add(cur.obs_climo_cdf); aggr.pd.wgt_na.add(default_grid_weight); aggr.fcst_var = cur.fcst_var; @@ -2188,9 +2207,11 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, m[key].pd.n_obs++; m[key].pd.f_na.add(cur.fcst); m[key].pd.o_na.add(cur.obs); - m[key].pd.cmn_na.add(cur.climo_mean); - m[key].pd.csd_na.add(cur.climo_stdev); - m[key].pd.cdf_na.add(cur.climo_cdf); + m[key].pd.fcmn_na.add(cur.fcst_climo_mean); + m[key].pd.fcsd_na.add(cur.fcst_climo_stdev); + m[key].pd.ocmn_na.add(cur.obs_climo_mean); + m[key].pd.ocsd_na.add(cur.obs_climo_stdev); + m[key].pd.ocdf_na.add(cur.obs_climo_cdf); m[key].pd.wgt_na.add(default_grid_weight); // @@ -3086,8 +3107,9 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, // ensemble spread, ensemble member values, and // valid ensemble count // - m[key].ens_pd.add_grid_obs(cur.obs, cur.climo_mean, - cur.climo_stdev, default_grid_weight); + ClimoPntInfo cpi(cur.fcst_climo_mean, cur.fcst_climo_stdev, + cur.obs_climo_mean, cur.obs_climo_stdev); + m[key].ens_pd.add_grid_obs(cur.obs, cpi, default_grid_weight); m[key].ens_pd.skip_ba.add(false); m[key].ens_pd.n_pair++; m[key].ens_pd.r_na.add(cur.rank); @@ -3112,7 +3134,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, // Derive ensemble from climo mean and standard deviation derive_climo_vals(&m[key].cdf_info, - cur.climo_mean, cur.climo_stdev, climo_vals); + cur.obs_climo_mean, cur.obs_climo_stdev, climo_vals); // Store empirical CRPS stats and CRPS-Fair double crps_emp = compute_crps_emp(cur.obs, cur.ens_na); @@ -3123,7 +3145,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, // Store Gaussian CRPS stats m[key].ens_pd.crps_gaus_na.add(compute_crps_gaus(cur.obs, cur.ens_mean, cur.spread)); - m[key].ens_pd.crpscl_gaus_na.add(compute_crps_gaus(cur.obs, cur.climo_mean, cur.climo_stdev)); + m[key].ens_pd.crpscl_gaus_na.add(compute_crps_gaus(cur.obs, cur.obs_climo_mean, cur.obs_climo_stdev)); m[key].ens_pd.ign_na.add(compute_ens_ign(cur.obs, cur.ens_mean, cur.spread)); m[key].ens_pd.pit_na.add(compute_ens_pit(cur.obs, cur.ens_mean, cur.spread)); @@ -3783,8 +3805,9 @@ void mpr_to_ctc(STATAnalysisJob &job, const AggrMPRInfo &info, // Populate the contingency table // for(i=0; isecond.pd.f_na, it->second.pd.o_na, it->second.pd.cmn_na); + job.set_perc_thresh(it->second.pd.f_na, it->second.pd.o_na, + it->second.pd.fcmn_na, it->second.pd.ocmn_na); // // Prepare the output STAT header columns diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index e2dc49fb9f..2c51c68857 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -449,8 +449,8 @@ void WaveletStatConfInfo::set_perc_thresh(const DataPlane &f_dp, // // Compute percentiles // - fcat_ta->set_perc(&fsort, &osort, (NumArray *) 0, fcat_ta, ocat_ta); - ocat_ta->set_perc(&fsort, &osort, (NumArray *) 0, fcat_ta, ocat_ta); + fcat_ta->set_perc(&fsort, &osort, nullptr, nullptr, fcat_ta, ocat_ta); + ocat_ta->set_perc(&fsort, &osort, nullptr, nullptr, fcat_ta, ocat_ta); return; } diff --git a/src/tools/dev_utils/met_nc_file.cc b/src/tools/dev_utils/met_nc_file.cc index 3579c52f8e..5b293ec211 100644 --- a/src/tools/dev_utils/met_nc_file.cc +++ b/src/tools/dev_utils/met_nc_file.cc @@ -127,7 +127,7 @@ bool MetNcFile::readFile(const int desired_grib_code, IS_INVALID_NC(obsArrVar)) { mlog << Error << "\nmain() -> " - << "trouble reading netCDF file " << _filePath << "\n\n"; + << "trouble reading netCDF file " << _filePath << "\n\n"; return false; } diff --git a/src/tools/other/ascii2nc/airnow_locations.cc b/src/tools/other/ascii2nc/airnow_locations.cc index a7908c7a7b..e8d09647b8 100644 --- a/src/tools/other/ascii2nc/airnow_locations.cc +++ b/src/tools/other/ascii2nc/airnow_locations.cc @@ -55,8 +55,8 @@ bool AirnowLocations::initialize(const string &fileName) LineDataFile locFile; if (!locFile.open(monitoringSiteFileName.c_str())) { mlog << Warning << "\n" << method_name << " -> " - << "can't open input ASCII file \"" << monitoringSiteFileName - << "\" for reading\n\n"; + << "can't open input ASCII file \"" << monitoringSiteFileName + << "\" for reading\n\n"; return false; } DataLine data_line; @@ -82,7 +82,7 @@ bool AirnowLocations::initialize(const string &fileName) if (!status) { return false; } - + // this is inefficient, but will work int bad_line_count = 0; while (locFile >> data_line) { @@ -126,12 +126,12 @@ bool AirnowLocations::initialize(const string &fileName) #ifdef DEBUGGING for (size_t i=0; i" - << "can't open input ASCII file \"" << fileName - << "\" for reading\n\n"; + << "can't open input ASCII file \"" << fileName + << "\" for reading\n\n"; return false; } DataLine data_line; @@ -77,7 +77,7 @@ bool NdbcLocations::initialize(const string &fName) string latKey = "lat="; string lonKey = "lon="; string elevKey = "elev="; - + while (locFile >> data_line) { string sline = data_line.get_line(); string stationId; @@ -88,14 +88,14 @@ bool NdbcLocations::initialize(const string &fName) } if (!_parseLineForDouble(sline, latKey, lat)) { mlog << Warning << method_name << "-> " - << "parsing out lat from line '" << sline << "'\n" - << "in file \"" << fileName << "\n\n"; + << "parsing out lat from line '" << sline << "'\n" + << "in file \"" << fileName << "\n\n"; continue; } if (!_parseLineForDouble(sline, lonKey, lon)) { mlog << Warning << method_name << "-> " - << "parsing out lon from line '" << sline << "'\n" - << "in file \"" << fileName << "\n\n"; + << "parsing out lon from line '" << sline << "'\n" + << "in file \"" << fileName << "\n\n"; continue; } if (!_parseLineForDouble(sline, elevKey, elev)) { diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index 46ad8b66df..368fceab6f 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -713,6 +713,9 @@ void track_counts(GenEnsProdVarInfo *ens_info, const DataPlane &ens_dp, bool is_ cmn = (cmn_dp.is_empty() ? bad_data_double : cmn_dp.data()[i]); csd = (csd_dp.is_empty() ? bad_data_double : csd_dp.data()[i]); + // MET #2924 Use the same data for the forecast and observation climatologies + ClimoPntInfo cpi(cmn, csd, cmn, csd); + // Skip bad data values if(is_bad_data(ens)) continue; @@ -738,7 +741,7 @@ void track_counts(GenEnsProdVarInfo *ens_info, const DataPlane &ens_dp, bool is_ // Event frequency for(j=0; j::iterator it = simp.begin(); it != simp.end(); it++) { - if(it->ptype() == perc_thresh_climo_dist && + if(it->ptype() == perc_thresh_fcst_climo_dist && !is_eq(it->pvalue(), 0.0) && !is_eq(it->pvalue(), 100.0)) { - snprintf(type_str, sizeof(type_str), "CLIMO_CDP%i", + snprintf(type_str, sizeof(type_str), "CLIMO_FCDP%i", + nint(it->pvalue())); + cdp_dp = normal_cdf_inv(it->pvalue()/100.0, cmn_dp, csd_dp); + write_ens_data_plane(ens_info, cdp_dp, ens_dp, type_str, + "Forecast climatology distribution percentile"); + } + else if(it->ptype() == perc_thresh_obs_climo_dist && + !is_eq(it->pvalue(), 0.0) && + !is_eq(it->pvalue(), 100.0)) { + snprintf(type_str, sizeof(type_str), "CLIMO_OCDP%i", nint(it->pvalue())); cdp_dp = normal_cdf_inv(it->pvalue()/100.0, cmn_dp, csd_dp); - write_ens_data_plane(ens_info, cdp_dp, ens_dp, - type_str, - "Climatology distribution percentile"); + write_ens_data_plane(ens_info, cdp_dp, ens_dp, type_str, + "Observation climatology distribution percentile"); } } // end for it } diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index e4c14b557b..7612f0d7d2 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -1081,7 +1081,8 @@ void apply_data_mask(DataPlane &dp) { for(int i=0; i #include #include @@ -51,7 +50,6 @@ using namespace std; using namespace netCDF; - //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); @@ -431,9 +429,9 @@ void setup_histograms(void) { bin_max.clear(); bin_mid.clear(); for(int k=0; kmagic_str_attr() - << " histogram with " << n_bins << " bins from " - << min << " to " << max << ".\n"; - + << "Initializing " << data_info->magic_str_attr() + << " histogram with " << n_bins << " bins from " + << min << " to " << max << ".\n"; + histograms[i_var_str] = vector(); init_pdf(n_bins, histograms[i_var_str]); // Keep track of unique output variable names if(nc_var_sa.has( data_info->magic_str_attr() )) unique_variable_names = false; nc_var_sa.add(data_info->magic_str_attr()); - + } // for i_var } @@ -462,7 +460,7 @@ void setup_histograms(void) { void setup_joint_histograms(void) { ConcatString i_var_str, j_var_str, ij_var_str; - for(int i_var=0; i_varn_bins(); @@ -487,7 +485,7 @@ void setup_joint_histograms(void) { init_joint_pdf(n_bins, n_joint_bins, joint_histograms[ij_var_str]); } // end for j_var - } // end for i_var + } // end for i_var } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gsi_tools/gsid2mpr.cc b/src/tools/other/gsi_tools/gsid2mpr.cc index 579d41bd19..e5a770f8e3 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.cc +++ b/src/tools/other/gsi_tools/gsid2mpr.cc @@ -16,12 +16,12 @@ // ---- ---- ---- ----------- // 000 06/09/15 Bullock New // 001 01/26/16 Halley Gotway Add -no_check_dup option. -// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main -// 003 10/03/22 Prestopnik MET #2227 Remove using namespace std from header files +// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. +// 003 10/03/22 Prestopnik MET #2227 Remove using namespace std from header files. +// 004 07/17/24 Halley Gotway MET #2924 Support forecast climatology. // //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -389,9 +389,13 @@ void write_mpr_row_conv(AsciiTable &at, int row, const ConvData &d) { at.set_entry(row, col++, d.guess); // FCST at.set_entry(row, col++, d.obs); // OBS at.set_entry(row, col++, d.obs_qc[0]); // OBS_QC - at.set_entry(row, col++, na_str); // CLIMO_MEAN - at.set_entry(row, col++, na_str); // CLIMO_STDEV - at.set_entry(row, col++, na_str); // CLIMO_CDF + at.set_entry(row, col++, na_str); // OBS_CLIMO_MEAN + at.set_entry(row, col++, na_str); // OBS_CLIMO_STDEV + at.set_entry(row, col++, na_str); // OBS_CLIMO_CDF + /* MET #2924 Uncomment this section + at.set_entry(row, col++, na_str); // FCST_CLIMO_MEAN + at.set_entry(row, col++, na_str); // FCST_CLIMO_STDEV + */ // Write extra columns at.set_entry(row, col++, d.prs); // OBS_PRS @@ -443,9 +447,13 @@ void write_mpr_row_rad(AsciiTable &at, int row, const RadData & d) { at.set_entry(row, col++, d.guess); // FCST at.set_entry(row, col++, d.obs); // OBS at.set_entry(row, col++, d.obs_qc[0]); // OBS_QC - at.set_entry(row, col++, na_str); // CLIMO_MEAN - at.set_entry(row, col++, na_str); // CLIMO_STDEV - at.set_entry(row, col++, na_str); // CLIMO_CDF + at.set_entry(row, col++, na_str); // OBS_CLIMO_MEAN + at.set_entry(row, col++, na_str); // OBS_CLIMO_STDEV + at.set_entry(row, col++, na_str); // OBS_CLIMO_CDF + /* MET #2924 Uncomment this section + at.set_entry(row, col++, na_str); // FCST_CLIMO_MEAN + at.set_entry(row, col++, na_str); // FCST_CLIMO_STDEV + */ // Write extra columns at.set_entry(row, col++, d.use); // CHAN_USE diff --git a/src/tools/other/gsi_tools/gsidens2orank.cc b/src/tools/other/gsi_tools/gsidens2orank.cc index 0c75717fa8..fed035bd69 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.cc +++ b/src/tools/other/gsi_tools/gsidens2orank.cc @@ -15,8 +15,9 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 07/09/15 Halley Gotway New -// 001 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main -// 002 10/03/22 Prestopnik MET #2227 Remove namespace std from header files +// 001 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. +// 002 10/03/22 Prestopnik MET #2227 Remove namespace std from header files. +// 003 07/17/24 Halley Gotway MET #2924 Support forecast climatology. // //////////////////////////////////////////////////////////////////////// @@ -266,10 +267,11 @@ void process_conv_data(ConvData &d, int i_mem) { conv_data.push_back(d); // Store the current observation info + ClimoPntInfo cpi(bad_data_double, bad_data_double, + bad_data_double, bad_data_double); ens_pd.add_point_obs(d.sid.c_str(), d.lat, d.lon, bad_data_double, bad_data_double, d.obs_ut, d.prs, - d.elv, d.obs, na_str, bad_data_double, bad_data_double, - default_grid_weight); + d.elv, d.obs, na_str, cpi, default_grid_weight); // Initialize ensemble members and mean to bad data for(i=0; in_use); // N_USE @@ -696,12 +704,17 @@ void write_orank_row_rad(AsciiTable &at, int row, int i_obs) { } at.set_entry(row, col++, cs); // OBS_QC at.set_entry(row, col++, ens_pd.mn_na[i_obs]); // ENS_MEAN - at.set_entry(row, col++, bad_data_double); // CLIMO - at.set_entry(row, col++, square_root(ens_pd.var_na[i_obs])); // ENS_SPREAD + at.set_entry(row, col++, bad_data_double); // OBS_CLIMO_MEAN + at.set_entry(row, col++, square_root(ens_pd.var_na[i_obs])); // SPREAD at.set_entry(row, col++, bad_data_double); // ENS_MEAN_OERR at.set_entry(row, col++, bad_data_double); // SPREAD_OERR at.set_entry(row, col++, bad_data_double); // SPREAD_PLUS_OERR + at.set_entry(row, col++, bad_data_double); // OBS_CLIMO_STDEV + /* MET #2924 Uncomment this section + at.set_entry(row, col++, bad_data_double); // FCST_CLIMO_MEAN + at.set_entry(row, col++, bad_data_double); // FCST_CLIMO_STDEV + */ // Write extra columns at.set_entry(row, col++, d->n_use); // N_USE diff --git a/src/tools/other/madis2nc/madis2nc_conf_info.cc b/src/tools/other/madis2nc/madis2nc_conf_info.cc index c4b864ab13..953aa296f1 100644 --- a/src/tools/other/madis2nc/madis2nc_conf_info.cc +++ b/src/tools/other/madis2nc/madis2nc_conf_info.cc @@ -59,7 +59,7 @@ void Madis2NcConfInfo::clear() //////////////////////////////////////////////////////////////////////// void Madis2NcConfInfo::read_config(const string &default_filename, - const string &user_filename) + const string &user_filename) { // Read the config file constants diff --git a/src/tools/other/modis_regrid/data_plane_to_netcdf.cc b/src/tools/other/modis_regrid/data_plane_to_netcdf.cc index e13719a321..819a67885b 100644 --- a/src/tools/other/modis_regrid/data_plane_to_netcdf.cc +++ b/src/tools/other/modis_regrid/data_plane_to_netcdf.cc @@ -79,57 +79,57 @@ void write_grid_to_netcdf(const DataPlane & plane, const Grid & grid, const char NcDim lat_dim ; NcDim lon_dim ; NcVar f_var ; - - + + // Create a new NetCDF file and open it f_out = open_ncfile(out_filename, true); - + if(IS_INVALID_NC_P(f_out)) { mlog << Error << "\nwrite_netcdf() -> " - << "trouble opening output file " << out_filename - << "\n\n"; + << "trouble opening output file " << out_filename + << "\n\n"; delete f_out; f_out = (NcFile *) nullptr; exit(1); } - + // Add global attributes const char * program_name = "data_plane_to_netcdf"; write_netcdf_global(f_out, out_filename, program_name); - + // Add the projection information write_netcdf_proj(f_out, grid, lat_dim, lon_dim); // Add the lat/lon variables write_netcdf_latlon(f_out, &lat_dim, &lon_dim, grid); - + int deflate_level = get_compress(); //if (deflate_level < 0) deflate_level = 0; - + // Define variable f_var = add_var(f_out, (string)var_info.name(), ncFloat, lat_dim, lon_dim, deflate_level); - + // Add variable attributes add_att(&f_var, "name", (string)var_info.name()); add_att(&f_var, "units", (string)var_info.units()); add_att(&f_var, "long_name", (string)var_info.long_name()); add_att(&f_var, "_FillValue", bad_data_float); - + // Write out the times write_netcdf_var_times(&f_var, plane); - + // Write the data if (!put_nc_data_with_dims(&f_var, plane.data(), plane.ny(), plane.nx())) { mlog << Error << "\nwrite_netcdf() -> " - << "error with f_var->put()\n\n"; + << "error with f_var->put()\n\n"; exit(1); } - + // Close and clean up delete f_out; f_out = (NcFile *) nullptr; - + return; } diff --git a/src/tools/tc_utils/tc_diag/python_tc_diag.cc b/src/tools/tc_utils/tc_diag/python_tc_diag.cc index 991295370f..f7791d8bcf 100644 --- a/src/tools/tc_utils/tc_diag/python_tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/python_tc_diag.cc @@ -306,7 +306,7 @@ bool parse_python_diag_data(PyObject *module_obj, // Get the diag_data item PyObject *data_obj = PyDict_GetItem(module_dict_obj, - PyUnicode_FromString(diag_data_dict_name)); + PyUnicode_FromString(diag_data_dict_name)); if(!data_obj || !PyDict_Check(data_obj)) { mlog << Warning << "\n" << method_name @@ -384,7 +384,7 @@ bool parse_python_string_value_map(PyObject *dict, long pos; PyObject *data_obj = PyDict_GetItem(dict, - PyUnicode_FromString(name)); + PyUnicode_FromString(name)); if(!data_obj || !PyDict_Check(data_obj)) { mlog << Warning << "\n" << method_name From 092205ddd7fabfcebb08aacbedf7f2131004c380 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 30 Jul 2024 20:59:08 +0000 Subject: [PATCH 099/114] Hotfix to the develop branch for a copy/paste bug introduced by PR #2939 --- src/tools/core/grid_stat/grid_stat.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 843344897c..fcd0bc33a9 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -1797,7 +1797,7 @@ void process_scores() { ocmn_dp_smooth = ocmn_dp; // Reset forecast climo spread since it does not apply to Fourier decomposition - if(!fcst_dp.is_empty()) fcsd_dp.set_constant(bad_data_double); + if(!fcsd_dp.is_empty()) fcsd_dp.set_constant(bad_data_double); // Reset observation climo spread since it does not apply to Fourier decomposition if(!ocsd_dp.is_empty()) ocsd_dp.set_constant(bad_data_double); From 8b7d49f31693888b957628d95029f2570274c6b0 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Fri, 9 Aug 2024 09:29:57 -0600 Subject: [PATCH 100/114] Feature #2924 sal1l2_mae, PR 3 of 3 (#2943) * Per #2924, track SL1L2 and SAL1L2 MAE scores with separate variables since they are no longer the same value. I renamed the existing 'mae' as 'smae' and added a new 'samae' variable. Renaming the existing lets me use the compiler help find all references to it throughout the code. * Per #2924, update the User's Guide climatology details and equations. * Per #2924, some changes to aggr_stat_line.cc and series_analysis.cc to satisfy some SonarQube code smells. --- docs/Users_Guide/appendixC.rst | 74 ++++++------ docs/Users_Guide/point-stat.rst | 34 +++--- src/libcode/vx_stat_out/stat_columns.cc | 4 +- src/libcode/vx_statistics/compute_stats.cc | 8 +- src/libcode/vx_statistics/met_stats.cc | 23 ++-- src/libcode/vx_statistics/met_stats.h | 5 +- .../core/series_analysis/series_analysis.cc | 108 +++++++++++++----- .../core/stat_analysis/aggr_stat_line.cc | 66 ++++++----- .../core/stat_analysis/parse_stat_line.cc | 4 +- 9 files changed, 198 insertions(+), 128 deletions(-) diff --git a/docs/Users_Guide/appendixC.rst b/docs/Users_Guide/appendixC.rst index 15c3ab5c2d..a6bbb0fe51 100644 --- a/docs/Users_Guide/appendixC.rst +++ b/docs/Users_Guide/appendixC.rst @@ -616,23 +616,23 @@ Anomaly Correlation Coefficient Called "ANOM_CORR" and "ANOM_CORR_UNCNTR" for centered and uncentered versions in CNT output :numref:`table_PS_format_info_CNT` -The anomaly correlation coefficient is equivalent to the Pearson correlation coefficient, except that both the forecasts and observations are first adjusted according to a climatology value. The anomaly is the difference between the individual forecast or observation and the typical situation, as measured by a climatology (**c**) of some variety. It measures the strength of linear association between the forecast anomalies and observed anomalies. The anomaly correlation coefficient is defined as: +The anomaly correlation coefficient is equivalent to the Pearson correlation coefficient, except that both the forecasts and observations are first adjusted by subtracting their corresponding climatology value. The anomaly is the difference between the individual forecast or observation and the typical situation, as measured by a forecast climatology (:math:`c_f`) and observation climatology (:math:`c_o`). It measures the strength of linear association between the forecast anomalies and observed anomalies. The anomaly correlation coefficient is defined as: -.. math:: \text{Anomaly Correlation} = \frac{\sum(f_i - c)(o_i - c)}{\sqrt{\sum(f_i - c)^2} \sqrt{\sum(o_i -c)^2}} . +.. math:: \text{Anomaly Correlation} = \frac{\sum(f_i - {c_f}_i)(o_i - {c_o}_i)}{\sqrt{\sum(f_i - {c_f}_i)^2} \sqrt{\sum(o_i - {c_o}_i)^2}} . The centered anomaly correlation coefficient (ANOM_CORR) which includes the mean error is defined as: .. only:: latex - .. math:: \text{ANOM\_CORR } = \frac{ \overline{[(f - c) - \overline{(f - c)}][(a - c) - \overline{(a - c)}]}}{ \sqrt{ \overline{( (f - c) - \overline{(f - c)})^2} \overline{( (a - c) - \overline{(a - c)})^2}}} + .. math:: \text{ANOM\_CORR } = \frac{ \overline{[(f - c_f) - \overline{(f - c_f)}][(o - c_o) - \overline{(o - c_o)}]}}{ \sqrt{ \overline{( (f - c_f) - \overline{(f - c_f)})^2} \overline{( (o - c_o) - \overline{(o - c_o)})^2}}} .. only:: html - .. math:: \text{ANOM_CORR } = \frac{ \overline{[(f - c) - \overline{(f - c)}][(a - c) - \overline{(a - c)}]}}{ \sqrt{ \overline{( (f - c) - \overline{(f - c)})^2} \overline{( (a - c) - \overline{(a - c)})^2}}} + .. math:: \text{ANOM_CORR } = \frac{ \overline{[(f - c_f) - \overline{(f - c_f)}][(o - c_o) - \overline{(o - c_o)}]}}{ \sqrt{ \overline{( (f - c_f) - \overline{(f - c_f)})^2} \overline{( (o - c_o) - \overline{(o - c_o)})^2}}} The uncentered anomaly correlation coefficient (ANOM_CORR_UNCNTR) which does not include the mean errors is defined as: -.. math:: \text{Anomaly Correlation Raw } = \frac{ \overline{(f - c)(a - c)}}{ \sqrt{\overline{(f - c)^2} \overline{(a - c)^2}}} +.. math:: \text{Anomaly Correlation Raw } = \frac{ \overline{(f - c_f)(o - c_o)}}{ \sqrt{\overline{(f - c_f)^2} \overline{(o - c_o)^2}}} Anomaly correlation can range between -1 and 1; a value of 1 indicates perfect correlation and a value of -1 indicates perfect negative correlation. A value of 0 indicates that the forecast and observed anomalies are not correlated. @@ -650,56 +650,60 @@ The partial sums can be accumulated over individual cases to produce statistics Scalar L1 and L2 Values ----------------------- -Called "FBAR", "OBAR", "FOBAR", "FFBAR", and "OOBAR" in SL1L2 output :numref:`table_PS_format_info_SL1L2` +Called "FBAR", "OBAR", "FOBAR", "FFBAR", "OOBAR", and "MAE" in SL1L2 output :numref:`table_PS_format_info_SL1L2` These statistics are simply the 1st and 2nd moments of the forecasts, observations and errors: .. math:: - \text{FBAR} = \text{Mean}(f) = \bar{f} = \frac{1}{n} \sum_{i=1}^n f_i + \text{FBAR} = \text{Mean}(f) = \frac{1}{n} \sum_{i=1}^n f_i - \text{OBAR} = \text{Mean}(o) = \bar{o} = \frac{1}{n} \sum_{i=1}^n o_i + \text{OBAR} = \text{Mean}(o) = \frac{1}{n} \sum_{i=1}^n o_i - \text{FOBAR} = \text{Mean}(fo) = \bar{fo} = \frac{1}{n} \sum_{i=1}^n f_i o_i + \text{FOBAR} = \text{Mean}(fo) = \frac{1}{n} \sum_{i=1}^n f_i o_i - \text{FFBAR} = \text{Mean}(f^2) = \bar{f}^2 = \frac{1}{n} \sum_{i=1}^n f_i^2 + \text{FFBAR} = \text{Mean}(f^2) = \frac{1}{n} \sum_{i=1}^n f_i^2 - \text{OOBAR} = \text{Mean}(o^2) = \bar{o}^2 = \frac{1}{n} \sum_{i=1}^n o_i^2 + \text{OOBAR} = \text{Mean}(o^2) = \frac{1}{n} \sum_{i=1}^n o_i^2 + + \text{MAE} = \text{Mean}(|f - o|) = \frac{1}{n} \sum_{i=1}^n |f_i - o_i| Some of the other statistics for continuous forecasts (e.g., RMSE) can be derived from these moments. Scalar Anomaly L1 and L2 Values ------------------------------- -Called "FABAR", "OABAR", "FOABAR", "FFABAR", "OOABAR" in SAL1L2 output :numref:`table_PS_format_info_SAL1L2` +Called "FABAR", "OABAR", "FOABAR", "FFABAR", "OOABAR", and "MAE" in SAL1L2 output :numref:`table_PS_format_info_SAL1L2` -Computation of these statistics requires a climatological value, c. These statistics are the 1st and 2nd moments of the scalar anomalies. The moments are defined as: +Computation of these statistics requires climatological values, where :math:`c_f` is the forecast climatology value and :math:`c_o` is the observation climatology value. These statistics are the 1st and 2nd moments of the scalar anomalies. The moments are defined as: .. math:: - \text{FABAR} = \text{Mean}(f - c) = \bar{f - c} = \frac{1}{n} \sum_{i=1}^n (f_i - c) + \text{FABAR} = \text{Mean}(f - c_f) = \frac{1}{n} \sum_{i=1}^n (f_i - {c_f}_i) + + \text{OABAR} = \text{Mean}(o - c_o) = \frac{1}{n} \sum_{i=1}^n (o_i - {c_o}_i) - \text{OABAR} = \text{Mean}(o - c) = \bar{o - c} = \frac{1}{n} \sum_{i=1}^n (o_i - c) + \text{FOABAR} = \text{Mean}[(f - c_f)(o - c_o)] = \frac{1}{n} \sum_{i=1}^n (f_i - {c_f}_i)(o_i - {c_o}_i) - \text{FOABAR} = \text{Mean}[(f - c)(o - c)] = \bar{(f - c)(o - c)} = \frac{1}{n} \sum_{i=1}^n (f_i - c)(o_i - c) + \text{FFABAR} = \text{Mean}[(f - c_f)^2] = \frac{1}{n} \sum_{i=1}^n (f_i - {c_f}_i)^2 - \text{FFABAR} = \text{Mean}[(f - c)^2] = \bar{(f - c)}^2 = \frac{1}{n} \sum_{i=1}^n (f_i - c)^2 + \text{OOABAR} = \text{Mean}[(o - c_o)^2] = \frac{1}{n} \sum_{i=1}^n (o_i - {c_o}_i)^2 - \text{OOABAR} = \text{Mean}[(o - c)^2] = \bar{(o - c)}^2 = \frac{1}{n} \sum_{i=1}^n (o_i - c)^2 + \text{MAE} = \text{Mean}(|(f - c_f) - (o - c_o)|) = \frac{1}{n} \sum_{i=1}^n |(f_i - {c_f}_i) - (o_i - {c_o}_i)| Vector L1 and L2 Values ----------------------- -Called "UFBAR", "VFBAR", "UOBAR", "VOBAR", "UVFOBAR", "UVFFBAR", "UVOOBAR" in VL1L2 output :numref:`table_PS_format_info_VL1L2` +Called "UFBAR", "VFBAR", "UOBAR", "VOBAR", "UVFOBAR", "UVFFBAR", and "UVOOBAR" in VL1L2 output :numref:`table_PS_format_info_VL1L2` -These statistics are the moments for wind vector values, where **u** is the E-W wind component and **v** is the N-S wind component ( :math:`u_f` is the forecast E-W wind component; :math:`u_o` is the observed E-W wind component; :math:`v_f` is the forecast N-S wind component; and :math:`v_o` is the observed N-S wind component). The following measures are computed: +These statistics are the moments for wind vector values, where :math:`u` is the E-W wind component and :math:`v` is the N-S wind component ( :math:`u_f` is the forecast E-W wind component; :math:`u_o` is the observed E-W wind component; :math:`v_f` is the forecast N-S wind component; and :math:`v_o` is the observed N-S wind component). The following measures are computed: .. math:: - \text{UFBAR} = \text{Mean}(u_f) = \bar{u}_f = \frac{1}{n} \sum_{i=1}^n u_{fi} + \text{UFBAR} = \text{Mean}(u_f) = \frac{1}{n} \sum_{i=1}^n u_{fi} - \text{VFBAR} = \text{Mean}(v_f) = \bar{v}_f = \frac{1}{n} \sum_{i=1}^n v_{fi} + \text{VFBAR} = \text{Mean}(v_f) = \frac{1}{n} \sum_{i=1}^n v_{fi} - \text{UOBAR} = \text{Mean}(u_o) = \bar{u}_o = \frac{1}{n} \sum_{i=1}^n u_{oi} + \text{UOBAR} = \text{Mean}(u_o) = \frac{1}{n} \sum_{i=1}^n u_{oi} - \text{VOBAR} = \text{Mean}(v_o) = \bar{v}_o = \frac{1}{n} \sum_{i=1}^n v_{oi} + \text{VOBAR} = \text{Mean}(v_o) = \frac{1}{n} \sum_{i=1}^n v_{oi} \text{UVFOBAR} = \text{Mean}(u_f u_o + v_f v_o) = \frac{1}{n} \sum_{i=1}^n (u_{fi} u_{oi} + v_{fi} v_{oi}) @@ -710,25 +714,27 @@ These statistics are the moments for wind vector values, where **u** is the E-W Vector Anomaly L1 and L2 Values ------------------------------- -Called "UFABAR", "VFABAR", "UOABAR", "VOABAR", "UVFOABAR", "UVFFABAR", "UVOOABAR" in VAL1L2 output :numref:`table_PS_format_info_VAL1L2` +Called "UFABAR", "VFABAR", "UOABAR", "VOABAR", "UVFOABAR", "UVFFABAR", and "UVOOABAR" in VAL1L2 output :numref:`table_PS_format_info_VAL1L2` -These statistics require climatological values for the wind vector components, :math:`u_c \text{ and } v_c`. The measures are defined below: +These statistics require climatological values for the wind vector components, where :math:`{u_c}_f` and :math:`{v_c}_f` are the forecast climatology vectors and :math:`{u_c}_o` and :math:`{v_c}_o` are the observation climatology vectors. The measures are defined below: .. math:: - \text{UFABAR} = \text{Mean}(u_f - u_c) = \frac{1}{n} \sum_{i=1}^n (u_{fi} - u_c) + \text{UFABAR} = \text{Mean}(u_f - {u_c}_f) = \frac{1}{n} \sum_{i=1}^n ({u_f}_i - {{u_c}_f}_i) - \text{VFBAR} = \text{Mean}(v_f - v_c) = \frac{1}{n} \sum_{i=1}^n (v_{fi} - v_c) + \text{VFBAR} = \text{Mean}(v_f - {v_c}_f) = \frac{1}{n} \sum_{i=1}^n ({v_f}_i - {{v_c}_f}_i) - \text{UOABAR} = \text{Mean}(u_o - u_c) = \frac{1}{n} \sum_{i=1}^n (u_{oi} - u_c) + \text{UOABAR} = \text{Mean}(u_o - {u_c}_o) = \frac{1}{n} \sum_{i=1}^n ({u_o}_i - {{u_c}_o}_i) - \text{VOABAR} = \text{Mean}(v_o - v_c) = \frac{1}{n} \sum_{i=1}^n (v_{oi} - v_c) + \text{VOABAR} = \text{Mean}(v_o - {v_c}_o) = \frac{1}{n} \sum_{i=1}^n ({v_o}_i - {{v_c}_o}_i) - \text{UVFOABAR} &= \text{Mean}[(u_f - u_c)(u_o - u_c) + (v_f - v_c)(v_o - v_c)] \\ - &= \frac{1}{n} \sum_{i=1}^n (u_{fi} - u_c) + (u_{oi} - u_c) + (v_{fi} - v_c)(v_{oi} - v_c) + \text{UVFOABAR} &= \text{Mean}[(u_f - {u_c}_f)(u_o - {u_c}_o) + (v_f - {v_c}_f)(v_o - {v_c}_o)] \\ + &= \frac{1}{n} \sum_{i=1}^n ({u_f}_i - {{u_c}_f}_i) + ({u_o}_i - {{u_c}_o}_i) + ({v_f}_i - {{v_c}_f}_i)({v_o}_i - {{v_c}_o}_i) - \text{UVFFABAR} = \text{Mean}[(u_f - u_c)^2 + (v_f - v_c)^2] = \frac{1}{n} \sum_{i=1}^n ((u_{fi} - u_c)^2 + (v_{fi} - v_c)^2) + \text{UVFFABAR} &= \text{Mean}[(u_f - {u_c}_f)^2 + (v_f - {v_c}_f)^2] \\ + &= \frac{1}{n} \sum_{i=1}^n (({u_f}_i - {{u_c}_f}_i)^2 + ({v_f}_i - {{v_c}_f}_i)^2) - \text{UVOOABAR} = \text{Mean}[(u_o - u_c)^2 + (v_o - v_c)^2] = \frac{1}{n} \sum_{i=1}^n ((u_{oi} - u_c)^2 + (v_{oi} - v_c)^2) + \text{UVOOABAR} &= \text{Mean}[(u_o - {u_c}_o)^2 + (v_o - {v_c}_o)^2] \\ + &= \frac{1}{n} \sum_{i=1}^n (({u_o}_i - {{u_c}_o}_i)^2 + ({v_o}_i - {{v_c}_o}_i)^2) Gradient Values --------------- diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index 6c9849511e..70e3847b79 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -1204,7 +1204,7 @@ The first set of header columns are common to all of the output files generated - Mean(o²) * - 31 - MAE - - Mean Absolute Error + - Mean(\|f-o\|) .. _table_PS_format_info_SAL1L2: @@ -1223,25 +1223,25 @@ The first set of header columns are common to all of the output files generated - Scalar Anomaly L1L2 line type * - 25 - TOTAL - - Total number of matched triplets of forecast (f), observation (o), and climatological value (c) + - Total number of matched pairs of forecast (f), observation (o), forecast climatology (cf), and observation climatology (co) * - 26 - FABAR - - Mean(f-c) + - Mean(f-cf) * - 27 - OABAR - - Mean(o-c) + - Mean(o-co) * - 28 - FOABAR - - Mean((f-c)*(o-c)) + - Mean((f-cf)*(o-co)) * - 29 - FFABAR - - Mean((f-c)²) + - Mean((f-cf)²) * - 30 - OOABAR - - Mean((o-c)²) + - Mean((o-co)²) * - 31 - MAE - - Mean Absolute Error + - Mean(\|(f-cf)-(o-co)\|) .. _table_PS_format_info_VL1L2: @@ -1318,28 +1318,28 @@ The first set of header columns are common to all of the output files generated - Vector Anomaly L1L2 line type * - 25 - TOTAL - - Total number of matched triplets of forecast winds (uf, vf), observation winds (uo, vo), and climatological winds (uc, vc) + - Total number of matched pairs of forecast winds (uf, vf), observation winds (uo, vo), forecast climatology winds (ucf, vcf), and observation climatology winds (uco, vco) * - 26 - UFABAR - - Mean(uf-uc) + - Mean(uf-ucf) * - 27 - VFABAR - - Mean(vf-vc) + - Mean(vf-vcf) * - 28 - UOABAR - - Mean(uo-uc) + - Mean(uo-uco) * - 29 - VOABAR - - Mean(vo-vc) + - Mean(vo-vco) * - 30 - UVFOABAR - - Mean((uf-uc)*(uo-uc)+(vf-vc)*(vo-vc)) + - Mean((uf-ucf)*(uo-uco)+(vf-vcf)*(vo-vco)) * - 31 - UVFFABAR - - Mean((uf-uc)²+(vf-vc)²) + - Mean((uf-ucf)²+(vf-vcf)²) * - 32 - UVOOABAR - - Mean((uo-uc)²+(vo-vc)²) + - Mean((uo-uco)²+(vo-vco)²) * - 33 - FA_SPEED_BAR - Mean forecast wind speed anomaly @@ -1348,7 +1348,7 @@ The first set of header columns are common to all of the output files generated - Mean observed wind speed anomaly * - 35 - TOTAL_DIR - - Total number of matched triplets for which the forecast, observation, and climatological wind directions are well-defined (i.e. non-zero vectors) + - Total number of matched pairs for which the forecast, observation, forecast climatology, and observation climatology wind directions are well-defined (i.e. non-zero vectors) * - 36 - DIRA_ME - Mean wind direction anomaly difference, from -180 to 180 degrees diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 330a74d827..35a2fe7ba0 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -2927,7 +2927,7 @@ void write_sl1l2_cols(const SL1L2Info &sl1l2_info, sl1l2_info.oobar); at.set_entry(r, c+6, // MAE - sl1l2_info.mae); + sl1l2_info.smae); return; } @@ -2963,7 +2963,7 @@ void write_sal1l2_cols(const SL1L2Info &sl1l2_info, sl1l2_info.ooabar); at.set_entry(r, c+6, // MAE - sl1l2_info.mae); + sl1l2_info.samae); return; } diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index 40c4e82589..bbc9e0ac1a 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -101,7 +101,7 @@ void compute_cntinfo(const SL1L2Info &s, bool aflag, CNTInfo &cnt_info) { cnt_info.me2.v = cnt_info.me.v * cnt_info.me.v; // Compute mean absolute error - cnt_info.mae.v = s.mae; + cnt_info.mae.v = s.smae; // Compute mean squared error cnt_info.mse.v = ffbar + oobar - 2.0*fobar; @@ -1111,7 +1111,7 @@ void compute_sl1l2_mean(const SL1L2Info *sl1l2_info, int n, sl1l2_mean.obar += sl1l2_info[i].obar; sl1l2_mean.ffbar += sl1l2_info[i].ffbar; sl1l2_mean.oobar += sl1l2_info[i].oobar; - sl1l2_mean.mae += sl1l2_info[i].mae; + sl1l2_mean.smae += sl1l2_info[i].smae; } if(sl1l2_info[i].sacount > 0) { @@ -1121,6 +1121,7 @@ void compute_sl1l2_mean(const SL1L2Info *sl1l2_info, int n, sl1l2_mean.oabar += sl1l2_info[i].oabar; sl1l2_mean.ffabar += sl1l2_info[i].ffabar; sl1l2_mean.ooabar += sl1l2_info[i].ooabar; + sl1l2_mean.samae += sl1l2_info[i].samae; } } // end for i @@ -1130,13 +1131,14 @@ void compute_sl1l2_mean(const SL1L2Info *sl1l2_info, int n, sl1l2_mean.obar /= n_sl1l2; sl1l2_mean.ffbar /= n_sl1l2; sl1l2_mean.oobar /= n_sl1l2; - sl1l2_mean.mae /= n_sl1l2; + sl1l2_mean.smae /= n_sl1l2; } if(sl1l2_mean.sacount > 0) { sl1l2_mean.fabar /= n_sal1l2; sl1l2_mean.oabar /= n_sal1l2; sl1l2_mean.ffabar /= n_sal1l2; sl1l2_mean.ooabar /= n_sal1l2; + sl1l2_mean.samae /= n_sal1l2; } return; diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index 9312867e49..4c679aed83 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -1124,11 +1124,11 @@ SL1L2Info & SL1L2Info::operator+=(const SL1L2Info &c) { s_info.ffbar = (ffbar*scount + c.ffbar*c.scount)/s_info.scount; s_info.oobar = (oobar*scount + c.oobar*c.scount)/s_info.scount; - if(is_bad_data(mae) || is_bad_data(c.mae)) { - s_info.mae = bad_data_double; + if(is_bad_data(smae) || is_bad_data(c.smae)) { + s_info.smae = bad_data_double; } else { - s_info.mae = (mae*scount + c.mae*c.scount)/s_info.scount; + s_info.smae = (smae*scount + c.smae*c.scount)/s_info.scount; } } @@ -1141,11 +1141,11 @@ SL1L2Info & SL1L2Info::operator+=(const SL1L2Info &c) { s_info.ffabar = (ffabar*sacount + c.ffabar*c.sacount)/s_info.sacount; s_info.ooabar = (ooabar*sacount + c.ooabar*c.sacount)/s_info.sacount; - if(is_bad_data(mae) || is_bad_data(c.mae)) { - s_info.mae = bad_data_double; + if(is_bad_data(samae) || is_bad_data(c.samae)) { + s_info.samae = bad_data_double; } else { - s_info.mae = (mae*sacount + c.mae*c.sacount)/s_info.sacount; + s_info.samae = (samae*sacount + c.samae*c.sacount)/s_info.sacount; } } @@ -1170,15 +1170,15 @@ void SL1L2Info::zero_out() { // SL1L2 Quantities fbar = obar = 0.0; fobar = ffbar = oobar = 0.0; + smae = 0.0; scount = 0; // SAL1L2 Quantities fabar = oabar = 0.0; foabar = ffabar = ooabar = 0.0; + samae = 0.0; sacount = 0; - mae = 0.0; - return; } @@ -1211,6 +1211,7 @@ void SL1L2Info::assign(const SL1L2Info &c) { fobar = c.fobar; ffbar = c.ffbar; oobar = c.oobar; + smae = c.smae; scount = c.scount; // SAL1L2 Quantities @@ -1219,10 +1220,9 @@ void SL1L2Info::assign(const SL1L2Info &c) { foabar = c.foabar; ffabar = c.ffabar; ooabar = c.ooabar; + samae = c.samae; sacount = c.sacount; - mae = c.mae; - return; } @@ -1272,7 +1272,7 @@ void SL1L2Info::set(const PairDataPoint &pd_all) { fobar += wgt*f*o; ffbar += wgt*f*f; oobar += wgt*o*o; - mae += wgt*fabs(f-o); + smae += wgt*fabs(f-o); scount++; // SAL1L2 sums @@ -1282,6 +1282,7 @@ void SL1L2Info::set(const PairDataPoint &pd_all) { foabar += wgt*(f-fc)*(o-oc); ffabar += wgt*(f-fc)*(f-fc); ooabar += wgt*(o-oc)*(o-oc); + samae += wgt*fabs((f-fc)-(o-oc)); sacount++; } } diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index b053266c33..f3bef1a90c 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -224,17 +224,16 @@ class SL1L2Info { double fbar, obar; double fobar; double ffbar, oobar; + double smae; int scount; // SAL1L2 Quantities double fabar, oabar; double foabar; double ffabar, ooabar; + double samae; int sacount; - // Mean absolute error - double mae; - // Compute sums void set(const PairDataPoint &); diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 9373c0e040..5622908e0d 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -92,17 +92,18 @@ static void do_cnt (int, const PairDataPoint *); static void do_sl1l2 (int, const PairDataPoint *); static void do_pct (int, const PairDataPoint *); -static void store_stat_fho (int, const ConcatString &, const CTSInfo &); -static void store_stat_ctc (int, const ConcatString &, const CTSInfo &); -static void store_stat_cts (int, const ConcatString &, const CTSInfo &); -static void store_stat_mctc (int, const ConcatString &, const MCTSInfo &); -static void store_stat_mcts (int, const ConcatString &, const MCTSInfo &); -static void store_stat_cnt (int, const ConcatString &, const CNTInfo &); -static void store_stat_sl1l2(int, const ConcatString &, const SL1L2Info &); -static void store_stat_pct (int, const ConcatString &, const PCTInfo &); -static void store_stat_pstd (int, const ConcatString &, const PCTInfo &); -static void store_stat_pjc (int, const ConcatString &, const PCTInfo &); -static void store_stat_prc (int, const ConcatString &, const PCTInfo &); +static void store_stat_fho (int, const ConcatString &, const CTSInfo &); +static void store_stat_ctc (int, const ConcatString &, const CTSInfo &); +static void store_stat_cts (int, const ConcatString &, const CTSInfo &); +static void store_stat_mctc (int, const ConcatString &, const MCTSInfo &); +static void store_stat_mcts (int, const ConcatString &, const MCTSInfo &); +static void store_stat_cnt (int, const ConcatString &, const CNTInfo &); +static void store_stat_sl1l2 (int, const ConcatString &, const SL1L2Info &); +static void store_stat_sal1l2(int, const ConcatString &, const SL1L2Info &); +static void store_stat_pct (int, const ConcatString &, const PCTInfo &); +static void store_stat_pstd (int, const ConcatString &, const PCTInfo &); +static void store_stat_pjc (int, const ConcatString &, const PCTInfo &); +static void store_stat_prc (int, const ConcatString &, const PCTInfo &); static void setup_nc_file(const VarInfo *, const VarInfo *); static void add_nc_var(const ConcatString &, const ConcatString &, @@ -860,8 +861,8 @@ void process_scores() { // Compute partial sums if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[STATLineType::sl1l2].n() > 0 || - conf_info.output_stats[STATLineType::sal1l2].n() > 0)) { + (conf_info.output_stats[STATLineType::sl1l2].n() + + conf_info.output_stats[STATLineType::sal1l2].n()) > 0) { do_sl1l2(i_point+i, &pd_ptr[i]); } @@ -1128,6 +1129,11 @@ void do_sl1l2(int n, const PairDataPoint *pd_ptr) { for(j=0; j " << "unsupported column name requested \"" << c @@ -1822,6 +1822,62 @@ void store_stat_sl1l2(int n, const ConcatString &col, //////////////////////////////////////////////////////////////////////// +void store_stat_sal1l2(int n, const ConcatString &col, + const SL1L2Info &s_info) { + double v; + + // Set the column name to all upper case + ConcatString c = to_upper(col); + + // Get the column value + if(c == "TOTAL") { v = (double) s_info.sacount; } + else if(c == "FABAR") { v = s_info.fabar; } + else if(c == "OABAR") { v = s_info.oabar; } + else if(c == "FOABAR") { v = s_info.foabar; } + else if(c == "FFABAR") { v = s_info.ffabar; } + else if(c == "OOABAR") { v = s_info.ooabar; } + else if(c == "MAE") { v = s_info.samae; } + else { + mlog << Error << "\nstore_stat_sal1l2() -> " + << "unsupported column name requested \"" << c + << "\"\n\n"; + exit(1); + } + + // Construct the NetCDF variable name + ConcatString var_name("series_sal1l2_"); + var_name << c; + + // Append threshold information, if supplied + if(s_info.fthresh.get_type() != thresh_na || + s_info.othresh.get_type() != thresh_na) { + var_name << "_fcst" << s_info.fthresh.get_abbr_str() + << "_" << setlogic_to_abbr(conf_info.cnt_logic) + << "_obs" << s_info.othresh.get_abbr_str(); + } + + // Add map for this variable name + if(stat_data.count(var_name) == 0) { + + // Build key + ConcatString lty_stat("SAL1L2_"); + lty_stat << c; + + // Add new map entry + add_nc_var(var_name, c, stat_long_name[lty_stat], + s_info.fthresh.get_str(), + s_info.othresh.get_str(), + bad_data_double); + } + + // Store the statistic value + put_nc_val(n, var_name, (float) v); + + return; +} + +//////////////////////////////////////////////////////////////////////// + void store_stat_pct(int n, const ConcatString &col, const PCTInfo &pct_info) { int i = 0; diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 75a9f60417..441cbe5e07 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -3999,12 +3999,6 @@ void mpr_to_cnt(STATAnalysisJob &job, const AggrMPRInfo &info, void mpr_to_psum(STATAnalysisJob &job, const AggrMPRInfo &info, int i_thresh, SL1L2Info &s_info) { - int i; - int scount, sacount; - double f, o, fc, oc; - double f_sum, o_sum, ff_sum, oo_sum, fo_sum; - double fa_sum, oa_sum, ffa_sum, ooa_sum, foa_sum; - double abs_err_sum; PairDataPoint pd_thr; // @@ -4034,31 +4028,41 @@ void mpr_to_psum(STATAnalysisJob &job, const AggrMPRInfo &info, // // Initialize counts // - scount = sacount = 0; - f_sum = o_sum = ff_sum = oo_sum = fo_sum = 0.0; - fa_sum = oa_sum = ffa_sum = ooa_sum = foa_sum = 0.0; - abs_err_sum = 0.0; + int scount = 0; + int sacount = 0; + double f_sum = 0.0; + double o_sum = 0.0; + double ff_sum = 0.0; + double oo_sum = 0.0; + double fo_sum = 0.0; + double smae_sum = 0.0; + double fa_sum = 0.0; + double oa_sum = 0.0; + double ffa_sum = 0.0; + double ooa_sum = 0.0; + double foa_sum = 0.0; + double samae_sum = 0.0; // // Update the partial sums // - for(i=0; i Date: Wed, 14 Aug 2024 16:53:37 -0600 Subject: [PATCH 101/114] Update develop to clarify masking poly options based on METplus Discussion dtcenter/METplus#2650 --- docs/Users_Guide/config_options.rst | 44 +++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index de538bd7cb..7b89d43875 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -1729,7 +1729,7 @@ Point-Stat and Ensemble-Stat, the reference time is the forecast valid time. .. _config_options-mask: mask ---- +---- The "mask" entry is a dictionary that specifies the verification masking regions to be used when computing statistics. Each mask defines a @@ -1749,11 +1749,18 @@ in the following ways: * The "poly" entry contains a comma-separated list of files that define verification masking regions. These masking regions may be specified in - two ways: in an ASCII file containing lat/lon points defining the mask polygon, - or using a gridded data file such as the NetCDF output of the Gen-Vx-Mask tool. - Some details for each of these options are described below: + three ways: + + 1. An ASCII polyline file containing lat/lon points defining the mask polygon. + 2. The NetCDF output of the Gen-Vx-Mask tool. + 3. Any gridded data file followed by a configuration string describing the + data to be read and an optional threshold to be applied to that data. + + These three options are described below: + + * Option 1 - ASCII polyline file: - * If providing an ASCII file containing the lat/lon points defining the mask + If providing an ASCII file containing the lat/lon points defining the mask polygon, the file must contain a name for the region followed by the latitude (degrees north) and longitude (degrees east) for each vertex of the polygon. The values are separated by whitespace (e.g. spaces or newlines), and the @@ -1781,17 +1788,38 @@ in the following ways: observation point falls within the polygon defined is done in x/y grid space. - * The NetCDF output of the gen_vx_mask tool. Please see :numref:`masking` + .. code-block:: none + + mask = { poly = [ "share/met/poly/CONUS.poly"; ]; } + + * Option 2 - Gen-Vx-Mask output: + + The NetCDF output of the gen_vx_mask tool. Please see :numref:`masking` for more details. - * Any gridded data file that MET can read may be used to define a + .. code-block:: none + + mask = { poly = [ "/path/to/gen_vx_mask_output.nc"; ]; } + + * Option 3 - Any gridded data file: + + Any gridded data file that MET can read may be used to define a verification masking region. Users must specify a description of the field to be used from the input file and, optionally, may specify a threshold to be applied to that field. Once this threshold is applied, any grid point where the resulting field is 0, the mask is turned off. Any grid point where it is non-zero, the mask is turned on. - For example, "sample.grib {name = \"TMP\"; level = \"Z2\";} >273" + + .. code-block:: none + + mask = { poly = [ "/path/to/sample.grib {name = \"TMP\"; level = \"Z2\";} >273" ]; } + + .. note:: + + The syntax for the Option 3 is complicated since it includes quotes + embedded within another quoted string. Any such embedded quotes must + be escaped using a preceeding backslash character. * The "sid" entry is an array of strings which define groups of observation station ID's over which to compute statistics. Each entry From 98e8be29be37aa17167357177ec439eff651cb99 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 15 Aug 2024 07:59:40 -0600 Subject: [PATCH 102/114] Remove two semi-colons that are not actually necessary to avoid confusion. --- docs/Users_Guide/config_options.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index 7b89d43875..81037ca184 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -1790,7 +1790,7 @@ in the following ways: .. code-block:: none - mask = { poly = [ "share/met/poly/CONUS.poly"; ]; } + mask = { poly = [ "share/met/poly/CONUS.poly" ]; } * Option 2 - Gen-Vx-Mask output: @@ -1799,7 +1799,7 @@ in the following ways: .. code-block:: none - mask = { poly = [ "/path/to/gen_vx_mask_output.nc"; ]; } + mask = { poly = [ "/path/to/gen_vx_mask_output.nc" ]; } * Option 3 - Any gridded data file: From 03cd070e8f03498e83be0101928e881560f8f96c Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 20 Aug 2024 16:32:41 -0600 Subject: [PATCH 103/114] Per dtcenter/METplus#2653 discussion, update the MTD usage statement to clarify that data specified in the fcst dictionary is read from the -single input files. --- docs/Users_Guide/mode-td.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Users_Guide/mode-td.rst b/docs/Users_Guide/mode-td.rst index c8c07c1117..f7dd558a7c 100644 --- a/docs/Users_Guide/mode-td.rst +++ b/docs/Users_Guide/mode-td.rst @@ -217,7 +217,9 @@ Required Arguments for mtd Optional Arguments for mtd ^^^^^^^^^^^^^^^^^^^^^^^^^^ -4. **-single file\_list** may be used instead of **-fcst** and **-obs** to define objects in a single field. +4. **-single file\_list** command line option may be used instead of the **-fcst** and **-obs** command line options to define objects in a single field. + +.. note:: When the **-single** command line option is used, data specified in the **fcst** configuration file entry is read from those input files. 5. **-log file** gives the name of a file where a log of this MTD run will be written. All output that appears on the screen during a MTD run will be duplicated in the log file. From e5ad6b291278e896346a4e70d0e76173ef1d4601 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 21 Aug 2024 09:00:59 -0600 Subject: [PATCH 104/114] Feature #2924 fcst climo, PR 2 of 3 (#2942) * Per #2924, Update the MPR and ORANK output line types to just write duplicate existing climo values, update the header tables and MPR/ORANK documentation tables. * Per #2924, update get_n_orank_columns() logic * Per #2924, update the Stat-Analysis parsing logic to parse the new MPR and ORANK climatology columns. * Per #2924, making some changes to the vx_statistics library to store climo data... but more work to come. Committing this first set of changes that are incomplete but do compile. * Per #2924, this big set of changes does compile but make test produces a segfault for ensemble-stat * Per #2924, fix return value for is_keeper_obs() * Per #2924, move fcst_info/obs_info into the VxPairBase pointer. * Per #2924, update Ensemble-Stat to set the VxPairBase::fcst_info pointer * Per #2924 udpate handling of fcst_info and obs_info pointers in Ensemble-Stat * Per #2924, update the GSI tools to handle the new fcst climo columns. * Per #2924, add backward compatibility logic so that when old climo column names are requested, the new ones are used. * Per #2924, print a DEBUG(2) log message if old column names are used. * Per #2924, switch the unit tests to reference the updated MPR column names rather than the old ones. * Per #2924, working progress. Not fully compiling yet * Per #2924, another round of changes. Removing MPR:FCST_CLIMO_CDF output column. This compiles but not sure if it actually runs yet * Per #2924, work in progress * Per #2924, work in progress. Almost compiling again. * Per #2924, get it compiling * Per #2924, add back in support for SCP and CDP which are interpreted as SOCP and OCDP, resp * Per #2924, update docs about SCP and CDP threshold types * Per #2924, minor whitespace changes * Per #2924, fix an uninitialized pointer bug by defining/calling SeepsClimoGrid::init_from_scratch() member function. The constructor had been calling clear() to delete pointers that weren't properly initialized to nullptr. Also, simplify some map processing logic. * Per #2924, rename SeepsAggScore from seeps to seeps_agg for clarity and to avoid conflicts in member function implementations. * Per #2924, fix seeps compilation error in Point-Stat * Per #2924, fix bug in the boolean logic for handling the do_climo_cdp NetCDF output option. * Per #2924, add missing exit statement. * Per #2924, tweak threshold.h * Per #2924, define one perc_thresh_info entry for each enumerated PercThreshType value * Per #2924, simplify the logic for handling percentile threshold types and print a log message once when the old versions are still used. * Per #2924, update the string comparison return value logic * Per #2924, fix the perc thresh string parsing logic by calling ConcatString::startswith() * Per #2924, switch all instances of CDP to OCDP. Gen-Ens-Prod was writing NetCDF files with OCDP in the output variable names, but Grid-Stat was requesting that the wrong variable name be read. So the unit tests failed. * Per #2924, add more doc details * Per #2924, update default config file to indicate when climo_mean and climo_stdev can be set seperately in the fcst and obs dictionaries. * Per #2924, update the MET tools to parse climo_mean and climo_stdev separately from the fcst and obs dictionaries. * Per #2924, backing out new/modified columns to minimize reg test diffs * Per #2924, one more section to be commented out later. * Per #2924, replace several calls to strncmp() with ConcatString::startswith() to simplify the code * Per #2924, strip out some more references to OBS_CLIMO_... in the unit tests. * Per #2924, delete accidental file * Per #2924 fix broken XML comments * Per #2924, fix comments * Per #2924, address SonarQube findings * Per #2924, tweak a Point-Stat and Grid-Stat unit test config file to make the output more comparable to develop. * Per #2924, fix bug in the logic of PairDataPoint and PairDataEnsemble, when looping over the 3-dim array do not return when checking the climo and fcst values. Instead we need to continue to the next loop iteration. * Per #2924, address more SonarQube code smells to reduce the overall number in MET for this PR. * Per #2924, correct the logic for parsing climo data from MPR lines. * Per #2924, update MPR and ORANK line types to update/add FCST/OBS_CLIMO_MEAN/STDEV/CDF columns. * Per #2924, cleanup grid_stat.cc source code by making calls to DataPlane::is_empty() and Grid::nxy(). * Per #2924, remove unneeded ==0 * Per #2924, working on PR2. * Per #2924, update User's Guide with notional example of specifying climo_mean and climo_stdev separately in the fcst and obs dicts. * Per #2924, adding a new unit test. It does NOT yet run as expected. Will debug on seneca * Per #2924, pass the description string to the read_climo_data_plane*() function to provide better log messages * Per #2924, more work on consistent log messages * Per #2924, tweak the configuration to define both field, climo_mean, and climo_stdev in both the fcst and obs dictionaries * Per #2924, tweak the unit_climatology_mixed.xml test * Per #2924, only whitespace changes. * Per #2924, missed swapping MET #2924 changes in 3 test files * Per #2924, delete accidentally committed file * Per #2924, delete accidentally committed files * Per #2924, add support for GRIB1 time range indicator value of 123 used for the corresponding METplus Use Case. Note that there are 22 other TRI values not currently supported. --- .github/workflows/testing.yml | 2 + data/table_files/met_header_columns_V12.0.txt | 4 +- docs/Users_Guide/config_options.rst | 54 +++- docs/Users_Guide/grid-diag.rst | 4 +- docs/Users_Guide/mode.rst | 2 +- internal/test_unit/bin/unit_test.sh | 1 + ...nfig_climo_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG | 277 ++++++++++++++++++ .../config/GridStatConfig_mpr_thresh | 20 +- .../config/PointStatConfig_mpr_thresh | 18 +- internal/test_unit/hdr/met_12_0.hdr | 2 +- .../test_unit/xml/unit_climatology_1.5deg.xml | 8 - .../test_unit/xml/unit_climatology_mixed.xml | 39 +++ src/basic/vx_config/threshold.cc | 5 +- src/basic/vx_util/stat_column_defs.h | 26 -- .../vx_data2d_grib/data2d_grib_utils.cc | 8 +- src/libcode/vx_stat_out/stat_columns.cc | 6 - src/libcode/vx_statistics/pair_data_point.cc | 11 - src/libcode/vx_statistics/read_climo.cc | 63 ++-- src/libcode/vx_statistics/read_climo.h | 6 +- src/tools/core/ensemble_stat/ensemble_stat.cc | 28 +- src/tools/core/grid_stat/grid_stat.cc | 148 +++------- src/tools/core/point_stat/point_stat.cc | 12 +- .../core/series_analysis/series_analysis.cc | 16 +- src/tools/other/gen_ens_prod/gen_ens_prod.cc | 6 +- src/tools/other/gsi_tools/gsid2mpr.cc | 4 - src/tools/other/gsi_tools/gsidens2orank.cc | 4 - 26 files changed, 498 insertions(+), 276 deletions(-) create mode 100644 internal/test_unit/config/GridStatConfig_climo_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG create mode 100644 internal/test_unit/xml/unit_climatology_mixed.xml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1fccc357fa..4c1eb33e9c 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -360,6 +360,8 @@ jobs: - jobid: 'job3' tests: 'climatology_2.5deg' - jobid: 'job4' + tests: 'climatology_mixed' + - jobid: 'job5' tests: 'python point2grid plot_data_plane mode mode_analysis perc_thresh hira plot_point_obs quality_filter obs_summary duplicate_flag' fail-fast: false steps: diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index 3d98f02206..5a7f27978e 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -5,7 +5,7 @@ V12.0 : STAT : FHO : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : ISC : 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 TILE_DIM TILE_XLL TILE_YLL NSCALE ISCALE MSE ISC FENERGY2 OENERGY2 BASER FBIAS V12.0 : STAT : MCTC : 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_CAT) F[0-9]*_O[0-9]* EC_VALUE V12.0 : STAT : MCTS : 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_CAT ACC ACC_NCL ACC_NCU ACC_BCL ACC_BCU HK HK_BCL HK_BCU HSS HSS_BCL HSS_BCU GER GER_BCL GER_BCU HSS_EC HSS_EC_BCL HSS_EC_BCU EC_VALUE -V12.0 : STAT : MPR : 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 FCST OBS OBS_QC CLIMO_MEAN CLIMO_STDEV CLIMO_CDF +V12.0 : STAT : MPR : 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 FCST OBS OBS_QC OBS_CLIMO_MEAN OBS_CLIMO_STDEV OBS_CLIMO_CDF FCST_CLIMO_MEAN FCST_CLIMO_STDEV V12.0 : STAT : SEEPS : 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 S12 S13 S21 S23 S31 S32 PF1 PF2 PF3 PV1 PV2 PV3 MEAN_FCST MEAN_OBS SEEPS V12.0 : STAT : SEEPS_MPR : 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 OBS_SID OBS_LAT OBS_LON FCST OBS OBS_QC FCST_CAT OBS_CAT P1 P2 T1 T2 SEEPS V12.0 : 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 @@ -13,7 +13,7 @@ V12.0 : STAT : NBRCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : 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.0 : 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.0 : 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.0 : 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 CLIMO_MEAN SPREAD ENS_MEAN_OERR SPREAD_OERR SPREAD_PLUS_OERR CLIMO_STDEV +V12.0 : 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.0 : 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]* V12.0 : STAT : PJC : 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_TP_[0-9]* ON_TP_[0-9]* CALIBRATION_[0-9]* REFINEMENT_[0-9]* LIKELIHOOD_[0-9]* BASER_[0-9]* V12.0 : STAT : PRC : 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]* PODY_[0-9]* POFD_[0-9]* diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index 81037ca184..3d892808e0 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -158,15 +158,15 @@ The configuration file language supports the following data types: .. note:: - Prior to MET version 12.0.0, forecast climatological inputs were not - supported. The observation climatological inputs were used to process - threshold types named "SCP" and "CDP". + Prior to MET version 12.0.0, forecast climatological inputs were not + supported. The observation climatological inputs were used to process + threshold types named "SCP" and "CDP". - For backward compatibility, the "SCP" threshold type is processed the same - as "SOCP" and "CDP" the same as "OCDP". + For backward compatibility, the "SCP" threshold type is processed the same + as "SOCP" and "CDP" the same as "OCDP". - Users are encouraged to replace the deprecated "SCP" and "CDP" threshold - types with the updated "SOCP" and "OCDP" types, respectively. + Users are encouraged to replace the deprecated "SCP" and "CDP" threshold + types with the updated "SOCP" and "OCDP" types, respectively. * Piecewise-Linear Function (currently used only by MODE): @@ -324,8 +324,10 @@ To run this utility: -e EXISTING_FILE, --existing=EXISTING_FILE Save the text into the named file (optional, default: ../../../data/table_files/ndbc_stations.xml) -NOTE: The downloaded files are written to a subdirectory ndbc_temp_data which -can be deleted once the final output file is created. +.. note:: + + The downloaded files are written to a subdirectory ndbc_temp_data which + can be deleted once the final output file is created. MET_BASE -------- @@ -1508,8 +1510,11 @@ the climatology file names and fields to be used. with 6 and 12 being common choices. Use "NA" if the timing of the climatology data should not be checked. -* The "day_interval" and "hour_interval" entries replace the deprecated - entries "match_month", "match_day", and "time_step". +.. note:: + + As of MET version 11.0.0, the "day_interval" and "hour_interval" entries + replace the "match_month", "match_day", and "time_step" entries, which are + now deprecated. .. code-block:: none @@ -1563,6 +1568,27 @@ over the "climo_mean" setting and then updating the "file_name" entry. file_name = [ "/path/to/climatological/standard/deviation/files" ]; } +Prior to MET version 12.0.0, forecast climatological inputs were not supported. +If the "climo_mean" and "climo_stdev" dictionaries are defined at the top-level +configuration file context, the same data is used for both the forecast and +observation climatologies. To specify separate forecast and observation +climatologies, define "climo_mean" and "climo_stdev" inside the "fcst" and "obs" +dictionaries, as shown below. + +.. code-block:: none + + fcst = { + field = [ ... ]; + climo_mean = { ... }; + climo_stdev = { ... }; + } + + obs = { + field = [ ... ]; + climo_mean = { ... }; + climo_stdev = { ... }; + } + climo_cdf --------- @@ -2297,8 +2323,10 @@ For example: | nc_pairs_var_suffix = "FREEZING"; (for the freezing level height) | -NOTE: This option was previously named "nc_pairs_var_str", which is -now deprecated. +.. note:: + + Prior to MET version 9.0.0, this option was named "nc_pairs_var_str",' + which is now deprecated. .. code-block:: none diff --git a/docs/Users_Guide/grid-diag.rst b/docs/Users_Guide/grid-diag.rst index f2fd55e78c..59bbb38616 100644 --- a/docs/Users_Guide/grid-diag.rst +++ b/docs/Users_Guide/grid-diag.rst @@ -27,7 +27,9 @@ The following sections describe the usage statement, required arguments, and opt [-v level] [-compress level] - NOTE: The "-data" option can be used once to read all fields from each input file or once for each field to be processed. +.. note:: + + The "-data" option can be used once to read all fields from each input file or once for each field to be processed. grid_diag has required arguments and can accept several optional arguments. diff --git a/docs/Users_Guide/mode.rst b/docs/Users_Guide/mode.rst index 491b452002..bb59cfee3e 100644 --- a/docs/Users_Guide/mode.rst +++ b/docs/Users_Guide/mode.rst @@ -913,7 +913,7 @@ The contents of the columns in this ASCII file are summarized in :numref:`MODE_o * - 50 - AREA_RATIO - The forecast object area divided by the observation object area (unitless) :raw-html:`
` - **NOTE:** Prior to met-10.0.0, defined as the lesser of the two object areas divided by the greater of the two + **NOTE:** Prior to MET version 10.0.0, the AREA_RATIO was defined as the lesser of the two object areas divided by the greater of the two. * - 51 - INTERSECTION :raw-html:`
` \_AREA - Intersection area of two objects (in grid squares) diff --git a/internal/test_unit/bin/unit_test.sh b/internal/test_unit/bin/unit_test.sh index 0e2579464d..e3bc29e181 100755 --- a/internal/test_unit/bin/unit_test.sh +++ b/internal/test_unit/bin/unit_test.sh @@ -86,6 +86,7 @@ UNIT_XML="unit_ascii2nc.xml \ unit_climatology_1.0deg.xml \ unit_climatology_1.5deg.xml \ unit_climatology_2.5deg.xml \ + unit_climatology_mixed.xml \ unit_grib_tables.xml \ unit_grid_weight.xml \ unit_netcdf.xml \ diff --git a/internal/test_unit/config/GridStatConfig_climo_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG b/internal/test_unit/config/GridStatConfig_climo_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG new file mode 100644 index 0000000000..ab1cdd8362 --- /dev/null +++ b/internal/test_unit/config/GridStatConfig_climo_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG @@ -0,0 +1,277 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Grid-Stat configuration file. +// +// For additional information, please see the MET User's Guide. +// +//////////////////////////////////////////////////////////////////////////////// + +// +// Output model name to be written +// +model = "GFS"; + +// +// Output description to be written +// May be set separately in each "obs.field" entry +// +desc = "NA"; + +// +// Output observation type to be written +// +obtype = "GFSANL"; + +//////////////////////////////////////////////////////////////////////////////// + +// +// Verification grid +// +regrid = { + to_grid = "${OBS_CLIMO_DIR}/mslp_mean.grib"; + method = BILIN; + width = 2; + vld_thresh = 0.5; + shape = SQUARE; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// May be set separately in each "field" entry +// +censor_thresh = []; +censor_val = []; +mpr_column = []; +mpr_thresh = []; +cat_thresh = []; +cnt_thresh = [ NA ]; +cnt_logic = UNION; +wind_thresh = [ NA ]; +wind_logic = UNION; +eclv_points = 0.05; +nc_pairs_var_name = ""; +nc_pairs_var_suffix = ""; +hss_ec_value = NA; +rank_corr_flag = FALSE; + +// +// Forecast and observation fields to be verified +// + +field_list = [ + { name = "TMP"; level = [ "P500" ]; }, + { name = "UGRD"; level = [ "P500" ]; }, + { name = "VGRD"; level = [ "P500" ]; }, + { name = "TMP"; level = [ "P850" ]; cat_thresh = [ >FCDP75, >OCDP75 ]; }, + { name = "UGRD"; level = [ "P850" ]; cat_thresh = [ >FCDP75, >OCDP75 ]; }, + { name = "VGRD"; level = [ "P850" ]; cat_thresh = [ >FCDP75, >OCDP75 ]; } +]; + +fcst = { + + field = field_list; + + climo_mean = { + field = field_list; + file_name = [ "${FCST_CLIMO_DIR}/cmean_1d.19590410" ]; + }; + + climo_stdev = { + field = field_list; + file_name = [ "${FCST_CLIMO_DIR}/cstdv_1d.19590410" ]; + }; + + time_interp_method = DW_MEAN; + day_interval = 1; + hour_interval = 6; +} + +obs = { + + field = field_list; + + climo_mean = { + field = field_list; + file_name = [ "${OBS_CLIMO_DIR}/t500hPa_mean.grib", + "${OBS_CLIMO_DIR}/t850hPa_mean.grib", + "${OBS_CLIMO_DIR}/u500hPa_mean.grib", + "${OBS_CLIMO_DIR}/u850hPa_mean.grib", + "${OBS_CLIMO_DIR}/v500hPa_mean.grib", + "${OBS_CLIMO_DIR}/v850hPa_mean.grib" ]; + }; + + climo_stdev = { + field = field_list; + file_name = [ "${OBS_CLIMO_DIR}/t850hPa_stdev.grib", + "${OBS_CLIMO_DIR}/u850hPa_stdev.grib", + "${OBS_CLIMO_DIR}/v850hPa_stdev.grib" ]; + }; + + time_interp_method = DW_MEAN; + day_interval = 1; + hour_interval = 12; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// May be set separately in each "obs.field" entry +// +climo_cdf = { + cdf_bins = 1; + center_bins = TRUE; + write_bins = FALSE; + direct_prob = FALSE; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Verification masking regions +// +mask = { + grid = [ "FULL" ]; + poly = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Confidence interval settings +// +ci_alpha = [ 0.05 ]; + +boot = { + interval = PCTILE; + rep_prop = 1.0; + n_rep = 0; + rng = "mt19937"; + seed = ""; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Data smoothing methods +// +interp = { + field = BOTH; + vld_thresh = 1.0; + shape = SQUARE; + + type = [ + { + method = NEAREST; + width = 1; + } + ]; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Neighborhood methods +// +nbrhd = { + width = [ 1 ]; + cov_thresh = [ >=0.5 ]; + vld_thresh = 1.0; + shape = SQUARE; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Fourier decomposition +// +fourier = { + wave_1d_beg = []; + wave_1d_end = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Gradient statistics +// May be set separately in each "obs.field" entry +// +gradient = { + dx = []; + dy = []; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Distance Map statistics +// May be set separately in each "obs.field" entry +// +distance_map = { + baddeley_p = 2; + baddeley_max_dist = NA; + fom_alpha = 0.1; + zhu_weight = 0.5; + beta_value(n) = n * n / 2.0; +} + +//////////////////////////////////////////////////////////////////////////////// + +// +// Statistical output types +// +output_flag = { + fho = NONE; + ctc = NONE; + cts = NONE; + mctc = NONE; + mcts = NONE; + cnt = STAT; + sl1l2 = STAT; + sal1l2 = STAT; + vl1l2 = STAT; + val1l2 = STAT; + vcnt = STAT; + pct = NONE; + pstd = NONE; + pjc = NONE; + prc = NONE; + eclv = NONE; + nbrctc = NONE; + nbrcts = NONE; + nbrcnt = NONE; + grad = NONE; + dmap = NONE; + seeps = NONE; +} + +// +// NetCDF matched pairs output file +// +nc_pairs_flag = { + latlon = TRUE; + raw = TRUE; + diff = TRUE; + climo = TRUE; + climo_cdp = TRUE; + weight = TRUE; + nbrhd = FALSE; + fourier = FALSE; + gradient = FALSE; + distance_map = FALSE; + apply_mask = FALSE; +} + +//////////////////////////////////////////////////////////////////////////////// +// Threshold for SEEPS p1 (Probability of being dry) + +seeps_p1_thresh = NA; + +//////////////////////////////////////////////////////////////////////////////// + +grid_weight_flag = COS_LAT; +tmp_dir = "/tmp"; +output_prefix = "${OUTPUT_PREFIX}"; +version = "V12.0.0"; + +//////////////////////////////////////////////////////////////////////////////// diff --git a/internal/test_unit/config/GridStatConfig_mpr_thresh b/internal/test_unit/config/GridStatConfig_mpr_thresh index 01a9037fd0..e99405be7a 100644 --- a/internal/test_unit/config/GridStatConfig_mpr_thresh +++ b/internal/test_unit/config/GridStatConfig_mpr_thresh @@ -79,32 +79,18 @@ fcst = { desc = "ABS_OBS_FCST_DIFF"; nc_pairs_var_suffix = desc; }, -// MET #2924 Replace this section -// { -// mpr_column = [ "ABS(OBS-OBS_CLIMO_MEAN)" ]; -// mpr_thresh = [ <=5 ]; -// desc = "ABS_OBS_CLIMO_MEAN_DIFF"; -// nc_pairs_var_suffix = desc; -// }, -// { -// mpr_column = [ "OBS_CLIMO_CDF" ]; -// mpr_thresh = [ >=0.25&&<=0.75 ]; -// desc = "OBS_CLIMO_CDF_IQR"; -// nc_pairs_var_suffix = desc; -// } { - mpr_column = [ "ABS(OBS-CLIMO_MEAN)" ]; + mpr_column = [ "ABS(OBS-OBS_CLIMO_MEAN)" ]; mpr_thresh = [ <=5 ]; desc = "ABS_OBS_CLIMO_MEAN_DIFF"; nc_pairs_var_suffix = desc; }, { - mpr_column = [ "CLIMO_CDF" ]; + mpr_column = [ "OBS_CLIMO_CDF" ]; mpr_thresh = [ >=0.25&&<=0.75 ]; - desc = "CLIMO_CDF_IQR"; + desc = "OBS_CLIMO_CDF_IQR"; nc_pairs_var_suffix = desc; } -// MET #2924 End replace ]; } obs = fcst; diff --git a/internal/test_unit/config/PointStatConfig_mpr_thresh b/internal/test_unit/config/PointStatConfig_mpr_thresh index e0d54b9219..675b0696c2 100644 --- a/internal/test_unit/config/PointStatConfig_mpr_thresh +++ b/internal/test_unit/config/PointStatConfig_mpr_thresh @@ -68,28 +68,16 @@ fcst = { mpr_thresh = [ <=5 ]; desc = "ABS_OBS_FCST_DIFF"; }, -// MET #2924 Replace this section -// { -// mpr_column = [ "ABS(OBS-OBS_CLIMO_MEAN)" ]; -// mpr_thresh = [ <=5 ]; -// desc = "ABS_OBS_CLIMO_MEAN_DIFF"; -// }, -// { -// mpr_column = [ "OBS_CLIMO_CDF" ]; -// mpr_thresh = [ >=0.25&&<=0.75 ]; -// desc = "OBS_CLIMO_CDF_IQR"; -// } { - mpr_column = [ "ABS(OBS-CLIMO_MEAN)" ]; + mpr_column = [ "ABS(OBS-OBS_CLIMO_MEAN)" ]; mpr_thresh = [ <=5 ]; desc = "ABS_OBS_CLIMO_MEAN_DIFF"; }, { - mpr_column = [ "CLIMO_CDF" ]; + mpr_column = [ "OBS_CLIMO_CDF" ]; mpr_thresh = [ >=0.25&&<=0.75 ]; - desc = "CLIMO_CDF_IQR"; + desc = "OBS_CLIMO_CDF_IQR"; } -// MET #2924 End replace ]; } obs = fcst; diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index b7d835c72c..f3785b7b48 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -5,7 +5,7 @@ FHO : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L ISC : 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 TILE_DIM TILE_XLL TILE_YLL NSCALE ISCALE MSE ISC FENERGY2 OENERGY2 BASER FBIAS MCTC : 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_CAT _VAR_ MCTS : 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_CAT ACC ACC_NCL ACC_NCU ACC_BCL ACC_BCU HK HK_BCL HK_BCU HSS HSS_BCL HSS_BCU GER GER_BCL GER_BCU HSS_EC HSS_EC_BCL HSS_EC_BCU EC_VALUE -MPR : 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 FCST OBS OBS_QC CLIMO_MEAN CLIMO_STDEV CLIMO_CDF +MPR : 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 FCST OBS OBS_QC OBS_CLIMO_MEAN OBS_CLIMO_STDEV OBS_CLIMO_CDF FCST_CLIMO_MEAN FCST_CLIMO_STDEV SEEPS : 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 S12 S13 S21 S23 S31 S32 PF1 PF2 PF3 PV1 PV2 PV3 MEAN_FCST MEAN_OBS SEEPS SEEPS_MPR : 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 OBS_SID OBS_LAT OBS_LON FCST OBS OBS_QC FCST_CAT OBS_CAT P1 P2 T1 T2 SEEPS 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 diff --git a/internal/test_unit/xml/unit_climatology_1.5deg.xml b/internal/test_unit/xml/unit_climatology_1.5deg.xml index 278df4a8be..de22d95673 100644 --- a/internal/test_unit/xml/unit_climatology_1.5deg.xml +++ b/internal/test_unit/xml/unit_climatology_1.5deg.xml @@ -82,19 +82,11 @@ OUTPUT_DIR &OUTPUT_DIR;/climatology_1.5deg - - \ - -lookin &OUTPUT_DIR;/climatology_1.5deg/point_stat_WMO_CLIMO_1.5DEG_120000L_20120409_120000V.stat \ - -job filter -line_type MPR -column_thresh CLIMO_CDF 'lt0.1||gt0.9' \ - -dump_row &OUTPUT_DIR;/climatology_1.5deg/stat_analysis_WMO_1.5DEG_FILTER_CDF_dump.stat - - &OUTPUT_DIR;/climatology_1.5deg/stat_analysis_WMO_1.5DEG_FILTER_CDF_dump.stat diff --git a/internal/test_unit/xml/unit_climatology_mixed.xml b/internal/test_unit/xml/unit_climatology_mixed.xml new file mode 100644 index 0000000000..0433b39e8d --- /dev/null +++ b/internal/test_unit/xml/unit_climatology_mixed.xml @@ -0,0 +1,39 @@ + + + + + + + + + + +]> + + + + + + &TEST_DIR; + true + + + &MET_BIN;/grid_stat + + OUTPUT_PREFIX FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG + FCST_CLIMO_DIR &DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg + OBS_CLIMO_DIR &DATA_DIR_CLIMO;/ERA_DAILY_1.5deg + + \ + &DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F024.grib2 \ + &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_0000_000.grb2 \ + &CONFIG_DIR;/GridStatConfig_climo_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG \ + -outdir &OUTPUT_DIR;/climatology_mixed -v 2 + + + &OUTPUT_DIR;/climatology_mixed/grid_stat_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG_240000L_20120410_000000V.stat + &OUTPUT_DIR;/climatology_mixed/grid_stat_FCST_NCEP_1.0DEG_OBS_WMO_1.5DEG_240000L_20120410_000000V_pairs.nc + + + diff --git a/src/basic/vx_config/threshold.cc b/src/basic/vx_config/threshold.cc index bfff7a0089..cbf0a3cb7d 100644 --- a/src/basic/vx_config/threshold.cc +++ b/src/basic/vx_config/threshold.cc @@ -103,9 +103,8 @@ for (auto const& x : perc_thresh_info_map) { } // - // MET #2924: For backward compatibility support SCP and CDP - // threshold types - // + // MET #2924 Backward compatible support for SCP and CDP types + // if ( !match && (search_cs.startswith(scp_perc_thresh_type_str.c_str()) || diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index 5ae3a64b1a..a7b5427143 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -197,7 +197,6 @@ static const char * const eclv_columns [] = { "N_PNT", "CL_", "VALUE_" }; -/* MET #2924 Replace this change static const char * const mpr_columns [] = { "TOTAL", "INDEX", "OBS_SID", "OBS_LAT", "OBS_LON", "OBS_LVL", @@ -206,17 +205,6 @@ static const char * const mpr_columns [] = { "OBS_CLIMO_MEAN", "OBS_CLIMO_STDEV", "OBS_CLIMO_CDF", "FCST_CLIMO_MEAN", "FCST_CLIMO_STDEV" }; -*/ - -static const char * const mpr_columns [] = { - "TOTAL", "INDEX", "OBS_SID", - "OBS_LAT", "OBS_LON", "OBS_LVL", - "OBS_ELV", "FCST", "OBS", - "OBS_QC", - "CLIMO_MEAN", "CLIMO_STDEV", "CLIMO_CDF" -}; - -// MET #2924 End replace static const char * const nbrctc_columns [] = { "TOTAL", "FY_OY", "FY_ON", @@ -308,7 +296,6 @@ static const char * const phist_columns [] = { "BIN_" }; -/* MET #2924 Replace this section static const char * const orank_columns [] = { "TOTAL", "INDEX", "OBS_SID", "OBS_LAT", "OBS_LON", "OBS_LVL", @@ -319,19 +306,6 @@ static const char * const orank_columns [] = { "SPREAD_OERR", "SPREAD_PLUS_OERR", "OBS_CLIMO_STDEV", "FCST_CLIMO_MEAN", "FCST_CLIMO_STDEV" }; -*/ - -static const char * const orank_columns [] = { - "TOTAL", "INDEX", "OBS_SID", - "OBS_LAT", "OBS_LON", "OBS_LVL", - "OBS_ELV", "OBS", "PIT", - "RANK", "N_ENS_VLD", "N_ENS", - "ENS_", "OBS_QC", "ENS_MEAN", - "CLIMO_MEAN", "SPREAD", "ENS_MEAN_OERR", - "SPREAD_OERR", "SPREAD_PLUS_OERR", "CLIMO_STDEV" -}; - -// MET #2924 End replace static const char * const ssvar_columns [] = { "TOTAL", "N_BIN", "BIN_i", diff --git a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc index f948b26253..cc3e81f82c 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib_utils.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib_utils.cc @@ -669,7 +669,8 @@ void read_pds(const GribRecord &r, int &bms_flag, // // Set the valid and accumulation times based on the - // contents of the time range indicator + // contents of the time range indicator in GRIB1 Table 5: + // https://www.nco.ncep.noaa.gov/pmb/docs/on388/table5.html // switch((int) pds->tri) { @@ -725,6 +726,11 @@ void read_pds(const GribRecord &r, int &bms_flag, accum = 0; break; + case 123: // Average of N uninitialized analyses, starting at the reference time, at intervals of P2. + valid_ut = init_ut; + accum = 0; + break; + case 136: // Climatological Standard Deviation valid_ut = init_ut; accum = 0; diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 35a2fe7ba0..51992d7b50 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -488,10 +488,8 @@ void write_orank_header_row(int hdr_flag, int n_ens, AsciiTable &at, at.set_entry(r, c+17+n_ens, (string)orank_columns[18]); at.set_entry(r, c+18+n_ens, (string)orank_columns[19]); at.set_entry(r, c+19+n_ens, (string)orank_columns[20]); - /* MET #2924 Uncomment this section at.set_entry(r, c+20+n_ens, (string)orank_columns[21]); at.set_entry(r, c+21+n_ens, (string)orank_columns[22]); - */ return; } @@ -4126,13 +4124,11 @@ void write_mpr_cols(const PairDataPoint *pd_ptr, int i, at.set_entry(r, c+12, // Observation Climatological CDF Value pd_ptr->ocdf_na[i]); -/* MET #2924 Uncomment this section at.set_entry(r, c+13, // Forecast Climatological Mean Value pd_ptr->fcmn_na[i]); at.set_entry(r, c+14, // Forecast Climatological Standard Deviation Value pd_ptr->fcsd_na[i]); -*/ return; } @@ -4589,7 +4585,6 @@ void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, at.set_entry(r, c+19+pd_ptr->n_ens, pd_ptr->ocsd_na[i]); -/* MET #2924 Uncomment this section // Forecast climatology mean values at.set_entry(r, c+20+pd_ptr->n_ens, pd_ptr->fcmn_na[i]); @@ -4597,7 +4592,6 @@ void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, // Forecast climatology standard deviation values at.set_entry(r, c+21+pd_ptr->n_ens, pd_ptr->fcsd_na[i]); -*/ return; } diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 0d29dda9ed..0e7f6203e7 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -820,7 +820,6 @@ double get_mpr_column_value(double f, double o, const ClimoPntInfo &cpi, const char *s) { double v; -/* #MET #2924 Replace this section if(strcasecmp(s, "FCST") == 0) v = f; else if(strcasecmp(s, "OBS") == 0) v = o; else if(strcasecmp(s, "FCST_CLIMO_MEAN") == 0) v = cpi.fcmn; @@ -831,16 +830,6 @@ double get_mpr_column_value(double f, double o, const ClimoPntInfo &cpi, v = (is_bad_data(cpi.ocmn) || is_bad_data(cpi.ocsd) ? bad_data_double : normal_cdf(o, cpi.ocmn, cpi.ocsd)); } -*/ - if(strcasecmp(s, "FCST") == 0) v = f; - else if(strcasecmp(s, "OBS") == 0) v = o; - else if(strcasecmp(s, "CLIMO_MEAN") == 0) v = cpi.ocmn; - else if(strcasecmp(s, "CLIMO_STDEV") == 0) v = cpi.ocsd; - else if(strcasecmp(s, "CLIMO_CDF") == 0) { - v = (is_bad_data(cpi.ocmn) || is_bad_data(cpi.ocsd) ? - bad_data_double : normal_cdf(o, cpi.ocmn, cpi.ocsd)); - } -// MET #2924 End replace else { mlog << Error << "\nget_mpr_column_value() -> " << "unsupported matched pair column name requested in \"" diff --git a/src/libcode/vx_statistics/read_climo.cc b/src/libcode/vx_statistics/read_climo.cc index 8e43749a8d..f5a0f2db71 100644 --- a/src/libcode/vx_statistics/read_climo.cc +++ b/src/libcode/vx_statistics/read_climo.cc @@ -29,7 +29,7 @@ using namespace std; static void read_climo_file( const char *, GrdFileType, Dictionary *, unixtime, int, int, const Grid &, const RegridInfo &, - DataPlaneArray &dpa); + DataPlaneArray &dpa, const char *); static DataPlaneArray climo_time_interp( const DataPlaneArray &, int, unixtime, InterpMthd); @@ -40,7 +40,8 @@ static DataPlane climo_hms_interp( //////////////////////////////////////////////////////////////////////// DataPlane read_climo_data_plane(Dictionary *dict, int i_vx, - unixtime vld_ut, const Grid &vx_grid) { + unixtime vld_ut, const Grid &vx_grid, + const char *desc) { DataPlane dp; DataPlaneArray dpa; @@ -48,13 +49,13 @@ DataPlane read_climo_data_plane(Dictionary *dict, int i_vx, if(!dict) return dp; // Read array of climatology fields - dpa = read_climo_data_plane_array(dict, i_vx, vld_ut, vx_grid); + dpa = read_climo_data_plane_array(dict, i_vx, vld_ut, vx_grid, desc); // Check for multiple matches if(dpa.n_planes() > 1) { mlog << Warning << "\nread_climo_data_plane() -> " - << "Found " << dpa.n_planes() << " matching climatology " - << "fields. Using the first match found.\n\n"; + << "Found " << dpa.n_planes() << " matching " << desc + << " fields. Using the first match found.\n\n"; } // Store the first match found @@ -67,7 +68,8 @@ DataPlane read_climo_data_plane(Dictionary *dict, int i_vx, DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, unixtime vld_ut, - const Grid &vx_grid) { + const Grid &vx_grid, + const char *desc) { DataPlaneArray dpa; StringArray climo_files; RegridInfo regrid_info; @@ -100,7 +102,7 @@ DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, // Range check day_interval if(!is_bad_data(day_interval) && day_interval < 1) { mlog << Error << "\nread_climo_data_plane_array() -> " - << "The \"" << conf_key_day_interval << "\" entry (" + << "The " << conf_key_day_interval << " entry (" << day_interval << ") can be set to " << na_str << " or a value of at least 1.\n\n"; exit(1); @@ -113,7 +115,7 @@ DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, if(!is_bad_data(hour_interval) && (hour_interval <= 0 || hour_interval > 24)) { mlog << Error << "\nread_climo_data_plane_array() -> " - << "The \"" << conf_key_hour_interval << "\" entry (" + << "The " << conf_key_hour_interval << " entry (" << hour_interval << ") can be set to " << na_str << " or a value between 0 and 24.\n\n"; exit(1); @@ -131,14 +133,15 @@ DataPlaneArray read_climo_data_plane_array(Dictionary *dict, int i_vx, // Search the files for the requested records for(i=0; i " - << "Trouble reading climatology file \"" - << climo_file << "\"\n\n"; + << "Trouble reading climatology file " + << climo_file << "\n\n"; return; } @@ -191,21 +194,21 @@ void read_climo_file(const char *climo_file, GrdFileType ctype, // Check the day time step if(!is_bad_data(day_ts) && abs(day_diff_sec) >= day_ts) { - mlog << Debug(3) << "Skipping " << clm_ut_cs << " \"" << info->magic_str() - << "\" climatology field with " << day_diff_sec / sec_per_day + mlog << Debug(3) << "Skipping " << clm_ut_cs << " " << info->magic_str() + << " climatology field with " << day_diff_sec / sec_per_day << " day offset (" << conf_key_day_interval << " = " - << day_ts / sec_per_day << ") from file \"" - << climo_file << "\".\n"; + << day_ts / sec_per_day << ") from file " + << climo_file << ".\n"; continue; } // Check the hour time step if(!is_bad_data(hour_ts) && abs(hms_diff_sec) >= hour_ts) { - mlog << Debug(3) << "Skipping " << clm_ut_cs << " \"" << info->magic_str() - << "\" climatology field with " << (double) hms_diff_sec / sec_per_hour + mlog << Debug(3) << "Skipping " << clm_ut_cs << " " << info->magic_str() + << " climatology field with " << (double) hms_diff_sec / sec_per_hour << " hour offset (" << conf_key_hour_interval << " = " - << hour_ts / sec_per_hour << ") from file \"" - << climo_file << "\".\n"; + << hour_ts / sec_per_hour << ") from file " + << climo_file << ".\n"; continue; } @@ -213,17 +216,17 @@ void read_climo_file(const char *climo_file, GrdFileType ctype, unixtime clm_vld_ut = vld_ut + day_diff_sec + hms_diff_sec; // Print log message for matching record - mlog << Debug(3) << "Storing " << clm_ut_cs << " \"" << info->magic_str() - << "\" climatology field with " << day_diff_sec / sec_per_day + mlog << Debug(3) << "Storing " << clm_ut_cs << " " << info->magic_str() + << " climatology field with " << day_diff_sec / sec_per_day << " day, " << (double) hms_diff_sec / sec_per_hour << " hour offset as time " - << unix_to_yyyymmdd_hhmmss(clm_vld_ut) << " from file \"" - << climo_file << "\".\n"; + << unix_to_yyyymmdd_hhmmss(clm_vld_ut) << " from file " + << climo_file << ".\n"; // Regrid, if needed if(!(mtddf->grid() == vx_grid)) { - mlog << Debug(2) << "Regridding " << clm_ut_cs << " \"" - << info->magic_str() - << "\" climatology field to the verification grid.\n"; + mlog << Debug(2) << "Regridding " << clm_ut_cs << " " + << desc << " field " << info->magic_str() + << " to the verification grid.\n"; dp = met_regrid(clm_dpa[i], mtddf->grid(), vx_grid, regrid_info); } @@ -343,8 +346,8 @@ DataPlaneArray climo_time_interp(const DataPlaneArray &dpa, int day_ts, // This should only occur when day_interval > 1. if(day_ts <= 3600*24) { mlog << Error << "\nclimo_time_interp() -> " - << "Expecting 1 or 2 climatology fields when \"" - << conf_key_day_interval << "\" <= 1 but found " + << "Expecting 1 or 2 climatology fields when " + << conf_key_day_interval << " <= 1 but found " << it->second.n() << "\n\n"; exit(1); } diff --git a/src/libcode/vx_statistics/read_climo.h b/src/libcode/vx_statistics/read_climo.h index a017df6388..362efa3fce 100644 --- a/src/libcode/vx_statistics/read_climo.h +++ b/src/libcode/vx_statistics/read_climo.h @@ -19,10 +19,12 @@ //////////////////////////////////////////////////////////////////////// extern DataPlane read_climo_data_plane(Dictionary *, int, - unixtime, const Grid &); + unixtime, const Grid &, + const char *); extern DataPlaneArray read_climo_data_plane_array(Dictionary *, int, - unixtime, const Grid &); + unixtime, const Grid &, + const char *); //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 3dedd76ef5..826b8eaf7a 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -784,18 +784,22 @@ void process_point_vx() { // Read forecast climatology data fcmn_dpa = read_climo_data_plane_array( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - i, ens_valid_ut, grid); + i, ens_valid_ut, grid, + "forecast climatology mean"); fcsd_dpa = read_climo_data_plane_array( - conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), - i, ens_valid_ut, grid); + conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), + i, ens_valid_ut, grid, + "forecast climatology standard deviation"); // Read observation climatology data ocmn_dpa = read_climo_data_plane_array( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - i, ens_valid_ut, grid); + i, ens_valid_ut, grid, + "observation climatology mean"); ocsd_dpa = read_climo_data_plane_array( - conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), - i, ens_valid_ut, grid); + conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), + i, ens_valid_ut, grid, + "observation climatology standard deviation"); mlog << Debug(3) << "For " << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() << ", found " @@ -1424,18 +1428,22 @@ void process_grid_vx() { // Read forecast climatology data fcmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - i, ens_valid_ut, grid); + i, ens_valid_ut, grid, + "forecast climatology mean"); fcsd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), - i, ens_valid_ut, grid); + i, ens_valid_ut, grid, + "forecast climatology standard deviation"); // Read observation climatology data ocmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - i, ens_valid_ut, grid); + i, ens_valid_ut, grid, + "observation climatology mean"); ocsd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), - i, ens_valid_ut, grid); + i, ens_valid_ut, grid, + "observation climatology standard deviation"); mlog << Debug(3) << "For " << conf_info.vx_opt[i].vx_pd.fcst_info->magic_str() << ", found " diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index fcd0bc33a9..33f3e14dfc 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -196,8 +196,8 @@ static void clean_up(); static void usage(); static void set_outdir(const StringArray &); static void set_compress(const StringArray &); -static bool read_data_plane(VarInfo* info, DataPlane& dp, Met2dDataFile* mtddf, - const ConcatString &filename); +static bool read_data_plane(VarInfo *info, DataPlane &dp, Met2dDataFile *mtddf, + const ConcatString &filename, const char *desc); #ifdef WITH_UGRID static void set_ugrid_config(const StringArray &); #endif @@ -725,7 +725,8 @@ void process_scores() { // Read the gridded data from the input forecast file if(!read_data_plane(conf_info.vx_opt[i].fcst_info, - fcst_dp, fcst_mtddf, fcst_file)) continue; + fcst_dp, fcst_mtddf, fcst_file, + "forecast")) continue; mlog << Debug(3) << "Reading forecast data for " @@ -740,7 +741,8 @@ void process_scores() { // Read the gridded data from the input observation file if(!read_data_plane(conf_info.vx_opt[i].obs_info, - obs_dp, obs_mtddf, obs_file)) continue; + obs_dp, obs_mtddf, obs_file, + "observation")) continue; mlog << Debug(3) << "Reading observation data for " @@ -790,18 +792,22 @@ void process_scores() { // Read forecast climatology data fcmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - i, fcst_dp.valid(), grid); + i, fcst_dp.valid(), grid, + "forecast climatology mean"); fcsd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), - i, fcst_dp.valid(), grid); + i, fcst_dp.valid(), grid, + "forecast climatology standard deviation"); // Read observation climatology data ocmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - i, fcst_dp.valid(), grid); + i, fcst_dp.valid(), grid, + "observation climatology mean"); ocsd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), - i, fcst_dp.valid(), grid); + i, fcst_dp.valid(), grid, + "observation climatology standard deviation"); mlog << Debug(3) << "For " << conf_info.vx_opt[i].fcst_info->magic_str() << ", found " @@ -1048,27 +1054,33 @@ void process_scores() { // Read forecast data for UGRD if(!read_data_plane(conf_info.vx_opt[ui].fcst_info, - fu_dp, fcst_mtddf, fcst_file)) continue; + fu_dp, fcst_mtddf, fcst_file, + "U-wind forecast")) continue; // Read observation data for UGRD if(!read_data_plane(conf_info.vx_opt[ui].obs_info, - ou_dp, obs_mtddf, obs_file)) continue; + ou_dp, obs_mtddf, obs_file, + "U-wind observation")) continue; // Read the forecast climatology data for UGRD fcmnu_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - ui, fcst_dp.valid(), grid); + ui, fcst_dp.valid(), grid, + "forecast U-wind climatology mean"); fcsdu_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), - ui, fcst_dp.valid(), grid); + ui, fcst_dp.valid(), grid, + "forecast U-wind climatology standard deviation"); // Read the observation climatology data for UGRD ocmnu_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - ui, fcst_dp.valid(), grid); + ui, fcst_dp.valid(), grid, + "observation U-wind climatology mean"); ocsdu_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), - ui, fcst_dp.valid(), grid); + ui, fcst_dp.valid(), grid, + "observation U-wind climatology standard deviation"); // If requested in the config file, smooth the forecast // and climatology U-wind fields @@ -1178,7 +1190,6 @@ void process_scores() { i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); } - /* MET #2924 Replace this section if(conf_info.vx_opt[i].nc_info.do_climo && !fcmn_dp.is_empty()) { write_nc((string)"FCST_CLIMO_MEAN", fcmn_dp, @@ -1209,26 +1220,6 @@ void process_scores() { i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); } - */ - if(conf_info.vx_opt[i].nc_info.do_climo && - !ocmn_dp.is_empty()) { - write_nc((string)"CLIMO_MEAN", ocmn_dp, - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - } - if(conf_info.vx_opt[i].nc_info.do_climo && - !ocsd_dp.is_empty()) { - write_nc((string)"CLIMO_STDEV", fcsd_dp, - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - } - if(conf_info.vx_opt[i].nc_info.do_climo && - !ocmn_dp.is_empty() && !ocsd_dp.is_empty()) { - write_nc((string)"CLIMO_CDF", normal_cdf(obs_dp, ocmn_dp, ocsd_dp), - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - } - // MET #2924 End replace // Write out the fields of requested climo distribution percentile threshold values if(conf_info.vx_opt[i].nc_info.do_climo_cdp && @@ -1249,7 +1240,6 @@ void process_scores() { // Process all CDP thresholds except 0 and 100 for(vector::iterator it = simp.begin(); it != simp.end(); it++) { - /* MET #2924 Replace this section if(it->ptype() == perc_thresh_fcst_climo_dist && !is_eq(it->pvalue(), 0.0) && !is_eq(it->pvalue(), 100.0)) { @@ -1266,16 +1256,6 @@ void process_scores() { i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); } - */ - if(it->ptype() == perc_thresh_obs_climo_dist && - !is_eq(it->pvalue(), 0.0) && - !is_eq(it->pvalue(), 100.0)) { - cs << cs_erase << "CLIMO_CDP" << nint(it->pvalue()); - write_nc(cs, normal_cdf_inv(it->pvalue()/100.0, ocmn_dp, ocsd_dp), - i, mthd, pnts, - conf_info.vx_opt[i].interp_info.field); - } - // MET #2924 End replace } // end for it } @@ -1912,19 +1892,23 @@ void process_scores() { // Read forecast data for UGRD if(!read_data_plane(conf_info.vx_opt[ui].fcst_info, - fu_dp, fcst_mtddf, fcst_file)) continue; + fu_dp, fcst_mtddf, fcst_file, + "U-wind forecast")) continue; // Read observation data for UGRD if(!read_data_plane(conf_info.vx_opt[ui].obs_info, - ou_dp, obs_mtddf, obs_file)) continue; + ou_dp, obs_mtddf, obs_file, + "U-wind observation")) continue; // Read climatology data for UGRD fcmnu_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - ui, fcst_dp.valid(), grid); + ui, fcst_dp.valid(), grid, + "forecast U-wind climatology mean"); ocmnu_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - ui, fcst_dp.valid(), grid); + ui, fcst_dp.valid(), grid, + "observation U-wind climatology mean"); // Apply Fourier decomposition to the U-wind fields fu_dp_smooth = fu_dp; @@ -2037,7 +2021,6 @@ void process_scores() { i, shc.get_interp_mthd(), bad_data_int, FieldType::Both); } - /* MET #2924 Replace this change if(conf_info.vx_opt[i].nc_info.do_climo && !fcmn_dp_smooth.is_empty()) { write_nc((string)"FCST_CLIMO_MEAN", fcmn_dp_smooth, @@ -2050,14 +2033,6 @@ void process_scores() { i, shc.get_interp_mthd(), bad_data_int, FieldType::Both); } - */ - if(conf_info.vx_opt[i].nc_info.do_climo && - !ocmn_dp_smooth.is_empty()) { - write_nc((string)"CLIMO_MEAN", ocmn_dp_smooth, - i, shc.get_interp_mthd(), - bad_data_int, FieldType::Both); - } - // MET #2924 End replace } // end if } // end for j @@ -2838,7 +2813,6 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, level_att = shc.get_fcst_lev(); units_att = conf_info.vx_opt[i_vx].fcst_info->units_attr(); } - /* MET #2924 Replace this section else if(field_name == "OBS_CLIMO_MEAN") { var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; @@ -2895,52 +2869,6 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, level_att = shc.get_obs_lev(); units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); } - */ - else if(field_name == "CLIMO_MEAN") { - var_name << cs_erase << field_name << "_" - << obs_name << var_suffix << "_" << mask_str; - - // Append interpolation string for Fourier decomposition - if(interp_str.nonempty()) { - if(interp_str.startswith("_WV")) var_name << interp_str; - } - long_att << cs_erase - << "Climatology mean for " - << obs_long_name; - level_att = shc.get_obs_lev(); - units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); - } - else if(field_name == "CLIMO_STDEV") { - var_name << cs_erase << field_name << "_" - << obs_name << var_suffix << "_" << mask_str; - long_att << cs_erase - << "Climatology standard deviation for " - << obs_long_name; - level_att = shc.get_obs_lev(); - units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); - } - else if(field_name == "CLIMO_CDF") { - var_name << cs_erase << field_name << "_" - << obs_name << var_suffix << "_" << mask_str; - long_att << cs_erase - << "Climatology cumulative distribution function for " - << obs_long_name; - level_att = shc.get_obs_lev(); - units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); - } - else if(field_name.startswith("CLIMO_CDP")) { - var_name << cs_erase - << field_name << "_" - << conf_info.vx_opt[i_vx].obs_info->name_attr() << "_" - << conf_info.vx_opt[i_vx].obs_info->level_attr() - << var_suffix << "_" << mask_str; - long_att << cs_erase - << "Climatology distribution percentile thresholds for " - << obs_long_name; - level_att = shc.get_obs_lev(); - units_att = conf_info.vx_opt[i_vx].obs_info->units_attr(); - } - // MET #2924 end replace else if(check_reg_exp("FCST_XGRAD_", field_name.c_str()) || check_reg_exp("FCST_YGRAD_", field_name.c_str())) { var_name << cs_erase << field_name << "_" @@ -3394,15 +3322,15 @@ void set_compress(const StringArray & a) { //////////////////////////////////////////////////////////////////////// -bool read_data_plane(VarInfo* info, DataPlane& dp, Met2dDataFile* mtddf, - const ConcatString &filename) { +bool read_data_plane(VarInfo *info, DataPlane &dp, Met2dDataFile *mtddf, + const ConcatString &filename, const char *desc) { bool status = mtddf->data_plane(*info, dp); if(!status) { mlog << Warning << "\nread_data_plane() -> " << info->magic_str() - << " not found in file: " << filename + << " not found in " << desc << " file: " << filename << "\n\n"; return false; } @@ -3410,7 +3338,7 @@ bool read_data_plane(VarInfo* info, DataPlane& dp, Met2dDataFile* mtddf, // Regrid, if necessary if(!(mtddf->grid() == grid)) { mlog << Debug(1) - << "Regridding field " + << "Regridding " << desc << " field " << info->magic_str() << " to the verification grid.\n"; dp = met_regrid(dp, mtddf->grid(), grid, info->regrid()); diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 5532ea7e1d..bda41ddf26 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -668,18 +668,22 @@ void process_fcst_climo_files() { // Read forecast climatology data fcmn_dpa = read_climo_data_plane_array( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - i, fcst_dpa[0].valid(), grid); + i, fcst_dpa[0].valid(), grid, + "forecast climatology mean"); fcsd_dpa = read_climo_data_plane_array( conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), - i, fcst_dpa[0].valid(), grid); + i, fcst_dpa[0].valid(), grid, + "forecast climatology standard deviation"); // Read observation climatology data ocmn_dpa = read_climo_data_plane_array( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - i, fcst_dpa[0].valid(), grid); + i, fcst_dpa[0].valid(), grid, + "observation climatology mean"); ocsd_dpa = read_climo_data_plane_array( conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), - i, fcst_dpa[0].valid(), grid); + i, fcst_dpa[0].valid(), grid, + "observation climatology standard deviation"); // Store data for the current verification task conf_info.vx_opt[i].vx_pd.set_fcst_dpa(fcst_dpa); diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index 5622908e0d..a2e8cdf5c1 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -738,19 +738,25 @@ void process_scores() { << min(i_point + conf_info.block_size, nxy) << ".\n"; } - // Read climatology data for the current series entry + // Read forecast climatology data fcmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_mean_field, false), - i_fcst, fcst_dp.valid(), grid); + i_fcst, fcst_dp.valid(), grid, + "forecast climatology mean"); fcsd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_fcst_climo_stdev_field, false), - i_fcst, fcst_dp.valid(), grid); + i_fcst, fcst_dp.valid(), grid, + "forecast climatology standard deviation"); + + // Read observation climatology data ocmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_mean_field, false), - i_fcst, fcst_dp.valid(), grid); + i_fcst, fcst_dp.valid(), grid, + "observation climatology mean"); ocsd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_obs_climo_stdev_field, false), - i_fcst, fcst_dp.valid(), grid); + i_fcst, fcst_dp.valid(), grid, + "observation climatology standard deviation"); bool fcmn_flag = (fcmn_dp.nx() == fcst_dp.nx() && fcmn_dp.ny() == fcst_dp.ny()); diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index 368fceab6f..b088c74dcf 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -469,7 +469,8 @@ void get_climo_mean_stdev(GenEnsProdVarInfo *ens_info, int i_var, cmn_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_climo_mean_field, false), - i_var, ens_valid_ut, grid); + i_var, ens_valid_ut, grid, + "climatology mean"); mlog << Debug(4) << "Reading climatology standard deviation data for ensemble field \"" @@ -477,7 +478,8 @@ void get_climo_mean_stdev(GenEnsProdVarInfo *ens_info, int i_var, csd_dp = read_climo_data_plane( conf_info.conf.lookup_array(conf_key_climo_stdev_field, false), - i_var, ens_valid_ut, grid); + i_var, ens_valid_ut, grid, + "climatology standard deviation"); // Unset the MET_ENS_MEMBER_ID environment variable if(set_ens_mem_id) { diff --git a/src/tools/other/gsi_tools/gsid2mpr.cc b/src/tools/other/gsi_tools/gsid2mpr.cc index e5a770f8e3..d0468d3b08 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.cc +++ b/src/tools/other/gsi_tools/gsid2mpr.cc @@ -392,10 +392,8 @@ void write_mpr_row_conv(AsciiTable &at, int row, const ConvData &d) { at.set_entry(row, col++, na_str); // OBS_CLIMO_MEAN at.set_entry(row, col++, na_str); // OBS_CLIMO_STDEV at.set_entry(row, col++, na_str); // OBS_CLIMO_CDF - /* MET #2924 Uncomment this section at.set_entry(row, col++, na_str); // FCST_CLIMO_MEAN at.set_entry(row, col++, na_str); // FCST_CLIMO_STDEV - */ // Write extra columns at.set_entry(row, col++, d.prs); // OBS_PRS @@ -450,10 +448,8 @@ void write_mpr_row_rad(AsciiTable &at, int row, const RadData & d) { at.set_entry(row, col++, na_str); // OBS_CLIMO_MEAN at.set_entry(row, col++, na_str); // OBS_CLIMO_STDEV at.set_entry(row, col++, na_str); // OBS_CLIMO_CDF - /* MET #2924 Uncomment this section at.set_entry(row, col++, na_str); // FCST_CLIMO_MEAN at.set_entry(row, col++, na_str); // FCST_CLIMO_STDEV - */ // Write extra columns at.set_entry(row, col++, d.use); // CHAN_USE diff --git a/src/tools/other/gsi_tools/gsidens2orank.cc b/src/tools/other/gsi_tools/gsidens2orank.cc index fed035bd69..39edb87cc5 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.cc +++ b/src/tools/other/gsi_tools/gsidens2orank.cc @@ -641,10 +641,8 @@ void write_orank_row_conv(AsciiTable &at, int row, int i_obs) { at.set_entry(row, col++, bad_data_double); // SPREAD_OERR at.set_entry(row, col++, bad_data_double); // SPREAD_PLUS_OERR at.set_entry(row, col++, bad_data_double); // OBS_CLIMO_STDEV - /* MET #2924 Uncomment this section at.set_entry(row, col++, bad_data_double); // FCST_CLIMO_MEAN at.set_entry(row, col++, bad_data_double); // FCST_CLIMO_STDEV - */ // Write extra columns at.set_entry(row, col++, d->n_use); // N_USE @@ -711,10 +709,8 @@ void write_orank_row_rad(AsciiTable &at, int row, int i_obs) { at.set_entry(row, col++, bad_data_double); // SPREAD_OERR at.set_entry(row, col++, bad_data_double); // SPREAD_PLUS_OERR at.set_entry(row, col++, bad_data_double); // OBS_CLIMO_STDEV - /* MET #2924 Uncomment this section at.set_entry(row, col++, bad_data_double); // FCST_CLIMO_MEAN at.set_entry(row, col++, bad_data_double); // FCST_CLIMO_STDEV - */ // Write extra columns at.set_entry(row, col++, d->n_use); // N_USE From 5085105b8031eaba02bd75bcfe739d6f93e92329 Mon Sep 17 00:00:00 2001 From: Dan Adriaansen Date: Wed, 21 Aug 2024 09:16:30 -0600 Subject: [PATCH 105/114] =?UTF-8?q?Adds=20caveat=20regarding=20longitudes?= =?UTF-8?q?=20appearing=20in=20DEBUG=20statements=20with=20a=E2=80=A6=20(#?= =?UTF-8?q?2947)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adds caveat regarding longitudes appearing in DEBUG statements with a different sign to the FAQ. * Update appendixA.rst Missing paren --- docs/Users_Guide/appendixA.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/Users_Guide/appendixA.rst b/docs/Users_Guide/appendixA.rst index 4dbf571008..f39c96913a 100644 --- a/docs/Users_Guide/appendixA.rst +++ b/docs/Users_Guide/appendixA.rst @@ -1801,8 +1801,11 @@ Q. What are MET's conventions for latitude, longitude, azimuth and bearing angle .. dropdown:: Answer - MET considers north latitude and east longitude positive. Latitudes - have range from :math:`-90^\circ` to :math:`+90^\circ`. Longitudes have + MET considers north latitude and east longitude positive. However, + internally MET considers east longitude negative so users may encounter + DEBUG statements with longitude of a different sign than they provided + (e.g. for observation locations or grid metadata). Latitudes have + range from :math:`-90^\circ` to :math:`+90^\circ`. Longitudes have range from :math:`-180^\circ` to :math:`+180^\circ`. Plane angles such as azimuths and bearing (example: horizontal wind direction) have range :math:`0^\circ` to :math:`360^\circ` and are measured clockwise From ad9c832e628d9a297e24f79ff705984669a385e7 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Wed, 21 Aug 2024 12:40:48 -0600 Subject: [PATCH 106/114] Create install_met_env.cactus --- .../config/install_met_env.cactus | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/scripts/installation/config/install_met_env.cactus diff --git a/internal/scripts/installation/config/install_met_env.cactus b/internal/scripts/installation/config/install_met_env.cactus new file mode 100644 index 0000000000..63ac85192a --- /dev/null +++ b/internal/scripts/installation/config/install_met_env.cactus @@ -0,0 +1,50 @@ +module reset +module use /apps/dev/modulefiles/ +module load ve/evs/2.0 +module use /apps/ops/para/libs/modulefiles/compiler/intel/19.1.3.304 +module load netcdf/4.7.4 +module load hdf5/1.10.6 +module load bufr/11.5.0 +module load zlib/1.2.11 +module load jasper/2.0.25 +module load libpng/1.6.37 +module load gsl/2.7 +module load g2c/1.6.4 +module load proj/7.1.0 +module use /apps/dev/modulefiles +module load fckit/0.11.0 +module load atlas/0.35.0 +module load eckit/1.24.4 + +export FC=ifort +export F77=ifort +export F90=ifort +export CC=icc +export CXX=icpc +export TEST_BASE=/lfs/h2/users/julie.prestopnik/12.0.0-beta5 +export LIB_DIR=${TEST_BASE}/external_libs +export COMPILER=intel_19.1.3.304 +export MET_SUBDIR=${TEST_BASE} +export MET_TARBALL=v12.0.0-beta5.tar.gz +export USE_MODULES=TRUE +export ADDTL_DIR=/apps/spack/gettext/0.21/intel/19.1.3.304/at2kdo4edvuhyzrt5g6zhwrdb7bdui4s/lib64/ +export PYTHON_MODULE=python_3.10.4 +export MET_PYTHON=/apps/spack/python/3.10.4/intel/19.1.3.304/xqft4d45h4dp4xnbz2ue3nbxv65i6bgp/ +export MET_PYTHON_LIB=/apps/spack/python/3.10.4/intel/19.1.3.304/xqft4d45h4dp4xnbz2ue3nbxv65i6bgp/lib64 +export MET_PYTHON_CC=-I/apps/spack/python/3.10.4/intel/19.1.3.304/xqft4d45h4dp4xnbz2ue3nbxv65i6bgp/include/python3.10 +export MET_PYTHON_LD=-L/apps/spack/python/3.10.4/intel/19.1.3.304/xqft4d45h4dp4xnbz2ue3nbxv65i6bgp/lib64\ -lpython3.10\ -lintl\ -lcrypt\ -ldl\ -lutil\ -lm\ -lm +export MET_NETCDF=/apps/prod/hpc-stack/intel-19.1.3.304/netcdf/4.7.4 +export MET_HDF5=/apps/prod/hpc-stack/intel-19.1.3.304/hdf5/1.10.6 +export MET_BUFRLIB=/apps/ops/prod/libs/intel/19.1.3.304/bufr/11.5.0/lib64 +export MET_GRIB2CLIB=/apps/ops/prod/libs/intel/19.1.3.304/g2c/1.6.4/lib64 +export MET_GRIB2CINC=/apps/ops/prod/libs/intel/19.1.3.304/g2c/1.6.4/include +export MET_GSL=/apps/spack/gsl/2.7/intel/19.1.3.304/xks7dxbowrdxhjck5zxc4rompopocevb +export MET_PROJ=/apps/spack/proj/7.1.0/intel/19.1.3.304/cjbmc7tacv5qcfatslqmcrzo5kb4raaq +export MET_ATLAS=/apps/dev/atlas/install-0.35.0 +export MET_ECKIT=/apps/dev/eckit/install-1.24.4 +export BUFRLIB_NAME=-lbufr_4 +export GRIB2CLIB_NAME=-lg2c +export LIB_JASPER=/apps/spack/jasper/2.0.25/intel/19.1.3.304/sjib74krrorkyczqpqah4tvewmlnqdx4/lib64 +export LIB_LIBPNG=/apps/spack/libpng/1.6.37/intel/19.1.3.304/4ohkronuhlyherusoszzrmur5ewvlwzh/lib +export LIB_Z=/apps/spack/zlib/1.2.11/intel/19.1.3.304/hjotqkckeoyt6j6tibalwzrlfljcjtdh/lib +export MAKE_ARGS=-j From 0ef87de9fa973ad3ef4c2b5bc76a3ba3475306ef Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Wed, 21 Aug 2024 13:17:02 -0600 Subject: [PATCH 107/114] Adding special script for installing beta5 on wcoss2 --- .../compile_MET_all.wcoss_beta5.sh | 959 ++++++++++++++++++ 1 file changed, 959 insertions(+) create mode 100755 internal/scripts/installation/compile_MET_all.wcoss_beta5.sh diff --git a/internal/scripts/installation/compile_MET_all.wcoss_beta5.sh b/internal/scripts/installation/compile_MET_all.wcoss_beta5.sh new file mode 100755 index 0000000000..5065643c84 --- /dev/null +++ b/internal/scripts/installation/compile_MET_all.wcoss_beta5.sh @@ -0,0 +1,959 @@ +#!/bin/bash +# +# Compile and install MET +# (Model Evaluation Tools) +#================================================ +# +# This compile_MET_all.sh script expects certain environment +# variables to be set: +# TEST_BASE, COMPILER (or COMPILER_FAMILY and COMPILER_VERSION), +# MET_SUBDIR, MET_TARBALL, and USE_MODULES. +# +# If compiling support for Python embedding, users will need to +# set MET_PYTHON, MET_PYTHON_BIN_EXE, MET_PYTHON_CC, and MET_PYTHON_LD. +# Users can directly set the python module to be loaded by setting +# either PYTHON_MODULE or by setting PYTHON_NAME and PYTHON_VERSION: +# - PYTHON_MODULE (only used if USE_MODULES=TRUE) - format is the name +# of the Python module to load followed by an underscore and then the +# version number (e.g. python_3.10.4, The script will then run "module +# load python/3.10.4") +# - PYTHON_NAME = python (or e.g. python3, etc.) +# - PYTHON_VERSION = 3.10.4 +# +# For a description of these and other variables, visit the MET +# downloads page under "Sample Script For Compiling External +# Libraries And MET": +# https://dtcenter.org/community-code/model-evaluation-tools-met/download +# +# An easy way to set these necessary environment variables is +# in an environment configuration file (for example, +# install_met_env.). This script and example +# environment config files for various machines can be found in +# the MET GitHub repository in the scripts/installation directory: +# https://github.com/dtcenter/MET +# +# USAGE: compile_MET_all.sh install_met_env. +# +# The compile_MET_all.sh script will compile and install MET and its +# external library dependencies, if needed, including: +# PROJ (with dependency SQLITE >= 3.11), GSL, BUFRLIB, +# GRIB2C (with dependencies Z, PNG, JASPER, JPEG), HDF5, NETCDF (C and CXX), +# HDF4 (optional for MODIS-Regrid and lidar2nc), HDFEOS (optional for +# MODIS-Regrid and lidar2nc), FREETYPE (optional for MODE Graphics), +# and CAIRO (optional for MODE Graphics). +# +# If these libraries have already been installed and don't need to be +# reinstalled or if you are compiling on a machine that uses modulefiles +# and you'd like to make use of the existing dependent libraries on +# your machine, there are more environment variables that you will +# need to set to let MET know where the library and header files are. +# Please supply values for the following environment variables +# in the input environment configuration file (install_met_env.: +# MET_GRIB2CLIB, MET_GRIB2CINC, GRIB2CLIB_NAME, MET_BUFRLIB, BUFRLIB_NAME, +# MET_HDF5, MET_NETCDF, MET_PROJ, MET_GSL, LIB_JASPER, LIB_LIBPNG, LIB_Z, +# LIB_JPEG, SQLITE_INCLUDE_DIR, SQLITE_LIB_DIR, TIFF_INCLUDE_DIR, TIFF_LIB_DIR. +# +# The optional libraries ecKit and atlas offer support for unstructured +# grids. The optional libraries HDF4, HDFEOS, FREETYPE, and CAIRO are +# used for the following, not widely used tools, MODIS-Regrid, +# lidar2nc, and MODE Graphics. To enable building of these libraries, +# set the compile flags for the library (e.g. COMPILE_ECKIT, COMPILE_ATLAS, +# COMPILE_HDF, COMPILE_HDFEOS) to any value in the environment config +# file. If these libraries have already been installed and don't need +# to be reinstalled, please supply values for the following environment +# variables in the input environment configuration file +# (install_met_env.): MET_ECKIT, MET_ATLAS, MET_HDF, +# MET_HDFEOS, MET_FREETYPEINC, MET_FREETYPELIB, MET_CAIROINC, +# MET_CAIROLIB. +# +# Users can speed up the compilation of MET and its dependent libraries +# by adding the following to their environment configuration file: +# export MAKE_ARGS=-j # +# replacing the # with the number of cores to use (integer) or simply +# specifying: +# export MAKE_ARGS=-j +# with no integer argument to start as many processes in parallel as +# possible. +#================================================ + +# print command, run it, then error and exit if non-zero value is returned +function run_cmd { + echo $* + eval "$@" + ret=$? + if [ $ret != 0 ]; then + echo "ERROR: Command returned with non-zero ($ret) status: $*" + exit $ret + fi +} + +if [ -z $1 ]; then + echo + echo "No environment configuration file provided (e.g. install_met_env.). Starting compilation with current environment." +else + if [ ! -f "$1" ]; then + echo "The file \"$1\" does not exist!" + exit 1 + fi + + source $1 +fi + +echo +echo "TEST_BASE = ${TEST_BASE? "ERROR: TEST_BASE must be set"}" +echo "MET_SUBDIR = ${MET_SUBDIR? "ERROR: MET_SUBDIR must be set"}" +echo "MET_TARBALL = ${MET_TARBALL? "ERROR: MET_TARBALL must be set"}" +echo "USE_MODULES = ${USE_MODULES? "ERROR: USE_MODULES must be set to TRUE if using modules or FALSE otherwise"}" +if [[ -z "$COMPILER" ]] && [[ -z "$COMPILER_FAMILY" && -z "$COMPILER_VERSION" ]]; then + echo "ERROR: COMPILER or COMPILER_FAMILY and COMPILER_VERSION must be set" + exit 1 +fi +echo ${MAKE_ARGS:+MAKE_ARGS = $MAKE_ARGS} + + +LIB_DIR=${TEST_BASE}/external_libs +MET_DIR=${MET_SUBDIR} + +if [ -z "${BIN_DIR_PATH}" ]; then + if [ -z "${MET_INSTALL_DIR}" ]; then + BIN_DIR_PATH=${TEST_BASE}/bin + else + BIN_DIR_PATH=${MET_INSTALL_DIR}/bin + fi +fi + +if [ -z "${MET_INSTALL_DIR}" ]; then + MET_INSTALL_DIR=${MET_DIR} +else + LIB_DIR=${MET_INSTALL_DIR} +fi + +TAR_DIR=${TEST_BASE}/tar_files +MET_TARBALL=${TAR_DIR}/${MET_TARBALL} + +# Create directory for libraries +mkdir -p ${LIB_DIR} + +# Check that tar files exist +if [ ! -e $TAR_DIR ]; then + echo "TAR File directory doesn't exist: ${TAR_DIR}" + exit 1 +fi + +# If MET_PYTHON_LIB is not set in the environment file, set it to the +# lib directory so it can be use to install MET with Python Embedding +# support +if [[ -z "$MET_PYTHON_LIB" ]]; then + MET_PYTHON_LIB=${MET_PYTHON}/lib +fi + + +# Print library linker path +echo "LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}" + +# if LIB_Z is not set in the environment file, set it to the +# lib directory so it can be used to install HDF5 with zlib support +if [[ -z "$LIB_Z" ]]; then + LIB_Z=${LIB_DIR}/lib +fi + +# if TIFF is not defined in the environment file, enable its compilation +if [[ -z ${TIFF_INCLUDE_DIR} ]] && [[ -z ${TIFF_LIB_DIR} ]]; then + COMPILE_TIFF=1 +else + COMPILE_TIFF=0 +fi + +# if SQLITE is not defined in the environment file, enable its compilation +if [[ -z ${SQLITE_INCLUDE_DIR} ]] && [[ -z ${SQLITE_LIB_DIR} ]]; then + COMPILE_SQLITE=1 +else + COMPILE_SQLITE=0 +fi + +# Constants +if [[ -z ${MET_GRIB2CLIB} ]] && [[ -z ${MET_GRIB2C} ]]; then + COMPILE_ZLIB=1 + COMPILE_LIBPNG=1 + COMPILE_JASPER=1 + COMPILE_JPEG=1 + COMPILE_G2CLIB=1 +else + COMPILE_ZLIB=0 + COMPILE_LIBPNG=0 + COMPILE_JASPER=0 + COMPILE_JPEG=0 + COMPILE_G2CLIB=0 +fi + +if [ -z ${MET_BUFRLIB} ]; then COMPILE_BUFRLIB=1; else COMPILE_BUFRLIB=0; fi + +if [ -z ${MET_NETCDF} ]; then COMPILE_NETCDF=1; else COMPILE_NETCDF=0; fi + +if [ -z ${MET_PROJ} ]; then COMPILE_PROJ=1; else COMPILE_PROJ=0; fi + +if [ -z ${MET_GSL} ]; then COMPILE_GSL=1; else COMPILE_GSL=0; fi + +# Only set COMPILE_ECKIT and COMPILE_ATLAS if you want to compile and enable support for unstructued grids +if [ ! -z "${COMPILE_ECKIT}" ]; then COMPILE_ECKIT=1; else COMPILE_ECKIT=0; fi +if [ ! -z "${COMPILE_ATLAS}" ]; then COMPILE_ATLAS=1; else COMPILE_ATLAS=0; fi + +if [[ -z ${MET_ECKIT} ]] && [[ -z ${MET_ATLAS} ]]; then + if [[ $COMPILE_ECKIT -eq 1 && $COMPILE_ATLAS -eq 1 ]]; then + export MET_ECKIT=${LIB_DIR} + export MET_ATLAS=${LIB_DIR} + fi +else + # Only set COMPILE_ECKIT and COMPILE_ATLAS to 1 if you have already compiled ECKIT and ATLAS, + # have set MET_ECKIT and MET_ATLAS in your configuration file, and want to enable + # unstructured grids + COMPILE_ECKIT=0 + COMPILE_ATLAS=0 +fi + +# Only set COMPILE_HDF and COMPILE_HDFEOS if you want to compile and enable MODIS-Regrid (not widely used) +if [ ! -z "${COMPILE_HDF}" ]; then COMPILE_HDF=1; else COMPILE_HDF=0; fi +if [ ! -z "${COMPILE_HDFEOS}" ]; then COMPILE_HDFEOS=1; else COMPILE_HDFEOS=0; fi + +if [[ -z ${MET_HDF} ]] && [[ -z ${MET_HDFEOS} ]]; then + if [[ $COMPILE_HDF -eq 1 && $COMPILE_HDFEOS -eq 1 ]]; then + export MET_HDF=${LIB_DIR} + export MET_HDFEOS=${LIB_DIR} + fi +else + # Only set COMPILE_HDF and COMPILE_HDFEOS to 1 if you have already compiled HDF4 and HDFEOS, + # have set MET_HDF and MET_HDFEOS in your configuration file, and want to enable + # MODIS-Regrid (not widely used) + COMPILE_HDF=0 + COMPILE_HDFEOS=0 +fi + +# Only set COMPILE_FREETYPE and COMPILE_CAIRO if you want to compile and enable MODE Graphics (not widely used) +if [ ! -z "${COMPILE_FREETYPE}" ]; then COMPILE_FREETYPE=1; else COMPILE_FREETYPE=0; fi +if [ ! -z "${COMPILE_CAIRO}" ]; then COMPILE_CAIRO=1; else COMPILE_CAIRO=0; fi + + +if [[ ! -z ${MET_FREETYPE} ]]; then + echo "ERROR: MET_FREETYPEINC and MET_FREETYPELIB must be set instead of MET_FREETYPE" + exit 1 +fi + +if [[ ! -z ${MET_CAIRO} ]]; then + echo "ERROR: MET_CAIROINC and MET_CAIROLIB must be set instead of MET_CAIRO" + exit 1 +fi + +if [[ -z ${MET_FREETYPEINC} && -z ${MET_FREETYPELIB} && -z ${MET_CAIROINC} && -z ${MET_CAIROLIB} ]]; then + if [[ $COMPILE_CAIRO -eq 1 && $COMPILE_FREETYPE -eq 1 ]]; then + export MET_CAIROINC=${LIB_DIR}/include/cairo + export MET_CAIROLIB=${LIB_DIR}/lib + export MET_FREETYPEINC=${LIB_DIR}/include/freetype2 + export MET_FREETYPELIB=${LIB_DIR}/lib + fi +else + # Only set COMPILE_FREETYPE and COMPILE_CAIRO to 1 if you have compiled FREETYPE and CAIRO, + # have set MET_FREETYPEINC, MET_FREETYPELIB, MET_CAIROINC, and MET_CAIROLIB in your + # configuration file, and want to enable MODE Graphics (not widely used) + COMPILE_FREETYPE=0 + COMPILE_CAIRO=0 +fi + +COMPILE_MET=1 + +# skip compilation of MET if SKIP_MET is set +if [ ! -z "${SKIP_MET}" ]; then COMPILE_MET=0; fi + +# skip compilation of external libraries if SKIP_LIBS is set +if [ ! -z "${SKIP_LIBS}" ]; then + COMPILE_PROJ=0 + COMPILE_GSL=0 + COMPILE_BUFRLIB=0 + COMPILE_ZLIB=0 + COMPILE_LIBPNG=0 + COMPILE_JASPER=0 + COMPILE_JPEG=0 + COMPILE_G2CLIB=0 + COMPILE_ECKIT=0 + COMPILE_ATLAS=0 + COMPILE_HDF=0 + COMPILE_HDFEOS=0 + COMPILE_NETCDF=0 + COMPILE_FREETYPE=0 + COMPILE_CAIRO=0 +fi + +if [ -z ${BIN_DIR_PATH} ]; then + BIN_DIR_PATH=${TEST_BASE}/bin +fi + +if [ -z ${USE_MET_TAR_FILE} ]; then + export USE_MET_TAR_FILE=TRUE +fi + +echo +echo "Compiling libraries into: ${LIB_DIR}" + +if [ ! -e ${LIB_DIR}/include ]; then + mkdir ${LIB_DIR}/include +fi + +if [ ! -e ${LIB_DIR}/lib ]; then + mkdir ${LIB_DIR}/lib +fi + +# Load compiler version +if [ -z ${COMPILER_FAMILY} ]; then + COMPILER_FAMILY=` echo $COMPILER | cut -d'_' -f1` +fi + +# Check for "oneapi" in compiler family name +#if echo ${COMPILER_FAMILY} | grep -E "^intel"; then +if [[ ${COMPILER_FAMILY} == *intel* ]]; then + COMPILER_FAMILY_SUFFIX=` echo $COMPILER_FAMILY | cut -d'-' -f2` +fi + +if [ -z ${COMPILER_VERSION} ]; then + COMPILER_VERSION=`echo $COMPILER | cut -d'_' -f2` +fi + +echo "COMPILER = $COMPILER" +echo "COMPILER_FAMILY = $COMPILER_FAMILY" +echo "COMPILER_FAMILY_SUFFIX = $COMPILER_FAMILY_SUFFIX" +echo "COMPILER_VERSION = $COMPILER_VERSION" +COMPILER_MAJOR_VERSION=`echo $COMPILER_VERSION | cut -d'.' -f1` +COMPILER_MINOR_VERSION=`echo $COMPILER_VERSION | cut -d'.' -f2` + +echo +echo "USE_MODULES = ${USE_MODULES}" +echo + +if [ ${USE_MODULES} = "TRUE" ]; then + echo "module load ${COMPILER_FAMILY}/${COMPILER_VERSION}" + echo ${COMPILER_FAMILY}/${COMPILER_VERSION} + + module load ${COMPILER_FAMILY}/${COMPILER_VERSION} + if [ ${COMPILER_FAMILY} = "PrgEnv-intel" ]; then + module load craype + module switch craype craype-sandybridge + fi +fi + +# After loading the compiler module, strip any extra +# characters off of "gnu" (e.g. "gnu9") +if [[ ${COMPILER_FAMILY} == *gnu* ]]; then + export COMPILER_FAMILY="gnu" +fi + +if [ ${COMPILER_FAMILY} = "gnu" ]; then + if [ -z ${CC} ]; then export CC=`which gcc`; fi + if [ -z ${CXX} ]; then export CXX=`which g++`; fi + if [ -z ${FC} ]; then export FC=`which gfortran`; fi + if [ -z ${F77} ]; then export F77=`which gfortran`; fi + if [ -z ${F90} ]; then export F90=`which gfortran`; fi +elif [ ${COMPILER_FAMILY} = "pgi" ]; then + if [ -z ${CC} ]; then export CC=`which pgcc`; fi + if [ -z ${CXX} ]; then export CXX=`which pgc++`; fi + if [ -z ${FC} ]; then export FC=`which pgf90`; fi + if [ -z ${F77} ]; then export F77=`which pgf90`; fi + if [ -z ${F90} ]; then export F90=`which pgf90`; fi +elif [[ ${COMPILER_FAMILY} == *intel* && ${CC} == "icc" ]] || \ + [[ ${COMPILER_FAMILY} == "ics" ]] || \ + [[ ${COMPILER_FAMILY} == "ips" ]] || \ + [[ ${COMPILER_FAMILY} == "intel-classic" ]] || \ + [[ ${COMPILER_FAMILY} == "PrgEnv-intel" ]]; then + if [ -z ${CC} ]; then export CC=`which icc`; fi + if [ -z ${CXX} ]; then export CXX=`which icpc`; fi + if [ -z ${FC} ]; then export FC=`which ifort`; fi + if [ -z ${F77} ]; then export F77=`which ifort`; fi + if [ -z ${F90} ]; then export F90=`which ifort`; fi +elif [[ ${COMPILER_FAMILY} == *intel* ]] && [[ ${CC} == *icx* ]]; then + export CXX=`which icpx` + export FC=`which ifx` + export F77=`which ifx` + export F90=`which ifx` +elif [[ ${COMPILER_FAMILY_SUFFIX} == oneapi ]]; then + export CC=`which icx` + export CXX=`which icpx` + export FC=`which ifx` + export F77=`which ifx` + export F90=`which ifx` +else + echo "ERROR: \${COMPILER} must start with gnu, intel, ics, ips, intel-classic, PrgEnv-intel, or pgi" + exit +fi + +echo "export CC=${CC}" +echo "export CXX=${CXX}" +echo "export FC=${FC}" +echo "export F77=${F77}" +echo "export F90=${F90}" +echo + +# Figure out what kind of OS is being used +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) machine=Linux;; + Darwin*) machine=Mac;; + CYGWIN*) machine=Cygwin;; + MINGW*) machine=MinGw;; + *) machine="UNKNOWN:${unameOut}" +esac + +# change sed command and extension for dynamic library files +if [[ $machine == "Mac" ]]; then + sed_inline="sed -i ''" +else + sed_inline="sed -i''" +fi + +if [[ "$(uname -m)" == "arm64" ]]; then + dynamic_lib_ext="dylib" +else + dynamic_lib_ext="so" +fi + +# Load Python module + +if [ ${USE_MODULES} = "TRUE" ]; then + if [ ! -z ${PYTHON_MODULE} ]; then + PYTHON_NAME=`echo $PYTHON_MODULE | cut -d'_' -f1` + PYTHON_VERSION_NUM=`echo $PYTHON_MODULE | cut -d'_' -f2` + echo "module load ${PYTHON_NAME}/${PYTHON_VERSION_NUM}" + echo ${PYTHON_NAME}/${PYTHON_VERSION_NUM} + module load ${PYTHON_NAME}/${PYTHON_VERSION_NUM} + # Allow the user to specify the name and version of the module to load + elif [[ ! -z ${PYTHON_NAME} && ! -z ${PYTHON_VERSION_NUM} ]]; then + echo "module load ${PYTHON_NAME}/${PYTHON_VERSION_NUM}" + echo ${PYTHON_NAME}/${PYTHON_VERSION_NUM} + module load ${PYTHON_NAME}/${PYTHON_VERSION_NUM} + fi +fi + +if [[ ${MET_PYTHON}/bin/python3 ]]; then + echo "Using python version: " + ${MET_PYTHON}/bin/python3 --version +fi + +# Compile Proj +if [ $COMPILE_PROJ -eq 1 ]; then + + + if [ $COMPILE_TIFF -eq 1 ]; then + echo + echo "Compiling TIFF at `date`" + mkdir -p ${LIB_DIR}/tiff + rm -rf ${LIB_DIR}/tiff/tiff* + tar -xzf ${TAR_DIR}/tiff*.tar.gz -C ${LIB_DIR}/tiff + cd ${LIB_DIR}/tiff/tiff* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} > $(pwd)/tiff.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/tiff.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/tiff.make_install.log 2>&1" + export TIFF_INCLUDE_DIR=${LIB_DIR}/include + export TIFF_LIB_DIR=${LIB_DIR}/lib + fi + + if [ $COMPILE_SQLITE -eq 1 ]; then + echo + echo "Compiling SQLITE at `date`" + mkdir -p ${LIB_DIR}/sqlite + rm -rf ${LIB_DIR}/sqlite/sqlite* + tar -xf ${TAR_DIR}/sqlite*.tar.gz -C ${LIB_DIR}/sqlite > /dev/null 2>&1 + cd ${LIB_DIR}/sqlite/sqlite* + echo "cd `pwd`" + run_cmd "./configure --enable-shared --prefix=${LIB_DIR} > $(pwd)/sqlite.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/sqlite.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/sqlite.make_install.log 2>&1" + export SQLITE_INCLUDE_DIR=${LIB_DIR}/include + export SQLITE_LIB_DIR=${LIB_DIR}/lib + fi + + vrs="7.1.0" + + echo + echo "Compiling PROJ_${vrs} at `date`" + echo "cmake version `cmake --version`" + mkdir -p ${LIB_DIR}/proj + rm -rf ${LIB_DIR}/proj/proj* + tar -xf ${TAR_DIR}/proj-${vrs}.tar.gz -C ${LIB_DIR}/proj + cd ${LIB_DIR}/proj/proj* + echo "cd `pwd`" + export PATH=${LIB_DIR}/bin:${PATH} + run_cmd "mkdir build; cd build" + + tiff_arg="" + # add tiff library and include arguments if necessary + if [[ ! -z "$TIFF_LIB_DIR" ]]; then + tiff_arg+="-DTIFF_LIBRARY_RELEASE=${TIFF_LIB_DIR}/libtiff.${dynamic_lib_ext}" + fi + if [[ ! -z "$TIFF_INCLUDE_DIR" ]]; then + tiff_arg+=" -DTIFF_INCLUDE_DIR=${TIFF_INCLUDE_DIR}" + fi + + cmd="cmake -DCMAKE_INSTALL_PREFIX=${LIB_DIR} -DSQLITE3_INCLUDE_DIR=${SQLITE_INCLUDE_DIR} -DSQLITE3_LIBRARY=${SQLITE_LIB_DIR}/libsqlite3.${dynamic_lib_ext} ${tiff_arg} .. > $(pwd)/proj.cmake.log 2>&1" + run_cmd ${cmd} + run_cmd "cmake --build . > $(pwd)/proj.cmake_build.log 2>&1" + run_cmd "cmake --build . --target install > $(pwd)/proj.cmake_install.log 2>&1" + +fi + +# Compile GSL +if [ $COMPILE_GSL -eq 1 ]; then + + if [ ${COMPILER_FAMILY} = "pgi" ]; then + vrs="1.11" + else + vrs="2.7.1" + fi + + echo + echo "Compiling GSL_${vrs} at `date`" + mkdir -p ${LIB_DIR}/gsl + rm -rf ${LIB_DIR}/gsl/gsl* + tar -xf ${TAR_DIR}/gsl-${vrs}.tar.gz -C ${LIB_DIR}/gsl + cd ${LIB_DIR}/gsl/gsl* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} > $(pwd)/gsl.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/gsl.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/gsl.make_install.log 2>&1" +fi + +# Compile BUFRLIB +if [ $COMPILE_BUFRLIB -eq 1 ]; then + + vrs="v11.6.0" + + echo + echo "Compiling bufr_${vrs} at `date`" + mkdir -p ${LIB_DIR}/bufrlib + rm -rf ${LIB_DIR}/bufrlib/NCEPLIBS-bufr-bufr_${vrs} + tar -xf ${TAR_DIR}/bufr_${vrs}.tar.gz -C ${LIB_DIR}/bufrlib + export SOURCE_DIR=${LIB_DIR}/bufrlib/NCEPLIBS-bufr-bufr_${vrs} + cd $SOURCE_DIR + echo "cd `pwd`" + run_cmd "mkdir build" + export BUILD_DIR=${SOURCE_DIR}/build + run_cmd "cmake -H${SOURCE_DIR} -B${BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${LIB_DIR} -DCMAKE_BUILD_TYPE=Debug > $(pwd)/bufr.cmake.log 2>&1" + run_cmd "cd ${BUILD_DIR}" + run_cmd "make ${MAKE_ARGS} > $(pwd)/bufr.make.log 2>&1" + run_cmd "ctest > $(pwd)/bufr.ctest.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/bufr.make_install.log 2>&1" +fi + + +# Compile ZLIB +if [ $COMPILE_ZLIB -eq 1 ]; then + echo + echo "Compiling ZLIB at `date`" + mkdir -p ${LIB_DIR}/zlib + rm -rf ${LIB_DIR}/zlib/zlib* + tar -xzf ${TAR_DIR}/zlib*.tar.gz -C ${LIB_DIR}/zlib + cd ${LIB_DIR}/zlib/zlib* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} > $(pwd)/zlib.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/zlib.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/zlib.make_install.log 2>&1" + + # GPM: why is this removed? Could we add a comment to + # describe why this is needed? + run_cmd "rm ${LIB_DIR}/lib/libz.a" +fi + +# Compile LIBPNG +if [[ $COMPILE_LIBPNG -eq 1 && $HOST != ys* ]]; then + echo + echo "Compiling LIBPNG at `date`" + mkdir -p ${LIB_DIR}/libpng + rm -rf ${LIB_DIR}/libpng/libpng* + tar -xzf ${TAR_DIR}/libpng*.tar.gz -C ${LIB_DIR}/libpng + cd ${LIB_DIR}/libpng/libpng* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} LDFLAGS=-L${LIB_DIR}/lib CPPFLAGS=-I${LIB_DIR}/include > $(pwd)/libpng.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/libpng.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/libpng.make_install.log 2>&1" +fi + + +# Compile JASPER +if [ $COMPILE_JASPER -eq 1 ]; then + + vrs="2.0.25" + + echo + echo "Compiling JASPER at `date`" + mkdir -p ${LIB_DIR}/jasper + rm -rf ${LIB_DIR}/jasper/jasper* + tar -xf ${TAR_DIR}/jasper-${vrs}.tar.gz -C ${LIB_DIR}/jasper + cd ${LIB_DIR}/jasper/jasper-version-${vrs} + export CPPFLAGS="-I${LIB_DIR}/include" + export SOURCE_DIR=${LIB_DIR}/jasper/jasper-version-${vrs} + echo "cd `pwd`" + export BUILD_DIR=${LIB_DIR}/jasper/jasper-version-${vrs}/build + run_cmd "cmake -G \"Unix Makefiles\" -H${SOURCE_DIR} -B${BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${LIB_DIR} -DJAS_ENABLE_DOC=false > $(pwd)/jasper.cmake.log 2>&1" + run_cmd "cd ${BUILD_DIR}" + run_cmd "make clean all > $(pwd)/jasper.make.log 2>&1" + # Commented out due to “which: no opj2_compress in …” error, which causes one of four tests to fail + # This is a known problem, so skipping tests for now: https://github.com/AAROC/CODE-RADE/issues/36#issuecomment-359744351 + #run_cmd "make ${MAKE_ARGS} test > $(pwd)/jasper.make_test.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/jasper.make_install.log 2>&1" +fi + +# Compile JPEG +if [ $COMPILE_JPEG -eq 1 ]; then + + vrs="9e" + + echo + echo "Compiling JPEG at `date`" + mkdir -p ${LIB_DIR}/jpeg + rm -rf ${LIB_DIR}/jpeg/jpeg* + tar -xf ${TAR_DIR}/jpegsrc.v${vrs}.tar.gz -C ${LIB_DIR}/jpeg + cd ${LIB_DIR}/jpeg/jpeg-${vrs} + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} LDFLAGS=-L${LIB_DIR}/lib CPPFLAGS=-I${LIB_DIR}/include > $(pwd)/libjpeg.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/libjpeg.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/libjpeg.make_install.log 2>&1" +fi + + +# Compile G2CLIB +if [ $COMPILE_G2CLIB -eq 1 ]; then + + vrs="1.6.4" + + echo + echo "Compiling G2CLIB at `date`" + mkdir -p ${LIB_DIR}/g2clib + rm -rf ${LIB_DIR}/g2clib/NCEP* + tar -xf ${TAR_DIR}/g2clib-${vrs}.tar.gz -C ${LIB_DIR}/g2clib + cd ${LIB_DIR}/g2clib/NCEP* + echo "cd `pwd`" + run_cmd "mkdir build; cd build" + run_cmd "cmake -DCMAKE_INSTALL_PREFIX=${LIB_DIR} -DCMAKE_PREFIX_PATH=${LIB_DIR} .. > $(pwd)/g2c.cmake.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/g2c.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} test > $(pwd)/g2c.make_test.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/g2c.make_install.log 2>&1" +fi + +# Compile ECKIT +if [ $COMPILE_ECKIT -eq 1 ]; then + + # Need to obtain ecbuild before installing eckit + + vrs="3.5.0" + + echo + echo "Compiling ECBUILD at `date`" + mkdir -p ${LIB_DIR}/ecbuild + rm -rf ${LIB_DIR}/ecbuild/ecbuild* + tar -xf ${TAR_DIR}/ecbuild-${vrs}.tar.gz -C ${LIB_DIR}/ecbuild + cd ${LIB_DIR}/ecbuild/ecbuild* + echo "cd `pwd`" + run_cmd "mkdir build; cd build" + run_cmd "cmake ../ -DCMAKE_INSTALL_PREFIX=${LIB_DIR} > $(pwd)/ecbuild.cmake.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/ecbuild.make_install.log 2>&1" + + vrs="1.20.2" + + echo + echo "Compiling ECKIT at `date`" + mkdir -p ${LIB_DIR}/eckit + rm -rf ${LIB_DIR}/eckit/eckit* + tar -xf ${TAR_DIR}/eckit-${vrs}.tar.gz -C ${LIB_DIR}/eckit + cd ${LIB_DIR}/eckit/eckit* + echo "cd `pwd`" + run_cmd "mkdir build; cd build" + run_cmd "cmake ../ -DCMAKE_INSTALL_PREFIX=${LIB_DIR} -DCMAKE_PREFIX_PATH=${LIB_DIR} > $(pwd)/eckit.cmake.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/eckit.make_install.log 2>&1" + +fi + +# Compile ATLAS +if [ $COMPILE_ATLAS -eq 1 ]; then + + vrs="0.30.0" + + echo + echo "Compiling ATLAS at `date`" + mkdir -p ${LIB_DIR}/atlas + rm -rf ${LIB_DIR}/atlas/atlas* + tar -xf ${TAR_DIR}/atlas-${vrs}.tar.gz -C ${LIB_DIR}/atlas + cd ${LIB_DIR}/atlas/atlas* + echo "cd `pwd`" + run_cmd "mkdir build; cd build" + run_cmd "cmake ../ -DCMAKE_INSTALL_PREFIX=${LIB_DIR} -DCMAKE_PREFIX_PATH=${LIB_DIR} > $(pwd)/atlas.cmake.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/atlas.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/atlas.make_install.log 2>&1" + +fi + +# Compile HDF +# Depends on jpeg +# Edit 'mfhdf/hdiff/Makefile' as follows: +# From: LIBS = -ljpeg -lz +# To: LIBS = -ljpeg -lz -lm +if [ $COMPILE_HDF -eq 1 ]; then + echo + echo "Compiling HDF at `date`" + mkdir -p ${LIB_DIR}/hdf + rm -rf ${LIB_DIR}/hdf/HDF* + tar -xf ${TAR_DIR}/HDF4.2*.tar.gz -C ${LIB_DIR}/hdf + cd ${LIB_DIR}/hdf/HDF* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} --disable-netcdf --with-jpeg=${LIB_DIR} --with-zlib=${LIB_DIR} CPPFLAGS=-I/usr/include/tirpc LIBS='-lm -ltirpc' > $(pwd)/hdf4.configure.log 2>&1" + if [[ ${COMPILER_MAJOR_VERSION} -ge 10 ]]; then + cat hdf/src/Makefile | \ + sed 's/FFLAGS = -O2/FFLAGS = -w -fallow-argument-mismatch -O2/g' \ + > Makefile_new + elif [[ ${COMPILER_MAJOR_VERSION} -lt 10 ]]; then + cat hdf/src/Makefile | \ + sed 's/FFLAGS = -O2/FFLAGS = -w -Wno-argument-mismatch -O2/g' \ + > Makefile_new + fi + mv Makefile_new hdf/src/Makefile + run_cmd "make ${MAKE_ARGS} > $(pwd)/hdf4.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/hdf4.make_install.log 2>&1" +fi + +# Compile HDFEOS +# Depends on HDF +if [ $COMPILE_HDFEOS -eq 1 ]; then + echo + echo "Compiling HDFEOS at `date`" + mkdir -p ${LIB_DIR}/hdfeos + rm -rf ${LIB_DIR}/hdfeos/HDF-EOS* + tar -xzf ${TAR_DIR}/HDF-EOS*.tar.* -C ${LIB_DIR}/hdfeos + cd ${LIB_DIR}/hdfeos/hdfeos + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} --with-hdf4=${LIB_DIR} --with-jpeg=${LIB_DIR} > $(pwd)/hdf-eos.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/hed-eos.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/hsf-eos.make_install.log 2>&1" + + cp include/*.h ${LIB_DIR}/include/ +fi + +# Compile NetCDF +if [ $COMPILE_NETCDF -eq 1 ]; then + + echo + echo "Compiling HDF5 at `date`" + mkdir -p ${LIB_DIR}/hdf5 + rm -rf ${LIB_DIR}/hdf5/hdf5* + tar -xzf ${TAR_DIR}/hdf5*.tar.gz -C ${LIB_DIR}/hdf5 + cd ${LIB_DIR}/hdf5/hdf5* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} --with-zlib=${LIB_Z} CFLAGS=-fPIC CXXFLAGS=-fPIC FFLAGS=-fPIC LDFLAGS=-L${LIB_DIR}/lib:${LIB_Z} CPPFLAGS=-I${LIB_DIR}/include > $(pwd)/hdf5.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/hdf5.make_install.log 2>&1" + + echo + echo "Compiling NetCDF-C at `date`" + mkdir -p ${LIB_DIR}/netcdf + rm -rf ${LIB_DIR}/netcdf/netcdf* + tar -xzf ${TAR_DIR}/netcdf-4*.tar.gz -C ${LIB_DIR}/netcdf > /dev/null 2>&1 || unzip ${TAR_DIR}/netcdf-4*.zip -d ${LIB_DIR}/netcdf + cd ${LIB_DIR}/netcdf/netcdf-* + export FC='' + export F90='' + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-L${LIB_DIR}/lib CPPFLAGS=-I${LIB_DIR}/include > $(pwd)/netcdf-c.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/netcdf-c.make_install.log 2>&1" + + echo + echo "Compiling NetCDF-CXX at `date`" + tar -xzf ${TAR_DIR}/netcdf-cxx*.tar.gz -C ${LIB_DIR}/netcdf + cd ${LIB_DIR}/netcdf/netcdf-cxx* + echo "cd `pwd`" + configure_lib_args="" + if [[ $machine == "Mac" ]]; then + configure_lib_args="-lnetcdf -lhdf5_hl -lhdf5 -lz" + fi + run_cmd "./configure --prefix=${LIB_DIR} LDFLAGS=-L${LIB_DIR}/lib CPPFLAGS=-I${LIB_DIR}/include LIBS=\"${LIBS} ${configure_lib_args}\" > $(pwd)/netcdf-cxx.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/netcdf-cxx.make_install.log 2>&1" +fi + +# Compile FREETYPE +if [ $COMPILE_FREETYPE -eq 1 ]; then + echo + echo "Compiling FREETYPE at `date`" + mkdir -p ${LIB_DIR}/freetype + rm -rf ${LIB_DIR}/freetype/freetype* + tar -xzf ${TAR_DIR}/freetype*.tar.gz -C ${LIB_DIR}/freetype + cd ${LIB_DIR}/freetype/freetype* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} --with-png=yes > $(pwd)/freetype.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/freetype.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/freetype.make_install.log 2>&1" +fi + + +# Compile CAIRO +if [ $COMPILE_CAIRO -eq 1 ]; then + + # If on Cray, compile PIXMAN + if [ ${COMPILER_FAMILY} = "PrgEnv-intel" ]; then + echo + echo "Compiling pixman at `date`" + mkdir -p ${LIB_DIR}/pixman + rm -rf ${LIB_DIR}/pixman/pixman* + tar -xzf ${TAR_DIR}/pixman*.tar.gz -C ${LIB_DIR}/pixman + cd ${LIB_DIR}/pixman/pixman* + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} > $(pwd)/pixman.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/pixman.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/pixman.make_install.log 2>&1" + fi + + echo + echo "Compiling CAIRO at `date`" + mkdir -p ${LIB_DIR}/cairo + rm -rf ${LIB_DIR}/cairo/cairo* + tar -xf ${TAR_DIR}/cairo*.tar* -C ${LIB_DIR}/cairo + cd ${LIB_DIR}/cairo/cairo* + export PKG_CONFIG=`which pkg-config` + if [ ${COMPILER_FAMILY} = "PrgEnv-intel" ]; then + export PKG_CONFIG_PATH=${LIB_DIR}/lib/pkgconfig/ + fi + echo "cd `pwd`" + run_cmd "./configure --prefix=${LIB_DIR} ax_cv_c_float_words_bigendian=no LDFLAGS=-L${LIB_DIR}/lib CPPFLAGS=-I${LIB_DIR}/include > $(pwd)/cairo.configure.log 2>&1" + run_cmd "make ${MAKE_ARGS} > $(pwd)/cairo.make.log 2>&1" + run_cmd "make ${MAKE_ARGS} install > $(pwd)/cairo.make_install.log 2>&1" +fi + +# Compile MET +if [ $COMPILE_MET -eq 0 ]; then + echo Skipping MET compilation + echo "Finished compiling at `date`" + exit 0 +fi + +echo +echo "Compiling MET at `date`" +# If using source from a tar file remove everything and unpack the tar file +# FALSE = compiling from github repo and we don't want to overwrite the files +if [ ${USE_MET_TAR_FILE} = "TRUE" ]; then + rm -rf ${MET_DIR}/MET* + tar -xzf ${MET_TARBALL} -C ${MET_DIR} +fi +cd ${MET_DIR}/MET* + +echo "Modifying configure" +cat configure | \ + sed 's/C11/C17/g' | \ + sed 's/c11/c17/g' | \ + sed 's/cxx11/cxx17/g' | \ + sed 's/c++11/c++17/g' | \ + sed 's/gnu11/gnu17/g' \ + > configure_new + +mv configure_new configure +chmod 755 configure + +if [ -z ${MET_BUFRLIB} ]; then + export MET_BUFRLIB=${LIB_DIR}/lib + export BUFRLIB_NAME=-lbufr_4 +fi + +if [ -z ${MET_GRIB2CLIB} ]; then + export MET_GRIB2CLIB=${LIB_DIR}/lib + export MET_GRIB2CINC=${LIB_DIR}/include + export LIB_JASPER=${LIB_DIR}/lib + export LIB_LIBPNG=${LIB_DIR}/lib + export LIB_Z=${LIB_DIR}/lib + export GRIB2CLIB_NAME=-lg2c +fi + +if [ -z ${MET_NETCDF} ]; then + export MET_NETCDF=${LIB_DIR} + export MET_HDF5=${LIB_DIR} +fi + +if [ -z ${MET_GSL} ]; then + export MET_GSL=${LIB_DIR} +fi + +if [ -z ${MET_PROJ} ]; then + export MET_PROJ=${LIB_DIR} +fi + +export MET_PYTHON_BIN_EXE=${MET_PYTHON_BIN_EXE:=${MET_PYTHON}/bin/python3} +export MET_PYTHON_LD +export MET_PYTHON_CC + +# add flags to user-defined LDFLAGS for MacOS +if [[ $machine != "Mac" ]]; then + LDFLAGS="${LDFLAGS} -Wl,--disable-new-dtags" +fi + +# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html +# ${parameter:+word} +# If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted. + +# add LIB_DIR/lib and LIB_DIR/lib64 to rpath and -L +LDFLAGS="${LDFLAGS} -Wl,-rpath,${LIB_DIR}/lib -L${LIB_DIR}/lib -Wl,-rpath,${LIB_DIR}/lib64 -L${LIB_DIR}/lib64" + +# if variables are set, add /lib to rpath and -L +for x in $MET_CAIRO $MET_FREETYPE $MET_GSL $MET_HDF $MET_HDF5 $MET_NETCDF; do + arg="${x:+-Wl,-rpath,$x/lib -L$x/lib}" + if [[ "$LDFLAGS" != *"$arg"* ]]; then + LDFLAGS+=" $arg" + fi +done + +# if variables are set, add /lib64 to rpath and -L +for x in $MET_ATLAS $MET_BUFR $MET_ECKIT $MET_GRIB2C $MET_PROJ $LIB_JASPER; do + arg="${x:+-Wl,-rpath,$x/lib64 -L$x/lib64}" + if [[ "$LDFLAGS" != *"$arg"* ]]; then + LDFLAGS+=" $arg" + fi +done + +# if variables are set, add to rpath and -L +for x in $MET_ATLASLIB $MET_BUFRLIB $MET_CAIROLIB $MET_ECKITLIB $MET_FREETYPELIB $MET_GRIB2CLIB $MET_GSLLIB $MET_HDF5LIB $MET_HDFLIB $MET_NETCDFLIB $MET_PROJLIB $MET_PYTHON_LIB $LIB_JASPER $LIB_LIBPNG $LIB_Z $ADDTL_DIR; do + arg="${x:+-Wl,-rpath,$x -L$x}" + if [[ "$LDFLAGS" != *"$arg"* ]]; then + LDFLAGS+=" $arg" + fi +done + +export LDFLAGS + +export LIBS="${LIBS} -lhdf5_hl -lhdf5 -lz" +export MET_FONT_DIR=${TEST_BASE}/fonts + + +echo "MET Configuration settings..." +printenv | egrep "^MET_" | sed -r 's/^/export /g' +echo "LDFLAGS = ${LDFLAGS}" +export OPT_ARGS='' +if [[ $COMPILER_FAMILY == "pgi" ]]; then + export OPT_ARGS="${OPT_ARGS} FFLAGS=-lpgf90" +fi + +configure_cmd="./configure --prefix=${MET_INSTALL_DIR} --bindir=${BIN_DIR_PATH}" +configure_cmd="${configure_cmd} BUFRLIB_NAME=${BUFRLIB_NAME}" +configure_cmd="${configure_cmd} GRIB2CLIB_NAME=${GRIB2CLIB_NAME} --enable-grib2" +if [[ ! -z ${MET_FREETYPEINC} && ! -z ${MET_FREETYPELIB} && \ + ! -z ${MET_CAIROINC} && ! -z ${MET_CAIROLIB} ]]; then + configure_cmd="${configure_cmd} --enable-mode_graphics" +fi + +if [[ ! -z $MET_ECKIT && ! -z $MET_ATLAS ]]; then + configure_cmd="${configure_cmd} --enable-ugrid" +fi + +if [[ ! -z $MET_HDF && ! -z $MET_HDFEOS ]]; then + configure_cmd="${configure_cmd} --enable-modis --enable-lidar2nc" +fi + +if [[ ! -z ${MET_PYTHON_CC} || ! -z ${MET_PYTHON_LD} ]]; then + configure_cmd="${configure_cmd} --enable-python" +fi + +configure_cmd="${configure_cmd} ${OPT_ARGS}" + +echo "cd `pwd`" +run_cmd "${configure_cmd} > $(pwd)/configure.log 2>&1" +run_cmd "make ${MAKE_ARGS} > $(pwd)/met.make.log 2>&1" +run_cmd "make install > $(pwd)/met.make_install.log 2>&1" +run_cmd "make test > $(pwd)/met.make_test.log 2>&1" + +echo "Finished compiling at `date`" From 60314676fed4f2a3834a6f7a2c0180c7b044cfe9 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Wed, 21 Aug 2024 13:17:34 -0600 Subject: [PATCH 108/114] Modifying script, including updates to eckit and atlas --- .../config/install_met_env.wcoss2 | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/internal/scripts/installation/config/install_met_env.wcoss2 b/internal/scripts/installation/config/install_met_env.wcoss2 index 86b73e0064..2d02be1f87 100644 --- a/internal/scripts/installation/config/install_met_env.wcoss2 +++ b/internal/scripts/installation/config/install_met_env.wcoss2 @@ -1,33 +1,32 @@ module reset -module use /apps/ops/para/libs/modulefiles/compiler/intel/19.1.3.304 -export HPC_OPT=/apps/ops/para/libs module use /apps/dev/modulefiles/ module load ve/evs/2.0 +module use /apps/ops/para/libs/modulefiles/compiler/intel/19.1.3.304 module load netcdf/4.7.4 module load hdf5/1.10.6 -module load bufr/11.6.0 +module load bufr/11.5.0 module load zlib/1.2.11 module load jasper/2.0.25 module load libpng/1.6.37 module load gsl/2.7 module load g2c/1.6.4 module load proj/7.1.0 -module use /apps/dev/lmodules/intel/19.1.3.304/ -module load atlas/0.30.0 -module load eckit/1.20.2 +module use /apps/dev/modulefiles +module load fckit/0.11.0 +module load atlas/0.35.0 +module load eckit/1.24.4 export FC=ifort export F77=ifort export F90=ifort export CC=icc export CXX=icpc -#export TEST_BASE=/apps/ops/para/libs/intel/19.1.3.304/met/12.0.0-beta3 export TEST_BASE=$(pwd) export LIB_DIR=${TEST_BASE}/external_libs export BIN_DIR_PATH=${TEST_BASE}/bin export COMPILER=intel_19.1.3.304 export MET_SUBDIR=${TEST_BASE} -export MET_TARBALL=v12.0.0-beta3.tar.gz +export MET_TARBALL=v12.0.0-beta5.tar.gz export USE_MODULES=TRUE export ADDTL_DIR=/apps/spack/gettext/0.21/intel/19.1.3.304/at2kdo4edvuhyzrt5g6zhwrdb7bdui4s/lib64 export PYTHON_MODULE=python_3.10.4 @@ -45,10 +44,10 @@ export MET_GRIB2CLIB=${g2c_ROOT}/lib64 export MET_GRIB2CINC=${G2C_INC} export MET_GSL=/apps/spack/gsl/2.7/intel/19.1.3.304/xks7dxbowrdxhjck5zxc4rompopocevb export MET_PROJ=/apps/spack/proj/7.1.0/intel/19.1.3.304/cjbmc7tacv5qcfatslqmcrzo5kb4raaq -export MET_ATLASLIB=/apps/dev/intel-19.1.3.304/cray-mpich-8.1.9/atlas/0.30.0/lib64 -export MET_ATLASINC=/apps/dev/intel-19.1.3.304/cray-mpich-8.1.9/atlas/0.30.0/include/atlas -export MET_ECKITLIB=/apps/dev/intel-19.1.3.304/cray-mpich-8.1.9/eckit/1.20.2/lib64 -export MET_ECKITINC=/apps/dev/intel-19.1.3.304/cray-mpich-8.1.9/eckit/1.20.2/include/eckit +export MET_ATLASLIB=/apps/dev/atlas/install-0.35.0/lib64 +export MET_ATLASINC=/apps/dev/atlas/install-0.35.0/include/atlas +export MET_ECKITLIB=/apps/dev/eckit/install-1.24.4/lib64 +export MET_ECKITINC=/apps/dev/eckit/install-1.24.4/include/eckit export BUFRLIB_NAME=-lbufr_4 export GRIB2CLIB_NAME=-lg2c # JY export LIB_JASPER=/apps/spack/jasper/2.0.25/intel/19.1.3.304/sjib74krrorkyczqpqah4tvewmlnqdx4/lib64 @@ -58,4 +57,3 @@ export LIB_LIBPNG=${LIBPNG_LIBDIR} # JY export LIB_Z=/apps/spack/zlib/1.2.11/intel/19.1.3.304/hjotqkckeoyt6j6tibalwzrlfljcjtdh/lib export LIB_Z=${ZLIB_LIBDIR} export MAKE_ARGS=-j -export CXXFLAGS="-std=c++11" From d494a15dddac18a1174f5858f2124111a7751c0f Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Thu, 22 Aug 2024 15:31:50 -0600 Subject: [PATCH 109/114] Corrected version of bufr being used --- internal/scripts/installation/config/install_met_env.wcoss2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scripts/installation/config/install_met_env.wcoss2 b/internal/scripts/installation/config/install_met_env.wcoss2 index 2d02be1f87..68e7ef2872 100644 --- a/internal/scripts/installation/config/install_met_env.wcoss2 +++ b/internal/scripts/installation/config/install_met_env.wcoss2 @@ -4,7 +4,7 @@ module load ve/evs/2.0 module use /apps/ops/para/libs/modulefiles/compiler/intel/19.1.3.304 module load netcdf/4.7.4 module load hdf5/1.10.6 -module load bufr/11.5.0 +module load bufr/11.6.0 module load zlib/1.2.11 module load jasper/2.0.25 module load libpng/1.6.37 From 13829515563a90ddd5447230d8b1c1f2e5f2c7a6 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 26 Aug 2024 16:03:28 -0600 Subject: [PATCH 110/114] Feature #2938 pb2nc_center_time (#2954) * Per #2938, define CRC_Array::add_uniq(...) member function which is now used in PB2NC * Per #2938, replace n_elements() with n() to make the code more concise. Refine log/warning message when multiple message center times are encountered. --- src/basic/vx_util/crc_array.h | 17 ++++ src/tools/other/pb2nc/pb2nc.cc | 155 +++++++++++++++++---------------- 2 files changed, 97 insertions(+), 75 deletions(-) diff --git a/src/basic/vx_util/crc_array.h b/src/basic/vx_util/crc_array.h index 02805d1bf5..6a8841afce 100644 --- a/src/basic/vx_util/crc_array.h +++ b/src/basic/vx_util/crc_array.h @@ -108,6 +108,7 @@ class CRC_Array { void add(const T &); void add(const CRC_Array &); + void add_uniq(const T &, bool forward=true); void add_css_sec(const char *); void set(const T & val); @@ -509,6 +510,22 @@ return; //////////////////////////////////////////////////////////////////////// +template + +void CRC_Array::add_uniq(const T & k, bool forward) + +{ + +if ( !has(k, forward) ) add(k); + +return; + +} + + +//////////////////////////////////////////////////////////////////////// + + template void CRC_Array::add_css_sec(const char * text) diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index a9abdf1be9..94a7750bad 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -58,9 +58,10 @@ // from header files // 019 07/21/23 Prestopnik, J. MET #2615 Add #include to compile // successfully using gcc12 +// 020 08/26/24 Halley Gotway MET #2938 Silence center time warnings +// //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -467,7 +468,7 @@ int met_main(int argc, char *argv[]) { if (collect_metadata) { // Process each PrepBufr file - for(int i=0; i 1) { + if(pbfile.n() > 1) { mlog << Error << "\n" << method_name << "the \"-dump\" and \"-pbfile\" options may not be " << "used together. Only one Bufr file may be dump " @@ -1067,15 +1067,14 @@ void process_pbfile(int i_pb) { cape_h = pbl_h = 0; cape_p = pbl_p = bad_data_float; - diff_file_time_count = 0; cycle_minute = missing_cycle_minute; // initialize - // Derive quantities which can be derived from - // P, Q, T, Z, U, V + // Check the number of variables to be derived from: + // P, Q, T, Z, U, V if (n_derive_gc > bufr_derive_cfgs.size()) { - mlog << Debug(3) << "\n" << method_name - << "Skip the derived variables because of not requested (" - << bufr_derive_cfgs.size() << ").\n\n"; + mlog << Debug(3) << method_name + << "No observation variables requested to be derived (" + << bufr_derive_cfgs.size() << ").\n"; } for (int idx=0; idx= debug_level_for_performance) { end_t = clock(); - cout << (end_t-start_t)/double(CLOCKS_PER_SEC) - << " seconds\n"; + cout << (end_t-start_t)/double(CLOCKS_PER_SEC) << " seconds\n"; start_t = clock(); } } @@ -1149,10 +1147,10 @@ void process_pbfile(int i_pb) { << " to " << end_time_str << "\n"; } - else if(file_ut != msg_ut) { - diff_file_time_count++; - if (!diff_file_times.has(msg_ut)) diff_file_times.add(msg_ut); - } + + // Keep track of the unique message reference times, + // searching from newest to oldest + unique_msg_ut.add_uniq(msg_ut, false); // Add minutes by calling IUPVS01(unit, "MINU") if (cycle_minute != missing_cycle_minute) { @@ -1802,7 +1800,7 @@ void process_pbfile(int i_pb) { int n_other_file_obs = 0; int n_other_total_obs = 0; int n_other_hdr_obs = 0; - int var_count = bufr_obs_name_arr.n_elements(); + int var_count = bufr_obs_name_arr.n(); for (int vIdx=0; vIdx= debug_level_for_performance) { end_t = clock(); log_message << (end_t-start_t)/double(CLOCKS_PER_SEC) << " seconds"; - //start_t = clock(); } cout << log_message << "\n"; } - if(0 < diff_file_time_count && 0 < diff_file_times.n_elements()) { - mlog << Warning << "\n" << method_name - << "The observation time should remain the same for " - << "all " << (is_prepbufr ? "PrepBufr" : "Bufr") << " messages\n"; - mlog << Warning << method_name << " " - << diff_file_time_count << " messages with different reference time (" - << unix_to_yyyymmdd_hhmmss(file_ut) << "):\n"; - for (int idx=0; idx 1) { + + ConcatString msg_cs; + msg_cs << "Found " << unique_msg_ut.n() << " unique " + << (is_prepbufr ? "PrepBufr" : "Bufr") + << " message reference time(s) from " + << unix_to_yyyymmdd_hhmmss(unique_msg_ut.min()) << " to " + << unix_to_yyyymmdd_hhmmss(unique_msg_ut.max()) << ".\n"; + + // Print warning if the time window was not defined on the command line + if(valid_beg_ut == (unixtime) 0 && + valid_end_ut == (unixtime) 0) { + mlog << Warning << "\n" << method_name + << msg_cs << "\n" + << R"(Set the "-valid_beg" and/or "-valid_end" )" + << "command line options to define the retention " + << "time window.\n\n"; + } + else { + mlog << Debug(3) << msg_cs; } - mlog << Warning << "\n"; } nc_point_obs.write_observation(); - if(mlog.verbosity_level() > 0) cout << "\n" << flush; - mlog << Debug(2) << "Messages processed\t\t\t= " << npbmsg << "\n" << "Rejected based on message type\t\t= " @@ -2065,7 +2070,7 @@ void process_pbfile(int i_pb) { int debug_level = 5; if(mlog.verbosity_level() >= debug_level) { log_message = "Filtered time:"; - for (kk=0; kk variable \"" @@ -2388,9 +2393,9 @@ void process_pbfile_metadata(int i_pb) { } } // if (0 == i_read) - if (0 == unchecked_var_list.n_elements()) break; + if (0 == unchecked_var_list.n()) break; - int var_count = unchecked_var_list.n_elements(); + int var_count = unchecked_var_list.n(); for (int vIdx=var_count-1; vIdx>=0; vIdx--) { int nlev2, count; bool has_valid_data; @@ -2441,7 +2446,7 @@ void process_pbfile_metadata(int i_pb) { bool has_prepbufr_vars = false; const char * tmp_var_name; bufr_obs_name_arr.clear(); - for (index=0; index obs_var_map = conf_info.getObsVarMap(); - for(int i=0; i= 0 && (do_all_vars || code < bufr_target_variables.n_elements())); + return(code >= 0 && (do_all_vars || code < bufr_target_variables.n())); } //////////////////////////////////////////////////////////////////////// bool keep_level_category(int category) { - return(conf_info.level_category.n_elements() == 0 || + return(conf_info.level_category.n() == 0 || conf_info.level_category.has(category, false)); } @@ -2884,8 +2889,8 @@ void display_bufr_variables(const StringArray &all_vars, const StringArray &all_ ConcatString description; ConcatString line_buf; - mlog << Debug(1) << "\n Header variables (" << hdr_arr.n_elements() << ") :\n"; - for(i=0; i pqtzuv_map_tq, log_array.add(buf.c_str()); } offset = 0; - for (int idx=log_array.n_elements()-1; idx>=0; idx--) { + for (int idx=log_array.n()-1; idx>=0; idx--) { mlog << Debug(PBL_DEBUG_LEVEL) << method_name << "TQZ record: " << offset++ << "\t" << log_array[idx] << "\n"; } @@ -3463,7 +3468,7 @@ void log_tqz_and_uv(map pqtzuv_map_tq, log_array.add(buf.c_str()); } offset = 0; - for (int idx=log_array.n_elements()-1; idx>=0; idx--) { + for (int idx=log_array.n()-1; idx>=0; idx--) { mlog << Debug(PBL_DEBUG_LEVEL) << method_name << " UV record: " << offset++ << "\t" << log_array[idx] << "\n"; } @@ -3496,7 +3501,7 @@ void log_merged_tqz_uv(map pqtzuv_map_tq, log_array.add(buf.c_str()); } int offset = 0; - for (int idx=log_array.n_elements()-1; idx>=0; idx--) { + for (int idx=log_array.n()-1; idx>=0; idx--) { mlog << Debug(PBL_DEBUG_LEVEL) << method_name << " merged: " << offset++ << "\t" << log_array[idx] << "\n"; } @@ -3523,7 +3528,7 @@ void log_pbl_input(int pbl_level, const char *method_name) { int offset = 0; mlog << Debug(PBL_DEBUG_LEVEL) << method_name << "input to calpbl_ (buffer): index, P, Q, T, Z, U, V\n"; - for (int idx=log_array.n_elements()-1; idx>=0; idx--) { + for (int idx=log_array.n()-1; idx>=0; idx--) { mlog << Debug(PBL_DEBUG_LEVEL) << method_name << " " << offset++ << "\t" << log_array[idx] << "\n"; } From 30fa96633ca45f66176509a7e435aff78f9d82c8 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 29 Aug 2024 15:09:43 -0600 Subject: [PATCH 111/114] Feature #1371 series_analysis (#2951) * Per #1371, add -input command line argument and add support for ALL for the CTC, MCTC, SL1L2, and PCT line types. * Per #1371, rename the -input command line option as -aggregate instead * Per #1371, work in progress * Per #1371, just comments * Per #1371, working on aggregating CTC counts * Per #1371, work in progress * Per #1371, update timing info using time stamps in the aggr file * Per #1371, close the aggregate data file * Per #1371, define set_event() and set_nonevent() member functions * Per #1371, add logic to aggregate MCTC and PCT counts * Merging changes from develop * Per #1371, work in progress aggregating all the line statistics types. Still have several issues to address * Per #1371, switch to using get_stat() functions * Per #1371, work in progress. More consolidation * Per #1371, correct expected output file name * Per #1371, consistent regridding log messages and fix the Series-Analysis PairDataPoint object handling logic. * Per #1371, check the return status when opening the aggregate file. * Per #1371, fix prc/pjc typo * Per #1371, fix the series_analysis PCT aggregation logic and add a test to unit_series_analysis.xml to demonstrate. * Per #1371, resolve a few SonarQube findings * Per #1371, make use of range-based for loop, as recommeded by SonarQube * Per #1371, update series-analysis to apply the valid data threshold properly using the old aggregate data and the new pair data. * Per #1371, update series_analysis to buffer data and write it all at once instead of storing data value by value for each point. * Per #1371, add useful error message when required aggregation variables are not present in the input -aggr file. * Per #1371, print a Debug(2) message listing the aggregation fields being read. * Per #1371, correct operator+= logic in met_stats.cc for SL1L2Info, VL1L2Info, and NBRCNTInfo. The metadata settings, like fthresh and othresh, were not being passed to the output. * Per #1371, the DataPlane for the computed statistics should be initialized to a field of bad data values rather than the default value of 0. Otherwise, 0's are reported for stats a grid points with no data when they should really be reported as bad data! * Per #1371, update logic of the compute_cntinfo() function so that CNT statistics can be derived from a single SL1L2Info object containing both scalar and scalar anomaly partial sums. These changes enable CNT:ANOM_CORR to be aggregated in the Series-Analysis tool. * Per #1371, fix logic of climo log message. * Per #1371, this is actually related to MET #2924. In compute_pctinfo() used obs climo data first, if provided. And if not, use fcst climo data. * Per #1371, fix indexing bug (+i instead of +1) when check the valid data count. Also update the logic of read_aggr_total() to return a count of 0 for bad data. * Per #1371, add logic to aggregate the PSTD BRIERCL and BSS statistics in the do_climo_brier() function. Tested manually to confirm that it works. * Per #1371, switch to using string literals to satisfy SonarQube * Per #1371, update series_analysis tests in unit_climatology_1.0deg.xml to demonstrate aggregating climo-based stats. * Per #1371, remove extra comment * Per #1371, skip writing the PCT THRESH_i columns to the Series-Analysis output since they are not used * Per #1371, fix the R string literals to remove \t and \n escape sequences. * Per #1371, update the read_aggr_data_plane() suggestion strings. * Per #1371, ignore unneeded PCT 'THRESH_' variables both when reading and writing ALL PCT columns. * Per #1371, update the test named series_analysis_AGGR_CMD_LINE to include data for the F42 lead time that had previously been included for the same run in the develop branch. Note however that the timestamps in the output file for the develop branch (2012040900_to_2012041100) were wrong and have been corrected here (2012040900_to_2012041018) to match the actual data. * Per #1371, update the -aggr note to warn users about slow runtimes --- docs/Users_Guide/series-analysis.rst | 15 +- .../config/SeriesAnalysisConfig_climo | 10 +- .../config/SeriesAnalysisConfig_climo_prob | 2 +- .../test_unit/xml/unit_climatology_1.0deg.xml | 96 +- .../test_unit/xml/unit_series_analysis.xml | 112 +- src/libcode/vx_stat_out/stat_columns.cc | 112 +- src/libcode/vx_stat_out/stat_columns.h | 3 + src/libcode/vx_statistics/compute_stats.cc | 182 +- src/libcode/vx_statistics/compute_stats.h | 3 +- src/libcode/vx_statistics/contable.h | 7 + src/libcode/vx_statistics/contable_nx2.cc | 90 +- src/libcode/vx_statistics/met_stats.cc | 1034 +++++++- src/libcode/vx_statistics/met_stats.h | 41 +- .../core/series_analysis/series_analysis.cc | 2183 +++++++++-------- .../core/series_analysis/series_analysis.h | 48 +- .../core/stat_analysis/aggr_stat_line.cc | 8 +- .../stat_analysis/skill_score_index_job.cc | 8 +- .../core/stat_analysis/stat_analysis_job.cc | 7 +- 18 files changed, 2555 insertions(+), 1406 deletions(-) diff --git a/docs/Users_Guide/series-analysis.rst b/docs/Users_Guide/series-analysis.rst index 0be681585f..ed9f5578ab 100644 --- a/docs/Users_Guide/series-analysis.rst +++ b/docs/Users_Guide/series-analysis.rst @@ -33,6 +33,7 @@ The usage statement for the Series-Analysis tool is shown below: -fcst file_1 ... file_n | fcst_file_list -obs file_1 ... file_n | obs_file_list [-both file_1 ... file_n | both_file_list] + [-aggr file] [-paired] -out file -config file @@ -58,13 +59,17 @@ Optional Arguments for series_analysis 5. To set both the forecast and observations to the same set of files, use the optional -both file_1 ... file_n | both_file_list option to the same set of files. This is useful when reading the NetCDF matched pair output of the Grid-Stat tool which contains both forecast and observation data. -6. The -paired option indicates that the -fcst and -obs file lists are already paired, meaning there is a one-to-one correspondence between the files in those lists. This option affects how missing data is handled. When -paired is not used, missing or incomplete files result in a runtime error with no output file being created. When -paired is used, missing or incomplete files result in a warning with output being created using the available data. +6. The -aggr option specifies the path to an existing Series-Analysis output file. When computing statistics for the input forecast and observation data, Series-Analysis aggregates the partial sums (SL1L2, SAL1L2 line types) and contingency table counts (CTC, MCTC, and PCT line types) with data provided in the aggregate file. This option enables Series-Analysis to run iteratively and update existing partial sums, counts, and statistics with new data. -7. The -log file outputs log messages to the specified file. +.. note:: When the -aggr option is used, only statistics that are derivable from partial sums and contingency table counts can be requested. Runtimes are generally much slower when aggregating data since it requires many additional NetCDF variables containing the scalar partial sums and contingency table counts to be read and written. -8. The -v level overrides the default level of logging (2). +7. The -paired option indicates that the -fcst and -obs file lists are already paired, meaning there is a one-to-one correspondence between the files in those lists. This option affects how missing data is handled. When -paired is not used, missing or incomplete files result in a runtime error with no output file being created. When -paired is used, missing or incomplete files result in a warning with output being created using the available data. -9. The -compress level option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. +8. The -log file outputs log messages to the specified file. + +9. The -v level overrides the default level of logging (2). + +10. The -compress level option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. An example of the series_analysis calling sequence is shown below: @@ -179,3 +184,5 @@ The output_stats array controls the type of output that the Series-Analysis tool 11. PJC for Joint and Conditional factorization for Probabilistic forecasts (See :numref:`table_PS_format_info_PJC`) 12. PRC for Receiver Operating Characteristic for Probabilistic forecasts (See :numref:`table_PS_format_info_PRC`) + +.. note:: When the -input option is used, all partial sum and contingency table count columns are required to aggregate statistics across multiple runs. To facilitate this, the output_stats entries for the CTC, SL1L2, SAL1L2, and PCT line types can be set to "ALL" to indicate that all available columns for those line types should be written. diff --git a/internal/test_unit/config/SeriesAnalysisConfig_climo b/internal/test_unit/config/SeriesAnalysisConfig_climo index 3728482541..f19bac7a20 100644 --- a/internal/test_unit/config/SeriesAnalysisConfig_climo +++ b/internal/test_unit/config/SeriesAnalysisConfig_climo @@ -132,13 +132,13 @@ vld_thresh = 0.5; // output_stats = { fho = [ "TOTAL", "F_RATE", "H_RATE", "O_RATE" ]; - ctc = [ ]; + ctc = [ "ALL" ]; cts = [ ]; mctc = [ ]; - mcts = [ "ACC" ]; - cnt = [ "TOTAL", "RMSE", "ANOM_CORR" ]; - sl1l2 = [ ]; - sal1l2 = [ ]; + mcts = [ ]; + cnt = [ "TOTAL", "RMSE", "ANOM_CORR", "RMSFA", "RMSOA" ]; + sl1l2 = [ "ALL" ]; + sal1l2 = [ "ALL" ]; pct = [ ]; pstd = [ ]; pjc = [ ]; diff --git a/internal/test_unit/config/SeriesAnalysisConfig_climo_prob b/internal/test_unit/config/SeriesAnalysisConfig_climo_prob index 8b55c508d3..149062dc41 100644 --- a/internal/test_unit/config/SeriesAnalysisConfig_climo_prob +++ b/internal/test_unit/config/SeriesAnalysisConfig_climo_prob @@ -148,7 +148,7 @@ output_stats = { cnt = [ ]; sl1l2 = [ ]; sal1l2 = [ ]; - pct = [ ]; + pct = [ "ALL" ]; pstd = [ "TOTAL", "ROC_AUC", "BRIER", "BRIERCL", "BSS", "BSS_SMPL" ]; pjc = [ ]; prc = [ ]; diff --git a/internal/test_unit/xml/unit_climatology_1.0deg.xml b/internal/test_unit/xml/unit_climatology_1.0deg.xml index a07d47ff6e..fcd6b59668 100644 --- a/internal/test_unit/xml/unit_climatology_1.0deg.xml +++ b/internal/test_unit/xml/unit_climatology_1.0deg.xml @@ -154,20 +154,18 @@ &OUTPUT_DIR;/climatology_1.0deg/stat_analysis_MPR_to_PSTD.stat
- +--!> &MET_BIN;/series_analysis CLIMO_MEAN_FILE_LIST "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590409", - "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590410", - "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590411" + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590410" CLIMO_STDEV_FILE_LIST "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590409", - "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590410", - "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590411" + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590410" @@ -175,11 +173,9 @@ -fcst &DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F012.grib2 \ &DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F024.grib2 \ &DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F036.grib2 \ - &DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F048.grib2 \ -obs &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120409_1200_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_0000_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_1200_000.grb2 \ - &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120411_0000_000.grb2 \ -paired \ -out &OUTPUT_DIR;/climatology_1.0deg/series_analysis_GFS_CLIMO_1.0DEG.nc \ -config &CONFIG_DIR;/SeriesAnalysisConfig_climo \ @@ -190,25 +186,84 @@
+ + &MET_BIN;/series_analysis + + CLIMO_MEAN_FILE_LIST + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590411" + + + CLIMO_STDEV_FILE_LIST + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590411" + + + + \ + -fcst &DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F048.grib2 \ + -obs &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120411_0000_000.grb2 \ + -paired \ + -aggr &OUTPUT_DIR;/climatology_1.0deg/series_analysis_GFS_CLIMO_1.0DEG.nc \ + -out &OUTPUT_DIR;/climatology_1.0deg/series_analysis_GFS_CLIMO_1.0DEG_AGGR.nc \ + -config &CONFIG_DIR;/SeriesAnalysisConfig_climo \ + -v 2 + + + &OUTPUT_DIR;/climatology_1.0deg/series_analysis_GFS_CLIMO_1.0DEG_AGGR.nc + + + echo "&DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F003.grib2 \ &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F009.grib2 \ &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F015.grib2 \ - &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F021.grib2 \ - &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F027.grib2 \ - &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F033.grib2 \ - &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F039.grib2 \ - &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F045.grib2" \ - > &OUTPUT_DIR;/climatology_1.0deg/input_fcst_file_list; \ + &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F021.grib2" \ + > &OUTPUT_DIR;/climatology_1.0deg/20120409_fcst_file_list; \ echo "&DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120409_0000_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120409_0600_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120409_1200_000.grb2 \ - &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120409_1800_000.grb2 \ - &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_0000_000.grb2 \ + &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120409_1800_000.grb2" \ + > &OUTPUT_DIR;/climatology_1.0deg/20120409_obs_file_list; \ + &MET_BIN;/series_analysis + + DAY_INTERVAL 1 + HOUR_INTERVAL 6 + CLIMO_MEAN_FILE_LIST + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590409", + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590410", + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cmean_1d.19590411" + + + CLIMO_STDEV_FILE_LIST + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590409", + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590410", + "&DATA_DIR_CLIMO;/NCEP_NCAR_40YR_1.0deg/cstdv_1d.19590411" + + + + \ + -fcst &OUTPUT_DIR;/climatology_1.0deg/20120409_fcst_file_list \ + -obs &OUTPUT_DIR;/climatology_1.0deg/20120409_obs_file_list \ + -paired \ + -out &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG.nc \ + -config &CONFIG_DIR;/SeriesAnalysisConfig_climo_prob \ + -v 2 + + + &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG.nc + + + + + echo "&DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F027.grib2 \ + &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F033.grib2 \ + &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F039.grib2 \ + &DATA_DIR_MODEL;/grib2/sref_pr/sref_prob_2012040821_F045.grib2" \ + > &OUTPUT_DIR;/climatology_1.0deg/20120410_fcst_file_list; \ + echo "&DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_0000_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_0600_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_1200_000.grb2 \ &DATA_DIR_MODEL;/grib2/gfsanl/gfsanl_4_20120410_1800_000.grb2" \ - > &OUTPUT_DIR;/climatology_1.0deg/input_obs_file_list; \ + > &OUTPUT_DIR;/climatology_1.0deg/20120410_obs_file_list; \ &MET_BIN;/series_analysis DAY_INTERVAL 1 @@ -227,15 +282,16 @@ \ - -fcst &OUTPUT_DIR;/climatology_1.0deg/input_fcst_file_list \ - -obs &OUTPUT_DIR;/climatology_1.0deg/input_obs_file_list \ + -fcst &OUTPUT_DIR;/climatology_1.0deg/20120410_fcst_file_list \ + -obs &OUTPUT_DIR;/climatology_1.0deg/20120410_obs_file_list \ -paired \ - -out &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG.nc \ + -aggr &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG.nc \ + -out &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG_AGGR.nc \ -config &CONFIG_DIR;/SeriesAnalysisConfig_climo_prob \ -v 2 - &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG.nc + &OUTPUT_DIR;/climatology_1.0deg/series_analysis_PROB_CLIMO_1.0DEG_AGGR.nc diff --git a/internal/test_unit/xml/unit_series_analysis.xml b/internal/test_unit/xml/unit_series_analysis.xml index c1e64416b3..96cda729dd 100644 --- a/internal/test_unit/xml/unit_series_analysis.xml +++ b/internal/test_unit/xml/unit_series_analysis.xml @@ -29,12 +29,12 @@ OBS_FIELD { name = "APCP"; level = [ "A06" ]; } MASK_POLY FHO_STATS "F_RATE", "O_RATE" - CTC_STATS "FY_OY", "FN_ON" + CTC_STATS "ALL" CTS_STATS "CSI", "GSS" - MCTC_STATS "F1_O1", "F2_O2", "F3_O3" + MCTC_STATS "ALL" MCTS_STATS "ACC", "ACC_NCL", "ACC_NCU" CNT_STATS "TOTAL", "ME", "ME_NCL", "ME_NCU" - SL1L2_STATS "FBAR", "OBAR" + SL1L2_STATS "ALL" SAL1L2_STATS PCT_STATS PSTD_STATS @@ -46,22 +46,56 @@ &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F012.grib \ &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F018.grib \ &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F024.grib \ - &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F030.grib \ - &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F036.grib \ - &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F042.grib \ -obs &DATA_DIR_OBS;/stage4_hmt/stage4_2012040906_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012040912_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012040918_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012041000_06h.grib \ - &DATA_DIR_OBS;/stage4_hmt/stage4_2012041006_06h.grib \ + -out &OUTPUT_DIR;/series_analysis/series_analysis_CMD_LINE_APCP_06_2012040900_to_2012041000.nc \ + -config &CONFIG_DIR;/SeriesAnalysisConfig \ + -v 1 + + + &OUTPUT_DIR;/series_analysis/series_analysis_CMD_LINE_APCP_06_2012040900_to_2012041000.nc + + + + + &MET_BIN;/series_analysis + + MODEL GFS + OBTYPE STAGE4 + FCST_CAT_THRESH >0.0, >5.0 + FCST_FIELD { name = "APCP"; level = [ "A06" ]; } + OBS_CAT_THRESH >0.0, >5.0 + OBS_FIELD { name = "APCP"; level = [ "A06" ]; } + MASK_POLY + FHO_STATS "F_RATE", "O_RATE" + CTC_STATS "ALL" + CTS_STATS "CSI", "GSS" + MCTC_STATS "ALL" + MCTS_STATS "ACC", "ACC_NCL", "ACC_NCU" + CNT_STATS "TOTAL", "ME", "ME_NCL", "ME_NCU" + SL1L2_STATS "ALL" + SAL1L2_STATS + PCT_STATS + PSTD_STATS + PJC_STATS + PRC_STATS + + \ + -fcst &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F030.grib \ + &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F036.grib \ + &DATA_DIR_MODEL;/grib1/gfs_hmt/gfs_2012040900_F042.grib \ + -obs &DATA_DIR_OBS;/stage4_hmt/stage4_2012041006_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012041012_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012041018_06h.grib \ - -out &OUTPUT_DIR;/series_analysis/series_analysis_CMD_LINE_APCP_06_2012040900_to_2012041100.nc \ + -aggr &OUTPUT_DIR;/series_analysis/series_analysis_CMD_LINE_APCP_06_2012040900_to_2012041000.nc \ + -out &OUTPUT_DIR;/series_analysis/series_analysis_AGGR_CMD_LINE_APCP_06_2012040900_to_2012041018.nc \ -config &CONFIG_DIR;/SeriesAnalysisConfig \ -v 1 - &OUTPUT_DIR;/series_analysis/series_analysis_CMD_LINE_APCP_06_2012040900_to_2012041100.nc + &OUTPUT_DIR;/series_analysis/series_analysis_AGGR_CMD_LINE_APCP_06_2012040900_to_2012041018.nc @@ -69,18 +103,12 @@ echo "&DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F009.grib \ &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F015.grib \ &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F021.grib \ - &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F027.grib \ - &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F033.grib \ - &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F039.grib \ - &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F045.grib" \ + &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F027.grib" \ > &OUTPUT_DIR;/series_analysis/input_fcst_file_list; \ echo "&DATA_DIR_OBS;/stage4_hmt/stage4_2012040906_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012040912_06h.grib \ &DATA_DIR_OBS;/stage4_hmt/stage4_2012040918_06h.grib \ - &DATA_DIR_OBS;/stage4_hmt/stage4_2012041000_06h.grib \ - &DATA_DIR_OBS;/stage4_hmt/stage4_2012041006_06h.grib \ - &DATA_DIR_OBS;/stage4_hmt/stage4_2012041012_06h.grib \ - &DATA_DIR_OBS;/stage4_hmt/stage4_2012041018_06h.grib" \ + &DATA_DIR_OBS;/stage4_hmt/stage4_2012041000_06h.grib" \ > &OUTPUT_DIR;/series_analysis/input_obs_file_list; \ &MET_BIN;/series_analysis @@ -99,7 +127,7 @@ CNT_STATS SL1L2_STATS SAL1L2_STATS - PCT_STATS "OY_1", "ON_1" + PCT_STATS "ALL" PSTD_STATS "TOTAL", "ROC_AUC", "BRIER", "BRIER_NCL", "BRIER_NCU" PJC_STATS "CALIBRATION_1", "REFINEMENT_1" PRC_STATS "PODY_1", "POFD_1" @@ -107,12 +135,56 @@ \ -fcst &OUTPUT_DIR;/series_analysis/input_fcst_file_list \ -obs &OUTPUT_DIR;/series_analysis/input_obs_file_list \ - -out &OUTPUT_DIR;/series_analysis/series_analysis_FILE_LIST_PROB_APCP_06_2012040900_to_2012041100.nc \ + -out &OUTPUT_DIR;/series_analysis/series_analysis_FILE_LIST_PROB_APCP_06_2012040900_to_2012041000.nc \ + -config &CONFIG_DIR;/SeriesAnalysisConfig \ + -v 1 + + + &OUTPUT_DIR;/series_analysis/series_analysis_FILE_LIST_PROB_APCP_06_2012040900_to_2012041000.nc + + + + + echo "&DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F033.grib \ + &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F039.grib \ + &DATA_DIR_MODEL;/grib1/sref/sref_2012040821_F045.grib" \ + > &OUTPUT_DIR;/series_analysis/aggregate_fcst_file_list; \ + echo "&DATA_DIR_OBS;/stage4_hmt/stage4_2012041006_06h.grib \ + &DATA_DIR_OBS;/stage4_hmt/stage4_2012041012_06h.grib \ + &DATA_DIR_OBS;/stage4_hmt/stage4_2012041018_06h.grib" \ + > &OUTPUT_DIR;/series_analysis/aggregate_obs_file_list; \ + &MET_BIN;/series_analysis + + MODEL SREF + OBTYPE STAGE4 + FCST_CAT_THRESH >=0.00, >=0.25, >=0.50, >=0.75, >=1.00 + FCST_FIELD { name = "PROB"; level = "A06"; prob = { name = "APCP"; thresh_lo = 0.25; }; } + OBS_CAT_THRESH >0.25 + OBS_FIELD { name = "APCP"; level = "A06"; } + MASK_POLY + FHO_STATS + CTC_STATS + CTS_STATS + MCTC_STATS + MCTS_STATS + CNT_STATS + SL1L2_STATS + SAL1L2_STATS + PCT_STATS "ALL" + PSTD_STATS "TOTAL", "ROC_AUC", "BRIER", "BRIER_NCL", "BRIER_NCU" + PJC_STATS "CALIBRATION_1", "REFINEMENT_1" + PRC_STATS "PODY_1", "POFD_1" + + \ + -fcst &OUTPUT_DIR;/series_analysis/aggregate_fcst_file_list \ + -obs &OUTPUT_DIR;/series_analysis/aggregate_obs_file_list \ + -aggr &OUTPUT_DIR;/series_analysis/series_analysis_FILE_LIST_PROB_APCP_06_2012040900_to_2012041000.nc \ + -out &OUTPUT_DIR;/series_analysis/series_analysis_AGGR_FILE_LIST_PROB_APCP_06_2012040900_to_2012041018.nc \ -config &CONFIG_DIR;/SeriesAnalysisConfig \ -v 1 - &OUTPUT_DIR;/series_analysis/series_analysis_FILE_LIST_PROB_APCP_06_2012040900_to_2012041100.nc + &OUTPUT_DIR;/series_analysis/series_analysis_AGGR_FILE_LIST_PROB_APCP_06_2012040900_to_2012041018.nc diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 51992d7b50..f4ccb6354b 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -122,32 +122,18 @@ void write_header_row(const char * const * cols, int n_cols, int hdr_flag, void write_mctc_header_row(int hdr_flag, int n_cat, AsciiTable &at, int r, int c) { - int i, j, col; - ConcatString cs; // Write the header column names if requested if(hdr_flag) { - for(i=0; i= 1) { - tmp_str.format("%s%i", pct_columns[2], n_thresh); - at.set_entry(r, col, tmp_str); // Threshold - } + StringArray sa(get_pct_columns(n_thresh)); + for(int i=0; i= 1) { + cs.format("%s%i", pct_columns[2], n_thresh); + sa.add(cs); + } + + return sa; +} + + //////////////////////////////////////////////////////////////////////// void write_fho_row(StatHdrColumns &shc, const CTSInfo &cts_info, @@ -4608,7 +4630,7 @@ void write_ssvar_cols(const PairDataEnsemble *pd_ptr, int i, // cnt_info.allocate_n_alpha(1); cnt_info.alpha[0] = alpha; - compute_cntinfo(pd_ptr->ssvar_bins[i].sl1l2_info, 0, cnt_info); + compute_cntinfo(pd_ptr->ssvar_bins[i].sl1l2_info, cnt_info); // // Ensemble spread/skill variance bins diff --git a/src/libcode/vx_stat_out/stat_columns.h b/src/libcode/vx_stat_out/stat_columns.h index 8af99ad730..7eb21c6fa0 100644 --- a/src/libcode/vx_stat_out/stat_columns.h +++ b/src/libcode/vx_stat_out/stat_columns.h @@ -49,6 +49,9 @@ extern void write_phist_header_row (int, int, AsciiTable &, int, int); extern void write_orank_header_row (int, int, AsciiTable &, int, int); extern void write_relp_header_row (int, int, AsciiTable &, int, int); +extern StringArray get_mctc_columns (int); +extern StringArray get_pct_columns (int); + extern void write_fho_row (StatHdrColumns &, const CTSInfo &, STATOutputType, AsciiTable &, int &, AsciiTable &, int &); extern void write_ctc_row (StatHdrColumns &, const CTSInfo &, STATOutputType, diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index bbc9e0ac1a..c0d988efd3 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -27,112 +27,97 @@ using namespace std; const int detailed_debug_level = 5; - //////////////////////////////////////////////////////////////////////// -void compute_cntinfo(const SL1L2Info &s, bool aflag, CNTInfo &cnt_info) { - double fbar, obar, ffbar, fobar, oobar, den; - int n; +void compute_cntinfo(const SL1L2Info &s, CNTInfo &cnt_info) { + + // Initialize statistics + cnt_info.zero_out(); - // Set the quantities that can't be derived from SL1L2Info to bad data - cnt_info.sp_corr.set_bad_data(); - cnt_info.kt_corr.set_bad_data(); - cnt_info.e10.set_bad_data(); - cnt_info.e25.set_bad_data(); - cnt_info.e50.set_bad_data(); - cnt_info.e75.set_bad_data(); - cnt_info.e90.set_bad_data(); - cnt_info.eiqr.set_bad_data(); - cnt_info.mad.set_bad_data(); - cnt_info.n_ranks = 0; - cnt_info.frank_ties = 0; - cnt_info.orank_ties = 0; - - // Get partial sums - n = (aflag ? s.sacount : s.scount); - fbar = (aflag ? s.fabar : s.fbar); - obar = (aflag ? s.oabar : s.obar); - fobar = (aflag ? s.foabar : s.fobar); - ffbar = (aflag ? s.ffabar : s.ffbar); - oobar = (aflag ? s.ooabar : s.oobar); + // Check for consistent counts + if(s.scount > 0 && s.sacount > 0 && + s.scount != s.sacount) { + mlog << Error << "\ncompute_cntinfo() -> " + << "the scalar partial sum and scalar anomaly partial sum " + << "counts are both non-zero but do not match (" + << s.scount << " != " << s.sacount << ").\n\n"; + exit(1); + } // Number of matched pairs + int n = max(s.scount, s.sacount); cnt_info.n = n; - // Forecast mean and standard deviation - cnt_info.fbar.v = fbar; - cnt_info.fstdev.v = compute_stdev(fbar*n, ffbar*n, n); - - // Observation mean and standard deviation - cnt_info.obar.v = obar; - cnt_info.ostdev.v = compute_stdev(obar*n, oobar*n, n); - - // Multiplicative bias - cnt_info.mbias.v = (is_eq(obar, 0.0) ? bad_data_double : fbar/obar); - - // Correlation coefficient - - // Handle SAL1L2 data - if(aflag) { - cnt_info.pr_corr.v = bad_data_double; - cnt_info.anom_corr.v = compute_corr( fbar*n, obar*n, - ffbar*n, oobar*n, - fobar*n, n); - cnt_info.rmsfa.v = sqrt(ffbar); - cnt_info.rmsoa.v = sqrt(oobar); - cnt_info.anom_corr_uncntr.v = compute_anom_corr_uncntr(ffbar, oobar, - fobar); - } - // Handle SL1L2 data - else { - cnt_info.pr_corr.v = compute_corr( fbar*n, obar*n, - ffbar*n, oobar*n, - fobar*n, n); - cnt_info.anom_corr.v = bad_data_double; - cnt_info.rmsfa.v = bad_data_double; - cnt_info.rmsoa.v = bad_data_double; - cnt_info.anom_corr_uncntr.v = bad_data_double; - } + // Process scalar partial sum statistics + if(s.scount > 0) { - // Compute mean error - cnt_info.me.v = fbar - obar; + // Forecast mean and standard deviation + cnt_info.fbar.v = s.fbar; + cnt_info.fstdev.v = compute_stdev(s.fbar*n, s.ffbar*n, n); - // Compute mean error squared - cnt_info.me2.v = cnt_info.me.v * cnt_info.me.v; + // Observation mean and standard deviation + cnt_info.obar.v = s.obar; + cnt_info.ostdev.v = compute_stdev(s.obar*n, s.oobar*n, n); - // Compute mean absolute error - cnt_info.mae.v = s.smae; + // Multiplicative bias + cnt_info.mbias.v = (is_eq(s.obar, 0.0) ? bad_data_double : s.fbar/s.obar); - // Compute mean squared error - cnt_info.mse.v = ffbar + oobar - 2.0*fobar; + // Correlation coefficient + cnt_info.pr_corr.v = compute_corr( s.fbar*n, s.obar*n, + s.ffbar*n, s.oobar*n, + s.fobar*n, n); - // Compute mean squared error skill score - den = cnt_info.ostdev.v * cnt_info.ostdev.v; - if(!is_eq(den, 0.0)) { - cnt_info.msess.v = 1.0 - cnt_info.mse.v / den; - } - else { - cnt_info.msess.v = bad_data_double; - } + // Compute mean error + cnt_info.me.v = s.fbar - s.obar; - // Compute standard deviation of the mean error - cnt_info.estdev.v = compute_stdev(cnt_info.me.v*n, - cnt_info.mse.v*n, n); + // Compute mean error squared + cnt_info.me2.v = cnt_info.me.v * cnt_info.me.v; - // Compute bias corrected mean squared error (decomposition of MSE) - cnt_info.bcmse.v = cnt_info.mse.v - (fbar - obar)*(fbar - obar); + // Compute mean absolute error + cnt_info.mae.v = s.smae; - // Compute root mean squared error - cnt_info.rmse.v = sqrt(cnt_info.mse.v); + // Compute mean squared error + cnt_info.mse.v = s.ffbar + s.oobar - 2.0*s.fobar; - // Compute Scatter Index (SI) - if(!is_eq(cnt_info.obar.v, 0.0)) { - cnt_info.si.v = cnt_info.rmse.v / cnt_info.obar.v; + // Compute mean squared error skill score + double den = cnt_info.ostdev.v * cnt_info.ostdev.v; + if(!is_eq(den, 0.0)) { + cnt_info.msess.v = 1.0 - cnt_info.mse.v / den; + } + else { + cnt_info.msess.v = bad_data_double; + } + + // Compute standard deviation of the mean error + cnt_info.estdev.v = compute_stdev(cnt_info.me.v*n, + cnt_info.mse.v*n, n); + + // Compute bias corrected mean squared error (decomposition of MSE) + cnt_info.bcmse.v = cnt_info.mse.v - (s.fbar - s.obar)*(s.fbar - s.obar); + + // Compute root mean squared error + cnt_info.rmse.v = sqrt(cnt_info.mse.v); + + // Compute Scatter Index (SI) + if(!is_eq(cnt_info.obar.v, 0.0)) { + cnt_info.si.v = cnt_info.rmse.v / cnt_info.obar.v; + } + else { + cnt_info.si.v = bad_data_double; + } } - else { - cnt_info.si.v = bad_data_double; + + // Process scalar anomaly partial sum statistics + if(s.sacount > 0) { + cnt_info.anom_corr.v = compute_corr( s.fabar*n, s.oabar*n, + s.ffabar*n, s.ooabar*n, + s.foabar*n, n); + cnt_info.rmsfa.v = sqrt(s.ffabar); + cnt_info.rmsoa.v = sqrt(s.ooabar); + cnt_info.anom_corr_uncntr.v = compute_anom_corr_uncntr(s.ffabar, s.ooabar, + s.foabar); } - + // Compute normal confidence intervals cnt_info.compute_ci(); @@ -772,10 +757,23 @@ void compute_pctinfo(const PairDataPoint &pd, bool pstd_flag, // Use input climatological probabilities or derive them if(cmn_flag) { - if(cprob_in) climo_prob = *cprob_in; - else climo_prob = derive_climo_prob(pd.cdf_info_ptr, - pd.ocmn_na, pd.ocsd_na, - pct_info.othresh); + + // Use climatological probabilities direclty, if supplied + if(cprob_in) { + climo_prob = *cprob_in; + } + // Use observation climatology data, if available + else if(pd.ocmn_na.n() > 0) { + climo_prob = derive_climo_prob(pd.cdf_info_ptr, + pd.ocmn_na, pd.ocsd_na, + pct_info.othresh); + } + // Otherwise, try using forecast climatology data + else { + climo_prob = derive_climo_prob(pd.cdf_info_ptr, + pd.fcmn_na, pd.fcsd_na, + pct_info.othresh); + } } // diff --git a/src/libcode/vx_statistics/compute_stats.h b/src/libcode/vx_statistics/compute_stats.h index 556afcd1e8..1649cdcec2 100644 --- a/src/libcode/vx_statistics/compute_stats.h +++ b/src/libcode/vx_statistics/compute_stats.h @@ -24,8 +24,7 @@ // //////////////////////////////////////////////////////////////////////// -extern void compute_cntinfo(const SL1L2Info &, bool, CNTInfo &); - +extern void compute_cntinfo(const SL1L2Info &, CNTInfo &); extern void compute_cntinfo(const PairDataPoint &, const NumArray &, bool, bool, bool, CNTInfo &); extern void compute_i_cntinfo(const PairDataPoint &, int, diff --git a/src/libcode/vx_statistics/contable.h b/src/libcode/vx_statistics/contable.h index cae46f880a..8c7823c4d7 100644 --- a/src/libcode/vx_statistics/contable.h +++ b/src/libcode/vx_statistics/contable.h @@ -193,6 +193,13 @@ class Nx2ContingencyTable : public ContingencyTable { double threshold(int index) const; // 0 <= index <= Nrows + // + // set counts + // + + void set_event(int row, int count); + void set_nonevent(int row, int count); + // // increment counts // diff --git a/src/libcode/vx_statistics/contable_nx2.cc b/src/libcode/vx_statistics/contable_nx2.cc index 9af0358511..c69ec38545 100644 --- a/src/libcode/vx_statistics/contable_nx2.cc +++ b/src/libcode/vx_statistics/contable_nx2.cc @@ -187,7 +187,8 @@ void Nx2ContingencyTable::set_size(int NR, int NC) if ( NC != 2 ) { - mlog << Error << "\nNx2ContingencyTable::set_size(int, int) -> must have 2 columns!\n\n"; + mlog << Error << "\nNx2ContingencyTable::set_size(int, int) -> " + << "must have 2 columns!\n\n"; exit ( 1 ); @@ -209,7 +210,8 @@ int Nx2ContingencyTable::value_to_row(double t) const if ( !Thresholds ) { - mlog << Error << "\nNx2ContingencyTable::value_to_row(double) const -> thresholds array not set!\n\n"; + mlog << Error << "\nNx2ContingencyTable::value_to_row(double) const -> " + << "thresholds array not set!\n\n"; exit ( 1 ); @@ -246,7 +248,8 @@ void Nx2ContingencyTable::set_thresholds(const double * Values) if ( E->empty() ) { - mlog << Error << "\nNx2ContingencyTable::set_thresholds(const double *) -> table empty!\n\n"; + mlog << Error << "\nNx2ContingencyTable::set_thresholds(const double *) -> " + << "table empty!\n\n"; exit ( 1 ); @@ -272,7 +275,8 @@ double Nx2ContingencyTable::threshold(int k) const if ( !Thresholds ) { - mlog << Error << "\nNx2ContingencyTable::threshold(int) const -> no thresholds set!\n\n"; + mlog << Error << "\nNx2ContingencyTable::threshold(int) const -> " + << "no thresholds set!\n\n"; exit ( 1 ); @@ -280,7 +284,8 @@ if ( !Thresholds ) { if ( (k < 0) || (k > Nrows) ) { // there are Nrows + 1 thresholds - mlog << Error << "\nNx2ContingencyTable::threshold(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::threshold(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -290,6 +295,51 @@ return Thresholds[k]; } +//////////////////////////////////////////////////////////////////////// + + +void Nx2ContingencyTable::set_event(int row, int value) + +{ + +if ( row < 0 || row >= Nrows ) { + + mlog << Error << "\nNx2ContingencyTable::set_event(double) -> " + << "bad row index ... " << row << "\n\n"; + + exit ( 1 ); + +} + +set_entry(row, nx2_event_column, value); + +return; + +} + + +//////////////////////////////////////////////////////////////////////// + + +void Nx2ContingencyTable::set_nonevent(int row, int value) + +{ + +if ( row < 0 || row >= Nrows ) { + + mlog << Error << "\nNx2ContingencyTable::set_nonevent(double) -> " + << "bad row index ... " << row << "\n\n"; + + exit ( 1 ); + +} + +set_entry(row, nx2_nonevent_column, value); + +return; + +} + //////////////////////////////////////////////////////////////////////// @@ -304,7 +354,8 @@ r = value_to_row(t); if ( r < 0 ) { - mlog << Error << "\nNx2ContingencyTable::inc_event(double) -> bad value ... " << t << "\n\n"; + mlog << Error << "\nNx2ContingencyTable::inc_event(double) -> " + << "bad value ... " << t << "\n\n"; exit ( 1 ); @@ -330,7 +381,8 @@ r = value_to_row(t); if ( r < 0 ) { - mlog << Error << "\nNx2ContingencyTable::inc_nonevent(double) -> bad value ... " << t << "\n\n"; + mlog << Error << "\nNx2ContingencyTable::inc_nonevent(double) -> " + << "bad value ... " << t << "\n\n"; exit ( 1 ); @@ -356,7 +408,8 @@ r = value_to_row(t); if ( r < 0 ) { - mlog << Error << "\nNx2ContingencyTable::event_count_by_thresh(double) -> bad value ... " << t << "\n\n"; + mlog << Error << "\nNx2ContingencyTable::event_count_by_thresh(double) -> " + << "bad value ... " << t << "\n\n"; exit ( 1 ); @@ -384,7 +437,8 @@ r = value_to_row(t); if ( r < 0 ) { - mlog << Error << "\nNx2ContingencyTable::nonevent_count_by_thresh(double) -> bad value ... " << t << "\n\n"; + mlog << Error << "\nNx2ContingencyTable::nonevent_count_by_thresh(double) -> " + << "bad value ... " << t << "\n\n"; exit ( 1 ); @@ -446,7 +500,8 @@ double Nx2ContingencyTable::row_proby(int row) const if ( (row < 0) || (row >= Nrows) ) { - mlog << Error << "\nNx2ContingencyTable::row_proby(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::row_proby(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -693,7 +748,8 @@ double Nx2ContingencyTable::row_calibration(int row) const if ( (row < 0) || (row >= Nrows) ) { - mlog << Error << "\nNx2ContingencyTable::row_calibration(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::row_calibration(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -723,7 +779,8 @@ double Nx2ContingencyTable::row_refinement(int row) const if ( (row < 0) || (row >= Nrows) ) { - mlog << Error << "\nNx2ContingencyTable::row_refinement(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::row_refinement(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -755,7 +812,8 @@ double Nx2ContingencyTable::row_event_likelihood(int row) const if ( (row < 0) || (row >= Nrows) ) { - mlog << Error << "\nNx2ContingencyTable::row_event_likelihood(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::row_event_likelihood(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -784,7 +842,8 @@ double Nx2ContingencyTable::row_nonevent_likelihood(int row) const if ( (row < 0) || (row >= Nrows) ) { - mlog << Error << "\nNx2ContingencyTable::row_nonevent_likelihood(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::row_nonevent_likelihood(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -815,7 +874,8 @@ TTContingencyTable tt; if ( (row < 0) || (row >= Nrows) ) { - mlog << Error << "\nNx2ContingencyTable::ctc_by_row(int) const -> range check error\n\n"; + mlog << Error << "\nNx2ContingencyTable::ctc_by_row(int) const -> " + << "range check error\n\n"; exit ( 1 ); diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index 4c679aed83..0ab9a05188 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -425,41 +425,208 @@ void CTSInfo::compute_ci() { //////////////////////////////////////////////////////////////////////// -double CTSInfo::get_stat(const char *stat_name) { +void CTSInfo::set_stat_ctc(const string &stat_name, double v) { + + if(stat_name == "FY_OY") cts.set_fy_oy(nint(v)); + else if(stat_name == "FY_ON") cts.set_fy_on(nint(v)); + else if(stat_name == "FN_OY") cts.set_fn_oy(nint(v)); + else if(stat_name == "FN_ON") cts.set_fn_on(nint(v)); + else if(stat_name == "EC_VALUE") cts.set_ec_value(v); + + return; +} + +//////////////////////////////////////////////////////////////////////// + +double CTSInfo::get_stat(STATLineType lt, const string &stat_name, int i_alpha) const { double v = bad_data_double; - // Find the statistic by name - if(strcmp(stat_name, "TOTAL" ) == 0) v = cts.n(); - else if(strcmp(stat_name, "BASER" ) == 0) v = cts.baser(); - else if(strcmp(stat_name, "FMEAN" ) == 0) v = cts.fmean(); - else if(strcmp(stat_name, "ACC" ) == 0) v = cts.accuracy(); - else if(strcmp(stat_name, "FBIAS" ) == 0) v = cts.fbias(); - else if(strcmp(stat_name, "PODY" ) == 0) v = cts.pod_yes(); - else if(strcmp(stat_name, "PODN" ) == 0) v = cts.pod_no(); - else if(strcmp(stat_name, "POFD" ) == 0) v = cts.pofd(); - else if(strcmp(stat_name, "FAR" ) == 0) v = cts.far(); - else if(strcmp(stat_name, "CSI" ) == 0) v = cts.csi(); - else if(strcmp(stat_name, "GSS" ) == 0) v = cts.gss(); - else if(strcmp(stat_name, "HK" ) == 0) v = cts.hk(); - else if(strcmp(stat_name, "HSS" ) == 0) v = cts.hss(); - else if(strcmp(stat_name, "HSS_EC") == 0) v = cts.gheidke_ec(cts.ec_value()); - else if(strcmp(stat_name, "ODDS" ) == 0) v = cts.odds(); - else if(strcmp(stat_name, "LODDS" ) == 0) v = cts.lodds(); - else if(strcmp(stat_name, "ORSS" ) == 0) v = cts.orss(); - else if(strcmp(stat_name, "EDS" ) == 0) v = cts.eds(); - else if(strcmp(stat_name, "SEDS" ) == 0) v = cts.seds(); - else if(strcmp(stat_name, "EDI" ) == 0) v = cts.edi(); - else if(strcmp(stat_name, "SEDI" ) == 0) v = cts.sedi(); - else if(strcmp(stat_name, "BAGSS" ) == 0) v = cts.bagss(); + // Get statistic by line type + if(lt == STATLineType::fho) v = get_stat_fho(stat_name); + else if(lt == STATLineType::ctc) v = get_stat_ctc(stat_name); + else if(lt == STATLineType::cts) v = get_stat_cts(stat_name, i_alpha); else { mlog << Error << "\nCTSInfo::get_stat() -> " + << "unexpected line type \"" << statlinetype_to_string(lt) + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double CTSInfo::get_stat_fho(const string &stat_name) const { + double v = bad_data_double; + + // Find the statistic by name + if(stat_name == "TOTAL" ) v = cts.n(); + else if(stat_name == "F_RATE") v = cts.f_rate(); + else if(stat_name == "H_RATE") v = cts.h_rate(); + else if(stat_name == "O_RATE") v = cts.o_rate(); + else { + mlog << Error << "\nCTSInfo::get_stat_fho() -> " + << "unknown categorical statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + // Return bad data for 0 pairs + if(cts.n() == 0 && stat_name != "TOTAL") { + v = bad_data_double; + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double CTSInfo::get_stat_ctc(const string &stat_name) const { + double v = bad_data_double; + + // Find the statistic by name + if(stat_name == "TOTAL" ) v = cts.n(); + else if(stat_name == "FY_OY" ) v = cts.fy_oy(); + else if(stat_name == "FY_ON" ) v = cts.fy_on(); + else if(stat_name == "FN_OY" ) v = cts.fn_oy(); + else if(stat_name == "FN_ON" ) v = cts.fn_on(); + else if(stat_name == "EC_VALUE") v = cts.ec_value(); + else { + mlog << Error << "\nCTSInfo::get_stat_ctc() -> " + << "unknown categorical statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + // Return bad data for 0 pairs + if(cts.n() == 0 && stat_name != "TOTAL") { + v = bad_data_double; + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double CTSInfo::get_stat_cts(const string &stat_name, int i_alpha) const { + double v = bad_data_double; + + // Range check alpha index + if(i_alpha >= n_alpha && is_ci_stat_name(stat_name)) { + mlog << Error << "\nCTSInfo::get_stat_cts() -> " + << "alpha index out of range (" << i_alpha << " >= " + << n_alpha << ")!\n\n"; + exit(1); + } + + // Find the statistic by name + if(stat_name == "TOTAL" ) v = (double) cts.n(); + else if(stat_name == "BASER" ) v = baser.v; + else if(stat_name == "BASER_NCL" ) v = baser.v_ncl[i_alpha]; + else if(stat_name == "BASER_NCU" ) v = baser.v_ncu[i_alpha]; + else if(stat_name == "BASER_BCL" ) v = baser.v_bcl[i_alpha]; + else if(stat_name == "BASER_BCU" ) v = baser.v_bcu[i_alpha]; + else if(stat_name == "FMEAN" ) v = fmean.v; + else if(stat_name == "FMEAN_NCL" ) v = fmean.v_ncl[i_alpha]; + else if(stat_name == "FMEAN_NCU" ) v = fmean.v_ncu[i_alpha]; + else if(stat_name == "FMEAN_BCL" ) v = fmean.v_bcl[i_alpha]; + else if(stat_name == "FMEAN_BCU" ) v = fmean.v_bcu[i_alpha]; + else if(stat_name == "ACC" ) v = acc.v; + else if(stat_name == "ACC_NCL" ) v = acc.v_ncl[i_alpha]; + else if(stat_name == "ACC_NCU" ) v = acc.v_ncu[i_alpha]; + else if(stat_name == "ACC_BCL" ) v = acc.v_bcl[i_alpha]; + else if(stat_name == "ACC_BCU" ) v = acc.v_bcu[i_alpha]; + else if(stat_name == "FBIAS" ) v = fbias.v; + else if(stat_name == "FBIAS_BCL" ) v = fbias.v_bcl[i_alpha]; + else if(stat_name == "FBIAS_BCU" ) v = fbias.v_bcu[i_alpha]; + else if(stat_name == "PODY" ) v = pody.v; + else if(stat_name == "PODY_NCL" ) v = pody.v_ncl[i_alpha]; + else if(stat_name == "PODY_NCU" ) v = pody.v_ncu[i_alpha]; + else if(stat_name == "PODY_BCL" ) v = pody.v_bcl[i_alpha]; + else if(stat_name == "PODY_BCU" ) v = pody.v_bcu[i_alpha]; + else if(stat_name == "PODN" ) v = podn.v; + else if(stat_name == "PODN_NCL" ) v = podn.v_ncl[i_alpha]; + else if(stat_name == "PODN_NCU" ) v = podn.v_ncu[i_alpha]; + else if(stat_name == "PODN_BCL" ) v = podn.v_bcl[i_alpha]; + else if(stat_name == "PODN_BCU" ) v = podn.v_bcu[i_alpha]; + else if(stat_name == "POFD" ) v = pofd.v; + else if(stat_name == "POFD_NCL" ) v = pofd.v_ncl[i_alpha]; + else if(stat_name == "POFD_NCU" ) v = pofd.v_ncu[i_alpha]; + else if(stat_name == "POFD_BCL" ) v = pofd.v_bcl[i_alpha]; + else if(stat_name == "POFD_BCU" ) v = pofd.v_bcu[i_alpha]; + else if(stat_name == "FAR" ) v = far.v; + else if(stat_name == "FAR_NCL" ) v = far.v_ncl[i_alpha]; + else if(stat_name == "FAR_NCU" ) v = far.v_ncu[i_alpha]; + else if(stat_name == "FAR_BCL" ) v = far.v_bcl[i_alpha]; + else if(stat_name == "FAR_BCU" ) v = far.v_bcu[i_alpha]; + else if(stat_name == "CSI" ) v = csi.v; + else if(stat_name == "CSI_NCL" ) v = csi.v_ncl[i_alpha]; + else if(stat_name == "CSI_NCU" ) v = csi.v_ncu[i_alpha]; + else if(stat_name == "CSI_BCL" ) v = csi.v_bcl[i_alpha]; + else if(stat_name == "CSI_BCU" ) v = csi.v_bcu[i_alpha]; + else if(stat_name == "GSS" ) v = gss.v; + else if(stat_name == "GSS_BCL" ) v = gss.v_bcl[i_alpha]; + else if(stat_name == "GSS_BCU" ) v = gss.v_bcu[i_alpha]; + else if(stat_name == "HK" ) v = hk.v; + else if(stat_name == "HK_NCL" ) v = hk.v_ncl[i_alpha]; + else if(stat_name == "HK_NCU" ) v = hk.v_ncu[i_alpha]; + else if(stat_name == "HK_BCL" ) v = hk.v_bcl[i_alpha]; + else if(stat_name == "HK_BCU" ) v = hk.v_bcu[i_alpha]; + else if(stat_name == "HSS" ) v = hss.v; + else if(stat_name == "HSS_BCL" ) v = hss.v_bcl[i_alpha]; + else if(stat_name == "HSS_BCU" ) v = hss.v_bcu[i_alpha]; + else if(stat_name == "ODDS" ) v = odds.v; + else if(stat_name == "ODDS_NCL" ) v = odds.v_ncl[i_alpha]; + else if(stat_name == "ODDS_NCU" ) v = odds.v_ncu[i_alpha]; + else if(stat_name == "ODDS_BCL" ) v = odds.v_bcl[i_alpha]; + else if(stat_name == "ODDS_BCU" ) v = odds.v_bcu[i_alpha]; + else if(stat_name == "LODDS" ) v = lodds.v; + else if(stat_name == "LODDS_NCL" ) v = lodds.v_ncl[i_alpha]; + else if(stat_name == "LODDS_NCU" ) v = lodds.v_ncu[i_alpha]; + else if(stat_name == "LODDS_BCL" ) v = lodds.v_bcl[i_alpha]; + else if(stat_name == "LODDS_BCU" ) v = lodds.v_bcu[i_alpha]; + else if(stat_name == "ORSS" ) v = orss.v; + else if(stat_name == "ORSS_NCL" ) v = orss.v_ncl[i_alpha]; + else if(stat_name == "ORSS_NCU" ) v = orss.v_ncu[i_alpha]; + else if(stat_name == "ORSS_BCL" ) v = orss.v_bcl[i_alpha]; + else if(stat_name == "ORSS_BCU" ) v = orss.v_bcu[i_alpha]; + else if(stat_name == "EDS" ) v = eds.v; + else if(stat_name == "EDS_NCL" ) v = eds.v_ncl[i_alpha]; + else if(stat_name == "EDS_NCU" ) v = eds.v_ncu[i_alpha]; + else if(stat_name == "EDS_BCL" ) v = eds.v_bcl[i_alpha]; + else if(stat_name == "EDS_BCU" ) v = eds.v_bcu[i_alpha]; + else if(stat_name == "SEDS" ) v = seds.v; + else if(stat_name == "SEDS_NCL" ) v = seds.v_ncl[i_alpha]; + else if(stat_name == "SEDS_NCU" ) v = seds.v_ncu[i_alpha]; + else if(stat_name == "SEDS_BCL" ) v = seds.v_bcl[i_alpha]; + else if(stat_name == "SEDS_BCU" ) v = seds.v_bcu[i_alpha]; + else if(stat_name == "EDI" ) v = edi.v; + else if(stat_name == "EDI_NCL" ) v = edi.v_ncl[i_alpha]; + else if(stat_name == "EDI_NCU" ) v = edi.v_ncu[i_alpha]; + else if(stat_name == "EDI_BCL" ) v = edi.v_bcl[i_alpha]; + else if(stat_name == "EDI_BCU" ) v = edi.v_bcu[i_alpha]; + else if(stat_name == "SEDI" ) v = sedi.v; + else if(stat_name == "SEDI_NCL" ) v = sedi.v_ncl[i_alpha]; + else if(stat_name == "SEDI_NCU" ) v = sedi.v_ncu[i_alpha]; + else if(stat_name == "SEDI_BCL" ) v = sedi.v_bcl[i_alpha]; + else if(stat_name == "SEDI_BCU" ) v = sedi.v_bcu[i_alpha]; + else if(stat_name == "BAGSS" ) v = bagss.v; + else if(stat_name == "BAGSS_BCL" ) v = bagss.v_bcl[i_alpha]; + else if(stat_name == "BAGSS_BCU" ) v = bagss.v_bcu[i_alpha]; + else if(stat_name == "HSS_EC" ) v = hss_ec.v; + else if(stat_name == "HSS_EC_BCL") v = hss_ec.v_bcl[i_alpha]; + else if(stat_name == "HSS_EC_BCU") v = hss_ec.v_bcu[i_alpha]; + else if(stat_name == "EC_VALUE" ) v = cts.ec_value(); + else { + mlog << Error << "\nCTSInfo::get_stat_cts() -> " << "unknown categorical statistic name \"" << stat_name << "\"!\n\n"; exit(1); } // Return bad data for 0 pairs - if(cts.n() == 0 && strcmp(stat_name, "TOTAL") != 0) { + if(cts.n() == 0 && stat_name != "TOTAL") { v = bad_data_double; } @@ -653,6 +820,122 @@ void MCTSInfo::compute_ci() { return; } +//////////////////////////////////////////////////////////////////////// + +double MCTSInfo::get_stat(STATLineType lt, + const string &stat_name, + ConcatString &col_name, + int i_alpha) const { + double v = bad_data_double; + + // Initialize + col_name = stat_name; + + // Get statistic by line type + if(lt == STATLineType::mctc) v = get_stat_mctc(stat_name, col_name); + else if(lt == STATLineType::mcts) v = get_stat_mcts(stat_name, i_alpha); + else { + mlog << Error << "\nMCTSInfo::get_stat() -> " + << "unexpected line type \"" << statlinetype_to_string(lt) + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double MCTSInfo::get_stat_mctc(const string &stat_name, + ConcatString &col_name) const { + double v = bad_data_double; + col_name = stat_name; + + // Find the statistic by name + if(stat_name == "TOTAL" ) v = (double) cts.total(); + else if(stat_name == "N_CAT" ) v = (double) cts.nrows(); + else if(stat_name == "EC_VALUE") v = cts.ec_value(); + else if(check_reg_exp("F[0-9]*_O[0-9]*", stat_name.c_str())) { + + col_name = "FI_OJ"; + + // Parse column name to retrieve index values + ConcatString cs(stat_name); + StringArray sa = cs.split("_"); + int i = atoi(sa[0].c_str()+1) - 1; + int j = atoi(sa[1].c_str()+1) - 1; + + // Range check + if(i < 0 || i >= cts.nrows() || + j < 0 || j >= cts.ncols()) { + mlog << Error << "\nget_stat_mctc() -> " + << "range check error for column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + + // Retrieve the value + v = (double) cts.entry(i, j); + } + else { + mlog << Error << "\nMCTSInfo::get_stat_mctc() -> " + << "unknown multi-category statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double MCTSInfo::get_stat_mcts(const string &stat_name, int i_alpha) const { + double v = bad_data_double; + + // Range check alpha index + if(i_alpha >= n_alpha && is_ci_stat_name(stat_name)) { + mlog << Error << "\nMCTSInfo::get_stat_mcts() -> " + << "alpha index out of range (" << i_alpha << " >= " + << n_alpha << ")!\n\n"; + exit(1); + } + + // Find the statistic by name + if(stat_name == "TOTAL" ) v = (double) cts.total(); + else if(stat_name == "N_CAT" ) v = (double) cts.nrows(); + else if(stat_name == "ACC" ) v = acc.v; + else if(stat_name == "ACC_NCL" ) v = acc.v_ncl[i_alpha]; + else if(stat_name == "ACC_NCU" ) v = acc.v_ncu[i_alpha]; + else if(stat_name == "ACC_BCL" ) v = acc.v_bcl[i_alpha]; + else if(stat_name == "ACC_BCU" ) v = acc.v_bcu[i_alpha]; + else if(stat_name == "HK" ) v = hk.v; + else if(stat_name == "HK_BCL" ) v = hk.v_bcl[i_alpha]; + else if(stat_name == "HK_BCU" ) v = hk.v_bcu[i_alpha]; + else if(stat_name == "HSS" ) v = hss.v; + else if(stat_name == "HSS_BCL" ) v = hss.v_bcl[i_alpha]; + else if(stat_name == "HSS_BCU" ) v = hss.v_bcu[i_alpha]; + else if(stat_name == "GER" ) v = ger.v; + else if(stat_name == "GER_BCL" ) v = ger.v_bcl[i_alpha]; + else if(stat_name == "GER_BCU" ) v = ger.v_bcu[i_alpha]; + else if(stat_name == "HSS_EC" ) v = hss_ec.v; + else if(stat_name == "HSS_EC_BCL") v = hss_ec.v_bcl[i_alpha]; + else if(stat_name == "HSS_EC_BCU") v = hss_ec.v_bcu[i_alpha]; + else if(stat_name == "EC_VALUE" ) v = cts.ec_value(); + else { + mlog << Error << "\nMCTSInfo::get_stat_mcts() -> " + << "unknown multi-category statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + // Return bad data for 0 pairs + if(cts.total() == 0 && stat_name != "TOTAL") { + v = bad_data_double; + } + + return v; +} + //////////////////////////////////////////////////////////////////////// // // Code for class CNTInfo @@ -702,6 +985,44 @@ void CNTInfo::init_from_scratch() { //////////////////////////////////////////////////////////////////////// +void CNTInfo::zero_out() { + + fbar.set_bad_data(); + fstdev.set_bad_data(); + obar.set_bad_data(); + ostdev.set_bad_data(); + pr_corr.set_bad_data(); + sp_corr.set_bad_data(); + kt_corr.set_bad_data(); + anom_corr.set_bad_data(); + rmsfa.set_bad_data(); + rmsoa.set_bad_data(); + anom_corr_uncntr.set_bad_data(); + me.set_bad_data(); + me2.set_bad_data(); + estdev.set_bad_data(); + mbias.set_bad_data(); + mae.set_bad_data(); + mse.set_bad_data(); + msess.set_bad_data(); + bcmse.set_bad_data(); + rmse.set_bad_data(); + si.set_bad_data(); + e10.set_bad_data(); + e25.set_bad_data(); + e50.set_bad_data(); + e75.set_bad_data(); + e90.set_bad_data(); + eiqr.set_bad_data(); + mad.set_bad_data(); + + n_ranks = frank_ties = orank_ties = 0; + + return; +} + +//////////////////////////////////////////////////////////////////////// + void CNTInfo::clear() { n = 0; @@ -1023,42 +1344,121 @@ void CNTInfo::compute_ci() { //////////////////////////////////////////////////////////////////////// -double CNTInfo::get_stat(const char *stat_name) { +double CNTInfo::get_stat(const string &stat_name, int i_alpha) const { double v = bad_data_double; + // Range check alpha index + if(i_alpha >= n_alpha && is_ci_stat_name(stat_name)) { + mlog << Error << "\nCNTInfo::get_stat() -> " + << "alpha index out of range (" << i_alpha << " >= " + << n_alpha << ")!\n\n"; + exit(1); + } + // Find the statistic by name - if(strcmp(stat_name, "TOTAL" ) == 0) v = n; - else if(strcmp(stat_name, "FBAR" ) == 0) v = fbar.v; - else if(strcmp(stat_name, "FSTDEV" ) == 0) v = fstdev.v; - else if(strcmp(stat_name, "OBAR" ) == 0) v = obar.v; - else if(strcmp(stat_name, "OSTDEV" ) == 0) v = ostdev.v; - else if(strcmp(stat_name, "PR_CORR" ) == 0) v = pr_corr.v; - else if(strcmp(stat_name, "SP_CORR" ) == 0) v = sp_corr.v; - else if(strcmp(stat_name, "KT_CORR" ) == 0) v = kt_corr.v; - else if(strcmp(stat_name, "RANKS" ) == 0) v = n_ranks; - else if(strcmp(stat_name, "FRANK_TIES" ) == 0) v = frank_ties; - else if(strcmp(stat_name, "ORANK_TIES" ) == 0) v = orank_ties; - else if(strcmp(stat_name, "ME" ) == 0) v = me.v; - else if(strcmp(stat_name, "ESTDEV" ) == 0) v = estdev.v; - else if(strcmp(stat_name, "MBIAS" ) == 0) v = mbias.v; - else if(strcmp(stat_name, "MAE" ) == 0) v = mae.v; - else if(strcmp(stat_name, "MSE" ) == 0) v = mse.v; - else if(strcmp(stat_name, "BCMSE" ) == 0) v = bcmse.v; - else if(strcmp(stat_name, "RMSE" ) == 0) v = rmse.v; - else if(strcmp(stat_name, "SI" ) == 0) v = si.v; - else if(strcmp(stat_name, "E10" ) == 0) v = e10.v; - else if(strcmp(stat_name, "E25" ) == 0) v = e25.v; - else if(strcmp(stat_name, "E50" ) == 0) v = e50.v; - else if(strcmp(stat_name, "E75" ) == 0) v = e75.v; - else if(strcmp(stat_name, "E90" ) == 0) v = e90.v; - else if(strcmp(stat_name, "EIQR" ) == 0) v = eiqr.v; - else if(strcmp(stat_name, "MAD " ) == 0) v = mad.v; - else if(strcmp(stat_name, "ANOM_CORR" ) == 0) v = anom_corr.v; - else if(strcmp(stat_name, "ME2" ) == 0) v = me2.v; - else if(strcmp(stat_name, "MSESS" ) == 0) v = msess.v; - else if(strcmp(stat_name, "RMSFA" ) == 0) v = rmsfa.v; - else if(strcmp(stat_name, "RMSOA" ) == 0) v = rmsoa.v; - else if(strcmp(stat_name, "ANOM_CORR_UNCNTR") == 0) v = anom_corr_uncntr.v; + if(stat_name == "TOTAL" ) v = (double) n; + else if(stat_name == "FBAR" ) v = fbar.v; + else if(stat_name == "FBAR_NCL" ) v = fbar.v_ncl[i_alpha]; + else if(stat_name == "FBAR_NCU" ) v = fbar.v_ncu[i_alpha]; + else if(stat_name == "FBAR_BCL" ) v = fbar.v_bcl[i_alpha]; + else if(stat_name == "FBAR_BCU" ) v = fbar.v_bcu[i_alpha]; + else if(stat_name == "FSTDEV" ) v = fstdev.v; + else if(stat_name == "FSTDEV_NCL" ) v = fstdev.v_ncl[i_alpha]; + else if(stat_name == "FSTDEV_NCU" ) v = fstdev.v_ncu[i_alpha]; + else if(stat_name == "FSTDEV_BCL" ) v = fstdev.v_bcl[i_alpha]; + else if(stat_name == "FSTDEV_BCU" ) v = fstdev.v_bcu[i_alpha]; + else if(stat_name == "OBAR" ) v = obar.v; + else if(stat_name == "OBAR_NCL" ) v = obar.v_ncl[i_alpha]; + else if(stat_name == "OBAR_NCU" ) v = obar.v_ncu[i_alpha]; + else if(stat_name == "OBAR_BCL" ) v = obar.v_bcl[i_alpha]; + else if(stat_name == "OBAR_BCU" ) v = obar.v_bcu[i_alpha]; + else if(stat_name == "OSTDEV" ) v = ostdev.v; + else if(stat_name == "OSTDEV_NCL" ) v = ostdev.v_ncl[i_alpha]; + else if(stat_name == "OSTDEV_NCU" ) v = ostdev.v_ncu[i_alpha]; + else if(stat_name == "OSTDEV_BCL" ) v = ostdev.v_bcl[i_alpha]; + else if(stat_name == "OSTDEV_BCU" ) v = ostdev.v_bcu[i_alpha]; + else if(stat_name == "PR_CORR" ) v = pr_corr.v; + else if(stat_name == "PR_CORR_NCL" ) v = pr_corr.v_ncl[i_alpha]; + else if(stat_name == "PR_CORR_NCU" ) v = pr_corr.v_ncu[i_alpha]; + else if(stat_name == "PR_CORR_BCL" ) v = pr_corr.v_bcl[i_alpha]; + else if(stat_name == "PR_CORR_BCU" ) v = pr_corr.v_bcu[i_alpha]; + else if(stat_name == "SP_CORR" ) v = sp_corr.v; + else if(stat_name == "KT_CORR" ) v = kt_corr.v; + else if(stat_name == "RANKS" ) v = n_ranks; + else if(stat_name == "FRANK_TIES" ) v = frank_ties; + else if(stat_name == "ORANK_TIES" ) v = orank_ties; + else if(stat_name == "ME" ) v = me.v; + else if(stat_name == "ME_NCL" ) v = me.v_ncl[i_alpha]; + else if(stat_name == "ME_NCU" ) v = me.v_ncu[i_alpha]; + else if(stat_name == "ME_BCL" ) v = me.v_bcl[i_alpha]; + else if(stat_name == "ME_BCU" ) v = me.v_bcu[i_alpha]; + else if(stat_name == "ESTDEV" ) v = estdev.v; + else if(stat_name == "ESTDEV_NCL" ) v = estdev.v_ncl[i_alpha]; + else if(stat_name == "ESTDEV_NCU" ) v = estdev.v_ncu[i_alpha]; + else if(stat_name == "ESTDEV_BCL" ) v = estdev.v_bcl[i_alpha]; + else if(stat_name == "ESTDEV_BCU" ) v = estdev.v_bcu[i_alpha]; + else if(stat_name == "MBIAS" ) v = mbias.v; + else if(stat_name == "MBIAS_BCL" ) v = mbias.v_bcl[i_alpha]; + else if(stat_name == "MBIAS_BCU" ) v = mbias.v_bcu[i_alpha]; + else if(stat_name == "MAE" ) v = mae.v; + else if(stat_name == "MAE_BCL" ) v = mae.v_bcl[i_alpha]; + else if(stat_name == "MAE_BCU" ) v = mae.v_bcu[i_alpha]; + else if(stat_name == "MSE" ) v = mse.v; + else if(stat_name == "MSE_BCL" ) v = mse.v_bcl[i_alpha]; + else if(stat_name == "MSE_BCU" ) v = mse.v_bcu[i_alpha]; + else if(stat_name == "BCMSE" ) v = bcmse.v; + else if(stat_name == "BCMSE_BCL" ) v = bcmse.v_bcl[i_alpha]; + else if(stat_name == "BCMSE_BCU" ) v = bcmse.v_bcu[i_alpha]; + else if(stat_name == "RMSE" ) v = rmse.v; + else if(stat_name == "RMSE_BCL" ) v = rmse.v_bcl[i_alpha]; + else if(stat_name == "RMSE_BCU" ) v = rmse.v_bcu[i_alpha]; + else if(stat_name == "SI" ) v = si.v; + else if(stat_name == "SI_BCL" ) v = si.v_bcl[i_alpha]; + else if(stat_name == "SI_BCU" ) v = si.v_bcu[i_alpha]; + else if(stat_name == "E10" ) v = e10.v; + else if(stat_name == "E10_BCL" ) v = e10.v_bcl[i_alpha]; + else if(stat_name == "E10_BCU" ) v = e10.v_bcu[i_alpha]; + else if(stat_name == "E25" ) v = e25.v; + else if(stat_name == "E25_BCL" ) v = e25.v_bcl[i_alpha]; + else if(stat_name == "E25_BCU" ) v = e25.v_bcu[i_alpha]; + else if(stat_name == "E50" ) v = e50.v; + else if(stat_name == "E50_BCL" ) v = e50.v_bcl[i_alpha]; + else if(stat_name == "E50_BCU" ) v = e50.v_bcu[i_alpha]; + else if(stat_name == "E75" ) v = e75.v; + else if(stat_name == "E75_BCL" ) v = e75.v_bcl[i_alpha]; + else if(stat_name == "E75_BCU" ) v = e75.v_bcu[i_alpha]; + else if(stat_name == "E90" ) v = e90.v; + else if(stat_name == "E90_BCL" ) v = e90.v_bcl[i_alpha]; + else if(stat_name == "E90_BCU" ) v = e90.v_bcu[i_alpha]; + else if(stat_name == "EIQR" ) v = eiqr.v; + else if(stat_name == "EIQR_BCL" ) v = eiqr.v_bcl[i_alpha]; + else if(stat_name == "EIQR_BCU" ) v = eiqr.v_bcu[i_alpha]; + else if(stat_name == "MAD" ) v = mad.v; + else if(stat_name == "MAD_BCL" ) v = mad.v_bcl[i_alpha]; + else if(stat_name == "MAD_BCU" ) v = mad.v_bcu[i_alpha]; + else if(stat_name == "ANOM_CORR" ) v = anom_corr.v; + else if(stat_name == "ANOM_CORR_NCL" ) v = anom_corr.v_ncl[i_alpha]; + else if(stat_name == "ANOM_CORR_NCU" ) v = anom_corr.v_ncu[i_alpha]; + else if(stat_name == "ANOM_CORR_BCL" ) v = anom_corr.v_bcl[i_alpha]; + else if(stat_name == "ANOM_CORR_BCU" ) v = anom_corr.v_bcu[i_alpha]; + else if(stat_name == "ME2" ) v = me2.v; + else if(stat_name == "ME2_BCL" ) v = me2.v_bcl[i_alpha]; + else if(stat_name == "ME2_BCU" ) v = me2.v_bcu[i_alpha]; + else if(stat_name == "MSESS" ) v = msess.v; + else if(stat_name == "MSESS_BCL" ) v = msess.v_bcl[i_alpha]; + else if(stat_name == "MSESS_BCU" ) v = msess.v_bcu[i_alpha]; + else if(stat_name == "RMSFA" ) v = rmsfa.v; + else if(stat_name == "RMSFA_BCL" ) v = rmsfa.v_bcl[i_alpha]; + else if(stat_name == "RMSFA_BCU" ) v = rmsfa.v_bcu[i_alpha]; + else if(stat_name == "RMSOA" ) v = rmsoa.v; + else if(stat_name == "RMSOA_BCL" ) v = rmsoa.v_bcl[i_alpha]; + else if(stat_name == "RMSOA_BCU" ) v = rmsoa.v_bcu[i_alpha]; + else if(stat_name == "ANOM_CORR_UNCNTR" ) v = anom_corr_uncntr.v; + else if(stat_name == "ANOM_CORR_UNCNTR_BCL") v = anom_corr_uncntr.v_bcl[i_alpha]; + else if(stat_name == "ANOM_CORR_UNCNTR_BCU") v = anom_corr_uncntr.v_bcu[i_alpha]; + else if(stat_name == "SI" ) v = si.v; + else if(stat_name == "SI_BCL" ) v = si.v_bcl[i_alpha]; + else if(stat_name == "SI_BCU" ) v = si.v_bcu[i_alpha]; else { mlog << Error << "\nCNTInfo::get_stat() -> " << "unknown continuous statistic name \"" << stat_name @@ -1067,7 +1467,7 @@ double CNTInfo::get_stat(const char *stat_name) { } // Return bad data for 0 pairs - if(n == 0 && strcmp(stat_name, "TOTAL") != 0) { + if(n == 0 && stat_name != "TOTAL") { v = bad_data_double; } @@ -1113,7 +1513,8 @@ SL1L2Info & SL1L2Info::operator=(const SL1L2Info &c) { //////////////////////////////////////////////////////////////////////// SL1L2Info & SL1L2Info::operator+=(const SL1L2Info &c) { - SL1L2Info s_info; + SL1L2Info s_info = *this; + s_info.zero_out(); s_info.scount = scount + c.scount; @@ -1305,6 +1706,110 @@ void SL1L2Info::set(const PairDataPoint &pd_all) { return; } +//////////////////////////////////////////////////////////////////////// + +void SL1L2Info::set_stat_sl1l2(const string &stat_name, double v) { + + if(stat_name == "TOTAL") scount = nint(v); + else if(stat_name == "FBAR" ) fbar = v; + else if(stat_name == "OBAR" ) obar = v; + else if(stat_name == "FOBAR") fobar = v; + else if(stat_name == "FFBAR") ffbar = v; + else if(stat_name == "OOBAR") oobar = v; + else if(stat_name == "MAE" ) smae = v; + else { + mlog << Error << "\nSL1L2Info::set_stat_sl1l2() -> " + << "unknown scalar partial sum statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +void SL1L2Info::set_stat_sal1l2(const string &stat_name, double v) { + + if(stat_name == "TOTAL" ) sacount = nint(v); + else if(stat_name == "FABAR" ) fabar = v; + else if(stat_name == "OABAR" ) oabar = v; + else if(stat_name == "FOABAR") foabar = v; + else if(stat_name == "FFABAR") ffabar = v; + else if(stat_name == "OOABAR") ooabar = v; + else if(stat_name == "MAE" ) samae = v; + else { + mlog << Error << "\nSL1L2Info::set_stat_sal1l2() -> " + << "unknown scalar anomaly partial sum statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return; +} + +//////////////////////////////////////////////////////////////////////// + +double SL1L2Info::get_stat(STATLineType lt, const string &stat_name) const { + double v = bad_data_double; + + // Get statistic by line type + if(lt == STATLineType::sl1l2) v = get_stat_sl1l2(stat_name); + else if(lt == STATLineType::sal1l2) v = get_stat_sal1l2(stat_name); + else { + mlog << Error << "\nSL1L2Info::get_stat() -> " + << "unexpected line type \"" << statlinetype_to_string(lt) + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double SL1L2Info::get_stat_sl1l2(const string &stat_name) const { + double v = bad_data_double; + + if(stat_name == "TOTAL") v = (double) scount; + else if(stat_name == "FBAR" ) v = fbar; + else if(stat_name == "OBAR" ) v = obar; + else if(stat_name == "FOBAR") v = fobar; + else if(stat_name == "FFBAR") v = ffbar; + else if(stat_name == "OOBAR") v = oobar; + else if(stat_name == "MAE" ) v = smae; + else { + mlog << Error << "\nSL1L2Info::get_stat_sl1l2() -> " + << "unknown scalar partial sum statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double SL1L2Info::get_stat_sal1l2(const string &stat_name) const { + double v = bad_data_double; + + if(stat_name == "TOTAL" ) v = (double) sacount; + else if(stat_name == "FABAR" ) v = fabar; + else if(stat_name == "OABAR" ) v = oabar; + else if(stat_name == "FOABAR") v = foabar; + else if(stat_name == "FFABAR") v = ffabar; + else if(stat_name == "OOABAR") v = ooabar; + else if(stat_name == "MAE" ) v = samae; + else { + mlog << Error << "\nSL1L2Info::get_stat_sal1l2() -> " + << "unknown scalar anomaly partial sum statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return v; +} + //////////////////////////////////////////////////////////////////////// // // Code for class VL1L2Info @@ -1344,11 +1849,8 @@ VL1L2Info & VL1L2Info::operator=(const VL1L2Info &c) { //////////////////////////////////////////////////////////////////////// VL1L2Info & VL1L2Info::operator+=(const VL1L2Info &c) { - VL1L2Info v_info; - - // Store alpha values - v_info.allocate_n_alpha(n_alpha); - for(int i=0; i " + << "unknown vector partial sums statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return v; +} //////////////////////////////////////////////////////////////////////// -double VL1L2Info::get_stat(const char *stat_name) { +double VL1L2Info::get_stat_val1l2(const string &stat_name) const { double v = bad_data_double; - if(strcmp(stat_name, "TOTAL" ) == 0) v = vcount; - else if(strcmp(stat_name, "FBAR" ) == 0) v = FBAR.v; - else if(strcmp(stat_name, "OBAR" ) == 0) v = OBAR.v; - else if(strcmp(stat_name, "FS_RMS" ) == 0) v = FS_RMS.v; - else if(strcmp(stat_name, "OS_RMS" ) == 0) v = OS_RMS.v; - else if(strcmp(stat_name, "MSVE" ) == 0) v = MSVE.v; - else if(strcmp(stat_name, "RMSVE" ) == 0) v = RMSVE.v; - else if(strcmp(stat_name, "FSTDEV" ) == 0) v = FSTDEV.v; - else if(strcmp(stat_name, "OSTDEV" ) == 0) v = OSTDEV.v; - else if(strcmp(stat_name, "FDIR" ) == 0) v = FDIR.v; - else if(strcmp(stat_name, "ODIR" ) == 0) v = ODIR.v; - else if(strcmp(stat_name, "FBAR_SPEED" ) == 0) v = FBAR_SPEED.v; - else if(strcmp(stat_name, "OBAR_SPEED" ) == 0) v = OBAR_SPEED.v; - else if(strcmp(stat_name, "VDIFF_SPEED" ) == 0) v = VDIFF_SPEED.v; - else if(strcmp(stat_name, "VDIFF_DIR" ) == 0) v = VDIFF_DIR.v; - else if(strcmp(stat_name, "SPEED_ERR" ) == 0) v = SPEED_ERR.v; - else if(strcmp(stat_name, "SPEED_ABSERR" ) == 0) v = SPEED_ABSERR.v; - else if(strcmp(stat_name, "DIR_ERR" ) == 0) v = DIR_ERR.v; - else if(strcmp(stat_name, "DIR_ABSERR" ) == 0) v = DIR_ABSERR.v; - else if(strcmp(stat_name, "ANOM_CORR" ) == 0) v = ANOM_CORR.v; - else if(strcmp(stat_name, "ANOM_CORR_UNCNTR") == 0) v = ANOM_CORR_UNCNTR.v; - else if(strcmp(stat_name, "DIR_ME" ) == 0) v = DIR_ME.v; - else if(strcmp(stat_name, "DIR_MAE" ) == 0) v = DIR_MAE.v; - else if(strcmp(stat_name, "DIR_MSE" ) == 0) v = DIR_MSE.v; - else if(strcmp(stat_name, "DIR_RMSE" ) == 0) v = DIR_RMSE.v; + // Find the statistic by name + if(stat_name == "TOTAL" ) v = vacount; + else if(stat_name == "UFABAR" ) v = ufa_bar; + else if(stat_name == "VFABAR" ) v = vfa_bar; + else if(stat_name == "UOABAR" ) v = uoa_bar; + else if(stat_name == "VOABAR" ) v = voa_bar; + else if(stat_name == "UVFOABAR" ) v = uvfoa_bar; + else if(stat_name == "UVFFABAR" ) v = uvffa_bar; + else if(stat_name == "UVOOABAR" ) v = uvooa_bar; + else if(stat_name == "FA_SPEED_BAR") v = fa_speed_bar; + else if(stat_name == "OA_SPEED_BAR") v = oa_speed_bar; + else if(stat_name == "TOTAL_DIR" ) v = dacount; + else if(stat_name == "DIRA_ME" ) v = dira_bar; + else if(stat_name == "DIRA_MAE" ) v = absdira_bar; + else if(stat_name == "DIRA_MSE" ) v = dira2_bar; else { mlog << Error << "\nVL1L2Info::get_stat() -> " - << "unknown continuous statistic name \"" << stat_name + << "unknown vector anomaly partial sums statistic name \"" << stat_name + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double VL1L2Info::get_stat_vcnt(const string &stat_name) const { + double v = bad_data_double; + + if(stat_name == "TOTAL" ) v = vcount; + else if(stat_name == "FBAR" ) v = FBAR.v; + else if(stat_name == "OBAR" ) v = OBAR.v; + else if(stat_name == "FS_RMS" ) v = FS_RMS.v; + else if(stat_name == "OS_RMS" ) v = OS_RMS.v; + else if(stat_name == "MSVE" ) v = MSVE.v; + else if(stat_name == "RMSVE" ) v = RMSVE.v; + else if(stat_name == "FSTDEV" ) v = FSTDEV.v; + else if(stat_name == "OSTDEV" ) v = OSTDEV.v; + else if(stat_name == "FDIR" ) v = FDIR.v; + else if(stat_name == "ODIR" ) v = ODIR.v; + else if(stat_name == "FBAR_SPEED" ) v = FBAR_SPEED.v; + else if(stat_name == "OBAR_SPEED" ) v = OBAR_SPEED.v; + else if(stat_name == "VDIFF_SPEED" ) v = VDIFF_SPEED.v; + else if(stat_name == "VDIFF_DIR" ) v = VDIFF_DIR.v; + else if(stat_name == "SPEED_ERR" ) v = SPEED_ERR.v; + else if(stat_name == "SPEED_ABSERR" ) v = SPEED_ABSERR.v; + else if(stat_name == "DIR_ERR" ) v = DIR_ERR.v; + else if(stat_name == "DIR_ABSERR" ) v = DIR_ABSERR.v; + else if(stat_name == "ANOM_CORR" ) v = ANOM_CORR.v; + else if(stat_name == "ANOM_CORR_UNCNTR") v = ANOM_CORR_UNCNTR.v; + else if(stat_name == "DIR_ME" ) v = DIR_ME.v; + else if(stat_name == "DIR_MAE" ) v = DIR_MAE.v; + else if(stat_name == "DIR_MSE" ) v = DIR_MSE.v; + else if(stat_name == "DIR_RMSE" ) v = DIR_RMSE.v; + else { + mlog << Error << "\nVL1L2Info::get_stat_vcnt() -> " + << "unknown vector continuous statistic name \"" << stat_name << "\"!\n\n"; exit(1); } @@ -2128,7 +2689,8 @@ NBRCNTInfo & NBRCNTInfo::operator=(const NBRCNTInfo &c) { //////////////////////////////////////////////////////////////////////// NBRCNTInfo & NBRCNTInfo::operator+=(const NBRCNTInfo &c) { - NBRCNTInfo n_info; + NBRCNTInfo n_info = *this; + n_info.sl1l2_info.zero_out(); double den; n_info.sl1l2_info.scount = sl1l2_info.scount + c.sl1l2_info.scount; @@ -2756,6 +3318,285 @@ void PCTInfo::compute_ci() { return; } +//////////////////////////////////////////////////////////////////////// + +double PCTInfo::get_stat(STATLineType lt, + const string &stat_name, + ConcatString &col_name, + int i_alpha) const { + double v = bad_data_double; + + // Get statistic by line type + if(lt == STATLineType::pct) v = get_stat_pct(stat_name, col_name); + else if(lt == STATLineType::pjc) v = get_stat_pjc(stat_name, col_name); + else if(lt == STATLineType::prc) v = get_stat_prc(stat_name, col_name); + else if(lt == STATLineType::pstd) v = get_stat_pstd(stat_name, col_name, i_alpha); + else { + mlog << Error << "\nPCTInfo::get_stat() -> " + << "unexpected line type \"" << statlinetype_to_string(lt) + << "\"!\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double PCTInfo::get_stat_pct(const string &stat_name, + ConcatString &col_name) const { + int i = 0; + double v = bad_data_double; + col_name = stat_name; + + // Get index value for variable column numbers + if(check_reg_exp("_[0-9]", stat_name.c_str())) { + + // Parse the index value from the column name + i = atoi(strrchr(stat_name.c_str(), '_') + 1) - 1; + + // Range check (allow THRESH_N for N == nrows) + if(i < 0 || i > pct.nrows()) { + mlog << Error << "\nPCTInfo::get_stat_pct() -> " + << "range check error for column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + } // end if + + // Find the statistic by name + if(stat_name == "TOTAL") { + v = (double) pct.n(); + } + else if(stat_name == "N_THRESH") { + v = (double) pct.nrows() + 1; + } + else if(check_reg_exp("THRESH_[0-9]", stat_name.c_str())) { + v = pct.threshold(i); + col_name = "THRESH_I"; + } + else if(check_reg_exp("OY_[0-9]", stat_name.c_str())){ + v = (double) pct.event_count_by_row(i); + col_name = "OY_I"; + } + else if(check_reg_exp("ON_[0-9]", stat_name.c_str())) { + v = (double) pct.nonevent_count_by_row(i); + col_name = "ON_I"; + } + else { + mlog << Error << "\nPCTInfo::get_stat_pct() -> " + << "unsupported column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double PCTInfo::get_stat_pjc(const string &stat_name, + ConcatString &col_name) const { + int i = 0; + double v = bad_data_double; + col_name = stat_name; + + // Get index value for variable column numbers + if(check_reg_exp("_[0-9]", stat_name.c_str())) { + + // Parse the index value from the column name + i = atoi(strrchr(stat_name.c_str(), '_') + 1) - 1; + + // Range check + if(i < 0 || i >= pct.nrows()) { + mlog << Error << "\nPCTInfo::get_stat_pjc() -> " + << "range check error for column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + } // end if + + // Find the statistic by name + if(stat_name == "TOTAL") { + v = (double) pct.n(); + } + else if(stat_name == "N_THRESH") { + v = (double) pct.nrows() + 1; + } + else if(check_reg_exp("THRESH_[0-9]", stat_name.c_str())) { + v = pct.threshold(i); + col_name = "THRESH_I"; + } + else if(check_reg_exp("OY_TP_[0-9]", stat_name.c_str())) { + v = pct.event_count_by_row(i)/(double) pct.n(); + col_name = "OY_TP_I"; + } + else if(check_reg_exp("ON_TP_[0-9]", stat_name.c_str())) { + v = pct.nonevent_count_by_row(i)/(double) pct.n(); + col_name = "ON_TP_I"; + } + else if(check_reg_exp("CALIBRATION_[0-9]", stat_name.c_str())) { + v = pct.row_calibration(i); + col_name = "CALIBRATION_I"; + } + else if(check_reg_exp("REFINEMENT_[0-9]", stat_name.c_str())) { + v = pct.row_refinement(i); + col_name = "REFINEMENT_I"; + } + else if(check_reg_exp("LIKELIHOOD_[0-9]", stat_name.c_str())) { + v = pct.row_event_likelihood(i); + col_name = "LIKELIHOOD_I"; + } + else if(check_reg_exp("BASER_[0-9]", stat_name.c_str())) { + v = pct.row_obar(i); + col_name = "BASER_I"; + } + else { + mlog << Error << "\nPCTInfo::get_stat_pjc() -> " + << "unsupported column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + + // Return bad data for 0 pairs + if(pct.n() == 0 && stat_name != "TOTAL") { + v = bad_data_double; + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double PCTInfo::get_stat_prc(const string &stat_name, + ConcatString &col_name) const { + int i = 0; + double v = bad_data_double; + col_name = stat_name; + TTContingencyTable ct; + + // Get index value for variable column numbers + if(check_reg_exp("_[0-9]", stat_name.c_str())) { + + // Parse the index value from the column name + i = atoi(strrchr(stat_name.c_str(), '_') + 1) - 1; + + // Range check + if(i < 0 || i >= pct.nrows()) { + mlog << Error << "\nPCTInfo::get_stat_prc() -> " + << "range check error for column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + + // Get the 2x2 contingency table for this row + ct = pct.ctc_by_row(i); + + } // end if + + // Find the statistic by name + if(stat_name == "TOTAL") { + v = (double) pct.n(); + } + else if(stat_name == "N_THRESH") { + v = (double) pct.nrows() + 1; + } + else if(check_reg_exp("THRESH_[0-9]", stat_name.c_str())) { + v = pct.threshold(i); + col_name = "THRESH_I"; + } + else if(check_reg_exp("PODY_[0-9]", stat_name.c_str())) { + v = ct.pod_yes(); + col_name = "PODY_I"; + } + else if(check_reg_exp("POFD_[0-9]", stat_name.c_str())) { + v = ct.pofd(); + col_name = "POFD_I"; + } + else { + mlog << Error << "\nPCTInfo::get_stat_prc() -> " + << "unsupported column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + + // Return bad data for 0 pairs + if(pct.n() == 0 && stat_name != "TOTAL") { + v = bad_data_double; + } + + return v; +} + +//////////////////////////////////////////////////////////////////////// + +double PCTInfo::get_stat_pstd(const string &stat_name, + ConcatString &col_name, + int i_alpha) const { + int i = 0; + double v = bad_data_double; + col_name = stat_name; + + // Range check alpha index + if(i_alpha >= n_alpha && is_ci_stat_name(stat_name)) { + mlog << Error << "\nPCTInfo::get_stat_pstd() -> " + << "alpha index out of range (" << i_alpha << " >= " + << n_alpha << ")!\n\n"; + exit(1); + } + + // Get index value for variable column numbers + if(check_reg_exp("_[0-9]", stat_name.c_str())) { + + // Parse the index value from the column name + i = atoi(strrchr(stat_name.c_str(), '_') + 1) - 1; + + // Range check + if(i < 0 || i >= pct.nrows()) { + mlog << Error << "\nPCTInfo::get_stat_pstd() -> " + << "range check error for column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + } // end if + + // Find the statistic by name + if(stat_name == "TOTAL" ) v = (double) pct.n(); + else if(stat_name == "N_THRESH" ) v = (double) pct.nrows() + 1; + else if(stat_name == "BASER" ) v = baser.v; + else if(stat_name == "BASER_NCL" ) v = baser.v_ncl[i_alpha]; + else if(stat_name == "BASER_NCU" ) v = baser.v_ncu[i_alpha]; + else if(stat_name == "RELIABILITY") v = pct.reliability(); + else if(stat_name == "RESOLUTION" ) v = pct.resolution(); + else if(stat_name == "UNCERTAINTY") v = pct.uncertainty(); + else if(stat_name == "ROC_AUC" ) v = pct.roc_auc(); + else if(stat_name == "BRIER" ) v = brier.v; + else if(stat_name == "BRIER_NCL" ) v = brier.v_ncl[i_alpha]; + else if(stat_name == "BRIER_NCU" ) v = brier.v_ncu[i_alpha]; + else if(stat_name == "BRIERCL" ) v = briercl.v; + else if(stat_name == "BRIERCL_NCL") v = briercl.v_ncl[i_alpha]; + else if(stat_name == "BRIERCL_NCU") v = briercl.v_ncu[i_alpha]; + else if(stat_name == "BSS" ) v = bss; + else if(stat_name == "BSS_SMPL" ) v = bss_smpl; + else if(check_reg_exp("THRESH_[0-9]", stat_name.c_str())) { + v = pct.threshold(i); + col_name = "THRESH_I"; + } + else { + mlog << Error << "\nPCTInfo::get_stat_pstd() -> " + << "unsupported column name requested \"" << stat_name + << "\"\n\n"; + exit(1); + } + + // Return bad data for 0 pairs + if(pct.n() == 0 && stat_name != "TOTAL") { + v = bad_data_double; + } + + return v; +} + //////////////////////////////////////////////////////////////////////// // // Code for class GRADInfo @@ -3627,3 +4468,10 @@ int compute_rank(const DataPlane &dp, DataPlane &dp_rank, double *data_rank, int } //////////////////////////////////////////////////////////////////////// + +bool is_ci_stat_name(const string &stat_name) { + return (stat_name.find("_NC") != string::npos || + stat_name.find("_BC") != string::npos); +} + +//////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index f3bef1a90c..c968697dd7 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -97,7 +97,12 @@ class CTSInfo { void compute_stats(); void compute_ci(); - double get_stat(const char *); + void set_stat_ctc(const std::string &, double); + + double get_stat(STATLineType, const std::string &, int i_alpha=0) const; + double get_stat_fho(const std::string &) const; + double get_stat_ctc(const std::string &) const; + double get_stat_cts(const std::string &, int i_alpha=0) const; }; //////////////////////////////////////////////////////////////////////// @@ -136,6 +141,10 @@ class MCTSInfo { void add(double, double, const ClimoPntInfo *cpi = nullptr); void compute_stats(); void compute_ci(); + + double get_stat(STATLineType, const std::string &, ConcatString &, int i_alpha=0) const; + double get_stat_mctc(const std::string &, ConcatString &) const; + double get_stat_mcts(const std::string &, int i_alpha=0) const; }; //////////////////////////////////////////////////////////////////////// @@ -188,11 +197,13 @@ class CNTInfo { int n_ranks, frank_ties, orank_ties; + void zero_out(); void clear(); + void allocate_n_alpha(int); void compute_ci(); - double get_stat(const char *); + double get_stat(const std::string &, int i_alpha=0) const; }; //////////////////////////////////////////////////////////////////////// @@ -239,6 +250,13 @@ class SL1L2Info { void zero_out(); void clear(); + + void set_stat_sl1l2(const std::string &, double); + void set_stat_sal1l2(const std::string &, double); + + double get_stat(STATLineType, const std::string &) const; + double get_stat_sl1l2(const std::string &) const; + double get_stat_sal1l2(const std::string &) const; }; //////////////////////////////////////////////////////////////////////// @@ -354,15 +372,17 @@ class VL1L2Info { // Compute sums void set(const PairDataPoint &, const PairDataPoint &); - - void clear(); + void zero_out(); + void clear(); void allocate_n_alpha(int); void compute_stats(); void compute_ci(); - double get_stat(const char *); + double get_stat_vl1l2(const std::string &) const; + double get_stat_val1l2(const std::string &) const; + double get_stat_vcnt(const std::string &) const; }; //////////////////////////////////////////////////////////////////////// @@ -502,8 +522,9 @@ class ISCInfo { double baser; double fbias; - void clear(); void zero_out(); + void clear(); + void allocate_n_scale(int); void compute_isc(); void compute_isc(int); @@ -558,6 +579,12 @@ class PCTInfo { void set_fthresh(const ThreshArray &); void compute_stats(); void compute_ci(); + + double get_stat(STATLineType, const std::string &, ConcatString &, int i_alpha=0) const; + double get_stat_pct(const std::string &, ConcatString &) const; + double get_stat_pjc(const std::string &, ConcatString &) const; + double get_stat_prc(const std::string &, ConcatString &) const; + double get_stat_pstd(const std::string &, ConcatString &, int i_alpha=0) const; }; //////////////////////////////////////////////////////////////////////// @@ -737,6 +764,8 @@ extern double compute_ufss(double); extern int compute_rank(const DataPlane &, DataPlane &, double *, int &); +extern bool is_ci_stat_name(const std::string &); + //////////////////////////////////////////////////////////////////////// #endif // __MET_STATS_H__ diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index a2e8cdf5c1..79b46710fe 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -36,10 +36,10 @@ // 015 10/03/22 Presotpnik MET #2227 Remove namespace netCDF from header files. // 016 01/29/24 Halley Gotway MET #2801 Configure time difference warnings. // 017 07/05/24 Halley Gotway MET #2924 Support forecast climatology. +// 018 07/26/24 Halley Gotway MET #1371 Aggregate previous output. // //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -65,7 +65,6 @@ using namespace std; using namespace netCDF; - //////////////////////////////////////////////////////////////////////// static void process_command_line(int, char **); @@ -84,32 +83,69 @@ static void get_series_entry(int, VarInfo *, const StringArray &, static bool read_single_entry(VarInfo *, const ConcatString &, const GrdFileType, DataPlane &, Grid &); +static void open_aggr_file(); +static DataPlane read_aggr_data_plane(const ConcatString &, + const char *suggestion=nullptr); + static void process_scores(); -static void do_cts (int, const PairDataPoint *); -static void do_mcts (int, const PairDataPoint *); -static void do_cnt (int, const PairDataPoint *); -static void do_sl1l2 (int, const PairDataPoint *); -static void do_pct (int, const PairDataPoint *); - -static void store_stat_fho (int, const ConcatString &, const CTSInfo &); -static void store_stat_ctc (int, const ConcatString &, const CTSInfo &); -static void store_stat_cts (int, const ConcatString &, const CTSInfo &); -static void store_stat_mctc (int, const ConcatString &, const MCTSInfo &); -static void store_stat_mcts (int, const ConcatString &, const MCTSInfo &); -static void store_stat_cnt (int, const ConcatString &, const CNTInfo &); -static void store_stat_sl1l2 (int, const ConcatString &, const SL1L2Info &); -static void store_stat_sal1l2(int, const ConcatString &, const SL1L2Info &); -static void store_stat_pct (int, const ConcatString &, const PCTInfo &); -static void store_stat_pstd (int, const ConcatString &, const PCTInfo &); -static void store_stat_pjc (int, const ConcatString &, const PCTInfo &); -static void store_stat_prc (int, const ConcatString &, const PCTInfo &); +static void do_categorical (int, const PairDataPoint *); +static void do_multicategory (int, const PairDataPoint *); +static void do_continuous (int, const PairDataPoint *); +static void do_partialsums (int, const PairDataPoint *); +static void do_probabilistic (int, const PairDataPoint *); +static void do_climo_brier (int, double, int, PCTInfo &); + +static int read_aggr_total (int); +static void read_aggr_ctc (int, const CTSInfo &, CTSInfo &); +static void read_aggr_mctc (int, const MCTSInfo &, MCTSInfo &); +static void read_aggr_sl1l2 (int, const SL1L2Info &, SL1L2Info &); +static void read_aggr_sal1l2 (int, const SL1L2Info &, SL1L2Info &); +static void read_aggr_pct (int, const PCTInfo &, PCTInfo &); + +static void store_stat_categorical(int, + STATLineType, const ConcatString &, + const CTSInfo &); +static void store_stat_multicategory(int, + STATLineType, const ConcatString &, + const MCTSInfo &); +static void store_stat_partialsums(int, + STATLineType, const ConcatString &, + const SL1L2Info &); +static void store_stat_continuous(int, + STATLineType, const ConcatString &, + const CNTInfo &); +static void store_stat_probabilistic(int, + STATLineType, const ConcatString &, + const PCTInfo &); + +static void store_stat_all_ctc (int, const CTSInfo &); +static void store_stat_all_mctc (int, const MCTSInfo &); +static void store_stat_all_sl1l2 (int, const SL1L2Info &); +static void store_stat_all_sal1l2(int, const SL1L2Info &); +static void store_stat_all_pct (int, const PCTInfo &); + +static ConcatString build_nc_var_name_categorical( + STATLineType, const ConcatString &, + const CTSInfo &, double); +static ConcatString build_nc_var_name_multicategory( + STATLineType, const ConcatString &, + double); +static ConcatString build_nc_var_name_partialsums( + STATLineType, const ConcatString &, + const SL1L2Info &); +static ConcatString build_nc_var_name_continuous( + STATLineType, const ConcatString &, + const CNTInfo &, double); +static ConcatString build_nc_var_name_probabilistic( + STATLineType, const ConcatString &, + const PCTInfo &, double); static void setup_nc_file(const VarInfo *, const VarInfo *); -static void add_nc_var(const ConcatString &, const ConcatString &, - const ConcatString &, const ConcatString &, - const ConcatString &, double); -static void put_nc_val(int, const ConcatString &, float); +static void add_stat_data(const ConcatString &, const ConcatString &, + const ConcatString &, const ConcatString &, + const ConcatString &, double); +static void write_stat_data(); static void set_range(const unixtime &, unixtime &, unixtime &); static void set_range(const int &, int &, int &); @@ -120,6 +156,7 @@ static void usage(); static void set_fcst_files(const StringArray &); static void set_obs_files(const StringArray &); static void set_both_files(const StringArray &); +static void set_aggr(const StringArray &); static void set_paired(const StringArray &); static void set_out_file(const StringArray &); static void set_config_file(const StringArray &); @@ -166,12 +203,13 @@ void process_command_line(int argc, char **argv) { cline.set_usage(usage); // Add the options function calls - cline.add(set_fcst_files, "-fcst", -1); - cline.add(set_obs_files, "-obs", -1); - cline.add(set_both_files, "-both", -1); - cline.add(set_paired, "-paired", 0); - cline.add(set_config_file, "-config", 1); - cline.add(set_out_file, "-out", 1); + cline.add(set_fcst_files, "-fcst", -1); + cline.add(set_obs_files, "-obs", -1); + cline.add(set_both_files, "-both", -1); + cline.add(set_aggr, "-aggr", 1); + cline.add(set_paired, "-paired", 0); + cline.add(set_config_file, "-config", 1); + cline.add(set_out_file, "-out", 1); cline.add(set_compress, "-compress", 1); // Parse the command line @@ -180,36 +218,43 @@ void process_command_line(int argc, char **argv) { // Check for error. There should be zero arguments left. if(cline.n() != 0) usage(); - // Warn about log output + // Recommend logging verbosity level of 3 or less if(mlog.verbosity_level() >= 3) { - mlog << Warning << "\nRunning Series-Analysis at verbosity >= 3 " + mlog << Debug(3) << "Running Series-Analysis at verbosity >= 3 " << "produces excessive log output and can slow the runtime " - << "considerably.\n\n"; + << "considerably.\n"; } // Check that the required arguments have been set. if(fcst_files.n() == 0) { mlog << Error << "\nprocess_command_line() -> " << "the forecast file list must be set using the " - << "\"-fcst\" or \"-both\" option.\n\n"; + << R"("-fcst" or "-both" option.)" << "\n\n"; usage(); } if(obs_files.n() == 0) { mlog << Error << "\nprocess_command_line() -> " << "the observation file list must be set using the " - << "\"-obs\" or \"-both\" option.\n\n"; + << R"("-obs" or "-both" option.)" << "\n\n"; usage(); } if(config_file.length() == 0) { mlog << Error << "\nprocess_command_line() -> " << "the configuration file must be set using the " - << "\"-config\" option.\n\n"; + << R"("-config" option.)" << "\n\n"; usage(); } if(out_file.length() == 0) { mlog << Error << "\nprocess_command_line() -> " << "the output NetCDF file must be set using the " - << "\"-out\" option.\n\n"; + << R"("-out" option.)" << "\n\n"; + usage(); + } + if(aggr_file == out_file) { + mlog << Error << "\nprocess_command_line() -> " + << R"(the "-out" and "-aggr" options cannot be )" + << R"(set to the same file (")" << aggr_file + << R"(")!)" << "\n\n"; usage(); } @@ -249,9 +294,9 @@ void process_command_line(int argc, char **argv) { // List the lengths of the series options mlog << Debug(1) - << "Length of configuration \"fcst.field\" = " + << R"(Length of configuration "fcst.field" = )" << conf_info.get_n_fcst() << "\n" - << "Length of configuration \"obs.field\" = " + << R"(Length of configuration "obs.field" = )" << conf_info.get_n_obs() << "\n" << "Length of forecast file list = " << fcst_files.n() << "\n" @@ -266,38 +311,38 @@ void process_command_line(int argc, char **argv) { // - Observation file list if(conf_info.get_n_fcst() > 1) { series_type = SeriesType::Fcst_Conf; - n_series = conf_info.get_n_fcst(); + n_series_pair = conf_info.get_n_fcst(); mlog << Debug(1) - << "Series defined by the \"fcst.field\" configuration entry " - << "of length " << n_series << ".\n"; + << R"(Series defined by the "fcst.field" configuration entry )" + << "of length " << n_series_pair << ".\n"; } else if(conf_info.get_n_obs() > 1) { series_type = SeriesType::Obs_Conf; - n_series = conf_info.get_n_obs(); + n_series_pair = conf_info.get_n_obs(); mlog << Debug(1) - << "Series defined by the \"obs.field\" configuration entry " - << "of length " << n_series << ".\n"; + << R"(Series defined by the "obs.field" configuration entry )" + << "of length " << n_series_pair << ".\n"; } else if(fcst_files.n() > 1) { series_type = SeriesType::Fcst_Files; - n_series = fcst_files.n(); + n_series_pair = fcst_files.n(); mlog << Debug(1) << "Series defined by the forecast file list of length " - << n_series << ".\n"; + << n_series_pair << ".\n"; } else if(obs_files.n() > 1) { series_type = SeriesType::Obs_Files; - n_series = obs_files.n(); + n_series_pair = obs_files.n(); mlog << Debug(1) << "Series defined by the observation file list of length " - << n_series << ".\n"; + << n_series_pair << ".\n"; } else { series_type = SeriesType::Fcst_Conf; - n_series = 1; + n_series_pair = 1; mlog << Debug(1) - << "The \"fcst.field\" and \"obs.field\" configuration entries " - << "and the \"-fcst\" and \"-obs\" command line options " + << R"(The "fcst.field" and "obs.field" configuration entries )" + << R"(and the "-fcst" and "-obs" command line options )" << "all have length one.\n"; } @@ -307,7 +352,7 @@ void process_command_line(int argc, char **argv) { // The number of forecast and observation files must match. if(fcst_files.n() != obs_files.n()) { mlog << Error << "\nprocess_command_line() -> " - << "when using the \"-paired\" command line option, the " + << R"(when using the "-paired" command line option, the )" << "number of forecast (" << fcst_files.n() << ") and observation (" << obs_files.n() << ") files must match.\n\n"; @@ -315,24 +360,24 @@ void process_command_line(int argc, char **argv) { } // The number of files must match the series length. - if(fcst_files.n() != n_series) { + if(fcst_files.n() != n_series_pair) { mlog << Error << "\nprocess_command_line() -> " - << "when using the \"-paired\" command line option, the " + << R"(when using the "-paired" command line option, the )" << "the file list length (" << fcst_files.n() - << ") and series length (" << n_series + << ") and series length (" << n_series_pair << ") must match.\n\n"; usage(); } // Set the series file names to the input file lists - for(i=0; iregrid(), &fcst_grid, &obs_grid); - nxy = grid.nx() * grid.ny(); // Process masking regions conf_info.process_masks(grid); // Set the block size, if needed - if(is_bad_data(conf_info.block_size)) conf_info.block_size = nxy; + if(is_bad_data(conf_info.block_size)) { + conf_info.block_size = grid.nxy(); + } // Compute the number of reads required - n_reads = nint(ceil((double) nxy / conf_info.block_size)); + n_reads = nint(ceil((double) grid.nxy() / conf_info.block_size)); mlog << Debug(2) << "Computing statistics using a block size of " @@ -371,7 +417,7 @@ void process_grid(const Grid &fcst_grid, const Grid &obs_grid) { << "\nA block size of " << conf_info.block_size << " for a " << grid.nx() << " x " << grid.ny() << " grid requires " << n_reads << " passes through the data which will be slow.\n" - << "Consider increasing \"block_size\" in the configuration " + << R"(Consider increasing "block_size" in the configuration )" << "file based on available memory.\n\n"; } @@ -398,8 +444,8 @@ Met2dDataFile *get_mtddf(const StringArray &file_list, // Read first valid file if(!(mtddf = mtddf_factory.new_met_2d_data_file(file_list[i].c_str(), type))) { - mlog << Error << "\nTrouble reading data file \"" - << file_list[i] << "\"\n\n"; + mlog << Error << "\nTrouble reading data file: " + << file_list[i] << "\n\n"; exit(1); } @@ -421,7 +467,7 @@ void get_series_data(int i_series, mlog << Debug(2) << "Processing series entry " << i_series + 1 << " of " - << n_series << ": " << fcst_info->magic_str() + << n_series_pair << ": " << fcst_info->magic_str() << " versus " << obs_info->magic_str() << "\n"; // Switch on the series type @@ -499,7 +545,7 @@ void get_series_data(int i_series, } // Setup the verification grid - if(nxy == 0) process_grid(fcst_grid, obs_grid); + if(!grid.is_set()) process_grid(fcst_grid, obs_grid); // Regrid the forecast, if necessary if(!(fcst_grid == grid)) { @@ -510,12 +556,12 @@ void get_series_data(int i_series, << "disabled:\n" << fcst_grid.serialize() << " !=\n" << grid.serialize() << "\nSpecify regridding logic in the config file " - << "\"regrid\" section.\n\n"; + << R"("regrid" section.)" << "\n\n"; exit(1); } - mlog << Debug(1) - << "Regridding field " << fcst_info->magic_str() + mlog << Debug(2) + << "Regridding forecast " << fcst_info->magic_str() << " to the verification grid.\n"; fcst_dp = met_regrid(fcst_dp, fcst_grid, grid, fcst_info->regrid()); @@ -530,12 +576,12 @@ void get_series_data(int i_series, << "disabled:\n" << obs_grid.serialize() << " !=\n" << grid.serialize() << "\nSpecify regridding logic in the config file " - << "\"regrid\" section.\n\n"; + << R"("regrid" section.)" << "\n\n"; exit(1); } - mlog << Debug(1) - << "Regridding field " << obs_info->magic_str() + mlog << Debug(2) + << "Regridding observation " << obs_info->magic_str() << " to the verification grid.\n"; obs_dp = met_regrid(obs_dp, obs_grid, grid, obs_info->regrid()); @@ -564,7 +610,8 @@ void get_series_data(int i_series, << cs << "\n\n"; } else { - mlog << Debug(3) << cs << "\n"; + mlog << Debug(3) + << cs << "\n"; } } @@ -578,7 +625,6 @@ void get_series_entry(int i_series, VarInfo *info, const GrdFileType type, StringArray &found_files, DataPlane &dp, Grid &cur_grid) { - int i, j; bool found = false; // Initialize @@ -588,10 +634,10 @@ void get_series_entry(int i_series, VarInfo *info, if(found_files[i_series].length() == 0) { // Loop through the file list - for(i=0; i " << "Could not find data for " << info->magic_str() << " in file list:\n"; - for(i=0; i " + << "unable to open the aggregate NetCDF file: " + << aggr_file << "\n\n"; + exit(1); + } + + // Update timing info based on aggregate file global attributes + ConcatString cs; + + if(get_att_value_string(aggr_nc.MetNc->Nc, "fcst_init_beg", cs)) { + set_range(timestring_to_unix(cs.c_str()), fcst_init_beg, fcst_init_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "fcst_init_end", cs)) { + set_range(timestring_to_unix(cs.c_str()), fcst_init_beg, fcst_init_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "fcst_valid_beg", cs)) { + set_range(timestring_to_unix(cs.c_str()), fcst_valid_beg, fcst_valid_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "fcst_valid_end", cs)) { + set_range(timestring_to_unix(cs.c_str()), fcst_valid_beg, fcst_valid_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "fcst_lead_beg", cs)) { + set_range(timestring_to_sec(cs.c_str()), fcst_lead_beg, fcst_lead_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "fcst_lead_end", cs)) { + set_range(timestring_to_sec(cs.c_str()), fcst_lead_beg, fcst_lead_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "obs_init_beg", cs)) { + set_range(timestring_to_unix(cs.c_str()), obs_init_beg, obs_init_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "obs_init_end", cs)) { + set_range(timestring_to_unix(cs.c_str()), obs_init_beg, obs_init_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "obs_valid_beg", cs)) { + set_range(timestring_to_unix(cs.c_str()), obs_valid_beg, obs_valid_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "obs_valid_end", cs)) { + set_range(timestring_to_unix(cs.c_str()), obs_valid_beg, obs_valid_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "obs_lead_beg", cs)) { + set_range(timestring_to_sec(cs.c_str()), obs_lead_beg, obs_lead_end); + } + if(get_att_value_string(aggr_nc.MetNc->Nc, "obs_lead_end", cs)) { + set_range(timestring_to_sec(cs.c_str()), obs_lead_beg, obs_lead_end); + } + + // Store the aggregate series length + n_series_aggr = get_int_var(aggr_nc.MetNc->Nc, n_series_var_name, 0); + + mlog << Debug(3) + << "Aggregation series has length " << n_series_aggr << ".\n"; + + return; +} + +//////////////////////////////////////////////////////////////////////// + +DataPlane read_aggr_data_plane(const ConcatString &var_name, + const char *suggestion) { + DataPlane aggr_dp; + + // Setup the data request + VarInfoNcMet aggr_info; + aggr_info.set_magic(var_name, "(*,*)"); + + mlog << Debug(2) + << R"(Reading aggregation ")" + << aggr_info.magic_str() + << R"(" field.)" << "\n"; + + // Attempt to read the gridded data from the current file + if(!aggr_nc.data_plane(aggr_info, aggr_dp)) { + mlog << Error << "\nread_aggr_data_plane() -> " + << R"(Required variable ")" << aggr_info.magic_str() + << R"(" not found in the aggregate file!)" << "\n\n"; + if(suggestion) { + mlog << Error + << R"(Recommend recreating ")" << aggr_file + << R"(" to request that )" << suggestion + << " column(s) be written.\n\n"; + } + exit(1); + } + + // Check that the grid has not changed + if(aggr_nc.grid().nx() != grid.nx() || + aggr_nc.grid().ny() != grid.ny()) { + mlog << Error << "\nread_aggr_data_plane() -> " + << "the input grid dimensions (" << grid.nx() << ", " << grid.ny() + << ") and aggregate grid dimensions (" << aggr_nc.grid().nx() + << ", " << aggr_nc.grid().ny() << ") do not match!\n\n"; + exit(1); + } + + return aggr_dp; +} + +//////////////////////////////////////////////////////////////////////// + void process_scores() { - int i, x, y, i_read, i_series, i_point, i_fcst; + int x; + int y; + int i_point = 0; VarInfo *fcst_info = (VarInfo *) nullptr; VarInfo *obs_info = (VarInfo *) nullptr; - PairDataPoint *pd_ptr = (PairDataPoint *) nullptr; - DataPlane fcst_dp, obs_dp; + DataPlane fcst_dp; + DataPlane obs_dp; + vector pd_block; const char *method_name = "process_scores() "; // Climatology mean and standard deviation DataPlane fcmn_dp, fcsd_dp; DataPlane ocmn_dp, ocsd_dp; + // Open the aggregate file, if needed + if(aggr_file.nonempty()) open_aggr_file(); + // Number of points skipped due to valid data threshold - int n_skip_zero = 0; - int n_skip_pos = 0; + int n_skip_zero_vld = 0; + int n_skip_some_vld = 0; // Loop over the data reads - for(i_read=0; i_read 1 ? i_series : 0); + int i_fcst = (conf_info.get_n_fcst() > 1 ? i_series : 0); // Store the current VarInfo objects fcst_info = conf_info.fcst_info[i_fcst]; @@ -715,18 +871,20 @@ void process_scores() { // Retrieve the data planes for the current series entry get_series_data(i_series, fcst_info, obs_info, fcst_dp, obs_dp); - // Allocate PairDataPoint objects, if needed - if(!pd_ptr) { - pd_ptr = new PairDataPoint [conf_info.block_size]; - for(i=0; imagic_str() << ", found " - << (fcmn_flag ? 0 : 1) << " forecast climatology mean and " - << (fcsd_flag ? 0 : 1) << " standard deviation field(s), and " - << (ocmn_flag ? 0 : 1) << " observation climatology mean and " - << (ocsd_flag ? 0 : 1) << " standard deviation field(s).\n"; + << (fcmn_flag ? 1 : 0) << " forecast climatology mean and " + << (fcsd_flag ? 1 : 0) << " standard deviation field(s), and " + << (ocmn_flag ? 1 : 0) << " observation climatology mean and " + << (ocsd_flag ? 1 : 0) << " standard deviation field(s).\n"; // Setup the output NetCDF file on the first pass - if(nc_out == (NcFile *) 0) setup_nc_file(fcst_info, obs_info); + if(!nc_out) setup_nc_file(fcst_info, obs_info); // Update timing info set_range(fcst_dp.init(), fcst_init_beg, fcst_init_end); @@ -786,7 +940,7 @@ void process_scores() { set_range(obs_dp.lead(), obs_lead_beg, obs_lead_end); // Store matched pairs for each grid point - for(i=0; i 0) { - do_cts(i_point+i, &pd_ptr[i]); + do_categorical(i_point+i, &pd_block[i]); } // Compute multi-category contingency table counts and statistics if(!conf_info.fcst_info[0]->is_prob() && (conf_info.output_stats[STATLineType::mctc].n() + conf_info.output_stats[STATLineType::mcts].n()) > 0) { - do_mcts(i_point+i, &pd_ptr[i]); + do_multicategory(i_point+i, &pd_block[i]); } // Compute continuous statistics if(!conf_info.fcst_info[0]->is_prob() && conf_info.output_stats[STATLineType::cnt].n() > 0) { - do_cnt(i_point+i, &pd_ptr[i]); + do_continuous(i_point+i, &pd_block[i]); } // Compute partial sums if(!conf_info.fcst_info[0]->is_prob() && (conf_info.output_stats[STATLineType::sl1l2].n() + conf_info.output_stats[STATLineType::sal1l2].n()) > 0) { - do_sl1l2(i_point+i, &pd_ptr[i]); + do_partialsums(i_point+i, &pd_block[i]); } // Compute probabilistics counts and statistics @@ -878,22 +1031,16 @@ void process_scores() { conf_info.output_stats[STATLineType::pstd].n() + conf_info.output_stats[STATLineType::pjc].n() + conf_info.output_stats[STATLineType::prc].n()) > 0) { - do_pct(i_point+i, &pd_ptr[i]); + do_probabilistic(i_point+i, &pd_block[i]); } - } // end for i - // Erase the data - for(i=0; i 0 && conf_info.vld_data_thresh == 1.0) { + if(n_skip_some_vld > 0 && conf_info.vld_data_thresh == 1.0) { mlog << Debug(2) << "Some points skipped due to missing data:\n" - << "Consider decreasing \"vld_thresh\" in the config file " + << R"(Consider decreasing "vld_thresh" in the config file )" << "to include more points.\n" - << "Consider requesting \"TOTAL\" from \"output_stats\" " + << R"(Consider requesting "TOTAL" from "output_stats" )" << "in the config file to see the valid data counts.\n"; } @@ -936,30 +1080,56 @@ void process_scores() { //////////////////////////////////////////////////////////////////////// -void do_cts(int n, const PairDataPoint *pd_ptr) { - int i, j; +void do_categorical(int n, const PairDataPoint *pd_ptr) { - mlog << Debug(4) << "Computing Categorical Statistics.\n"; + mlog << Debug(4) + << "Computing Categorical Statistics.\n"; // Allocate objects to store categorical statistics int n_cts = conf_info.fcat_ta.n(); CTSInfo *cts_info = new CTSInfo [n_cts]; // Setup CTSInfo objects - for(i=0; in_obs-1); + + // Loop over the thresholds + for(int i=0; in_obs-1); + + // Compute the current MCTSInfo + compute_mctsinfo(*pd_ptr, i_na, false, false, mcts_info); + + // Read the MCTC data to be aggregated + MCTSInfo aggr_mcts; + read_aggr_mctc(n, mcts_info, aggr_mcts); + + // Aggregate MCTC counts + mcts_info.cts += aggr_mcts.cts; + + // Compute statistics and confidence intervals + mcts_info.compute_stats(); + mcts_info.compute_ci(); + + } // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals - if(conf_info.boot_interval == BootIntervalType::BCA) { + else if(conf_info.boot_interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.n_boot_rep, mcts_info, true, @@ -1037,15 +1232,17 @@ void do_mcts(int n, const PairDataPoint *pd_ptr) { } // Add statistic value for each possible MCTC column - for(i=0; isubset_pairs_cnt_thresh(cnt_info.fthresh, cnt_info.othresh, - cnt_info.logic); - - // Check for no matched pairs to process - if(pd.n_obs == 0) continue; - - // Compute the stats, normal confidence intervals, and - // bootstrap confidence intervals - int precip_flag = (conf_info.fcst_info[0]->is_precipitation() && - conf_info.obs_info[0]->is_precipitation()); + // Aggregate input pair data with existing partial sums + if(aggr_file.nonempty()) { + + // Compute partial sums from the pair data + SL1L2Info s_info; + s_info.fthresh = cnt_info.fthresh; + s_info.othresh = cnt_info.othresh; + s_info.logic = cnt_info.logic; + s_info.set(*pd_ptr); + + // Aggregate scalar partial sums + SL1L2Info aggr_psum; + read_aggr_sl1l2(n, s_info, aggr_psum); + s_info += aggr_psum; + + // Aggregate scalar anomaly partial sums + if(conf_info.output_stats[STATLineType::cnt].has("ANOM_CORR")) { + read_aggr_sal1l2(n, s_info, aggr_psum); + s_info += aggr_psum; + } - if(conf_info.boot_interval == BootIntervalType::BCA) { - compute_cnt_stats_ci_bca(rng_ptr, pd, - precip_flag, conf_info.rank_corr_flag, - conf_info.n_boot_rep, - cnt_info, conf_info.tmp_dir.c_str()); + // Compute continuous statistics from partial sums + compute_cntinfo(s_info, cnt_info); } + // Compute continuous statistics from the pair data else { - compute_cnt_stats_ci_perc(rng_ptr, pd, - precip_flag, conf_info.rank_corr_flag, - conf_info.n_boot_rep, conf_info.boot_rep_prop, - cnt_info, conf_info.tmp_dir.c_str()); + + // Apply continuous filtering thresholds to subset pairs + pd = pd_ptr->subset_pairs_cnt_thresh(cnt_info.fthresh, cnt_info.othresh, + cnt_info.logic); + + // Check for no matched pairs to process + if(pd.n_obs == 0) continue; + + // Compute the stats, normal confidence intervals, and + // bootstrap confidence intervals + int precip_flag = (conf_info.fcst_info[0]->is_precipitation() && + conf_info.obs_info[0]->is_precipitation()); + + if(conf_info.boot_interval == BootIntervalType::BCA) { + compute_cnt_stats_ci_bca(rng_ptr, pd, + precip_flag, conf_info.rank_corr_flag, + conf_info.n_boot_rep, + cnt_info, conf_info.tmp_dir.c_str()); + } + else { + compute_cnt_stats_ci_perc(rng_ptr, pd, + precip_flag, conf_info.rank_corr_flag, + conf_info.n_boot_rep, conf_info.boot_rep_prop, + cnt_info, conf_info.tmp_dir.c_str()); + } } // Add statistic value for each possible CNT column - for(j=0; j 0) { + read_aggr_sl1l2(n, s_info, aggr_psum); + s_info += aggr_psum; + } + + // Aggregate SAL1L2 partial sums + if(conf_info.output_stats[STATLineType::sal1l2].n() > 0) { + read_aggr_sal1l2(n, s_info, aggr_psum); + s_info += aggr_psum; + } + } + // Add statistic value for each possible SL1L2 column - for(j=0; jNc, &aggr_var_names); - // Setup the PCTInfo object - pct_info.fthresh = conf_info.fcat_ta; - pct_info.allocate_n_alpha(conf_info.ci_alpha.n()); + // Search for one containing TOTAL + for(int i=0; i " + << R"(No variable containing ")" << total_name + << R"(" "found in the aggregate file!)" << "\n\n"; + exit(1); + } } - // Compute PCTInfo for each observation threshold - for(i=0; i " + << "the number of MCTC categories do not match (" + << nint(v) << " != " << aggr_mcts.cts.nrows() << ")!\n\n"; + exit(1); } - } // end for i + // Check the expected correct + else if(c == "EC_VALUE" && !is_bad_data(v) && + !is_eq(v, aggr_mcts.cts.ec_value(), loose_tol)) { + mlog << Error << "\nread_aggr_mctc() -> " + << "the MCTC expected correct values do not match (" + << v << " != " << aggr_mcts.cts.ec_value() << ")!\n\n"; + exit(1); + } + // Populate the MCTC table + else if(check_reg_exp("F[0-9]*_O[0-9]*", c.c_str())) { + StringArray sa(c.split("_")); + int i_row = atoi(sa[0].c_str()+1) - 1; + int i_col = atoi(sa[1].c_str()+1) - 1; + aggr_mcts.cts.set_entry(i_row, i_col, nint(v)); + } + } return; } //////////////////////////////////////////////////////////////////////// -void store_stat_fho(int n, const ConcatString &col, - const CTSInfo &cts_info) { - double v; - ConcatString lty_stat, var_name; +void read_aggr_sl1l2(int n, const SL1L2Info &s_info, + SL1L2Info &aggr_psum) { - // Set the column name to all upper case - ConcatString c = to_upper(col); + // Initialize + aggr_psum.zero_out(); - // Get the column value - if(c == "TOTAL") { v = (double) cts_info.cts.n(); } - else if(c == "F_RATE") { v = cts_info.cts.f_rate(); } - else if(c == "H_RATE") { v = cts_info.cts.h_rate(); } - else if(c == "O_RATE") { v = cts_info.cts.o_rate(); } - else { - mlog << Error << "\nstore_stat_fho() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + // Loop over the SL1L2 columns + for(auto &col : sl1l2_columns) { - // Construct the NetCDF variable name - var_name << cs_erase << "series_fho_" << c; + ConcatString c(to_upper(col)); + ConcatString var_name(build_nc_var_name_partialsums( + STATLineType::sl1l2, c, + s_info)); - // Append threshold information - if(cts_info.fthresh == cts_info.othresh) { - var_name << "_" << cts_info.fthresh.get_abbr_str(); - } - else { - var_name << "_fcst" << cts_info.fthresh.get_abbr_str() - << "_obs" << cts_info.othresh.get_abbr_str(); + // Read aggregate data, if needed + if(aggr_data.count(var_name) == 0) { + aggr_data[var_name] = read_aggr_data_plane( + var_name, R"("ALL" SL1L2)"); + } + + // Populate the partial sums + aggr_psum.set_stat_sl1l2(col, aggr_data[var_name].buf()[n]); } - // Add map for this variable name - if(stat_data.count(var_name) == 0) { + return; +} - // Build key - lty_stat << "FHO_" << c; +//////////////////////////////////////////////////////////////////////// - // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - cts_info.fthresh.get_str(), - cts_info.othresh.get_str(), - bad_data_double); - } +void read_aggr_sal1l2(int n, const SL1L2Info &s_info, + SL1L2Info &aggr_psum) { - // Store the statistic value - put_nc_val(n, var_name, (float) v); + // Initialize + aggr_psum.zero_out(); + + // Loop over the SAL1L2 columns + for(auto &col : sal1l2_columns) { + + ConcatString c(to_upper(col)); + ConcatString var_name(build_nc_var_name_partialsums( + STATLineType::sal1l2, c, + s_info)); + + // Read aggregate data, if needed + if(aggr_data.count(var_name) == 0) { + aggr_data[var_name] = read_aggr_data_plane( + var_name, R"("ALL" SAL1L2)"); + } + + // Populate the partial sums + aggr_psum.set_stat_sal1l2(col, aggr_data[var_name].buf()[n]); + } return; } //////////////////////////////////////////////////////////////////////// -void store_stat_ctc(int n, const ConcatString &col, - const CTSInfo &cts_info) { - int v; - ConcatString lty_stat, var_name; +void read_aggr_pct(int n, const PCTInfo &pct_info, + PCTInfo &aggr_pct) { - // Set the column name to all upper case - ConcatString c = to_upper(col); + // Initialize + aggr_pct.pct = pct_info.pct; + aggr_pct.pct.zero_out(); - // Get the column value - if(c == "TOTAL") { v = cts_info.cts.n(); } - else if(c == "FY_OY") { v = cts_info.cts.fy_oy(); } - else if(c == "FY_ON") { v = cts_info.cts.fy_on(); } - else if(c == "FN_OY") { v = cts_info.cts.fn_oy(); } - else if(c == "FN_ON") { v = cts_info.cts.fn_on(); } - else if(c == "EC_VALUE") { v = cts_info.cts.ec_value(); } - else { - mlog << Error << "\nstore_stat_ctc() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + // Get PCT column names + StringArray pct_cols(get_pct_columns(aggr_pct.pct.nrows()+1)); - // Construct the NetCDF variable name - var_name << cs_erase << "series_ctc_" << c; + // Loop over the PCT columns + for(int i=0; i " + << "the number of PCT thresholds do not match (" + << nint(v) << " != " << aggr_pct.pct.nrows()+1 + << ")!\n\n"; + exit(1); + } + // Set the event counts + else if(check_reg_exp("OY_[0-9]", c.c_str())) { - // Store the statistic value - put_nc_val(n, var_name, (float) v); + // Parse the index value from the column name + int i_row = atoi(strrchr(c.c_str(), '_') + 1) - 1; + aggr_pct.pct.set_event(i_row, nint(v)); + } + // Set the non-event counts + else if(check_reg_exp("ON_[0-9]", c.c_str())) { + + // Parse the index value from the column name + int i_row = atoi(strrchr(c.c_str(), '_') + 1) - 1; + aggr_pct.pct.set_nonevent(i_row, nint(v)); + } + } return; } //////////////////////////////////////////////////////////////////////// -void store_stat_cts(int n, const ConcatString &col, - const CTSInfo &cts_info) { - int i; - double v; - ConcatString lty_stat, var_name; - int n_ci = 1; +void do_probabilistic(int n, const PairDataPoint *pd_ptr) { - // Set the column name to all upper case - ConcatString c = to_upper(col); + mlog << Debug(4) + << "Computing Probabilistic Statistics.\n"; - // Check for columns with normal or bootstrap confidence limits - if(strstr(c.c_str(), "_NC") || strstr(c.c_str(), "_BC")) n_ci = cts_info.n_alpha; - - // Loop over the alpha values, if necessary - for(i=0; i " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + // Object to store probabilistic statistics + PCTInfo pct_info; - // Construct the NetCDF variable name - var_name << cs_erase << "series_cts_" << c; + // Setup the PCTInfo object + pct_info.fthresh = conf_info.fcat_ta; + pct_info.allocate_n_alpha(conf_info.ci_alpha.n()); + + for(int i=0; i 1) var_name << "_a" << cts_info.alpha[i]; - - // Add map for this variable name - if(stat_data.count(var_name) == 0) { - - // Build key - lty_stat << "CTS_" << c; + // Add statistic value for each possible PCT column + for(int j=0; j 1 ? cts_info.alpha[i] : bad_data_double)); + // Add statistic value for each possible PSTD column + for(int j=0; j= mcts_info.cts.nrows() || - j < 0 || j >= mcts_info.cts.ncols()) { - mlog << Error << "\nstore_stat_mctc() -> " - << "range check error for column name requested \"" << c - << "\"\n\n"; - exit(1); - } + // Aggregate the climatology brier score as a weighted + // average and recompute the brier skill score - // Retrieve the value - v = (double) mcts_info.cts.entry(i, j); - } - else { - mlog << Error << "\nstore_stat_mctc() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + if(is_bad_data(briercl_pair) || total_pair == 0) return; // Construct the NetCDF variable name - var_name << cs_erase << "series_mctc_" << c; + ConcatString var_name(build_nc_var_name_probabilistic( + STATLineType::pstd, "BRIERCL", + pct_info, bad_data_double)); - // Add map for this variable name - if(stat_data.count(var_name) == 0) { + // Read aggregate data, if needed + if(aggr_data.count(var_name) == 0) { + aggr_data[var_name] = read_aggr_data_plane( + var_name, R"(the "BRIERCL" PSTD)"); + } - // Build key - lty_stat << "MCTC_" << d; + // Get the n-th BRIERCL value + double briercl_aggr = aggr_data[var_name].buf()[n]; + int total_aggr = read_aggr_total(n); - // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - mcts_info.fthresh.get_str(","), - mcts_info.othresh.get_str(","), - bad_data_double); - } + // Aggregate BRIERCL as a weighted average + if(!is_bad_data(briercl_pair) && + !is_bad_data(briercl_aggr) && + (total_pair + total_aggr) > 0) { - // Store the statistic value - put_nc_val(n, var_name, (float) v); + pct_info.briercl.v = (total_pair * briercl_pair + + total_aggr * briercl_aggr) / + (total_pair + total_aggr); + + // Compute the brier skill score + if(!is_bad_data(pct_info.brier.v) && + !is_bad_data(pct_info.briercl.v)) { + pct_info.bss = 1.0 - (pct_info.brier.v / pct_info.briercl.v); + } + } return; } //////////////////////////////////////////////////////////////////////// -void store_stat_mcts(int n, const ConcatString &col, - const MCTSInfo &mcts_info) { - int i; - double v; - ConcatString lty_stat, var_name; - int n_ci = 1; +void store_stat_categorical(int n, STATLineType lt, + const ConcatString &col, + const CTSInfo &cts_info) { // Set the column name to all upper case ConcatString c = to_upper(col); + // Handle ALL CTC columns + if(lt == STATLineType::ctc && c == all_columns) { + return store_stat_all_ctc(n, cts_info); + } + // Check for columns with normal or bootstrap confidence limits - if(strstr(c.c_str(), "_NC") || strstr(c.c_str(), "_BC")) n_ci = mcts_info.n_alpha; - - // Loop over the alpha values, if necessary - for(i=0; i " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + int n_alpha = 1; + if(lt == STATLineType::cts && is_ci_stat_name(c)) { + n_alpha = cts_info.n_alpha; + } - // Construct the NetCDF variable name - var_name << cs_erase << "series_mcts_" << c; + // Loop over the alpha values + for(int i_alpha=0; i_alpha 1) var_name << "_a" << mcts_info.alpha[i]; + // Store alpha value + double alpha = (n_alpha > 1 ? cts_info.alpha[i_alpha] : bad_data_double); + + // Construct the NetCDF variable name + ConcatString var_name(build_nc_var_name_categorical( + lt, c, cts_info, alpha)); // Add map for this variable name if(stat_data.count(var_name) == 0) { // Build key - lty_stat << "MCTS_" << c; + ConcatString lty_stat(statlinetype_to_string(lt)); + lty_stat << "_" << c; // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - mcts_info.fthresh.get_str(","), - mcts_info.othresh.get_str(","), - (n_ci > 1 ? mcts_info.alpha[i] : bad_data_double)); + add_stat_data(var_name, c, stat_long_name[lty_stat], + cts_info.fthresh.get_str(), + cts_info.othresh.get_str(), + alpha); } // Store the statistic value - put_nc_val(n, var_name, (float) v); + stat_data[var_name].dp.buf()[n] = cts_info.get_stat(lt, c, i_alpha); - } // end for i + } // end for i_alpha return; } //////////////////////////////////////////////////////////////////////// -void store_stat_cnt(int n, const ConcatString &col, - const CNTInfo &cnt_info) { - int i; - double v; - ConcatString lty_stat, var_name; - int n_ci = 1; +void store_stat_multicategory(int n, STATLineType lt, + const ConcatString &col, + const MCTSInfo &mcts_info) { // Set the column name to all upper case ConcatString c = to_upper(col); + // Handle ALL MCTC columns + if(lt == STATLineType::mctc && c == all_columns) { + return store_stat_all_mctc(n, mcts_info); + } + // Check for columns with normal or bootstrap confidence limits - if(strstr(c.c_str(), "_NC") || strstr(c.c_str(), "_BC")) n_ci = cnt_info.n_alpha; - - // Loop over the alpha values, if necessary - for(i=0; i " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + int n_alpha = 1; + if(lt == STATLineType::mcts && is_ci_stat_name(c)) { + n_alpha = mcts_info.n_alpha; + } + + // Loop over the alpha values + for(int i_alpha=0; i_alpha 1 ? mcts_info.alpha[i_alpha] : bad_data_double); // Construct the NetCDF variable name - var_name << cs_erase << "series_cnt_" << c; - - // Append threshold information, if supplied - if(cnt_info.fthresh.get_type() != thresh_na || - cnt_info.othresh.get_type() != thresh_na) { - var_name << "_fcst" << cnt_info.fthresh.get_abbr_str() - << "_" << setlogic_to_abbr(conf_info.cnt_logic) - << "_obs" << cnt_info.othresh.get_abbr_str(); - } + ConcatString var_name(build_nc_var_name_multicategory( + lt, c, alpha)); - // Append confidence interval alpha value - if(n_ci > 1) var_name << "_a" << cnt_info.alpha[i]; + // Store the data value + ConcatString col_name; + auto v = (float) mcts_info.get_stat(lt, c, col_name, i_alpha); // Add map for this variable name if(stat_data.count(var_name) == 0) { // Build key - lty_stat << "CNT_" << c; + ConcatString lty_stat; + lty_stat << statlinetype_to_string(lt) << "_" << col_name; // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - cnt_info.fthresh.get_str(), - cnt_info.othresh.get_str(), - (n_ci > 1 ? cnt_info.alpha[i] : bad_data_double)); + add_stat_data(var_name, c, stat_long_name[lty_stat], + mcts_info.fthresh.get_str(","), + mcts_info.othresh.get_str(","), + alpha); } // Store the statistic value - put_nc_val(n, var_name, (float) v); + stat_data[var_name].dp.buf()[n] = v; - } // end for i + } // end for i_alpha return; } //////////////////////////////////////////////////////////////////////// -void store_stat_sl1l2(int n, const ConcatString &col, - const SL1L2Info &s_info) { - double v; - ConcatString lty_stat, var_name; +void store_stat_continuous(int n, STATLineType lt, + const ConcatString &col, + const CNTInfo &cnt_info) { // Set the column name to all upper case ConcatString c = to_upper(col); - // Get the column value - if(c == "TOTAL") { v = (double) s_info.scount; } - else if(c == "FBAR") { v = s_info.fbar; } - else if(c == "OBAR") { v = s_info.obar; } - else if(c == "FOBAR") { v = s_info.fobar; } - else if(c == "FFBAR") { v = s_info.ffbar; } - else if(c == "OOBAR") { v = s_info.oobar; } - else if(c == "MAE") { v = s_info.smae; } - else { - mlog << Error << "\nstore_stat_sl1l2() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + // Check for columns with normal or bootstrap confidence limits + int n_alpha = 1; + if(is_ci_stat_name(c)) n_alpha = cnt_info.n_alpha; - // Construct the NetCDF variable name - var_name << cs_erase << "series_sl1l2_" << c; + // Loop over the alpha values + for(int i_alpha=0; i_alpha 1 ? cnt_info.alpha[i_alpha] : bad_data_double); - // Add map for this variable name - if(stat_data.count(var_name) == 0) { + // Construct the NetCDF variable name + ConcatString var_name(build_nc_var_name_continuous( + lt, c, cnt_info, alpha)); - // Build key - lty_stat << "SL1L2_" << c; + // Add map for this variable name + if(stat_data.count(var_name) == 0) { - // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - s_info.fthresh.get_str(), - s_info.othresh.get_str(), - bad_data_double); - } + // Build key + ConcatString lty_stat(statlinetype_to_string(lt)); + lty_stat << "_" << c; - // Store the statistic value - put_nc_val(n, var_name, (float) v); + // Add new map entry + add_stat_data(var_name, c, stat_long_name[lty_stat], + cnt_info.fthresh.get_str(), + cnt_info.othresh.get_str(), + alpha); + } + + // Store the statistic value + stat_data[var_name].dp.buf()[n] = cnt_info.get_stat(c, i_alpha); + + } // end for i_alpha return; } //////////////////////////////////////////////////////////////////////// -void store_stat_sal1l2(int n, const ConcatString &col, - const SL1L2Info &s_info) { - double v; +void store_stat_partialsums(int n, STATLineType lt, + const ConcatString &col, + const SL1L2Info &s_info) { // Set the column name to all upper case ConcatString c = to_upper(col); - // Get the column value - if(c == "TOTAL") { v = (double) s_info.sacount; } - else if(c == "FABAR") { v = s_info.fabar; } - else if(c == "OABAR") { v = s_info.oabar; } - else if(c == "FOABAR") { v = s_info.foabar; } - else if(c == "FFABAR") { v = s_info.ffabar; } - else if(c == "OOABAR") { v = s_info.ooabar; } - else if(c == "MAE") { v = s_info.samae; } - else { - mlog << Error << "\nstore_stat_sal1l2() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); + // Handle ALL columns + if(c == all_columns) { + if(lt == STATLineType::sl1l2) return store_stat_all_sl1l2(n, s_info); + else if(lt == STATLineType::sal1l2) return store_stat_all_sal1l2(n, s_info); } // Construct the NetCDF variable name - ConcatString var_name("series_sal1l2_"); - var_name << c; - - // Append threshold information, if supplied - if(s_info.fthresh.get_type() != thresh_na || - s_info.othresh.get_type() != thresh_na) { - var_name << "_fcst" << s_info.fthresh.get_abbr_str() - << "_" << setlogic_to_abbr(conf_info.cnt_logic) - << "_obs" << s_info.othresh.get_abbr_str(); - } + ConcatString var_name(build_nc_var_name_partialsums( + lt, c, s_info)); // Add map for this variable name if(stat_data.count(var_name) == 0) { // Build key - ConcatString lty_stat("SAL1L2_"); - lty_stat << c; + ConcatString lty_stat(statlinetype_to_string(lt)); + lty_stat << "_" << c; // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - s_info.fthresh.get_str(), - s_info.othresh.get_str(), - bad_data_double); + add_stat_data(var_name, c, stat_long_name[lty_stat], + s_info.fthresh.get_str(), + s_info.othresh.get_str(), + bad_data_double); } // Store the statistic value - put_nc_val(n, var_name, (float) v); + stat_data[var_name].dp.buf()[n] = s_info.get_stat(lt, c); return; } //////////////////////////////////////////////////////////////////////// -void store_stat_pct(int n, const ConcatString &col, - const PCTInfo &pct_info) { - int i = 0; - double v; - ConcatString lty_stat, var_name; +void store_stat_probabilistic(int n, STATLineType lt, + const ConcatString &col, + const PCTInfo &pct_info) { // Set the column name to all upper case ConcatString c = to_upper(col); - ConcatString d = c; - - // Get index value for variable column numbers - if(check_reg_exp("_[0-9]", c.c_str())) { - - // Parse the index value from the column name - i = atoi(strrchr(c.c_str(), '_') + 1) - 1; - - // Range check - if(i < 0 || i >= pct_info.pct.nrows()) { - mlog << Error << "\nstore_stat_pct() -> " - << "range check error for column name requested \"" << c - << "\"\n\n"; - exit(1); - } - } // end if - - // Get the column value - if(c == "TOTAL") { v = (double) pct_info.pct.n(); } - else if(c == "N_THRESH") { v = (double) pct_info.pct.nrows() + 1; } - else if(check_reg_exp("THRESH_[0-9]", c.c_str())) { v = pct_info.pct.threshold(i); } - else if(check_reg_exp("OY_[0-9]", c.c_str())) { v = (double) pct_info.pct.event_count_by_row(i); - d = "OY_I"; } - else if(check_reg_exp("ON_[0-9]", c.c_str())) { v = (double) pct_info.pct.nonevent_count_by_row(i); - d = "ON_I"; } - else { - mlog << Error << "\nstore_stat_pct() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } - - // Construct the NetCDF variable name - var_name << cs_erase << "series_pct_" << c - << "_obs" << pct_info.othresh.get_abbr_str(); - - // Add map for this variable name - if(stat_data.count(var_name) == 0) { - - // Build key - lty_stat << "PCT_" << d; - // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - pct_info.fthresh.get_str(","), - pct_info.othresh.get_str(), - bad_data_double); + // Handle ALL PCT columns + if(lt == STATLineType::pct && c == all_columns) { + return store_stat_all_pct(n, pct_info); } - // Store the statistic value - put_nc_val(n, var_name, (float) v); - - return; -} - -//////////////////////////////////////////////////////////////////////// - -void store_stat_pstd(int n, const ConcatString &col, - const PCTInfo &pct_info) { - int i; - double v; - ConcatString lty_stat, var_name; - int n_ci = 1; + // Check for columns with normal or bootstrap confidence limits + int n_alpha = 1; + if(is_ci_stat_name(c)) n_alpha = pct_info.n_alpha; - // Set the column name to all upper case - ConcatString c = to_upper(col); + // Loop over the alpha values + for(int i_alpha=0; i_alpha " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); - } + // Store alpha value + double alpha = (n_alpha > 1 ? pct_info.alpha[i_alpha] : bad_data_double); // Construct the NetCDF variable name - var_name << cs_erase << "series_pstd_" << c; + ConcatString var_name(build_nc_var_name_probabilistic( + lt, c, pct_info, alpha)); - // Append confidence interval alpha value - if(n_ci > 1) var_name << "_a" << pct_info.alpha[i]; + // Store the data value + ConcatString col_name; + auto v = (float) pct_info.get_stat(lt, c, col_name, i_alpha); // Add map for this variable name if(stat_data.count(var_name) == 0) { // Build key - lty_stat << "PSTD_" << c; + ConcatString lty_stat(statlinetype_to_string(lt)); + lty_stat << "_" << col_name; // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - pct_info.fthresh.get_str(","), - pct_info.othresh.get_str(), - (n_ci > 1 ? pct_info.alpha[i] : bad_data_double)); + add_stat_data(var_name, c, stat_long_name[lty_stat], + pct_info.fthresh.get_str(","), + pct_info.othresh.get_str(), + alpha); } // Store the statistic value - put_nc_val(n, var_name, (float) v); + stat_data[var_name].dp.buf()[n] = v; - } // end for i + } // end for i_alpha return; } //////////////////////////////////////////////////////////////////////// -void store_stat_pjc(int n, const ConcatString &col, - const PCTInfo &pct_info) { - int i = 0; - int tot; - double v; - ConcatString lty_stat, var_name; +void store_stat_all_ctc(int n, const CTSInfo &cts_info) { + for(auto &col : ctc_columns) { + store_stat_categorical(n, STATLineType::ctc, col, cts_info); + } +} - // Set the column name to all upper case - ConcatString c = to_upper(col); - ConcatString d = c; +//////////////////////////////////////////////////////////////////////// - // Get index value for variable column numbers - if(check_reg_exp("_[0-9]", c.c_str())) { +void store_stat_all_mctc(int n, const MCTSInfo &mcts_info) { + StringArray mctc_cols(get_mctc_columns(mcts_info.cts.nrows())); + for(int i=0; i= pct_info.pct.nrows()) { - mlog << Error << "\nstore_stat_pjc() -> " - << "range check error for column name requested \"" << c - << "\"\n\n"; - exit(1); - } - } // end if - - // Store the total count - tot = pct_info.pct.n(); - - // Get the column value - if(c == "TOTAL") { v = (double) tot; } - else if(c == "N_THRESH") { v = (double) pct_info.pct.nrows() + 1; } - else if(check_reg_exp("THRESH_[0-9]", c.c_str())) { v = pct_info.pct.threshold(i); - d = "THRESH_I"; } - else if(check_reg_exp("OY_TP_[0-9]", c.c_str())) { v = pct_info.pct.event_count_by_row(i)/(double) tot; - d = "OY_TP_I"; } - else if(check_reg_exp("ON_TP_[0-9]", c.c_str())) { v = pct_info.pct.nonevent_count_by_row(i)/(double) tot; - d = "ON_TP_I"; } - else if(check_reg_exp("CALIBRATION_[0-9]", c.c_str())) { v = pct_info.pct.row_calibration(i); - d = "CALIBRATION_I"; } - else if(check_reg_exp("REFINEMENT_[0-9]", c.c_str())) { v = pct_info.pct.row_refinement(i); - d = "REFINEMENT_I"; } - else if(check_reg_exp("LIKELIHOOD_[0-9]", c.c_str())) { v = pct_info.pct.row_event_likelihood(i); - d = "LIKELIHOOD_I"; } - else if(check_reg_exp("BASER_[0-9]", c.c_str())) { v = pct_info.pct.row_obar(i); - d = "BASER_I"; } - else { - mlog << Error << "\nstore_stat_pjc() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); +void store_stat_all_sl1l2(int n, const SL1L2Info &s_info) { + for(auto &col : sl1l2_columns) { + store_stat_partialsums(n, STATLineType::sl1l2, col, s_info); + } +} + +//////////////////////////////////////////////////////////////////////// + +void store_stat_all_sal1l2(int n, const SL1L2Info &s_info) { + for(auto &col : sal1l2_columns) { + store_stat_partialsums(n, STATLineType::sal1l2, col, s_info); } +} - // Construct the NetCDF variable name - var_name << cs_erase << "series_pjc_" << c - << "_obs" << pct_info.othresh.get_abbr_str(); +//////////////////////////////////////////////////////////////////////// - // Add map for this variable name - if(stat_data.count(var_name) == 0) { +void store_stat_all_pct(int n, const PCTInfo &pct_info) { + StringArray pct_cols(get_pct_columns(pct_info.pct.nrows() + 1)); + for(int i=0; i= pct_info.pct.nrows()) { - mlog << Error << "\nstore_stat_prc() -> " - << "range check error for column name requested \"" << c - << "\"\n\n"; - exit(1); - } +//////////////////////////////////////////////////////////////////////// - // Get the 2x2 contingency table for this row - ct = pct_info.pct.ctc_by_row(i); +ConcatString build_nc_var_name_partialsums( + STATLineType lt, const ConcatString &col, + const SL1L2Info &s_info) { - } // end if + // Append the column name + ConcatString var_name("series_"); + var_name << to_lower(statlinetype_to_string(lt)) << "_" << col; - // Get the column value - if(c == "TOTAL") { v = (double) pct_info.pct.n(); } - else if(c == "N_THRESH") { v = (double) pct_info.pct.nrows() + 1; } - else if(check_reg_exp("THRESH_[0-9]", c.c_str())) { v = pct_info.pct.threshold(i); - d = "THRESH_I"; } - else if(check_reg_exp("PODY_[0-9]", c.c_str())) { v = ct.pod_yes(); - d = "PODY_I"; } - else if(check_reg_exp("POFD_[0-9]", c.c_str())) { v = ct.pofd(); - d = "POFD_I"; } - else { - mlog << Error << "\nstore_stat_prc() -> " - << "unsupported column name requested \"" << c - << "\"\n\n"; - exit(1); + // Append threshold information, if supplied + if(s_info.fthresh.get_type() != thresh_na || + s_info.othresh.get_type() != thresh_na) { + var_name << "_fcst" << s_info.fthresh.get_abbr_str() + << "_" << setlogic_to_abbr(s_info.logic) + << "_obs" << s_info.othresh.get_abbr_str(); } - // Add map for this variable name - if(stat_data.count(var_name) == 0) { + return var_name; +} - // Build key - lty_stat << "PRC_" << d; +//////////////////////////////////////////////////////////////////////// - // Add new map entry - add_nc_var(var_name, c, stat_long_name[lty_stat], - pct_info.fthresh.get_str(","), - pct_info.othresh.get_str(), - bad_data_double); +ConcatString build_nc_var_name_continuous( + STATLineType lt, const ConcatString &col, + const CNTInfo &cnt_info, double alpha) { + + // Append the column name + ConcatString var_name("series_"); + var_name << to_lower(statlinetype_to_string(lt)) << "_" << col; + + // Append threshold information, if supplied + if(cnt_info.fthresh.get_type() != thresh_na || + cnt_info.othresh.get_type() != thresh_na) { + var_name << "_fcst" << cnt_info.fthresh.get_abbr_str() + << "_" << setlogic_to_abbr(cnt_info.logic) + << "_obs" << cnt_info.othresh.get_abbr_str(); } - // Store the statistic value - put_nc_val(n, var_name, (float) v); + // Append confidence interval alpha value + if(!is_bad_data(alpha)) var_name << "_a" << alpha; - return; + return var_name; +} + +//////////////////////////////////////////////////////////////////////// + +ConcatString build_nc_var_name_probabilistic( + STATLineType lt, const ConcatString &col, + const PCTInfo &pct_info, double alpha) { + + // Append the column name + ConcatString var_name("series_"); + var_name << to_lower(statlinetype_to_string(lt)) << "_" << col; + + // Append the observation threshold + var_name << "_obs" << pct_info.othresh.get_abbr_str(); + + // Append confidence interval alpha value + if(!is_bad_data(alpha)) var_name << "_a" << alpha; + + return var_name; } //////////////////////////////////////////////////////////////////////// @@ -2200,9 +2204,10 @@ void setup_nc_file(const VarInfo *fcst_info, const VarInfo *obs_info) { if (deflate_level < 0) deflate_level = conf_info.get_compression_level(); // Add the series length variable - NcVar var = add_var(nc_out, "n_series", ncInt, deflate_level); + NcVar var = add_var(nc_out, n_series_var_name, ncInt, deflate_level); add_att(&var, "long_name", "length of series"); + int n_series = n_series_pair + n_series_aggr; if(!put_nc_data(&var, &n_series)) { mlog << Error << "\nsetup_nc_file() -> " << "error writing the series length variable.\n\n"; @@ -2217,68 +2222,77 @@ void setup_nc_file(const VarInfo *fcst_info, const VarInfo *obs_info) { //////////////////////////////////////////////////////////////////////// -void add_nc_var(const ConcatString &var_name, - const ConcatString &name, - const ConcatString &long_name, - const ConcatString &fcst_thresh, - const ConcatString &obs_thresh, - double alpha) { - NcVarData d; - - int deflate_level = compress_level; - if (deflate_level < 0) deflate_level = conf_info.get_compression_level(); - - // Add a new variable to the NetCDF file - NcVar var = add_var(nc_out, (string)var_name, ncFloat, lat_dim, lon_dim, deflate_level); - d.var = new NcVar(var); - - // Add variable attributes - add_att(d.var, "_FillValue", bad_data_float); - if(name.length() > 0) add_att(d.var, "name", (string)name); - if(long_name.length() > 0) add_att(d.var, "long_name", (string)long_name); - if(fcst_thresh.length() > 0) add_att(d.var, "fcst_thresh", (string)fcst_thresh); - if(obs_thresh.length() > 0) add_att(d.var, "obs_thresh", (string)obs_thresh); - if(!is_bad_data(alpha)) add_att(d.var, "alpha", alpha); - - // Store the new NcVarData object in the map - stat_data[var_name] = d; +void add_stat_data(const ConcatString &var_name, + const ConcatString &name, + const ConcatString &long_name, + const ConcatString &fcst_thresh, + const ConcatString &obs_thresh, + double alpha) { + + NcVarData data; + data.dp.set_size(grid.nx(), grid.ny(), bad_data_double); + data.name = name; + data.long_name = long_name; + data.fcst_thresh = fcst_thresh; + data.obs_thresh = obs_thresh; + data.alpha = alpha; + + // Store the new NcVarData object + stat_data[var_name] = data; + stat_data_keys.push_back(var_name); return; } //////////////////////////////////////////////////////////////////////// -void put_nc_val(int n, const ConcatString &var_name, float v) { - int x, y; +void write_stat_data() { - // Determine x,y location - DefaultTO.one_to_two(grid.nx(), grid.ny(), n, x, y); + mlog << Debug(2) + << "Writing " << stat_data_keys.size() + << " output variables.\n"; - // Check for key in the map - if(stat_data.count(var_name) == 0) { - mlog << Error << "\nput_nc_val() -> " - << "variable name \"" << var_name - << "\" does not exist in the map.\n\n"; - exit(1); + int deflate_level = compress_level; + if(deflate_level < 0) deflate_level = conf_info.get_compression_level(); + + // Allocate memory to store data values for each grid point + float *data = new float [grid.nx()*grid.ny()]; + + // Write output for each stat_data map entry + for(auto &key : stat_data_keys) { + + NcVarData *ptr = &stat_data[key]; + + // Add a new variable to the NetCDF file + NcVar nc_var = add_var(nc_out, key, ncFloat, lat_dim, lon_dim, deflate_level); + + // Add variable attributes + add_att(&nc_var, "_FillValue", bad_data_float); + add_att(&nc_var, "name", ptr->name); + add_att(&nc_var, "long_name", ptr->long_name); + if(ptr->fcst_thresh.length() > 0) add_att(&nc_var, "fcst_thresh", ptr->fcst_thresh); + if(ptr->obs_thresh.length() > 0) add_att(&nc_var, "obs_thresh", ptr->obs_thresh); + if(!is_bad_data(ptr->alpha)) add_att(&nc_var, "alpha", ptr->alpha); + + // Store the data + for(int x=0; xdp(x, y); + } // end for y + } // end for x + + // Write out the data + if(!put_nc_data_with_dims(&nc_var, &data[0], grid.ny(), grid.nx())) { + mlog << Error << "\nwrite_stat_data() -> " + << R"(error writing ")" << key + << R"(" data to the output file.)" << "\n\n"; + exit(1); + } } - // Get the NetCDF variable to be written - NcVar *var = stat_data[var_name].var; - - long offsets[2]; - long lengths[2]; - offsets[0] = y; - offsets[1] = x; - lengths[0] = 1; - lengths[1] = 1; - - // Store the current value - if(!put_nc_data(var, &v, lengths, offsets)) { - mlog << Error << "\nput_nc_val() -> " - << "error writing to variable " << var_name - << " for point (" << x << ", " << y << ").\n\n"; - exit(1); - } + // Clean up + if(data) { delete [] data; data = (float *) nullptr; } return; } @@ -2311,25 +2325,23 @@ void set_range(const int &t, int &beg, int &end) { void clean_up() { - // Deallocate NetCDF variable for each map entry - map::const_iterator it; - for(it=stat_data.begin(); it!=stat_data.end(); it++) { - if(it->second.var) { delete it->second.var; } - } - // Close the output NetCDF file if(nc_out) { // List the NetCDF file after it is finished - mlog << Debug(1) << "Output file: " << out_file << "\n"; + mlog << Debug(1) + << "Output file: " << out_file << "\n"; delete nc_out; nc_out = (NcFile *) nullptr; } + // Close the aggregate NetCDF file + if(aggr_nc.MetNc) aggr_nc.close(); + // Deallocate memory for data files - if(fcst_mtddf) { delete fcst_mtddf; fcst_mtddf = (Met2dDataFile *) nullptr; } - if(obs_mtddf) { delete obs_mtddf; obs_mtddf = (Met2dDataFile *) nullptr; } + if(fcst_mtddf) { delete fcst_mtddf; fcst_mtddf = nullptr; } + if(obs_mtddf) { delete obs_mtddf; obs_mtddf = nullptr; } // Deallocate memory for the random number generator rng_free(rng_ptr); @@ -2348,6 +2360,7 @@ void usage() { << "\t-fcst file_1 ... file_n | fcst_file_list\n" << "\t-obs file_1 ... file_n | obs_file_list\n" << "\t[-both file_1 ... file_n | both_file_list]\n" + << "\t[-aggr file]\n" << "\t[-paired]\n" << "\t-out file\n" << "\t-config file\n" @@ -2355,37 +2368,53 @@ void usage() { << "\t[-v level]\n" << "\t[-compress level]\n\n" - << "\twhere\t\"-fcst file_1 ... file_n\" are the gridded " + << "\twhere\t" + << R"("-fcst file_1 ... file_n" are the gridded )" << "forecast files to be used (required).\n" - << "\t\t\"-fcst fcst_file_list\" is an ASCII file containing " + << "\t\t" + << R"("-fcst fcst_file_list" is an ASCII file containing )" << "a list of gridded forecast files to be used (required).\n" - << "\t\t\"-obs file_1 ... file_n\" are the gridded " + << "\t\t" + << R"("-obs file_1 ... file_n" are the gridded )" << "observation files to be used (required).\n" - << "\t\t\"-obs obs_file_list\" is an ASCII file containing " + << "\t\t" + << R"("-obs obs_file_list" is an ASCII file containing )" << "a list of gridded observation files to be used (required).\n" - << "\t\t\"-both\" sets the \"-fcst\" and \"-obs\" options to " + << "\t\t" + << R"("-both" sets the "-fcst" and "-obs" options to )" << "the same set of files (optional).\n" - << "\t\t\"-paired\" to indicate that the input -fcst and -obs " + << "\t\t" + << R"("-aggr file" specifies a series_analysis output )" + << "file with partial sums and/or contingency table counts to be " + << "updated prior to deriving statistics (optional).\n" + + << "\t\t" + << R"("-paired" to indicate that the input -fcst and -obs )" << "file lists are already paired (optional).\n" - << "\t\t\"-out file\" is the NetCDF output file containing " + << "\t\t" + << R"("-out file" is the NetCDF output file containing )" << "computed statistics (required).\n" - << "\t\t\"-config file\" is a SeriesAnalysisConfig file " + << "\t\t" + << R"("-config file" is a SeriesAnalysisConfig file )" << "containing the desired configuration settings (required).\n" - << "\t\t\"-log file\" outputs log messages to the specified " + << "\t\t" + << R"("-log file" outputs log messages to the specified )" << "file (optional).\n" - << "\t\t\"-v level\" overrides the default level of logging (" + << "\t\t" + << R"("-v level" overrides the default level of logging ()" << mlog.verbosity_level() << ") (optional).\n" - << "\t\t\"-compress level\" overrides the compression level of NetCDF variable (" + << "\t\t" + << R"("-compress level" overrides the compression level of NetCDF variable ()" << conf_info.get_compression_level() << ") (optional).\n\n" << flush; exit(1); @@ -2412,6 +2441,12 @@ void set_both_files(const StringArray & a) { //////////////////////////////////////////////////////////////////////// +void set_aggr(const StringArray & a) { + aggr_file = a[0]; +} + +//////////////////////////////////////////////////////////////////////// + void set_paired(const StringArray & a) { paired = true; } @@ -2449,8 +2484,8 @@ void parse_long_names() { f_in.open(file_name.c_str()); if(!f_in) { mlog << Error << "\nparse_long_names() -> " - << "can't open the ASCII file \"" << file_name - << "\" for reading\n\n"; + << R"(can't open the ASCII file ") << file_name + << R"(" for reading!)" << "\n\n"; exit(1); } diff --git a/src/tools/core/series_analysis/series_analysis.h b/src/tools/core/series_analysis/series_analysis.h index 2540540015..73b2f3d6f6 100644 --- a/src/tools/core/series_analysis/series_analysis.h +++ b/src/tools/core/series_analysis/series_analysis.h @@ -17,7 +17,6 @@ // 000 12/10/12 Halley Gotway New // 001 09/28/22 Prestopnik MET #2227 Remove namespace std and netCDF from header files // -// //////////////////////////////////////////////////////////////////////// #ifndef __SERIES_ANALYSIS_H__ @@ -43,6 +42,7 @@ #include "series_analysis_conf_info.h" #include "vx_data2d_factory.h" +#include "vx_data2d_nc_met.h" #include "vx_grid.h" #include "vx_util.h" #include "vx_stat_out.h" @@ -60,6 +60,11 @@ static const char * program_name = "series_analysis"; static const char * default_config_filename = "MET_BASE/config/SeriesAnalysisConfig_default"; +static const char * all_columns = "ALL"; +static const char * n_series_var_name = "n_series"; + +static const char * total_name = "TOTAL"; + //////////////////////////////////////////////////////////////////////// // // Variables for Command Line Arguments @@ -68,10 +73,11 @@ static const char * default_config_filename = // Input files static StringArray fcst_files, found_fcst_files; -static StringArray obs_files, found_obs_files; -static GrdFileType ftype = FileType_None; -static GrdFileType otype = FileType_None; -static bool paired = false; +static StringArray obs_files, found_obs_files; +static GrdFileType ftype = FileType_None; +static GrdFileType otype = FileType_None; +static ConcatString aggr_file; +static bool paired = false; static int compress_level = -1; // Output file @@ -88,17 +94,26 @@ static SeriesAnalysisConfInfo conf_info; //////////////////////////////////////////////////////////////////////// // Output NetCDF file -static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; -static netCDF::NcDim lat_dim; -static netCDF::NcDim lon_dim ; +static netCDF::NcFile *nc_out = nullptr; +static netCDF::NcDim lat_dim; +static netCDF::NcDim lon_dim ; -// Structure to store computed statistics and corresponding metadata +// Structure to store computed statistics struct NcVarData { - netCDF::NcVar * var; // Pointer to NetCDF variable + DataPlane dp; + std::string name; + std::string long_name; + std::string fcst_thresh; + std::string obs_thresh; + double alpha; }; // Mapping of NetCDF variable name to computed statistic -std::map stat_data; +std::map stat_data; +std::vector stat_data_keys; + +// Mapping of aggregate NetCDF variable name to DataPlane +std::map aggr_data; //////////////////////////////////////////////////////////////////////// // @@ -108,16 +123,16 @@ std::map stat_data; // Grid variables static Grid grid; -static int nxy = 0; static int n_reads = 1; // Initialize to at least one pass // Data file factory and input files static Met2dDataFileFactory mtddf_factory; -static Met2dDataFile *fcst_mtddf = (Met2dDataFile *) nullptr; -static Met2dDataFile *obs_mtddf = (Met2dDataFile *) nullptr; +static Met2dDataFile *fcst_mtddf = nullptr; +static Met2dDataFile *obs_mtddf = nullptr; +static MetNcMetDataFile aggr_nc; // Pointer to the random number generator to be used -static gsl_rng *rng_ptr = (gsl_rng *) nullptr; +static gsl_rng *rng_ptr = nullptr; // Enumeration of ways that a series can be defined enum class SeriesType { @@ -130,7 +145,8 @@ enum class SeriesType { static SeriesType series_type = SeriesType::None; // Series length -static int n_series = 0; +static int n_series_pair = 0; // Input pair data series +static int n_series_aggr = 0; // Input aggr series // Range of timing values encountered in the data static unixtime fcst_init_beg = (unixtime) 0; diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 441cbe5e07..6c0a7add52 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -706,7 +706,7 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, else if(do_cnt && (line.type() == STATLineType::sl1l2 || line.type() == STATLineType::sal1l2)) { parse_sl1l2_line(line, sl1l2_info); - compute_cntinfo(sl1l2_info, 0, cnt_info); + compute_cntinfo(sl1l2_info, cnt_info); } // @@ -731,7 +731,7 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // if((line.type() == STATLineType::fho || line.type() == STATLineType::ctc) && lty == STATLineType::cts) { - v = cts_info.get_stat(req_col[i].c_str()); + v = cts_info.get_stat_cts(req_col[i].c_str()); w = cts_info.cts.n(); } else if(line.type() == STATLineType::sl1l2 && lty == STATLineType::cnt) { @@ -743,7 +743,7 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, w = cnt_info.n; } else if(line.type() == STATLineType::vl1l2 && lty == STATLineType::vcnt) { - v = vl1l2_info.get_stat(req_col[i].c_str()); + v = vl1l2_info.get_stat_vcnt(req_col[i].c_str()); w = (is_vector_dir_stat(line.type(), req_col[i].c_str()) ? vl1l2_info.dcount : vl1l2_info.vcount); @@ -1519,7 +1519,7 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, // // Compute the stats for the current time // - compute_cntinfo(cur_sl1l2, 0, cur_cnt); + compute_cntinfo(cur_sl1l2, cur_cnt); // // Append the stats diff --git a/src/tools/core/stat_analysis/skill_score_index_job.cc b/src/tools/core/stat_analysis/skill_score_index_job.cc index 9651e50a0d..88bc450900 100644 --- a/src/tools/core/stat_analysis/skill_score_index_job.cc +++ b/src/tools/core/stat_analysis/skill_score_index_job.cc @@ -245,17 +245,17 @@ SSIDXData SSIndexJobInfo::compute_ss_index() { // Continuous stats if(job_lt[i] == STATLineType::sl1l2) { - compute_cntinfo(fcst_sl1l2[i], 0, fcst_cnt); + compute_cntinfo(fcst_sl1l2[i], fcst_cnt); fcst_stat = fcst_cnt.get_stat(fcst_job[i].column[0].c_str()); - compute_cntinfo(ref_sl1l2[i], 0, ref_cnt); + compute_cntinfo(ref_sl1l2[i], ref_cnt); ref_stat = ref_cnt.get_stat(fcst_job[i].column[0].c_str()); } // Categorical stats else if(job_lt[i] == STATLineType::ctc) { fcst_cts[i].compute_stats(); - fcst_stat = fcst_cts[i].get_stat(fcst_job[i].column[0].c_str()); + fcst_stat = fcst_cts[i].get_stat_cts(fcst_job[i].column[0].c_str()); ref_cts[i].compute_stats(); - ref_stat = ref_cts[i].get_stat(fcst_job[i].column[0].c_str()); + ref_stat = ref_cts[i].get_stat_cts(fcst_job[i].column[0].c_str()); } else { mlog << Error << "\nSSIndexJobInfo::compute_ss_index() -> " diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index 3492309da1..b3a9eb12cb 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -1876,10 +1876,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // Compute CNTInfo statistics from the aggregated partial sums // - if(it->second.sl1l2_info.scount > 0) - compute_cntinfo(it->second.sl1l2_info, 0, it->second.cnt_info); - else - compute_cntinfo(it->second.sl1l2_info, 1, it->second.cnt_info); + compute_cntinfo(it->second.sl1l2_info, it->second.cnt_info); if(job.stat_out) { write_cnt_cols(it->second.cnt_info, 0, job.stat_at, @@ -2610,7 +2607,7 @@ void write_job_aggr_ssvar(STATAnalysisJob &job, STATLineType lt, // // Compute CNTInfo statistics from the aggregated partial sums // - compute_cntinfo(bin_it->second.sl1l2_info, 0, cnt_info); + compute_cntinfo(bin_it->second.sl1l2_info, cnt_info); // // Write the output STAT line From c5fa790b1740ce4bc320a226ca1bd38f8d97a253 Mon Sep 17 00:00:00 2001 From: Julie Prestopnik Date: Tue, 3 Sep 2024 13:31:17 -0600 Subject: [PATCH 112/114] Feature 2948 cxx17 (#2953) * Per #2948, updating versions of ecbuild, eckit, and atlas * Per #2948, Adding MET_CXX_STANDARD * Per #2948, updated wording for MET_CXX_STANDARD description * Per #2948, updating script to work with two versions of ecbuild, eckit, and atlas * Per #2948, without this change, there are compilation problems if the user wants to compile wihtout python * Per #2948, fixing logic for MET_CXX_STANDARD * Per #2928, adding missing end bracket * Per #2948, fixed the logic for compiling versions of ecbuild, eckit, and atlas * Per 948, fixed syntax for setting CXXFLAGS * Per #2948, adding new Makefile.in files and configure and changing METbaseimage 3.2 to 3.3. * Per #2948, updating version of met base tag from 3.2 to 3.3 * Per #2948, adding --enable-all MET_CXX_STANDARD=11 job * Update compilation_options.yml * Per #2948, added a job10 for MET_CXX_STANDARD=14 * Per #2948, added brief documentation for the MET_CXX_STANDARD option --------- Co-authored-by: Julie Prestopnik Co-authored-by: John Halley Gotway --- .github/jobs/set_job_controls.sh | 2 +- .../build_docker_and_trigger_metplus.yml | 2 +- .github/workflows/compilation_options.yml | 4 +++ .github/workflows/sonarqube.yml | 2 +- Makefile.in | 1 + configure | 27 +++++++++++++++++- configure.ac | 20 ++++++++++++- data/Makefile.in | 1 + data/climo/Makefile.in | 1 + data/climo/seeps/Makefile.in | 1 + data/colortables/Makefile.in | 1 + data/colortables/NCL_colortables/Makefile.in | 1 + data/config/Makefile.in | 1 + data/map/Makefile.in | 1 + data/map/admin_by_country/Makefile.in | 1 + data/poly/HMT_masks/Makefile.in | 1 + data/poly/Makefile.in | 1 + data/poly/NCEP_masks/Makefile.in | 1 + data/ps/Makefile.in | 1 + data/table_files/Makefile.in | 1 + data/tc_data/Makefile.in | 1 + docs/Users_Guide/installation.rst | 10 +++++-- internal/scripts/docker/Dockerfile | 2 +- internal/scripts/docker/Dockerfile.copy | 2 +- internal/scripts/docker/Dockerfile.sonarqube | 2 +- .../scripts/installation/compile_MET_all.sh | 28 ++++++++++++++----- internal/test_util/Makefile.in | 1 + internal/test_util/basic/Makefile.in | 1 + .../test_util/basic/vx_config/Makefile.in | 1 + internal/test_util/basic/vx_log/Makefile.in | 1 + internal/test_util/basic/vx_util/Makefile.in | 1 + internal/test_util/libcode/Makefile.in | 1 + .../test_util/libcode/vx_data2d/Makefile.in | 1 + .../libcode/vx_data2d_factory/Makefile.in | 1 + .../libcode/vx_data2d_grib/Makefile.in | 1 + .../libcode/vx_data2d_nc_cf/Makefile.in | 1 + .../libcode/vx_data2d_nc_met/Makefile.in | 1 + .../test_util/libcode/vx_geodesy/Makefile.in | 1 + .../test_util/libcode/vx_grid/Makefile.in | 1 + .../test_util/libcode/vx_nc_util/Makefile.in | 1 + .../test_util/libcode/vx_physics/Makefile.in | 1 + .../libcode/vx_plot_util/Makefile.in | 1 + internal/test_util/libcode/vx_ps/Makefile.in | 1 + .../libcode/vx_python3_utils/Makefile.in | 1 + .../libcode/vx_series_data/Makefile.in | 1 + .../test_util/libcode/vx_solar/Makefile.in | 1 + .../test_util/libcode/vx_tc_util/Makefile.in | 1 + internal/test_util/tools/Makefile.in | 1 + internal/test_util/tools/other/Makefile.in | 1 + .../tools/other/mode_time_domain/Makefile.in | 1 + scripts/Rscripts/Makefile.in | 1 + scripts/Rscripts/include/Makefile.in | 1 + scripts/python/Makefile.in | 1 + scripts/python/examples/Makefile.in | 1 + scripts/python/met/Makefile.in | 1 + scripts/python/pyembed/Makefile.in | 1 + scripts/python/tc_diag/Makefile.in | 1 + scripts/python/tc_diag/atcf_tools/Makefile.in | 1 + scripts/python/tc_diag/config/Makefile.in | 1 + scripts/python/tc_diag/diag_lib/Makefile.in | 1 + .../python/tc_diag/tc_diag_driver/Makefile.in | 1 + scripts/python/utility/Makefile.in | 1 + src/Makefile.in | 1 + src/basic/Makefile.in | 1 + src/basic/enum_to_string/Makefile.in | 1 + src/basic/vx_cal/Makefile.in | 1 + src/basic/vx_config/Makefile.in | 1 + src/basic/vx_log/Makefile.in | 1 + src/basic/vx_math/Makefile.in | 1 + src/basic/vx_util/Makefile.in | 1 + src/basic/vx_util_math/Makefile.in | 1 + src/libcode/Makefile.in | 1 + src/libcode/vx_afm/Makefile.in | 1 + src/libcode/vx_analysis_util/Makefile.in | 1 + src/libcode/vx_bool_calc/Makefile.in | 1 + src/libcode/vx_color/Makefile.in | 1 + src/libcode/vx_data2d/Makefile.in | 1 + src/libcode/vx_data2d_factory/Makefile.in | 1 + src/libcode/vx_data2d_grib/Makefile.in | 1 + src/libcode/vx_data2d_grib2/Makefile.in | 1 + src/libcode/vx_data2d_nc_cf/Makefile.in | 1 + src/libcode/vx_data2d_nc_met/Makefile.in | 1 + src/libcode/vx_data2d_nc_wrf/Makefile.in | 1 + src/libcode/vx_data2d_python/Makefile.in | 1 + src/libcode/vx_data2d_ugrid/Makefile.in | 1 + src/libcode/vx_geodesy/Makefile.in | 1 + src/libcode/vx_gis/Makefile.in | 1 + src/libcode/vx_gnomon/Makefile.in | 1 + src/libcode/vx_grid/Makefile.in | 1 + src/libcode/vx_gsl_prob/Makefile.in | 1 + src/libcode/vx_nav/Makefile.in | 1 + src/libcode/vx_nc_obs/Makefile.in | 1 + src/libcode/vx_nc_util/Makefile.in | 1 + src/libcode/vx_pb_util/Makefile.in | 1 + src/libcode/vx_physics/Makefile.in | 1 + src/libcode/vx_plot_util/Makefile.in | 1 + src/libcode/vx_pointdata_python/Makefile.in | 1 + src/libcode/vx_ps/Makefile.in | 1 + src/libcode/vx_pxm/Makefile.in | 1 + src/libcode/vx_python3_utils/Makefile.in | 1 + src/libcode/vx_regrid/Makefile.in | 1 + src/libcode/vx_render/Makefile.in | 1 + src/libcode/vx_seeps/Makefile.in | 1 + src/libcode/vx_series_data/Makefile.in | 1 + src/libcode/vx_shapedata/Makefile.in | 1 + src/libcode/vx_solar/Makefile.in | 1 + src/libcode/vx_stat_out/Makefile.in | 1 + src/libcode/vx_statistics/Makefile.in | 1 + src/libcode/vx_summary/Makefile.in | 1 + src/libcode/vx_tc_util/Makefile.in | 1 + src/libcode/vx_time_series/Makefile.in | 1 + src/tools/Makefile.in | 1 + src/tools/core/Makefile.in | 1 + src/tools/core/ensemble_stat/Makefile.in | 1 + src/tools/core/grid_stat/Makefile.in | 1 + src/tools/core/mode/Makefile.in | 1 + src/tools/core/mode_analysis/Makefile.in | 1 + src/tools/core/pcp_combine/Makefile.in | 1 + src/tools/core/point_stat/Makefile.in | 1 + src/tools/core/series_analysis/Makefile.in | 1 + src/tools/core/stat_analysis/Makefile.in | 1 + src/tools/core/wavelet_stat/Makefile.in | 1 + src/tools/dev_utils/Makefile.in | 1 + src/tools/dev_utils/shapefiles/Makefile.in | 1 + src/tools/other/Makefile.in | 1 + src/tools/other/ascii2nc/Makefile.in | 1 + src/tools/other/gen_ens_prod/Makefile.in | 1 + src/tools/other/gen_vx_mask/Makefile.in | 1 + src/tools/other/gis_utils/Makefile.in | 1 + src/tools/other/grid_diag/Makefile.in | 1 + src/tools/other/gsi_tools/Makefile.in | 1 + src/tools/other/ioda2nc/Makefile.in | 1 + src/tools/other/lidar2nc/Makefile.in | 1 + src/tools/other/madis2nc/Makefile.in | 1 + src/tools/other/mode_graphics/Makefile.in | 1 + src/tools/other/mode_time_domain/Makefile.in | 1 + src/tools/other/modis_regrid/Makefile.in | 1 + src/tools/other/pb2nc/Makefile.in | 1 + src/tools/other/plot_data_plane/Makefile.in | 1 + src/tools/other/plot_point_obs/Makefile.in | 1 + src/tools/other/point2grid/Makefile.in | 1 + src/tools/other/regrid_data_plane/Makefile.in | 1 + src/tools/other/shift_data_plane/Makefile.in | 1 + src/tools/other/wwmca_tool/Makefile.in | 1 + src/tools/tc_utils/Makefile.in | 1 + src/tools/tc_utils/rmw_analysis/Makefile.in | 1 + src/tools/tc_utils/tc_diag/Makefile.in | 1 + src/tools/tc_utils/tc_dland/Makefile.in | 1 + src/tools/tc_utils/tc_gen/Makefile.in | 1 + src/tools/tc_utils/tc_pairs/Makefile.in | 1 + src/tools/tc_utils/tc_rmw/Makefile.in | 1 + src/tools/tc_utils/tc_stat/Makefile.in | 1 + 152 files changed, 224 insertions(+), 18 deletions(-) diff --git a/.github/jobs/set_job_controls.sh b/.github/jobs/set_job_controls.sh index 10f3b4c21e..aa72ad4162 100755 --- a/.github/jobs/set_job_controls.sh +++ b/.github/jobs/set_job_controls.sh @@ -6,7 +6,7 @@ run_unit_tests=false run_diff=false run_update_truth=false met_base_repo=met-base -met_base_tag=v3.2 +met_base_tag=v3.3 input_data_version=develop truth_data_version=develop diff --git a/.github/workflows/build_docker_and_trigger_metplus.yml b/.github/workflows/build_docker_and_trigger_metplus.yml index 13606d5ed3..7d7dcce29c 100644 --- a/.github/workflows/build_docker_and_trigger_metplus.yml +++ b/.github/workflows/build_docker_and_trigger_metplus.yml @@ -29,7 +29,7 @@ jobs: env: SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }}-lite MET_BASE_REPO: met-base - MET_BASE_TAG: v3.2 + MET_BASE_TAG: v3.3 - name: Push Docker Image run: .github/jobs/push_docker_image.sh diff --git a/.github/workflows/compilation_options.yml b/.github/workflows/compilation_options.yml index 7a8dc73cf0..cf6c5fc97a 100644 --- a/.github/workflows/compilation_options.yml +++ b/.github/workflows/compilation_options.yml @@ -63,6 +63,10 @@ jobs: config: '--enable-mode_graphics' - jobid: 'job8' config: '--enable-modis' + - jobid: 'job9' + config: '--enable-all MET_CXX_STANDARD=11' + - jobid: 'job10' + config: '--enable-all MET_CXX_STANDARD=14' fail-fast: false steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 6a6627fb69..b476a488b6 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -61,7 +61,7 @@ jobs: run: .github/jobs/build_sonarqube_image.sh env: MET_BASE_REPO: met-base - MET_BASE_TAG: v3.2 + MET_BASE_TAG: v3.3 SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }} WD_REFERENCE_BRANCH: ${{ github.event.inputs.reference_branch }} SONAR_SCANNER_VERSION: 5.0.1.3006 diff --git a/Makefile.in b/Makefile.in index 582d2a65c8..0ae957d7b3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -256,6 +256,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/configure b/configure index 40672ec913..758f3502f6 100755 --- a/configure +++ b/configure @@ -797,6 +797,7 @@ MET_ATLAS MET_PROJLIB MET_PROJINC MET_PROJ +MET_CXX_STANDARD OPENMP_CFLAGS am__fastdepCC_FALSE am__fastdepCC_TRUE @@ -933,6 +934,7 @@ CFLAGS LDFLAGS LIBS CPPFLAGS +MET_CXX_STANDARD MET_PROJ MET_PROJINC MET_PROJLIB @@ -1667,6 +1669,9 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + MET_CXX_STANDARD + Specify the version of the supported C++ standard. Values may be + 11, 14, or 17. Default value is 17. MET_PROJ Where proj lib and include subdirectories are located. If they are installed in /usr/local, you don't have to specify them. MET_PROJINC Where proj include files are located. Use if the libraries and @@ -5317,6 +5322,26 @@ printf "%s\n" "$ac_cv_prog_c_openmp" >&6; } CPPFLAGS="${CPPFLAGS} ${OPENMP_CFLAGS}" LDFLAGS="${LDFLAGS} ${OPENMP_CFLAGS}" +# +# Look for a specified C++ Standard +# + +# Configure the variable. The help text will appear if the user uses "configure --help". + + + +# Set a default value + +if (test -z "$MET_CXX_STANDARD"); then + MET_CXX_STANDARD=17 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: c++17 will be used as the C++ standard" >&5 +printf "%s\n" "$as_me: c++17 will be used as the C++ standard" >&6;} +elif (test -n "$MET_CXX_STANDARD"); then + MET_CXX_STANDARD=${MET_CXX_STANDARD} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: MET_CXX_STANDARD will be set" >&5 +printf "%s\n" "$as_me: MET_CXX_STANDARD will be set" >&6;} +fi + # # Look for the Proj library. # @@ -6988,7 +7013,7 @@ fi CPPFLAGS=$CPPFLAGS' -DMET_BASE="\"$(pkgdatadir)\""' # Add -std=c++11 to CXXFLAGS -CXXFLAGS=$CXXFLAGS' -std=c++11' +CXXFLAGS=$CXXFLAGS' -std=c++'$MET_CXX_STANDARD # Define other variables for the makefiles diff --git a/configure.ac b/configure.ac index 2f8159d58c..03436847af 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,24 @@ AC_OPENMP() CPPFLAGS="${CPPFLAGS} ${OPENMP_CFLAGS}" LDFLAGS="${LDFLAGS} ${OPENMP_CFLAGS}" +# +# Look for a specified C++ Standard +# + +# Configure the variable. The help text will appear if the user uses "configure --help". + +AC_ARG_VAR([MET_CXX_STANDARD], [Specify the version of the supported C++ standard. Values may be 11, 14, or 17. Default value is 17.]) + +# Set a default value + +if (test -z "$MET_CXX_STANDARD"); then + MET_CXX_STANDARD=17 + AC_MSG_NOTICE([c++17 will be used as the C++ standard]) +elif (test -n "$MET_CXX_STANDARD"); then + MET_CXX_STANDARD=${MET_CXX_STANDARD} + AC_MSG_NOTICE([MET_CXX_STANDARD will be set]) +fi + # # Look for the Proj library. # @@ -1160,7 +1178,7 @@ AM_CONDITIONAL([ENABLE_DEVELOPMENT], [test -n "$MET_DEVELOPMENT"]) CPPFLAGS=$CPPFLAGS' -DMET_BASE="\"$(pkgdatadir)\""' # Add -std=c++11 to CXXFLAGS -CXXFLAGS=$CXXFLAGS' -std=c++11' +CXXFLAGS=$CXXFLAGS' -std=c++'$MET_CXX_STANDARD # Define other variables for the makefiles diff --git a/data/Makefile.in b/data/Makefile.in index 262e9e43cc..43aab3f3d9 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -260,6 +260,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/climo/Makefile.in b/data/climo/Makefile.in index c6415ac06c..0030bfbd90 100644 --- a/data/climo/Makefile.in +++ b/data/climo/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/climo/seeps/Makefile.in b/data/climo/seeps/Makefile.in index 761a867e6b..f40096bb49 100644 --- a/data/climo/seeps/Makefile.in +++ b/data/climo/seeps/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/colortables/Makefile.in b/data/colortables/Makefile.in index 82b6b46710..05fcc3df5a 100644 --- a/data/colortables/Makefile.in +++ b/data/colortables/Makefile.in @@ -260,6 +260,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/colortables/NCL_colortables/Makefile.in b/data/colortables/NCL_colortables/Makefile.in index df79826d8d..1d174cffda 100644 --- a/data/colortables/NCL_colortables/Makefile.in +++ b/data/colortables/NCL_colortables/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/config/Makefile.in b/data/config/Makefile.in index e88150a766..6ff5c30139 100644 --- a/data/config/Makefile.in +++ b/data/config/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/map/Makefile.in b/data/map/Makefile.in index a34c9c189f..12e4540ca0 100644 --- a/data/map/Makefile.in +++ b/data/map/Makefile.in @@ -260,6 +260,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/map/admin_by_country/Makefile.in b/data/map/admin_by_country/Makefile.in index 3f36ae61fb..825f9576c6 100644 --- a/data/map/admin_by_country/Makefile.in +++ b/data/map/admin_by_country/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/poly/HMT_masks/Makefile.in b/data/poly/HMT_masks/Makefile.in index 7284d8de7d..305405cc2a 100644 --- a/data/poly/HMT_masks/Makefile.in +++ b/data/poly/HMT_masks/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/poly/Makefile.in b/data/poly/Makefile.in index 36890cca0a..04906070f5 100644 --- a/data/poly/Makefile.in +++ b/data/poly/Makefile.in @@ -260,6 +260,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/poly/NCEP_masks/Makefile.in b/data/poly/NCEP_masks/Makefile.in index acda936d43..4ecea4b0d0 100644 --- a/data/poly/NCEP_masks/Makefile.in +++ b/data/poly/NCEP_masks/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/ps/Makefile.in b/data/ps/Makefile.in index c017420485..2677c7fb04 100644 --- a/data/ps/Makefile.in +++ b/data/ps/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/table_files/Makefile.in b/data/table_files/Makefile.in index 08d91b866e..5f82cc573e 100644 --- a/data/table_files/Makefile.in +++ b/data/table_files/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/data/tc_data/Makefile.in b/data/tc_data/Makefile.in index 9ef1261884..eee63e1885 100644 --- a/data/tc_data/Makefile.in +++ b/data/tc_data/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/docs/Users_Guide/installation.rst b/docs/Users_Guide/installation.rst index 4540d341b4..2494abe520 100644 --- a/docs/Users_Guide/installation.rst +++ b/docs/Users_Guide/installation.rst @@ -247,7 +247,7 @@ Environment Variable Descriptions containing the bin, include, lib, and share directories for Python. **MET_PYTHON_CC** - Format is -I followed by the directory containing - the Python include files (ex. -I/usr/local/python3/include/python3.10). + the Python include files (e.g. -I/usr/local/python3/include/python3.10). This information may be obtained by running :code:`python3-config --cflags`; however, this command can, on certain systems, @@ -257,7 +257,7 @@ Environment Variable Descriptions the Python library files then a space, then -l followed by the necessary Python libraries to link to - (ex. -L/usr/local/python3/lib/\\ -lpython3.10\\ + (e.g. -L/usr/local/python3/lib/\\ -lpython3.10\\ -lpthread\\ -ldl\\ -lutil\\ -lm). The backslashes are necessary in the example shown because of the spaces, which will be @@ -285,7 +285,11 @@ Environment Variable Descriptions without a specified value of cores to use. The automated MET testing scripts in the Docker environment have been successful with a value of - 5 (ex. export MAKE_ARGS=”-j 5”). + 5 (e.g. export MAKE_ARGS=”-j 5”). + + **export MET_CXX_STANDARD** - Specify the version of the supported + C++ standard. Values may be 11, 14, or 17. The default value is 17. + (e.g. export MET_CXX_STANDARD=11). External Library Handling in compile_MET_all.sh diff --git a/internal/scripts/docker/Dockerfile b/internal/scripts/docker/Dockerfile index c5daf58492..c7a2ca5bdd 100644 --- a/internal/scripts/docker/Dockerfile +++ b/internal/scripts/docker/Dockerfile @@ -1,5 +1,5 @@ ARG MET_BASE_REPO=met-base -ARG MET_BASE_TAG=v3.2 +ARG MET_BASE_TAG=v3.3 FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG} MAINTAINER John Halley Gotway diff --git a/internal/scripts/docker/Dockerfile.copy b/internal/scripts/docker/Dockerfile.copy index 4d3d9476cd..51ae55ec3a 100644 --- a/internal/scripts/docker/Dockerfile.copy +++ b/internal/scripts/docker/Dockerfile.copy @@ -1,5 +1,5 @@ ARG MET_BASE_REPO=met-base-unit-test -ARG MET_BASE_TAG=v3.2 +ARG MET_BASE_TAG=v3.3 FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG} MAINTAINER John Halley Gotway diff --git a/internal/scripts/docker/Dockerfile.sonarqube b/internal/scripts/docker/Dockerfile.sonarqube index 75dc3c952c..e1e935d857 100644 --- a/internal/scripts/docker/Dockerfile.sonarqube +++ b/internal/scripts/docker/Dockerfile.sonarqube @@ -1,5 +1,5 @@ ARG MET_BASE_REPO=met-base -ARG MET_BASE_TAG=v3.2 +ARG MET_BASE_TAG=v3.3 FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG} MAINTAINER John Halley Gotway diff --git a/internal/scripts/installation/compile_MET_all.sh b/internal/scripts/installation/compile_MET_all.sh index 6524aa8563..2497e582a8 100755 --- a/internal/scripts/installation/compile_MET_all.sh +++ b/internal/scripts/installation/compile_MET_all.sh @@ -640,7 +640,11 @@ if [ $COMPILE_ECKIT -eq 1 ]; then # Need to obtain ecbuild before installing eckit - vrs="3.5.0" + if [[ ! -z ${MET_CXX_STANDARD} && ${MET_CXX_STANDARD} -le 14 ]]; then + vrs="3.5.0" + elif [[ -z ${MET_CXX_STANDARD} ]]; then + vrs="3.7.0" + fi echo echo "Compiling ECBUILD at `date`" @@ -652,9 +656,13 @@ if [ $COMPILE_ECKIT -eq 1 ]; then run_cmd "mkdir build; cd build" run_cmd "cmake ../ -DCMAKE_INSTALL_PREFIX=${LIB_DIR} > $(pwd)/ecbuild.cmake.log 2>&1" run_cmd "make ${MAKE_ARGS} install > $(pwd)/ecbuild.make_install.log 2>&1" - - vrs="1.20.2" + if [[ ! -z ${MET_CXX_STANDARD} && ${MET_CXX_STANDARD} -le 14 ]]; then + vrs="1.20.2" + elif [[ -z ${MET_CXX_STANDARD} ]]; then + vrs="1.24.4" + fi + echo echo "Compiling ECKIT at `date`" mkdir -p ${LIB_DIR}/eckit @@ -671,7 +679,11 @@ fi # Compile ATLAS if [ $COMPILE_ATLAS -eq 1 ]; then - vrs="0.30.0" + if [[ ! -z ${MET_CXX_STANDARD} && ${MET_CXX_STANDARD} -le 14 ]]; then + vrs="0.30.0" + elif [[ -z ${MET_CXX_STANDARD} ]]; then + vrs="0.35.0" + fi echo echo "Compiling ATLAS at `date`" @@ -862,9 +874,11 @@ if [ -z ${MET_PROJ} ]; then export MET_PROJ=${LIB_DIR} fi -export MET_PYTHON_BIN_EXE=${MET_PYTHON_BIN_EXE:=${MET_PYTHON}/bin/python3} -export MET_PYTHON_LD -export MET_PYTHON_CC +if [[ ! -z ${MET_PYTHON_CC} || ! -z ${MET_PYTHON_LD} ]]; then + export MET_PYTHON_BIN_EXE=${MET_PYTHON_BIN_EXE:=${MET_PYTHON}/bin/python3} + export MET_PYTHON_LD + export MET_PYTHON_CC +fi # add flags to user-defined LDFLAGS for MacOS if [[ $machine != "Mac" ]]; then diff --git a/internal/test_util/Makefile.in b/internal/test_util/Makefile.in index 91fbb38a04..32c2b09cef 100644 --- a/internal/test_util/Makefile.in +++ b/internal/test_util/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/basic/Makefile.in b/internal/test_util/basic/Makefile.in index 8f7a6ae5f5..eacf3b24c2 100644 --- a/internal/test_util/basic/Makefile.in +++ b/internal/test_util/basic/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/basic/vx_config/Makefile.in b/internal/test_util/basic/vx_config/Makefile.in index 259d6dae5e..11f8c27d32 100644 --- a/internal/test_util/basic/vx_config/Makefile.in +++ b/internal/test_util/basic/vx_config/Makefile.in @@ -255,6 +255,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/basic/vx_log/Makefile.in b/internal/test_util/basic/vx_log/Makefile.in index 0913f22a00..bc602758e2 100644 --- a/internal/test_util/basic/vx_log/Makefile.in +++ b/internal/test_util/basic/vx_log/Makefile.in @@ -224,6 +224,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/basic/vx_util/Makefile.in b/internal/test_util/basic/vx_util/Makefile.in index ebbef0522c..7c4663e135 100644 --- a/internal/test_util/basic/vx_util/Makefile.in +++ b/internal/test_util/basic/vx_util/Makefile.in @@ -262,6 +262,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/Makefile.in b/internal/test_util/libcode/Makefile.in index 4d4f244b34..38acababa3 100644 --- a/internal/test_util/libcode/Makefile.in +++ b/internal/test_util/libcode/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_data2d/Makefile.in b/internal/test_util/libcode/vx_data2d/Makefile.in index f659f7c81a..25f644ed86 100644 --- a/internal/test_util/libcode/vx_data2d/Makefile.in +++ b/internal/test_util/libcode/vx_data2d/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_data2d_factory/Makefile.in b/internal/test_util/libcode/vx_data2d_factory/Makefile.in index 1d93387de5..31ea2c180b 100644 --- a/internal/test_util/libcode/vx_data2d_factory/Makefile.in +++ b/internal/test_util/libcode/vx_data2d_factory/Makefile.in @@ -228,6 +228,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_data2d_grib/Makefile.in b/internal/test_util/libcode/vx_data2d_grib/Makefile.in index 5591f6439b..892f5eca9e 100644 --- a/internal/test_util/libcode/vx_data2d_grib/Makefile.in +++ b/internal/test_util/libcode/vx_data2d_grib/Makefile.in @@ -221,6 +221,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_data2d_nc_cf/Makefile.in b/internal/test_util/libcode/vx_data2d_nc_cf/Makefile.in index 52429cc106..749c25c8c9 100644 --- a/internal/test_util/libcode/vx_data2d_nc_cf/Makefile.in +++ b/internal/test_util/libcode/vx_data2d_nc_cf/Makefile.in @@ -220,6 +220,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_data2d_nc_met/Makefile.in b/internal/test_util/libcode/vx_data2d_nc_met/Makefile.in index 25fc3da12e..b02eb106d7 100644 --- a/internal/test_util/libcode/vx_data2d_nc_met/Makefile.in +++ b/internal/test_util/libcode/vx_data2d_nc_met/Makefile.in @@ -222,6 +222,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_geodesy/Makefile.in b/internal/test_util/libcode/vx_geodesy/Makefile.in index 63e759c489..f196c88c92 100644 --- a/internal/test_util/libcode/vx_geodesy/Makefile.in +++ b/internal/test_util/libcode/vx_geodesy/Makefile.in @@ -218,6 +218,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_grid/Makefile.in b/internal/test_util/libcode/vx_grid/Makefile.in index 05203d024a..9f7c65ed86 100644 --- a/internal/test_util/libcode/vx_grid/Makefile.in +++ b/internal/test_util/libcode/vx_grid/Makefile.in @@ -220,6 +220,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_nc_util/Makefile.in b/internal/test_util/libcode/vx_nc_util/Makefile.in index ad865d558f..af0e249f7b 100644 --- a/internal/test_util/libcode/vx_nc_util/Makefile.in +++ b/internal/test_util/libcode/vx_nc_util/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_physics/Makefile.in b/internal/test_util/libcode/vx_physics/Makefile.in index 02f6ef57ae..20b0102618 100644 --- a/internal/test_util/libcode/vx_physics/Makefile.in +++ b/internal/test_util/libcode/vx_physics/Makefile.in @@ -218,6 +218,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_plot_util/Makefile.in b/internal/test_util/libcode/vx_plot_util/Makefile.in index 6a950df3aa..7f6bdd6dbc 100644 --- a/internal/test_util/libcode/vx_plot_util/Makefile.in +++ b/internal/test_util/libcode/vx_plot_util/Makefile.in @@ -219,6 +219,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_ps/Makefile.in b/internal/test_util/libcode/vx_ps/Makefile.in index d288997194..78db014c97 100644 --- a/internal/test_util/libcode/vx_ps/Makefile.in +++ b/internal/test_util/libcode/vx_ps/Makefile.in @@ -218,6 +218,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_python3_utils/Makefile.in b/internal/test_util/libcode/vx_python3_utils/Makefile.in index 3d3d12cefb..b416b84940 100644 --- a/internal/test_util/libcode/vx_python3_utils/Makefile.in +++ b/internal/test_util/libcode/vx_python3_utils/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_series_data/Makefile.in b/internal/test_util/libcode/vx_series_data/Makefile.in index 94871489e0..ff1dd2b402 100644 --- a/internal/test_util/libcode/vx_series_data/Makefile.in +++ b/internal/test_util/libcode/vx_series_data/Makefile.in @@ -220,6 +220,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_solar/Makefile.in b/internal/test_util/libcode/vx_solar/Makefile.in index a7026539c3..9912971dc5 100644 --- a/internal/test_util/libcode/vx_solar/Makefile.in +++ b/internal/test_util/libcode/vx_solar/Makefile.in @@ -218,6 +218,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/libcode/vx_tc_util/Makefile.in b/internal/test_util/libcode/vx_tc_util/Makefile.in index daf8dce673..a7d3c13818 100644 --- a/internal/test_util/libcode/vx_tc_util/Makefile.in +++ b/internal/test_util/libcode/vx_tc_util/Makefile.in @@ -243,6 +243,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/tools/Makefile.in b/internal/test_util/tools/Makefile.in index e84bca7acf..c22646fb06 100644 --- a/internal/test_util/tools/Makefile.in +++ b/internal/test_util/tools/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/tools/other/Makefile.in b/internal/test_util/tools/other/Makefile.in index c054cf412f..8e6a1799bd 100644 --- a/internal/test_util/tools/other/Makefile.in +++ b/internal/test_util/tools/other/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/internal/test_util/tools/other/mode_time_domain/Makefile.in b/internal/test_util/tools/other/mode_time_domain/Makefile.in index 3e70894414..c87b755d7d 100644 --- a/internal/test_util/tools/other/mode_time_domain/Makefile.in +++ b/internal/test_util/tools/other/mode_time_domain/Makefile.in @@ -245,6 +245,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/Rscripts/Makefile.in b/scripts/Rscripts/Makefile.in index fa8e805787..e53f9fe2df 100644 --- a/scripts/Rscripts/Makefile.in +++ b/scripts/Rscripts/Makefile.in @@ -260,6 +260,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/Rscripts/include/Makefile.in b/scripts/Rscripts/include/Makefile.in index 5d625c4e28..d62ae95412 100644 --- a/scripts/Rscripts/include/Makefile.in +++ b/scripts/Rscripts/include/Makefile.in @@ -202,6 +202,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/Makefile.in b/scripts/python/Makefile.in index e45eb05cd4..670db075a0 100644 --- a/scripts/python/Makefile.in +++ b/scripts/python/Makefile.in @@ -232,6 +232,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/examples/Makefile.in b/scripts/python/examples/Makefile.in index b994ccfd57..cdf8f0feb4 100644 --- a/scripts/python/examples/Makefile.in +++ b/scripts/python/examples/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/met/Makefile.in b/scripts/python/met/Makefile.in index 6a7570efa2..d8541387db 100644 --- a/scripts/python/met/Makefile.in +++ b/scripts/python/met/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/pyembed/Makefile.in b/scripts/python/pyembed/Makefile.in index b8fef31f8b..1ffd7a4eb5 100644 --- a/scripts/python/pyembed/Makefile.in +++ b/scripts/python/pyembed/Makefile.in @@ -260,6 +260,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/tc_diag/Makefile.in b/scripts/python/tc_diag/Makefile.in index 9d098740ad..6cda357496 100644 --- a/scripts/python/tc_diag/Makefile.in +++ b/scripts/python/tc_diag/Makefile.in @@ -262,6 +262,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/tc_diag/atcf_tools/Makefile.in b/scripts/python/tc_diag/atcf_tools/Makefile.in index fec6217c14..67b691d180 100644 --- a/scripts/python/tc_diag/atcf_tools/Makefile.in +++ b/scripts/python/tc_diag/atcf_tools/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/tc_diag/config/Makefile.in b/scripts/python/tc_diag/config/Makefile.in index cc4019b28f..df494ac1c5 100644 --- a/scripts/python/tc_diag/config/Makefile.in +++ b/scripts/python/tc_diag/config/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/tc_diag/diag_lib/Makefile.in b/scripts/python/tc_diag/diag_lib/Makefile.in index aa48ed0c5f..64b9c40add 100644 --- a/scripts/python/tc_diag/diag_lib/Makefile.in +++ b/scripts/python/tc_diag/diag_lib/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/tc_diag/tc_diag_driver/Makefile.in b/scripts/python/tc_diag/tc_diag_driver/Makefile.in index b4468d4bb2..41d0c24e56 100644 --- a/scripts/python/tc_diag/tc_diag_driver/Makefile.in +++ b/scripts/python/tc_diag/tc_diag_driver/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/scripts/python/utility/Makefile.in b/scripts/python/utility/Makefile.in index 0b977854db..bb8de463d2 100644 --- a/scripts/python/utility/Makefile.in +++ b/scripts/python/utility/Makefile.in @@ -204,6 +204,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/Makefile.in b/src/Makefile.in index 175bb0381a..05916e66b0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -230,6 +230,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/Makefile.in b/src/basic/Makefile.in index 1df9e615ba..a5e04f07e1 100644 --- a/src/basic/Makefile.in +++ b/src/basic/Makefile.in @@ -232,6 +232,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/enum_to_string/Makefile.in b/src/basic/enum_to_string/Makefile.in index 6c1a9607bf..69c57f75cf 100644 --- a/src/basic/enum_to_string/Makefile.in +++ b/src/basic/enum_to_string/Makefile.in @@ -249,6 +249,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/vx_cal/Makefile.in b/src/basic/vx_cal/Makefile.in index a80d944f0a..bf9c15aa6c 100644 --- a/src/basic/vx_cal/Makefile.in +++ b/src/basic/vx_cal/Makefile.in @@ -256,6 +256,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/vx_config/Makefile.in b/src/basic/vx_config/Makefile.in index 5fddc64397..61940aed88 100644 --- a/src/basic/vx_config/Makefile.in +++ b/src/basic/vx_config/Makefile.in @@ -304,6 +304,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/vx_log/Makefile.in b/src/basic/vx_log/Makefile.in index 272dddb3ca..9b4c7969ca 100644 --- a/src/basic/vx_log/Makefile.in +++ b/src/basic/vx_log/Makefile.in @@ -235,6 +235,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/vx_math/Makefile.in b/src/basic/vx_math/Makefile.in index f42012d3ea..28c953fbbf 100644 --- a/src/basic/vx_math/Makefile.in +++ b/src/basic/vx_math/Makefile.in @@ -249,6 +249,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/vx_util/Makefile.in b/src/basic/vx_util/Makefile.in index 83579ba1b4..4c05def519 100644 --- a/src/basic/vx_util/Makefile.in +++ b/src/basic/vx_util/Makefile.in @@ -354,6 +354,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/basic/vx_util_math/Makefile.in b/src/basic/vx_util_math/Makefile.in index bd06680091..b742f23078 100644 --- a/src/basic/vx_util_math/Makefile.in +++ b/src/basic/vx_util_math/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/Makefile.in b/src/libcode/Makefile.in index 5a7e7eb12d..f7629e1481 100644 --- a/src/libcode/Makefile.in +++ b/src/libcode/Makefile.in @@ -242,6 +242,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_afm/Makefile.in b/src/libcode/vx_afm/Makefile.in index 27f3023563..5498f8a896 100644 --- a/src/libcode/vx_afm/Makefile.in +++ b/src/libcode/vx_afm/Makefile.in @@ -243,6 +243,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_analysis_util/Makefile.in b/src/libcode/vx_analysis_util/Makefile.in index 10bbb3aea6..fe6a3bb1a4 100644 --- a/src/libcode/vx_analysis_util/Makefile.in +++ b/src/libcode/vx_analysis_util/Makefile.in @@ -250,6 +250,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_bool_calc/Makefile.in b/src/libcode/vx_bool_calc/Makefile.in index 07bead994d..531f87fa08 100644 --- a/src/libcode/vx_bool_calc/Makefile.in +++ b/src/libcode/vx_bool_calc/Makefile.in @@ -245,6 +245,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_color/Makefile.in b/src/libcode/vx_color/Makefile.in index 08977daff3..217fc0590c 100644 --- a/src/libcode/vx_color/Makefile.in +++ b/src/libcode/vx_color/Makefile.in @@ -262,6 +262,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d/Makefile.in b/src/libcode/vx_data2d/Makefile.in index 947fb3d73f..ead0ee6915 100644 --- a/src/libcode/vx_data2d/Makefile.in +++ b/src/libcode/vx_data2d/Makefile.in @@ -247,6 +247,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_factory/Makefile.in b/src/libcode/vx_data2d_factory/Makefile.in index e9254cb32b..ee7e40e244 100644 --- a/src/libcode/vx_data2d_factory/Makefile.in +++ b/src/libcode/vx_data2d_factory/Makefile.in @@ -248,6 +248,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_grib/Makefile.in b/src/libcode/vx_data2d_grib/Makefile.in index 684bfa9d81..c844d9278b 100644 --- a/src/libcode/vx_data2d_grib/Makefile.in +++ b/src/libcode/vx_data2d_grib/Makefile.in @@ -245,6 +245,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_grib2/Makefile.in b/src/libcode/vx_data2d_grib2/Makefile.in index e26d1e102b..ed24c03da3 100644 --- a/src/libcode/vx_data2d_grib2/Makefile.in +++ b/src/libcode/vx_data2d_grib2/Makefile.in @@ -238,6 +238,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_nc_cf/Makefile.in b/src/libcode/vx_data2d_nc_cf/Makefile.in index cd972c6936..fb06b420b5 100644 --- a/src/libcode/vx_data2d_nc_cf/Makefile.in +++ b/src/libcode/vx_data2d_nc_cf/Makefile.in @@ -240,6 +240,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_nc_met/Makefile.in b/src/libcode/vx_data2d_nc_met/Makefile.in index e160b86a38..a40eb0c86a 100644 --- a/src/libcode/vx_data2d_nc_met/Makefile.in +++ b/src/libcode/vx_data2d_nc_met/Makefile.in @@ -242,6 +242,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_nc_wrf/Makefile.in b/src/libcode/vx_data2d_nc_wrf/Makefile.in index dbe34976c3..682fe818bc 100644 --- a/src/libcode/vx_data2d_nc_wrf/Makefile.in +++ b/src/libcode/vx_data2d_nc_wrf/Makefile.in @@ -242,6 +242,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_python/Makefile.in b/src/libcode/vx_data2d_python/Makefile.in index cf782561fc..6367816286 100644 --- a/src/libcode/vx_data2d_python/Makefile.in +++ b/src/libcode/vx_data2d_python/Makefile.in @@ -246,6 +246,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_data2d_ugrid/Makefile.in b/src/libcode/vx_data2d_ugrid/Makefile.in index 7712baafe9..b6f107c162 100644 --- a/src/libcode/vx_data2d_ugrid/Makefile.in +++ b/src/libcode/vx_data2d_ugrid/Makefile.in @@ -240,6 +240,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_geodesy/Makefile.in b/src/libcode/vx_geodesy/Makefile.in index 25a281b257..d3160d305f 100644 --- a/src/libcode/vx_geodesy/Makefile.in +++ b/src/libcode/vx_geodesy/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_gis/Makefile.in b/src/libcode/vx_gis/Makefile.in index a382caa1d3..dd666ba6cd 100644 --- a/src/libcode/vx_gis/Makefile.in +++ b/src/libcode/vx_gis/Makefile.in @@ -243,6 +243,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_gnomon/Makefile.in b/src/libcode/vx_gnomon/Makefile.in index adec4f8fb1..62729f1c9f 100644 --- a/src/libcode/vx_gnomon/Makefile.in +++ b/src/libcode/vx_gnomon/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_grid/Makefile.in b/src/libcode/vx_grid/Makefile.in index 99bb769bf1..c42467a57a 100644 --- a/src/libcode/vx_grid/Makefile.in +++ b/src/libcode/vx_grid/Makefile.in @@ -276,6 +276,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_gsl_prob/Makefile.in b/src/libcode/vx_gsl_prob/Makefile.in index e3ca39e845..298ff0f95d 100644 --- a/src/libcode/vx_gsl_prob/Makefile.in +++ b/src/libcode/vx_gsl_prob/Makefile.in @@ -242,6 +242,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_nav/Makefile.in b/src/libcode/vx_nav/Makefile.in index e91a581ff9..75018bdc9b 100644 --- a/src/libcode/vx_nav/Makefile.in +++ b/src/libcode/vx_nav/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_nc_obs/Makefile.in b/src/libcode/vx_nc_obs/Makefile.in index b88b793888..709b4c356d 100644 --- a/src/libcode/vx_nc_obs/Makefile.in +++ b/src/libcode/vx_nc_obs/Makefile.in @@ -244,6 +244,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_nc_util/Makefile.in b/src/libcode/vx_nc_util/Makefile.in index f2f564ff93..8079c5d628 100644 --- a/src/libcode/vx_nc_util/Makefile.in +++ b/src/libcode/vx_nc_util/Makefile.in @@ -242,6 +242,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_pb_util/Makefile.in b/src/libcode/vx_pb_util/Makefile.in index 4155cbd87d..c60be5fb82 100644 --- a/src/libcode/vx_pb_util/Makefile.in +++ b/src/libcode/vx_pb_util/Makefile.in @@ -240,6 +240,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_physics/Makefile.in b/src/libcode/vx_physics/Makefile.in index 4a92b393e6..88c09d0f76 100644 --- a/src/libcode/vx_physics/Makefile.in +++ b/src/libcode/vx_physics/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_plot_util/Makefile.in b/src/libcode/vx_plot_util/Makefile.in index b04ac2aff8..16cd426cde 100644 --- a/src/libcode/vx_plot_util/Makefile.in +++ b/src/libcode/vx_plot_util/Makefile.in @@ -239,6 +239,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_pointdata_python/Makefile.in b/src/libcode/vx_pointdata_python/Makefile.in index 9df1cb65f5..e2ff7db4d5 100644 --- a/src/libcode/vx_pointdata_python/Makefile.in +++ b/src/libcode/vx_pointdata_python/Makefile.in @@ -241,6 +241,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_ps/Makefile.in b/src/libcode/vx_ps/Makefile.in index 9f1f61d8d9..3b1c14b3e7 100644 --- a/src/libcode/vx_ps/Makefile.in +++ b/src/libcode/vx_ps/Makefile.in @@ -244,6 +244,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_pxm/Makefile.in b/src/libcode/vx_pxm/Makefile.in index 9f78c084cc..b3053d4199 100644 --- a/src/libcode/vx_pxm/Makefile.in +++ b/src/libcode/vx_pxm/Makefile.in @@ -241,6 +241,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_python3_utils/Makefile.in b/src/libcode/vx_python3_utils/Makefile.in index 625aeafb9a..6c9138d22f 100644 --- a/src/libcode/vx_python3_utils/Makefile.in +++ b/src/libcode/vx_python3_utils/Makefile.in @@ -247,6 +247,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_regrid/Makefile.in b/src/libcode/vx_regrid/Makefile.in index dacbe937e9..67e3833844 100644 --- a/src/libcode/vx_regrid/Makefile.in +++ b/src/libcode/vx_regrid/Makefile.in @@ -236,6 +236,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_render/Makefile.in b/src/libcode/vx_render/Makefile.in index 54ad601137..647a42f006 100644 --- a/src/libcode/vx_render/Makefile.in +++ b/src/libcode/vx_render/Makefile.in @@ -258,6 +258,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_seeps/Makefile.in b/src/libcode/vx_seeps/Makefile.in index 0fabf3df09..510e05b214 100644 --- a/src/libcode/vx_seeps/Makefile.in +++ b/src/libcode/vx_seeps/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_series_data/Makefile.in b/src/libcode/vx_series_data/Makefile.in index 897d818054..6344467e44 100644 --- a/src/libcode/vx_series_data/Makefile.in +++ b/src/libcode/vx_series_data/Makefile.in @@ -237,6 +237,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_shapedata/Makefile.in b/src/libcode/vx_shapedata/Makefile.in index 290ee7582f..9702c46133 100644 --- a/src/libcode/vx_shapedata/Makefile.in +++ b/src/libcode/vx_shapedata/Makefile.in @@ -250,6 +250,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_solar/Makefile.in b/src/libcode/vx_solar/Makefile.in index 3d12890618..ada5952624 100644 --- a/src/libcode/vx_solar/Makefile.in +++ b/src/libcode/vx_solar/Makefile.in @@ -236,6 +236,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_stat_out/Makefile.in b/src/libcode/vx_stat_out/Makefile.in index d12b414cf1..77d31a4ea1 100644 --- a/src/libcode/vx_stat_out/Makefile.in +++ b/src/libcode/vx_stat_out/Makefile.in @@ -236,6 +236,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_statistics/Makefile.in b/src/libcode/vx_statistics/Makefile.in index dbd2500d6a..ef3c09e5e9 100644 --- a/src/libcode/vx_statistics/Makefile.in +++ b/src/libcode/vx_statistics/Makefile.in @@ -261,6 +261,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_summary/Makefile.in b/src/libcode/vx_summary/Makefile.in index 6c057f2622..42cac04abd 100644 --- a/src/libcode/vx_summary/Makefile.in +++ b/src/libcode/vx_summary/Makefile.in @@ -256,6 +256,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_tc_util/Makefile.in b/src/libcode/vx_tc_util/Makefile.in index 747df71532..faae6b3f1d 100644 --- a/src/libcode/vx_tc_util/Makefile.in +++ b/src/libcode/vx_tc_util/Makefile.in @@ -270,6 +270,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/libcode/vx_time_series/Makefile.in b/src/libcode/vx_time_series/Makefile.in index a5eacf5ac7..a7bed2cf24 100644 --- a/src/libcode/vx_time_series/Makefile.in +++ b/src/libcode/vx_time_series/Makefile.in @@ -238,6 +238,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/Makefile.in b/src/tools/Makefile.in index c9b6f05b61..6862443abb 100644 --- a/src/tools/Makefile.in +++ b/src/tools/Makefile.in @@ -232,6 +232,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/Makefile.in b/src/tools/core/Makefile.in index 6e18774f39..cacc9eabec 100644 --- a/src/tools/core/Makefile.in +++ b/src/tools/core/Makefile.in @@ -240,6 +240,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/ensemble_stat/Makefile.in b/src/tools/core/ensemble_stat/Makefile.in index a960e21483..0c0f147c70 100644 --- a/src/tools/core/ensemble_stat/Makefile.in +++ b/src/tools/core/ensemble_stat/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/grid_stat/Makefile.in b/src/tools/core/grid_stat/Makefile.in index 30cc717d27..97b6321c73 100644 --- a/src/tools/core/grid_stat/Makefile.in +++ b/src/tools/core/grid_stat/Makefile.in @@ -224,6 +224,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/mode/Makefile.in b/src/tools/core/mode/Makefile.in index 10f09a3200..55999c4871 100644 --- a/src/tools/core/mode/Makefile.in +++ b/src/tools/core/mode/Makefile.in @@ -243,6 +243,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/mode_analysis/Makefile.in b/src/tools/core/mode_analysis/Makefile.in index 334137147a..1c7c1f441d 100644 --- a/src/tools/core/mode_analysis/Makefile.in +++ b/src/tools/core/mode_analysis/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/pcp_combine/Makefile.in b/src/tools/core/pcp_combine/Makefile.in index 44b0f69c50..f866be8cc3 100644 --- a/src/tools/core/pcp_combine/Makefile.in +++ b/src/tools/core/pcp_combine/Makefile.in @@ -222,6 +222,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/point_stat/Makefile.in b/src/tools/core/point_stat/Makefile.in index 81735f1efb..4efc7d8ba8 100644 --- a/src/tools/core/point_stat/Makefile.in +++ b/src/tools/core/point_stat/Makefile.in @@ -224,6 +224,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/series_analysis/Makefile.in b/src/tools/core/series_analysis/Makefile.in index 2e26c49701..fd4915a5a5 100644 --- a/src/tools/core/series_analysis/Makefile.in +++ b/src/tools/core/series_analysis/Makefile.in @@ -226,6 +226,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/stat_analysis/Makefile.in b/src/tools/core/stat_analysis/Makefile.in index 168c3da589..e1b0bda93d 100644 --- a/src/tools/core/stat_analysis/Makefile.in +++ b/src/tools/core/stat_analysis/Makefile.in @@ -231,6 +231,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/core/wavelet_stat/Makefile.in b/src/tools/core/wavelet_stat/Makefile.in index 96490833a2..5826b4102e 100644 --- a/src/tools/core/wavelet_stat/Makefile.in +++ b/src/tools/core/wavelet_stat/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/dev_utils/Makefile.in b/src/tools/dev_utils/Makefile.in index e9b745a97f..46d98a6aeb 100644 --- a/src/tools/dev_utils/Makefile.in +++ b/src/tools/dev_utils/Makefile.in @@ -368,6 +368,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/dev_utils/shapefiles/Makefile.in b/src/tools/dev_utils/shapefiles/Makefile.in index f5454f70fb..62ec442a56 100644 --- a/src/tools/dev_utils/shapefiles/Makefile.in +++ b/src/tools/dev_utils/shapefiles/Makefile.in @@ -219,6 +219,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/Makefile.in b/src/tools/other/Makefile.in index 7574bf3ce1..010a792155 100644 --- a/src/tools/other/Makefile.in +++ b/src/tools/other/Makefile.in @@ -252,6 +252,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/ascii2nc/Makefile.in b/src/tools/other/ascii2nc/Makefile.in index ccc217163a..d7d75fb04a 100644 --- a/src/tools/other/ascii2nc/Makefile.in +++ b/src/tools/other/ascii2nc/Makefile.in @@ -274,6 +274,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/gen_ens_prod/Makefile.in b/src/tools/other/gen_ens_prod/Makefile.in index 8586403cb6..4f070ce15d 100644 --- a/src/tools/other/gen_ens_prod/Makefile.in +++ b/src/tools/other/gen_ens_prod/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/gen_vx_mask/Makefile.in b/src/tools/other/gen_vx_mask/Makefile.in index 0454fcc726..4203003677 100644 --- a/src/tools/other/gen_vx_mask/Makefile.in +++ b/src/tools/other/gen_vx_mask/Makefile.in @@ -222,6 +222,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/gis_utils/Makefile.in b/src/tools/other/gis_utils/Makefile.in index aa3780a9bc..0afd97e00c 100644 --- a/src/tools/other/gis_utils/Makefile.in +++ b/src/tools/other/gis_utils/Makefile.in @@ -234,6 +234,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/grid_diag/Makefile.in b/src/tools/other/grid_diag/Makefile.in index c93be79561..65e3b5196f 100644 --- a/src/tools/other/grid_diag/Makefile.in +++ b/src/tools/other/grid_diag/Makefile.in @@ -224,6 +224,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/gsi_tools/Makefile.in b/src/tools/other/gsi_tools/Makefile.in index c7f068cfd9..455195d757 100644 --- a/src/tools/other/gsi_tools/Makefile.in +++ b/src/tools/other/gsi_tools/Makefile.in @@ -261,6 +261,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/ioda2nc/Makefile.in b/src/tools/other/ioda2nc/Makefile.in index 37f335deae..cff7fbea89 100644 --- a/src/tools/other/ioda2nc/Makefile.in +++ b/src/tools/other/ioda2nc/Makefile.in @@ -237,6 +237,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/lidar2nc/Makefile.in b/src/tools/other/lidar2nc/Makefile.in index e5d3703780..ad7371e7f2 100644 --- a/src/tools/other/lidar2nc/Makefile.in +++ b/src/tools/other/lidar2nc/Makefile.in @@ -237,6 +237,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/madis2nc/Makefile.in b/src/tools/other/madis2nc/Makefile.in index c6eb822fc3..e70b8e0d65 100644 --- a/src/tools/other/madis2nc/Makefile.in +++ b/src/tools/other/madis2nc/Makefile.in @@ -224,6 +224,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/mode_graphics/Makefile.in b/src/tools/other/mode_graphics/Makefile.in index ead2e5dcb4..abc9301ea0 100644 --- a/src/tools/other/mode_graphics/Makefile.in +++ b/src/tools/other/mode_graphics/Makefile.in @@ -245,6 +245,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/mode_time_domain/Makefile.in b/src/tools/other/mode_time_domain/Makefile.in index 3f3d8b446a..a0f69996a1 100644 --- a/src/tools/other/mode_time_domain/Makefile.in +++ b/src/tools/other/mode_time_domain/Makefile.in @@ -263,6 +263,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/modis_regrid/Makefile.in b/src/tools/other/modis_regrid/Makefile.in index 68ff194a77..5e97e8735a 100644 --- a/src/tools/other/modis_regrid/Makefile.in +++ b/src/tools/other/modis_regrid/Makefile.in @@ -233,6 +233,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/pb2nc/Makefile.in b/src/tools/other/pb2nc/Makefile.in index 05629adb61..f10cc0fcae 100644 --- a/src/tools/other/pb2nc/Makefile.in +++ b/src/tools/other/pb2nc/Makefile.in @@ -252,6 +252,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/plot_data_plane/Makefile.in b/src/tools/other/plot_data_plane/Makefile.in index fcf2a525cf..a443a0e688 100644 --- a/src/tools/other/plot_data_plane/Makefile.in +++ b/src/tools/other/plot_data_plane/Makefile.in @@ -224,6 +224,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/plot_point_obs/Makefile.in b/src/tools/other/plot_point_obs/Makefile.in index 18b81a273c..b6fe39864c 100644 --- a/src/tools/other/plot_point_obs/Makefile.in +++ b/src/tools/other/plot_point_obs/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/point2grid/Makefile.in b/src/tools/other/point2grid/Makefile.in index 17f72484ab..9c8efa6ea4 100644 --- a/src/tools/other/point2grid/Makefile.in +++ b/src/tools/other/point2grid/Makefile.in @@ -236,6 +236,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/regrid_data_plane/Makefile.in b/src/tools/other/regrid_data_plane/Makefile.in index 61c475b1ae..75f0f17630 100644 --- a/src/tools/other/regrid_data_plane/Makefile.in +++ b/src/tools/other/regrid_data_plane/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/shift_data_plane/Makefile.in b/src/tools/other/shift_data_plane/Makefile.in index 4eb7b7f50b..aa38481fea 100644 --- a/src/tools/other/shift_data_plane/Makefile.in +++ b/src/tools/other/shift_data_plane/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/other/wwmca_tool/Makefile.in b/src/tools/other/wwmca_tool/Makefile.in index 972b3f9255..e3be6b2af6 100644 --- a/src/tools/other/wwmca_tool/Makefile.in +++ b/src/tools/other/wwmca_tool/Makefile.in @@ -285,6 +285,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/Makefile.in b/src/tools/tc_utils/Makefile.in index 7c74bba2fa..858a6de0b8 100644 --- a/src/tools/tc_utils/Makefile.in +++ b/src/tools/tc_utils/Makefile.in @@ -232,6 +232,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/rmw_analysis/Makefile.in b/src/tools/tc_utils/rmw_analysis/Makefile.in index 9a89e51057..6d37dbd043 100644 --- a/src/tools/tc_utils/rmw_analysis/Makefile.in +++ b/src/tools/tc_utils/rmw_analysis/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/tc_diag/Makefile.in b/src/tools/tc_utils/tc_diag/Makefile.in index b884c28f85..66b5eb365d 100644 --- a/src/tools/tc_utils/tc_diag/Makefile.in +++ b/src/tools/tc_utils/tc_diag/Makefile.in @@ -227,6 +227,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/tc_dland/Makefile.in b/src/tools/tc_utils/tc_dland/Makefile.in index 66bc377e52..b31ca8a29e 100644 --- a/src/tools/tc_utils/tc_dland/Makefile.in +++ b/src/tools/tc_utils/tc_dland/Makefile.in @@ -235,6 +235,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/tc_gen/Makefile.in b/src/tools/tc_utils/tc_gen/Makefile.in index 97b0b5994f..98881f5a22 100644 --- a/src/tools/tc_utils/tc_gen/Makefile.in +++ b/src/tools/tc_utils/tc_gen/Makefile.in @@ -225,6 +225,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/tc_pairs/Makefile.in b/src/tools/tc_utils/tc_pairs/Makefile.in index 736cb2afe3..f56d6bbcbd 100644 --- a/src/tools/tc_utils/tc_pairs/Makefile.in +++ b/src/tools/tc_utils/tc_pairs/Makefile.in @@ -249,6 +249,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/tc_rmw/Makefile.in b/src/tools/tc_utils/tc_rmw/Makefile.in index 0c5220595a..05430c1fa0 100644 --- a/src/tools/tc_utils/tc_rmw/Makefile.in +++ b/src/tools/tc_utils/tc_rmw/Makefile.in @@ -227,6 +227,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ diff --git a/src/tools/tc_utils/tc_stat/Makefile.in b/src/tools/tc_utils/tc_stat/Makefile.in index 24bba4f72e..d6926559a0 100644 --- a/src/tools/tc_utils/tc_stat/Makefile.in +++ b/src/tools/tc_utils/tc_stat/Makefile.in @@ -227,6 +227,7 @@ MET_BUFRLIB = @MET_BUFRLIB@ MET_CAIRO = @MET_CAIRO@ MET_CAIROINC = @MET_CAIROINC@ MET_CAIROLIB = @MET_CAIROLIB@ +MET_CXX_STANDARD = @MET_CXX_STANDARD@ MET_ECKIT = @MET_ECKIT@ MET_ECKITINC = @MET_ECKITINC@ MET_ECKITLIB = @MET_ECKITLIB@ From d041d73516dcf2d4a2080b02091e76217d074a5d Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 5 Sep 2024 08:27:03 -0600 Subject: [PATCH 113/114] Feature 1729 set attr grid (#2955) * #1729 Allow to change to differnt grid size if the raw size is 0 * Added build_grid_by_grid_string and build_grid_by_grid_string * #1729 Calls build_grid_by_grid_string * #1729 Added set_attr_grid at the -field option * #1729 Set obs_type to TYPE_NCCF if the file_type is given at the config file * #1729 Support set_sttr_grid and changed Error messages to Warning * #1729 FIxed SonmarQube findings * #1729 Initial release for unit test * #1729 Added update_missing_values * #1729 Deleted a shadowed local variable * #2673 Added more is_eq * #2673 Added get_exe_duration * 2673 Reducded nested statements * 2673 Fixed SonarGube findings * 2673 Fixed SonarQube findings * 2673 Fixed SonarQube findings * #1729 Added aan unittest plot_data_plane_set_attr_grid * #1729 Added aan unittest point2grid_cice_set_attr_grid * #1729 Added changed back the verbose level * #1729 Corrected typo --------- Co-authored-by: Howard Soh --- docs/Users_Guide/reformat_point.rst | 15 +- .../config/Point2GridConfig_tlat_tlon | 6 + .../test_unit/xml/unit_plot_data_plane.xml | 14 + internal/test_unit/xml/unit_point2grid.xml | 19 + src/basic/vx_log/vx_log.h | 9 + src/basic/vx_math/is_bad_data.h | 26 +- src/libcode/vx_data2d/data2d_utils.cc | 48 +++ src/libcode/vx_data2d/data2d_utils.h | 8 + src/libcode/vx_data2d/data_class.cc | 14 +- src/libcode/vx_data2d/var_info.cc | 21 +- src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc | 10 +- src/libcode/vx_data2d_nc_cf/nc_cf_file.cc | 362 ++++++++++-------- src/libcode/vx_data2d_nc_cf/nc_cf_file.h | 12 +- src/libcode/vx_nc_util/nc_utils.hpp | 171 ++++++--- src/libcode/vx_statistics/apply_mask.cc | 37 +- src/tools/other/gen_vx_mask/gen_vx_mask.cc | 37 +- src/tools/other/mode_time_domain/3d_conv.cc | 46 +-- .../plot_point_obs_conf_info.cc | 19 +- src/tools/other/point2grid/point2grid.cc | 340 +++++++++------- 19 files changed, 721 insertions(+), 493 deletions(-) create mode 100644 internal/test_unit/config/Point2GridConfig_tlat_tlon diff --git a/docs/Users_Guide/reformat_point.rst b/docs/Users_Guide/reformat_point.rst index fb0a7b2766..ae9691745f 100644 --- a/docs/Users_Guide/reformat_point.rst +++ b/docs/Users_Guide/reformat_point.rst @@ -1092,9 +1092,22 @@ Optional Arguments for point2grid 16. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. Only 4 interpolation methods are applied to the field variables; MIN/MAX/MEDIAN/UW_MEAN. The GAUSSIAN method is applied to the probability variable only. Unlike regrad_data_plane, MAX method is applied to the file variable and Gaussian method to the probability variable with the MAXGAUSS method. If the probability variable is not requested, MAXGAUSS method is the same as MAX method. - + For the GOES-16 and GOES-17 data, the computing lat/long is time consuming. The computed coordinate (lat/long) is saved to a temporary NetCDF file, as described in :numref:`Contributor's Guide Section %s `. The computing lat/long step can be skipped if the coordinate file is given through the environment variable MET_GEOSTATIONARY_DATA. The grid mapping to the target grid is saved to MET_TMP_DIR to save the execution time. Once this file is created, the MET_GEOSTATIONARY_DATA is ignored. The grid mapping file should be deleted manually in order to apply a new MET_GEOSTATIONARY_DATA environment variable or to re-generate the grid mapping file. An example of call point2grid to process GOES-16 AOD data is shown below: + +The grid name or the grid definition can be given with the -field option when the grid information is missing from the input NetCDF file for the latitude_longitude projection. The latitude and longitude variable names should be defined by the user, and the grid information from the set_attr_grid is ignored in this case + +.. code-block:: none + + point2grid \ + iceh.2018-01-03.c00.tlat_tlon.nc \ + G231 \ + point2grid_cice_to_G231.nc \ + -config Point2GridConfig_tlat_tlon \ + -field 'name="hi_d"; level="(0,*,*)"; set_attr_grid="latlon 1440 1080 -79.80672 60.28144 0.04 0.04";' \ + -v 1 + .. code-block:: none point2grid \ diff --git a/internal/test_unit/config/Point2GridConfig_tlat_tlon b/internal/test_unit/config/Point2GridConfig_tlat_tlon new file mode 100644 index 0000000000..66f2f854b4 --- /dev/null +++ b/internal/test_unit/config/Point2GridConfig_tlat_tlon @@ -0,0 +1,6 @@ +file_type = NETCDF_NCCF; + +var_name_map = [ + { key = "lat_vname"; val = "TLAT"; }, + { key = "lon_vname"; val = "TLON"; } +]; diff --git a/internal/test_unit/xml/unit_plot_data_plane.xml b/internal/test_unit/xml/unit_plot_data_plane.xml index 5c56a389d8..599bfd0742 100644 --- a/internal/test_unit/xml/unit_plot_data_plane.xml +++ b/internal/test_unit/xml/unit_plot_data_plane.xml @@ -680,4 +680,18 @@ + + &MET_BIN;/plot_data_plane + \ + &DATA_DIR_MODEL;/nccf/MITLL.ProxyEchoTopsCalibratedMosaic.20200831_235328_v_20200831_235328.nc \ + &OUTPUT_DIR;/plot_data_plane/EchoTops_set_attr_grid.ps \ + 'name="ProxyEchoTopsCalibratedMosaic"; level="(0,*,*)"; set_attr_grid="latlon 8008 4004 -90 -180 0.04 0.04";' \ + -title "Global Synthetic Weather Radar EchoTops" \ + -v 1 + + + &OUTPUT_DIR;/plot_data_plane/EchoTops_set_attr_grid.ps + + + diff --git a/internal/test_unit/xml/unit_point2grid.xml b/internal/test_unit/xml/unit_point2grid.xml index aa9a1d0410..840fbdc7ea 100644 --- a/internal/test_unit/xml/unit_point2grid.xml +++ b/internal/test_unit/xml/unit_point2grid.xml @@ -356,4 +356,23 @@ + + &MET_BIN;/point2grid + + MET_TMP_DIR &OUTPUT_DIR;/point2grid + + \ + &DATA_DIR_MODEL;/cice/iceh.2018-01-03.c00.tlat_tlon.nc \ + G231 \ + &OUTPUT_DIR;/point2grid/point2grid_cice_to_G231.nc \ + -config &CONFIG_DIR;/Point2GridConfig_tlat_tlon \ + -field 'name="hi_d"; level="(0,*,*)"; set_attr_grid="latlon 180 360 -80 -180 1 1";' \ + -v 1 + + + &OUTPUT_DIR;/point2grid/point2grid_cice_to_G231.nc + + + + diff --git a/src/basic/vx_log/vx_log.h b/src/basic/vx_log/vx_log.h index ce8a8132cb..0ae10c3811 100644 --- a/src/basic/vx_log/vx_log.h +++ b/src/basic/vx_log/vx_log.h @@ -26,6 +26,15 @@ //////////////////////////////////////////////////////////////////////// +inline double get_exe_duration(clock_t start_clock, clock_t end_clock) { + return ((double)(end_clock - start_clock)) / CLOCKS_PER_SEC; +} + +inline double get_exe_duration(clock_t start_clock) { + return get_exe_duration(start_clock, clock()); +} + +//////////////////////////////////////////////////////////////////////// #endif // __VX_LOG_H__ diff --git a/src/basic/vx_math/is_bad_data.h b/src/basic/vx_math/is_bad_data.h index d8d7b334c3..80af0916ef 100644 --- a/src/basic/vx_math/is_bad_data.h +++ b/src/basic/vx_math/is_bad_data.h @@ -48,7 +48,7 @@ inline int is_bad_data(float a) { } inline int is_bad_data(char a) { - return(a == bad_data_char); + return (a == bad_data_char); } inline int is_eq(double a, double b, double tol) { @@ -60,6 +60,30 @@ inline int is_eq(double a, double b) { return is_eq(a, b, default_tol); } +inline int is_eq(double a, int b) { + return is_eq(a, (double)b); +} + +inline int is_eq(int a, double b) { + return is_eq((double)a, b); +} + +inline int is_eq(double a, unixtime b) { + return is_eq(a, (double)b); +} + +inline int is_eq(unixtime a, double b) { + return is_eq((double)a, b); +} + +inline int is_eq(float a, float b) { + return is_eq((double)a, (double)b); +} + +template +inline int is_eq(T a, T b) { + return (a == b); +} //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/data2d_utils.cc b/src/libcode/vx_data2d/data2d_utils.cc index 6284ca434b..6fc68a93cc 100644 --- a/src/libcode/vx_data2d/data2d_utils.cc +++ b/src/libcode/vx_data2d/data2d_utils.cc @@ -24,6 +24,54 @@ using namespace std; //////////////////////////////////////////////////////////////////////// +bool build_grid_by_grid_string(const char *grid_str, Grid &grid, + const char *caller_name, bool do_warning) { + bool status = false; + + if (nullptr != grid_str && m_strlen(grid_str) > 0) { + // Parse as a white-space separated string + + StringArray sa; + sa.parse_wsss(grid_str); + + // Search for a named grid + if (sa.n() == 1 && find_grid_by_name(sa[0].c_str(), grid)) { + status = true; + mlog << Debug(3) << "Use the grid named \"" << grid_str << "\".\n"; + } + // Parse grid definition + else if (sa.n() > 1 && parse_grid_def(sa, grid)) { + status = true; + mlog << Debug(3) << "Use the grid defined by string \"" + << grid_str << "\".\n"; + } + else if (do_warning) { + mlog << Warning << "\nbuild_grid_by_grid_string() by " << caller_name + << " unsupported " << conf_key_set_attr_grid + << " definition string (" << grid_str + << ")!\n\n"; + } + } + + return status; +} + +//////////////////////////////////////////////////////////////////////// + +bool build_grid_by_grid_string(const ConcatString &grid_str, Grid &grid, + const char *caller_name, bool do_warning) { + bool status = false; + + if(grid_str.nonempty()) { + status = build_grid_by_grid_string(grid_str.c_str(), grid, + caller_name, do_warning); + } + + return status; +} + +//////////////////////////////////////////////////////////////////////// + bool derive_wdir(const DataPlane &u2d, const DataPlane &v2d, DataPlane &wdir2d) { int x, y; diff --git a/src/libcode/vx_data2d/data2d_utils.h b/src/libcode/vx_data2d/data2d_utils.h index 317eb92f72..24299475d3 100644 --- a/src/libcode/vx_data2d/data2d_utils.h +++ b/src/libcode/vx_data2d/data2d_utils.h @@ -20,6 +20,14 @@ //////////////////////////////////////////////////////////////////////// +extern bool build_grid_by_grid_string(const char *attr_grid, Grid &grid, + const char *caller_name=nullptr, + bool do_warning=true); + +extern bool build_grid_by_grid_string(const ConcatString &attr_grid, Grid &grid, + const char *caller_name=nullptr, + bool do_warning=true); + extern bool derive_wdir(const DataPlane &u2d, const DataPlane &v2d, DataPlane &wdir); diff --git a/src/libcode/vx_data2d/data_class.cc b/src/libcode/vx_data2d/data_class.cc index 23ff40f93f..f364e34e42 100644 --- a/src/libcode/vx_data2d/data_class.cc +++ b/src/libcode/vx_data2d/data_class.cc @@ -257,13 +257,21 @@ mlog << Debug(3) << "Resetting grid definition from \"" // Make sure the grid dimensions do not change // - if ( raw_nx() != grid.nx() || raw_ny() != grid.ny() ) { + if ( raw_nx() <= 0 && raw_ny() <= 0 ) { - mlog << Error << "\nMet2dDataFile::set_grid() -> " + mlog << Warning << "\nMet2dDataFile::set_grid() -> " << "When resetting the grid definition to \"" << grid.serialize() << "\", the grid dimensions " - << "cannot change (" << grid.nx() << ", " << grid.ny() + << "are changed (" << grid.nx() << ", " << grid.ny() << ") != (" << raw_nx() << ", " << raw_ny() << ").\n\n"; + } + else if ( raw_nx() != grid.nx() || raw_ny() != grid.ny() ) { + + mlog << Error << "\nMet2dDataFile::set_grid() -> " + << "When resetting the grid definition to \"" + << grid.serialize() << "\", the grid dimensions " + << "cannot change to (" << grid.nx() << ", " << grid.ny() + << ") from (" << raw_nx() << ", " << raw_ny() << ").\n\n"; exit ( 1 ); diff --git a/src/libcode/vx_data2d/var_info.cc b/src/libcode/vx_data2d/var_info.cc index a1775a7275..2c92c6bf69 100644 --- a/src/libcode/vx_data2d/var_info.cc +++ b/src/libcode/vx_data2d/var_info.cc @@ -26,6 +26,7 @@ #include "vx_cal.h" #include "vx_math.h" #include "vx_log.h" +#include "data2d_utils.h" using namespace std; @@ -541,25 +542,7 @@ void VarInfo::set_dict(Dictionary &dict) { // Parse set_attr grid s = parse_set_attr_string(dict, conf_key_set_attr_grid); - if(s.nonempty()) { - - // Parse as a white-space separated string - StringArray sa; - sa.parse_wsss(s); - - // Search for a named grid - if(sa.n() == 1 && find_grid_by_name(sa[0].c_str(), SetAttrGrid)) { - } - // Parse grid definition - else if(sa.n() > 1 && parse_grid_def(sa, SetAttrGrid)) { - } - else { - mlog << Warning << "\nVarInfo::set_dict() -> " - << "unsupported " << conf_key_set_attr_grid - << " definition string (" << s - << ")!\n\n"; - } - } + build_grid_by_grid_string(s, SetAttrGrid, "VarInfo::set_dict(Dictionary &dict) ->"); // Parse set_attr times s = parse_set_attr_string(dict, conf_key_set_attr_init); diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc index 8c4373a62c..cc77b7f17a 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc @@ -159,11 +159,14 @@ bool MetNcCFDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) { // Not sure why we do this - NcVarInfo *data_var = (NcVarInfo *)nullptr; - VarInfoNcCF *vinfo_nc = (VarInfoNcCF *)&vinfo; + auto data_var = (NcVarInfo *)nullptr; + auto vinfo_nc = (VarInfoNcCF *)&vinfo; static const string method_name = "MetNcCFDataFile::data_plane(VarInfo &, DataPlane &) -> "; + Grid grid_attr = vinfo.grid_attr(); + _file->update_grid(grid_attr); + // Initialize the data plane plane.clear(); @@ -339,6 +342,9 @@ int MetNcCFDataFile::data_plane_array(VarInfo &vinfo, static const string method_name = "MetNcCFDataFile::data_plane_array(VarInfo &, DataPlaneArray &) -> "; + Grid grid_attr = vinfo.grid_attr(); + _file->update_grid(grid_attr); + // Initialize plane_array.clear(); diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index 3038965ab6..a739c5ae0d 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -57,8 +57,6 @@ static ConcatString y_dim_var_name; static double get_nc_var_att_double(const NcVar *nc_var, const char *att_name, bool is_required=true); -#define USE_BUFFER 1 - //////////////////////////////////////////////////////////////////////// @@ -136,6 +134,9 @@ void NcCfFile::close() _dims = (NcDim **)nullptr; } + grid_ready = false; + has_attr_grid = false; + _numDims = 0; _dimNames.clear(); @@ -213,8 +214,8 @@ bool NcCfFile::open(const char * filepath) // Pull out the variables int max_dim_count = 0; - NcVar *z_var = (NcVar *)nullptr; - NcVar *valid_time_var = (NcVar *)nullptr; + auto z_var = (NcVar *)nullptr; + auto valid_time_var = (NcVar *)nullptr; ConcatString att_value; StringArray varNames; @@ -311,7 +312,7 @@ bool NcCfFile::open(const char * filepath) // Parse the units for the time variable. ut = sec_per_unit = 0; if (get_var_units(valid_time_var, units)) { - if (units.length() == 0) { + if (units.empty()) { mlog << Warning << "\n" << method_name << "the \"time\" variable must contain a \"units\" attribute. " << "Using valid time of 0\n\n"; @@ -324,7 +325,7 @@ bool NcCfFile::open(const char * filepath) } NcVar bounds_time_var; - NcVar *nc_time_var = (NcVar *)nullptr; + auto nc_time_var = (NcVar *)nullptr; bool use_bounds_var = false; ConcatString bounds_var_name; nc_time_var = valid_time_var; @@ -341,10 +342,10 @@ bool NcCfFile::open(const char * filepath) if (bounds_att) delete bounds_att; // Determine the number of times present. - int n_times = (int) get_data_size(valid_time_var); + int n_times = get_data_size(valid_time_var); int tim_buf_size = n_times; if (use_bounds_var) tim_buf_size *= 2; - double *time_values = new double[tim_buf_size]; + auto time_values = new double[tim_buf_size]; if( get_nc_data(nc_time_var, time_values) ) { bool no_leap_year = get_att_no_leap_year(valid_time_var); @@ -403,7 +404,7 @@ bool NcCfFile::open(const char * filepath) // Parse the units for the time variable. if (get_var_units(&init_time_var, units)) { - if (units.length() == 0) { + if (units.empty()) { mlog << Warning << "\n" << method_name << "the \"forecast_reference_time\" variable must contain a \"units\" attribute.\n\n"; ut = sec_per_unit = 0; @@ -418,8 +419,8 @@ bool NcCfFile::open(const char * filepath) ut = sec_per_unit = 0; } - double time_value = get_nc_time(&init_time_var,(int)0); - InitTime = (unixtime)ut + sec_per_unit * time_value; + double time_value = get_nc_time(&init_time_var,0); + InitTime = ut + (unixtime)(sec_per_unit * time_value); } // Pull out the grid. This must be done after pulling out the dimension @@ -436,7 +437,8 @@ bool NcCfFile::open(const char * filepath) StringArray z_dims; StringArray t_dims; StringArray dimNames; - string var_x_dim_name, var_y_dim_name; + string var_x_dim_name; + string var_y_dim_name; if (IS_VALID_NC_P(_xDim)) var_x_dim_name = GET_NC_NAME_P(_xDim); if (IS_VALID_NC_P(_yDim)) var_y_dim_name = GET_NC_NAME_P(_yDim); for (int j=0; jx_slot) && (j != var->y_slot)) ) { - ++count; - if ( var == nullptr || ((j != var->x_slot) && (j != var->y_slot)) ) - { + if (has_attr_grid) { + mlog << Debug(3) << "\n" << method_name + << "star found in unknown slot (" << j << ") for " << GET_NC_NAME_P(v) << "\n\n"; + } + else { mlog << Error << "\n" << method_name << "star found in bad slot (" << j << ") for " << GET_NC_NAME_P(v) << "\n\n"; + exit(1); } } @@ -1011,13 +1041,22 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const } // check slots - additional logic to satisfy Fortify Null Dereference - int x_slot_tmp = 0; - int y_slot_tmp = 0; + int x_slot_tmp = 0; + int y_slot_tmp = 0; if (var == nullptr || var->x_slot < 0 || var->y_slot < 0) { - mlog << Error << "\n" << method_name - << "bad x|y|z slot\n\n"; - exit(1); + if (has_attr_grid) { + mlog << Warning << "\n" << method_name + << "bad x|y|z slot (" << var->x_slot << "|" << var->y_slot + << "|" << var->z_slot << "|" << var->t_slot <<")\n\n"; + x_slot_tmp = dim_count - 1; + y_slot_tmp = dim_count - 2; + } + else { + mlog << Error << "\n" << method_name + << "bad x|y|z slot\n\n"; + exit(1); + } } else { x_slot_tmp = var->x_slot; @@ -1116,7 +1155,7 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const // done mlog << Debug(6) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; return true; } @@ -1462,9 +1501,9 @@ void NcCfFile::read_netcdf_grid() !((_xDim && _yDim) || (x_dim_var_name.nonempty() && y_dim_var_name.nonempty()))) { - mlog << Error << "\nNcCfFile::read_netcdf_grid() -> " + mlog << Warning << "\nNcCfFile::read_netcdf_grid() -> " << "Couldn't figure out projection from information in netCDF file.\n\n"; - exit(1); + return; } return; @@ -1478,7 +1517,7 @@ void NcCfFile::read_netcdf_grid() Grid NcCfFile::build_grid_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, const long lat_counts, const long lon_counts) { Grid grid_ll; - bool swap_to_north; + bool swap_to_north = false; LatLonData data = get_data_from_lat_lon_vars(lat_var, lon_var, lat_counts, lon_counts, swap_to_north); @@ -1506,9 +1545,9 @@ void NcCfFile::get_grid_from_grid_mapping(const NcVarAtt *grid_mapping_att) bool status = get_att_value_chars(grid_mapping_att, mapping_name); if (!status) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot extract grid mapping name from netCDF file.\n\n"; - exit(1); + return; } NcVar *grid_mapping_var = nullptr; @@ -1522,12 +1561,12 @@ void NcCfFile::get_grid_from_grid_mapping(const NcVarAtt *grid_mapping_att) } } /* endfor - i */ - if ((grid_mapping_var == 0) || (IS_INVALID_NC_P(grid_mapping_var))) + if ((nullptr == grid_mapping_var) || (IS_INVALID_NC_P(grid_mapping_var))) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot extract grid mapping variable (" << mapping_name << ") from netCDF file.\n\n"; - exit(1); + return; } // Get the name of the grid mapping @@ -1536,9 +1575,10 @@ void NcCfFile::get_grid_from_grid_mapping(const NcVarAtt *grid_mapping_att) if (IS_INVALID_NC_P(grid_mapping_name_att)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot get coordinate system name from netCDF file.\n\n"; - exit(1); + if (grid_mapping_name_att) delete grid_mapping_name_att; + return; } //string grid_mapping_name = grid_mapping_name_att->getValues(att->as_string(0); @@ -1606,10 +1646,10 @@ void NcCfFile::get_grid_from_grid_mapping(const NcVarAtt *grid_mapping_att) } else { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Unknown grid mapping name (" << grid_mapping_name << ") found in netCDF file.\n\n"; - exit(1); + return; } } @@ -1673,9 +1713,9 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m x_coord_units_name == "meters") x_coord_to_m_cf = 1.0; else if (x_coord_units_name == "km") x_coord_to_m_cf = 1000.0; else { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "The X coordinates must be in meters or kilometers for MET.\n\n"; - exit(1); + return; } } } @@ -1698,9 +1738,9 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m y_coord_units_name == "meters" ) y_coord_to_m_cf = 1.0; else if (y_coord_units_name == "km") y_coord_to_m_cf = 1000.0; else { - mlog << Error << "\n" << method_name << " -> " - << "The X coordinates must be in meters or kilometers for MET.\n\n"; - exit(1); + mlog << Warning << "\n" << method_name << " -> " + << "The Y coordinates must be in meters or kilometers for MET.\n\n"; + return; } } } @@ -1737,11 +1777,11 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m double curr_delta = fabs(x_values[i] - x_values[i-1]); if (fabs(curr_delta - dx_m_a) > DELTA_TOLERANCE) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Lambert Azimuthal Equal Area files " << "where the delta along the x-axis is constant (" << curr_delta << " != " << dx_m_a << ")\n\n"; - exit(1); + return; } } @@ -1750,11 +1790,11 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m double curr_delta = fabs(y_values[i] - y_values[i-1]); if (fabs(curr_delta - dy_m_a) > DELTA_TOLERANCE) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Lambert Azimuthal Equal Area files " << "where the delta along the y-axis is constant (" << curr_delta << " != " << dy_m_a << ")\n\n"; - exit(1); + return; } } @@ -1806,11 +1846,11 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m if(!is_bad_data(false_easting) && !is_eq(false_easting, 0.0)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET cannot process Lambert Azimuthal Equal Area files " << "with non-zero false_easting (" << false_easting << ").\n\n"; - exit(1); + return; } // false_northing @@ -1820,11 +1860,11 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m if(!is_bad_data(false_northing) && !is_eq(false_northing, 0.0)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET cannot process Lambert Azimuthal Equal Area files " << "with non-zero false_northing (" << false_northing << ").\n\n"; - exit(1); + return; } // Calculate the pin indices. The pin will be located at the grid's reference @@ -1845,6 +1885,8 @@ void NcCfFile::get_grid_mapping_lambert_azimuthal_equal_area(const NcVar *grid_m grid.set(data); if (dy_m < 0) grid.set_swap_to_north(true); + grid_ready = true; + } @@ -1863,10 +1905,10 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin grid_mapping_var, (string)"standard_parallel"); if (IS_INVALID_NC_P(std_parallel_att)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot get standard_parallel attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // longitude_of_central_meridian @@ -1875,10 +1917,10 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin grid_mapping_var, (string)"longitude_of_central_meridian"); if (IS_INVALID_NC_P(central_lon_att)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot get longitude_of_central_meridian attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // latitude_of_projection_origin @@ -1887,10 +1929,10 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin grid_mapping_var, (string)"latitude_of_projection_origin"); if (IS_INVALID_NC_P(proj_origin_lat_att)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot get latitude_of_projection_origin attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // Look for the x/y dimensions and x/y coordinate variables @@ -1899,9 +1941,9 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin if (get_data_size(_xCoordVar) != (int) GET_NC_SIZE_P(_xDim) || get_data_size(_yCoordVar) != (int) GET_NC_SIZE_P(_yDim)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Coordinate variables don't match dimension sizes in netCDF file.\n\n"; - exit(1); + return; } // Make sure that the coordinate variables are given in meters. If we get @@ -1925,9 +1967,9 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin x_coord_units_name == "meters") x_coord_to_m_cf = 1.0; else if (x_coord_units_name == "km") x_coord_to_m_cf = 1000.0; else { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "The X coordinates must be in meters or kilometers for MET.\n\n"; - exit(1); + return; } } } @@ -1949,9 +1991,9 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin y_coord_units_name == "meters" ) y_coord_to_m_cf = 1.0; else if (y_coord_units_name == "km") y_coord_to_m_cf = 1000.0; else { - mlog << Error << "\n" << method_name << " -> " - << "The X coordinates must be in meters or kilometers for MET.\n\n"; - exit(1); + mlog << Warning << "\n" << method_name << " -> " + << "The Y coordinates must be in meters or kilometers for MET.\n\n"; + return; } } } @@ -1983,9 +2025,9 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin if (fabs(dx_m_a - dy_m_a) > DELTA_TOLERANCE) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Lambert Conformal files where the x-axis and y-axis deltas are the same\n\n"; - exit(1); + return; } // As a sanity check, make sure that the deltas are constant through the @@ -1996,9 +2038,9 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin double curr_delta = fabs(x_values[i] - x_values[i-1]); if (fabs(curr_delta - dx_m_a) > DELTA_TOLERANCE) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Lambert Conformal files where the delta along the x-axis is constant\n\n"; - exit(1); + return; } } @@ -2007,9 +2049,9 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin double curr_delta = fabs(y_values[i] - y_values[i-1]); if (fabs(curr_delta - dy_m_a) > DELTA_TOLERANCE) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Lambert Conformal files where the delta along the y-axis is constant\n\n"; - exit(1); + return; } } @@ -2051,6 +2093,7 @@ void NcCfFile::get_grid_mapping_lambert_conformal_conic(const NcVar *grid_mappin grid.set(data); if (dy_m < 0) grid.set_swap_to_north(true); + grid_ready = true; if(std_parallel_att) delete std_parallel_att; if(central_lon_att) delete central_lon_att; @@ -2144,32 +2187,32 @@ void NcCfFile::get_grid_mapping_latitude_longitude(const NcVar *grid_mapping_var if (_xDim == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find X dimension (degrees_east) in netCDF file.\n\n"; - exit(1); + return; } if (_yDim == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find Y dimension (degrees_north) in netCDF file.\n\n"; - exit(1); + return; } if (_xCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find X coord variable (" << GET_NC_NAME_P(_xDim) << ") in netCDF file.\n\n"; - exit(1); + return; } if (_yCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find Y coord variable (" << GET_NC_NAME_P(_yDim) << ") in netCDF file.\n\n"; - exit(1); + return; } long lon_counts = _xDim->getSize(); @@ -2177,9 +2220,9 @@ void NcCfFile::get_grid_mapping_latitude_longitude(const NcVar *grid_mapping_var if (get_data_size(_xCoordVar) != lon_counts || get_data_size(_yCoordVar) != lat_counts) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Coordinate variables don't match dimension sizes in netCDF file.\n\n"; - exit(1); + return; } get_grid_from_lat_lon_vars(_yCoordVar, _xCoordVar, lat_counts, lon_counts); @@ -2277,17 +2320,17 @@ void NcCfFile::get_grid_mapping_polar_stereographic(const NcVar *grid_mapping_va << "This is an ellipsoidal earth.\n\n"; } else if(!has_scale_factor && !has_standard_parallel) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "The attribute \"scale_factor_at_projection_origin\" and \"standard_parallel\" of the " << GET_NC_NAME_P(grid_mapping_var) << " variable do not exist.\n\n"; - exit(1); + return; } else if(has_scale_factor && !is_eq(proj_origin_scale_factor, 1.0)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "Unexpected attribute value of " << proj_origin_scale_factor << " for the scale_factor_at_projection_origin attribute of the " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // Look for the x/y dimensions and x/y coordinate variables @@ -2296,9 +2339,9 @@ void NcCfFile::get_grid_mapping_polar_stereographic(const NcVar *grid_mapping_va if (get_data_size(_xCoordVar) != (int) GET_NC_SIZE_P(_xDim) || get_data_size(_yCoordVar) != (int) GET_NC_SIZE_P(_yDim)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "Coordinate variables don't match dimension sizes in netCDF file.\n\n"; - exit(1); + return; } // Make sure that the coordinate variables are given in meters. If we get @@ -2322,10 +2365,10 @@ void NcCfFile::get_grid_mapping_polar_stereographic(const NcVar *grid_mapping_va x_coord_units_name == "meters") x_coord_to_m_cf = 1.0; else if ( x_coord_units_name == "km") x_coord_to_m_cf = 1000.0; else { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "The X coordinates (" << x_coord_units_name << ") must be in meters or kilometers for MET.\n\n"; - exit(1); + return; } } } @@ -2347,9 +2390,9 @@ void NcCfFile::get_grid_mapping_polar_stereographic(const NcVar *grid_mapping_va y_coord_units_name == "meters" ) y_coord_to_m_cf = 1.0; else if ( y_coord_units_name == "km") y_coord_to_m_cf = 1000.0; else { - mlog << Error << "\n" << method_name - << "The X coordinates must be in meters or kilometers for MET.\n\n"; - exit(1); + mlog << Warning << "\n" << method_name + << "The Y coordinates must be in meters or kilometers for MET.\n\n"; + return; } } } @@ -2381,9 +2424,9 @@ void NcCfFile::get_grid_mapping_polar_stereographic(const NcVar *grid_mapping_va if (fabs(dx_m_a - dy_m_a) > DELTA_TOLERANCE) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "MET can only process Polar Stereographic files where the x-axis and y-axis deltas are the same.\n\n"; - exit(1); + return; } if (is_eq(semi_major_axis, bad_data_double)) @@ -2470,6 +2513,7 @@ void NcCfFile::get_grid_mapping_polar_stereographic(const NcVar *grid_mapping_va data.dump(); grid.set(data); + grid_ready = true; //Note: do not set grid.set_swap_to_north() @@ -2611,10 +2655,10 @@ void NcCfFile::get_grid_mapping_rotated_latitude_longitude(const NcVar *grid_map grid_mapping_var, (string)"grid_north_pole_latitude"); if (IS_INVALID_NC_P(grid_np_lat_att)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot get grid_north_pole_latitude attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // grid_north_pole_longitude @@ -2623,10 +2667,10 @@ void NcCfFile::get_grid_mapping_rotated_latitude_longitude(const NcVar *grid_map grid_mapping_var, (string)"grid_north_pole_longitude"); if (IS_INVALID_NC_P(grid_np_lon_att)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Cannot get grid_north_pole_longitude attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // Look for the grid_latitude and grid_longitude dimensions @@ -2703,32 +2747,32 @@ void NcCfFile::get_grid_mapping_rotated_latitude_longitude(const NcVar *grid_map if (_xDim == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find X dimension (degrees_east) in netCDF file.\n\n"; - exit(1); + return; } if (_yDim == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find Y dimension (degrees_north) in netCDF file.\n\n"; - exit(1); + return; } if (_xCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find X coord variable (" << GET_NC_NAME_P(_xDim) << ") in netCDF file.\n\n"; - exit(1); + return; } if (_yCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find Y coord variable (" << GET_NC_NAME_P(_yDim) << ") in netCDF file.\n\n"; - exit(1); + return; } long lon_counts = _xDim->getSize(); @@ -2736,9 +2780,9 @@ void NcCfFile::get_grid_mapping_rotated_latitude_longitude(const NcVar *grid_map if (get_data_size(_xCoordVar) != lon_counts || get_data_size(_yCoordVar) != lat_counts) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Coordinate variables don't match dimension sizes in netCDF file.\n\n"; - exit(1); + return; } // Store spacing in LatLon data structure @@ -2832,10 +2876,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"perspective_point_height"); if (IS_INVALID_NC_P(perspective_point_height_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get perspective_point_height attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // semi_major_axis @@ -2843,10 +2887,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"semi_major_axis"); if (IS_INVALID_NC_P(semi_major_axis_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get semi_major_axis attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // semi_minor_axis @@ -2854,10 +2898,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"semi_minor_axis"); if (IS_INVALID_NC_P(semi_minor_axis_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get semi_minor_axis attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // inverse_flattening @@ -2865,10 +2909,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"inverse_flattening"); if (IS_INVALID_NC_P(inverse_flattening_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get inverse_flattening attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // latitude_of_projection_origin @@ -2876,10 +2920,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"latitude_of_projection_origin"); if (IS_INVALID_NC_P(proj_origin_lat_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get latitude_of_projection_origin attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // longitude_of_projection_origin @@ -2887,10 +2931,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"longitude_of_projection_origin"); if (IS_INVALID_NC_P(proj_origin_lon_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get longitude_of_projection_origin attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // sweep_angle_axis @@ -2898,10 +2942,10 @@ void NcCfFile::get_grid_mapping_geostationary( grid_mapping_var, (string)"sweep_angle_axis"); if (IS_INVALID_NC_P(sweep_angle_axis_att)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Cannot get sweep_angle_axis attribute from " << GET_NC_NAME_P(grid_mapping_var) << " variable.\n\n"; - exit(1); + return; } // Look for the x/y dimensions and x/y coordinate variables @@ -2910,21 +2954,21 @@ void NcCfFile::get_grid_mapping_geostationary( bool do_exit = false; if (_xDim == nullptr) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Didn't find X dimension (projection_x_coordinate) in netCDF file.\n\n"; do_exit = true; } if (_yDim == nullptr) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Didn't find Y dimension (projection_y_coordinate) in netCDF file.\n\n"; do_exit = true; } if (_xCoordVar == nullptr) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Didn't find X coord variable (" << GET_NC_NAME_P(_xDim) << ") in netCDF file.\n\n"; do_exit = true; @@ -2932,7 +2976,7 @@ void NcCfFile::get_grid_mapping_geostationary( if (_yCoordVar == nullptr) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Didn't find Y coord variable (" << GET_NC_NAME_P(_yDim) << ") in netCDF file.\n\n"; do_exit = true; @@ -2941,12 +2985,12 @@ void NcCfFile::get_grid_mapping_geostationary( if (get_data_size(_xCoordVar) != (int) GET_NC_SIZE_P(_xDim) || get_data_size(_yCoordVar) != (int) GET_NC_SIZE_P(_yDim)) { - mlog << Error << "\n" << method_name + mlog << Warning << "\n" << method_name << "-> Coordinate variables don't match dimension sizes in netCDF file.\n\n"; do_exit = true; } - if (do_exit) exit(1); + if (do_exit) return; // Figure out the dx/dy and x/y pin values from the dimension variables @@ -2955,7 +2999,6 @@ void NcCfFile::get_grid_mapping_geostationary( get_nc_data(_xCoordVar, x_values); - long y_counts = GET_NC_SIZE_P(_yDim); double y_values[y_counts]; @@ -2977,7 +3020,7 @@ void NcCfFile::get_grid_mapping_geostationary( NcVar *var_y_bound = (NcVar *)nullptr; for (int j=0; j 0) { data.x_image_bounds = new double[bound_count]; data.y_image_bounds = new double[bound_count]; - if (0 != var_x_bound) get_nc_data(var_x_bound, data.x_image_bounds); - if (0 != var_y_bound) get_nc_data(var_y_bound, data.y_image_bounds); + if (nullptr != var_x_bound) get_nc_data(var_x_bound, data.x_image_bounds); + if (nullptr != var_y_bound) get_nc_data(var_y_bound, data.y_image_bounds); } double flatten = 1.0/data.inverse_flattening; @@ -3034,6 +3077,7 @@ void NcCfFile::get_grid_mapping_geostationary( // Note: Computing lat/lon was deferred because it took 1 minutes grid.set(data); + grid_ready = true; if (perspective_point_height_att) delete perspective_point_height_att; if (semi_major_axis_att) delete semi_major_axis_att; @@ -3112,19 +3156,19 @@ bool NcCfFile::get_grid_from_coordinates(const NcVar *data_var) { } if (_xCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find X coord variable (" << x_dim_var_name << ") in netCDF file.\n\n"; if (coordinates_att) delete coordinates_att; - return true; + return false; } if (_yCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find Y coord variable (" << y_dim_var_name << ") in netCDF file.\n\n"; if (coordinates_att) delete coordinates_att; - return true; + return false; } StringArray dimNames; @@ -3153,10 +3197,10 @@ bool NcCfFile::get_grid_from_coordinates(const NcVar *data_var) { if ((x_size != lon_counts && x_size != latlon_counts) || (y_size != lat_counts && x_size != latlon_counts)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Coordinate variables don't match dimension sizes in netCDF file.\n\n"; if (coordinates_att) delete coordinates_att; - exit(1); + return false; } if (coordinates_att) { @@ -3280,18 +3324,18 @@ bool NcCfFile::get_grid_from_dimensions() if (_xCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find X coord variable (" << GET_NC_NAME_P(_xDim) << ") in netCDF file.\n\n"; - exit(1); + return false; } if (_yCoordVar == nullptr) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Didn't find Y coord variable (" << GET_NC_NAME_P(_yDim) << ") in netCDF file.\n\n"; - exit(1); + return false; } long lat_counts = GET_NC_SIZE_P(_yDim); @@ -3327,19 +3371,25 @@ void NcCfFile::get_grid_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, const long lat_counts, const long lon_counts, bool &swap_to_north) { - static const string method_name = "get_data_from_lat_lon_vars()"; + static const string method_name = "NcCfFile::get_data_from_lat_lon_vars()"; // Figure out the dlat/dlon values from the dimension variables + LatLonData data; + data.name = latlon_proj_type; + data.Nlat = (int)lat_counts; + data.Nlon = (int)lon_counts; + long x_size = get_data_size(lon_var); long y_size = get_data_size(lat_var); long latlon_counts = lon_counts*lat_counts; bool two_dim_coord = (x_size == latlon_counts) && (y_size == latlon_counts ); + if( !two_dim_coord && (x_size != lon_counts || y_size != lat_counts)) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Coordinate variables don't match dimension sizes in netCDF file.\n\n"; - exit(1); + return data; } double lat_values[lat_counts]; @@ -3365,6 +3415,8 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, get_nc_data(lat_var,lat_values); get_nc_data(lon_var,lon_values); } + data.lat_ll = lat_values[0]; + data.lon_ll = rescale_lon(-lon_values[0]); // Calculate dlat and dlon assuming they are constant. @@ -3376,6 +3428,9 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, << " lon[" << (lon_counts-1) << "]=" << lon_values[lon_counts-1] << " dlon=" << dlon << "\n"; + data.delta_lat = dlat; + data.delta_lon = dlon; + ConcatString point_nccf; bool skip_sanity_check = get_att_value_string(_ncFile, nc_att_met_point_nccf, point_nccf); if (!skip_sanity_check) { @@ -3406,7 +3461,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, << i-1 << "]=" << lat_values[i-1] << " lat[" << i << "]=" << lat_values[i] << " " << fabs(curr_delta - dlat) << " > " << degree_tolerance << "\n"; - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Latitude/Longitude files where the latitudes are evenly spaced (dlat=" << dlat <<", delta[" << i << "]=" << curr_delta << ")\n\n"; sanity_check_failed = true; @@ -3426,7 +3481,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, << i-1 << "]=" << lon_values[i-1] << " lon[" << i << "]=" << lon_values[i] << " " << fabs(curr_delta - dlon) << " > " << degree_tolerance << "\n"; - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Latitude/Longitude files where the longitudes are evenly spaced (dlon=" << dlon <<", delta[" << i << "]=" << curr_delta << ")\n\n"; sanity_check_failed = true; @@ -3435,9 +3490,9 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, } if (sanity_check_failed) { - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "Please check the input data is the lat/lon projection\n\n"; - exit(1); + return data; } } @@ -3450,16 +3505,6 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, // guaranteed anywhere that I see. But if this is not the case, then we // will probably also need to reorder the data itself. - LatLonData data; - - data.name = latlon_proj_type; - data.lat_ll = lat_values[0]; - data.lon_ll = rescale_lon(-lon_values[0]); - data.delta_lat = dlat; - data.delta_lon = dlon; - data.Nlat = lat_counts; - data.Nlon = lon_counts; - if (dlat < 0) { swap_to_north = true; data.delta_lat = -dlat; @@ -3468,6 +3513,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, else { swap_to_north = false; } + grid_ready = true; return data; diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.h b/src/libcode/vx_data2d_nc_cf/nc_cf_file.h index 5e29896459..f6f0b8b3fa 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.h +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.h @@ -56,18 +56,18 @@ class NcCfFile { int getNx() const { - if (_xDim == 0) + if (_xDim == nullptr) return 0; - return GET_NC_SIZE_P(_xDim); + return (int)GET_NC_SIZE_P(_xDim); } int getNy() const { - if (_yDim == 0) + if (_yDim == nullptr) return 0; - return GET_NC_SIZE_P(_yDim); + return (int)GET_NC_SIZE_P(_yDim); } NcVarInfo *get_time_var_info() const { return _time_var_info; } @@ -112,6 +112,8 @@ class NcCfFile { bool getData(const char *, const LongArray &, DataPlane &, NcVarInfo *&) const; + bool update_grid(const Grid &); + Grid build_grid_from_lat_lon_vars(netCDF::NcVar *lat_var, netCDF::NcVar *lon_var, const long lat_counts, const long lon_counts); NcVarInfo* find_var_name(const char * var_name) const; @@ -122,6 +124,8 @@ class NcCfFile { static const double DELTA_TOLERANCE; netCDF::NcFile * _ncFile; // allocated + bool grid_ready; + bool has_attr_grid; // // dimensions diff --git a/src/libcode/vx_nc_util/nc_utils.hpp b/src/libcode/vx_nc_util/nc_utils.hpp index c9024a471d..7298a7e4d8 100644 --- a/src/libcode/vx_nc_util/nc_utils.hpp +++ b/src/libcode/vx_nc_util/nc_utils.hpp @@ -236,46 +236,100 @@ void apply_scale_factor_(T *data, const int cell_count, clock_t start_clock = clock(); const char *method_name = "apply_scale_factor(T) "; - if (cell_count > 0) { - int idx; - int positive_cnt = 0; - int unpacked_count = 0; - T min_value, max_value; - T raw_min_val, raw_max_val; + if (cell_count <= 0) return; + + T min_value; + T max_value; + T raw_min_val; + T raw_max_val; + int idx = 0; + int positive_cnt = 0; + int unpacked_count = 0; + + if (has_fill_value) { + // Set met_fill_value (-9999) for FillValues (missing values) + for (; idx data[idx]) raw_min_val = data[idx]; + if (raw_max_val < data[idx]) raw_max_val = data[idx]; + data[idx] = (data[idx] * scale_factor) + add_offset; + if (data[idx] > 0) positive_cnt++; + if (min_value > data[idx]) min_value = data[idx]; + if (max_value < data[idx]) max_value = data[idx]; + unpacked_count++; } + } + mlog << Debug(debug_level) << method_name << var_name + << "(data_type=" << typeid(data[0]).name() << "): unpacked data: count=" + << unpacked_count << " out of " << cell_count + << ", scale_factor=" << scale_factor<< " add_offset=" << add_offset + << ". FillValue(" << data_type << ")=" << nc_fill_value << "\n"; + mlog << Debug(debug_level) << method_name + << " data range [" << min_value << " - " << max_value + << "] raw data: [" << raw_min_val << " - " << raw_max_val + << "] Positive count: " << positive_cnt << "\n"; - raw_min_val = raw_max_val = data[idx]; - min_value = max_value = (data[idx] * scale_factor) + add_offset; - for (; idx data[idx]) raw_min_val = data[idx]; - if (raw_max_val < data[idx]) raw_max_val = data[idx]; - data[idx] = (data[idx] * scale_factor) + add_offset; - if (data[idx] > 0) positive_cnt++; - if (min_value > data[idx]) min_value = data[idx]; - if (max_value < data[idx]) max_value = data[idx]; - unpacked_count++; - } + mlog << Debug(debug_level) << method_name << " took " + << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + return; +} + +//////////////////////////////////////////////////////////////////////// + +template +void update_missing_values(T *data, const long cell_count, + const T nc_fill_value, const T met_fill_value, + const char *data_type, const char *var_name) { + int missing_count = 0; + const int debug_level = 7; + clock_t start_clock = clock(); + const char *method_name = "update_missing_values(T) "; + + if (cell_count <= 0) return; + + T max_value; + T min_value; + long idx = 0; + int positive_cnt = 0; + + // Set met_fill_value (-9999) for FillValues (missing values) + for (; idx data[idx]) min_value = data[idx]; + if (max_value < data[idx]) max_value = data[idx]; + } + } + mlog << Debug(debug_level) << method_name << var_name + << "(data_type=" << typeid(data[0]).name() << "): FillValue(" << data_type << ")=" << nc_fill_value << "\n"; + mlog << Debug(debug_level) << method_name + << " data range [" << min_value << " - " << max_value + << "] Positive count: " << positive_cnt << "\n"; + if (0 < missing_count) { + mlog << Debug(3) << method_name << var_name + << "(data_type=" << typeid(data[0]).name() << "): found " << missing_count << " FillValues out of " << cell_count << "\n"; } mlog << Debug(debug_level) << method_name << " took " << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; @@ -311,18 +365,23 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, const T met_missing) { bool return_status = get_nc_data_t(var, data); if (return_status) { + T nc_missing; + const int cell_count = get_data_size(var); + bool has_missing_attr = get_var_fill_value(var, nc_missing); + if (!has_missing_attr) nc_missing = met_missing; + //scale_factor and add_offset if (has_add_offset_attr(var) || has_scale_factor_attr(var)) { - T nc_missing; - const int cell_count = get_data_size(var); double add_offset = get_var_add_offset(var); double scale_factor = get_var_scale_factor(var); - bool has_missing_attr = get_var_fill_value(var, nc_missing); - if (!has_missing_attr) nc_missing = met_missing; apply_scale_factor_(data, cell_count, add_offset, scale_factor, nc_missing, met_missing, has_missing_attr, "", GET_NC_NAME_P(var).c_str()); } + else if (has_missing_attr) { + update_missing_values(data, cell_count, nc_missing, met_missing, + "", GET_NC_NAME_P(var).c_str()); + } } return return_status; } @@ -330,7 +389,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, const T met_missing) { //////////////////////////////////////////////////////////////////////// template -bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &dims, const LongArray &curs) { +bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const LongArray &dims, const LongArray &curs) { bool return_status = false; const char *method_name = "get_nc_data_(T, *dims, *curs) "; @@ -371,7 +430,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &dims } for (int idx1=0; idx1getVar(start, count, data); return_status = true; + T nc_missing; + bool has_missing_attr = get_var_fill_value(var, nc_missing); + if (!has_missing_attr) nc_missing = met_missing; + //scale_factor and add_offset if (has_add_offset_attr(var) || has_scale_factor_attr(var)) { - T nc_missing; double add_offset = get_var_add_offset(var); double scale_factor = get_var_scale_factor(var); - bool has_missing_attr = get_var_fill_value(var, nc_missing); - if (!has_missing_attr) nc_missing = bad_data; apply_scale_factor_(data, data_size, add_offset, scale_factor, - nc_missing, bad_data, has_missing_attr, + nc_missing, met_missing, has_missing_attr, "", GET_NC_NAME_P(var).c_str()); } + else if (has_missing_attr) { + update_missing_values(data, data_size, nc_missing, met_missing, + "", GET_NC_NAME_P(var).c_str()); + } } return return_status; } @@ -437,17 +501,22 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const long dim, co var->getVar(start, count, data); return_status = true; + T nc_missing; + bool has_missing_attr = get_var_fill_value(var, nc_missing); + if (!has_missing_attr) nc_missing = met_missing; + //scale_factor and add_offset if (has_add_offset_attr(var) || has_scale_factor_attr(var)) { - T nc_missing; double add_offset = get_var_add_offset(var); double scale_factor = get_var_scale_factor(var); - bool has_missing_attr = get_var_fill_value(var, nc_missing); - if (!has_missing_attr) nc_missing = met_missing; apply_scale_factor_(data, dim, add_offset, scale_factor, nc_missing, met_missing, has_missing_attr, "", GET_NC_NAME_P(var).c_str()); } + else if (has_missing_attr) { + update_missing_values(data, dim, nc_missing, met_missing, + "", GET_NC_NAME_P(var).c_str()); + } } return return_status; } @@ -456,7 +525,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const long dim, co // read a single data template -bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &curs) { +bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const LongArray &curs) { bool return_status = false; //const char *method_name = "get_nc_data_(*curs) "; @@ -470,7 +539,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &curs } // Retrieve the NetCDF value from the NetCDF variable. - return_status = get_nc_data_(var, data, bad_data, dims, curs); + return_status = get_nc_data_(var, data, met_missing, dims, curs); } return return_status; } diff --git a/src/libcode/vx_statistics/apply_mask.cc b/src/libcode/vx_statistics/apply_mask.cc index 03e31e97c7..bd12b1a25b 100644 --- a/src/libcode/vx_statistics/apply_mask.cc +++ b/src/libcode/vx_statistics/apply_mask.cc @@ -89,21 +89,8 @@ Grid parse_grid_string(const char *grid_str) { Grid grid; StringArray sa; - // Parse as a white-space separated string - sa.parse_wsss(grid_str); - - // Search for a named grid - if(sa.n() == 1 && find_grid_by_name(sa[0].c_str(), grid)) { - mlog << Debug(3) << "Use the grid named \"" - << grid_str << "\".\n"; - } - // Parse grid definition - else if(sa.n() > 1 && parse_grid_def(sa, grid)) { - mlog << Debug(3) << "Use the grid defined by string \"" - << grid_str << "\".\n"; - } - // Extract the grid from a gridded data file - else { + if (!build_grid_by_grid_string(grid_str, grid, "parse_grid_strin", false)) { + // Extract the grid from a gridded data file mlog << Debug(3) << "Use the grid defined by file \"" << grid_str << "\".\n"; @@ -228,24 +215,8 @@ void parse_grid_mask(const ConcatString &mask_grid_str, Grid &grid) { // Check for empty input string if(mask_grid_str.empty()) return; - // Parse mask_grid_str as a white-space separated string - StringArray sa; - sa.parse_wsss(mask_grid_str); - - // Named grid - if(sa.n() == 1 && find_grid_by_name(mask_grid_str.c_str(), grid)) { - mlog << Debug(3) - << "Use the grid named \"" << mask_grid_str << "\".\n"; - } - // Grid specification string - else if(sa.n() > 1 && parse_grid_def(sa, grid)) { - mlog << Debug(3) - << "Use the grid defined by string \"" << mask_grid_str - << "\".\n"; - } - // Extract the grid from a gridded data file - else { - + if (!build_grid_by_grid_string(mask_grid_str, grid, "parse_grid_mask", false)) { + // Extract the grid from a gridded data file mlog << Debug(3) << "Use the grid defined by file \"" << mask_grid_str << "\".\n"; diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 7612f0d7d2..98b15a212a 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -177,24 +177,8 @@ void process_command_line(int argc, char **argv) { void process_input_grid(DataPlane &dp) { - // Parse the input grid as a white-space separated string - StringArray sa; - sa.parse_wsss(input_gridname); - - // Search for a named grid - if(sa.n() == 1 && find_grid_by_name(sa[0].c_str(), grid)) { - mlog << Debug(3) - << "Use input grid named \"" << input_gridname << "\".\n"; - } - // Parse grid definition - else if(sa.n() > 1 && parse_grid_def(sa, grid)) { - mlog << Debug(3) - << "Use input grid defined by string \"" << input_gridname - << "\".\n"; - } - // Extract the grid from a gridded data file - else { - + if (!build_grid_by_grid_string(input_gridname, grid, "process_input_grid", false)) { + // Extract the grid from a gridded data file mlog << Debug(3) << "Use input grid defined by file \"" << input_gridname << "\".\n"; @@ -284,22 +268,7 @@ void process_mask_file(DataPlane &dp) { // For the grid mask type, support named grids and grid // specification strings if(mask_type == MaskType::Grid) { - - // Parse the mask file as a white-space separated string - StringArray sa; - sa.parse_wsss(mask_filename); - - // Search for a named grid - if(sa.n() == 1 && find_grid_by_name(sa[0].c_str(), grid_mask)) { - mlog << Debug(3) - << "Use mask grid named \"" << mask_filename << "\".\n"; - } - // Parse grid definition - else if(sa.n() > 1 && parse_grid_def(sa, grid_mask)) { - mlog << Debug(3) - << "Use mask grid defined by string \"" << mask_filename - << "\".\n"; - } + build_grid_by_grid_string(mask_filename, grid_mask, "process_mask_file", false); } // Parse as a gridded data file if not already set diff --git a/src/tools/other/mode_time_domain/3d_conv.cc b/src/tools/other/mode_time_domain/3d_conv.cc index d204ee61b0..1ecbe0b68a 100644 --- a/src/tools/other/mode_time_domain/3d_conv.cc +++ b/src/tools/other/mode_time_domain/3d_conv.cc @@ -154,8 +154,6 @@ struct DataHandle { { - int j; - _out.put('\n'); _out << " DataHandle:\n"; @@ -168,13 +166,13 @@ struct DataHandle { _out << " plane_loaded = ["; - for (j=0; j 0) { - - // Parse as a white-space separated string - sa.parse_wsss(plot_grid_string); - - // Search for a named grid - if(sa.n() == 1 && find_grid_by_name(sa[0].c_str(), grid)) { - mlog << Debug(3) << "Use the grid named \"" - << plot_grid_string << "\".\n"; - } - // Parse grid definition - else if(sa.n() > 1 && parse_grid_def(sa, grid)) { - mlog << Debug(3) << "Use the grid defined by string \"" - << plot_grid_string << "\".\n"; - } - // Extract the grid from a gridded data file - else { + if (!build_grid_by_grid_string(plot_grid_string, grid, + "PlotPointObsConfInfo::process_config -> ", false)) { + // Extract the grid from a gridded data file mlog << Debug(3) << "Use the grid defined by file \"" << plot_grid_string << "\".\n"; diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index de7d284fc1..73210e4b27 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -30,7 +30,7 @@ #include #include -#include +#include #include "main.h" #include "vx_log.h" @@ -424,6 +424,7 @@ static void process_data_file() { // Get the obs type before opening NetCDF obs_type = get_obs_type(nc_in); goes_data = (obs_type == TYPE_GOES || obs_type == TYPE_GOES_ADP); + if (obs_type == TYPE_UNKNOWN && ftype == FileType_NcCF) obs_type = TYPE_NCCF; if (obs_type == TYPE_NCCF) setenv(nc_att_met_point_nccf, "yes", 1); // Read the input data file @@ -594,14 +595,33 @@ bool get_nc_data_string_array(NcFile *nc, const char *var_name, static int get_obs_type(NcFile *nc) { int obs_type = TYPE_UNKNOWN; + MetConfig config; ConcatString att_val_scene_id; ConcatString att_val_project; ConcatString input_type; static const char *method_name = "get_obs_type() -> "; - bool has_project = get_global_att(nc, (string)"project", att_val_project); - bool has_scene_id = get_global_att(nc, (string)"scene_id", att_val_scene_id); - if( has_scene_id && has_project && att_val_project == "GOES" ) { + bool has_attr_grid = false; + auto vinfo = VarInfoFactory::new_var_info(FileType_NcCF); + for(int i=0; iclear(); + // Populate the VarInfo object using the config string + config.read_string(FieldSA[i].c_str()); + vinfo->set_dict(config); + if (vinfo->grid_attr().is_set()) { + has_attr_grid = true; + break; + } + } + if (vinfo) { delete vinfo; vinfo = (VarInfo *) nullptr; } + + if (has_attr_grid) { + obs_type = TYPE_NCCF; + input_type = "OBS_NCCF"; + } + else if (get_global_att(nc, (string)"scene_id", att_val_scene_id) + && get_global_att(nc, (string)"project", att_val_project) + && att_val_project == "GOES" ) { obs_type = TYPE_GOES; input_type = "GOES"; if (!adp_filename.empty()) { @@ -693,12 +713,15 @@ std::set prepare_qoes_qc_array() { void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarInfo *vinfo, const Grid &to_grid) { - int idx, hdr_idx; + int hdr_idx; int var_idx_or_gc; ConcatString vname; - DataPlane fr_dp, to_dp; - DataPlane cnt_dp, mask_dp; - DataPlane prob_dp, prob_mask_dp; + DataPlane fr_dp; + DataPlane to_dp; + DataPlane cnt_dp; + DataPlane mask_dp; + DataPlane prob_dp; + DataPlane prob_mask_dp; bool has_prob_thresh = !prob_cat_thresh.check(bad_data_double); @@ -807,7 +830,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI } else { bool not_found_grib_code = true; - for (idx=0; idxobs_ids[idx]) { not_found_grib_code = false; break; @@ -824,7 +847,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI if (exit_by_field_name_error) { ConcatString log_msg; if (use_var_id) { - for (idx=0; idxobs_ids[idx])) { grib_codes.add(obs_data->obs_ids[idx]); if (0 < idx) log_msg << ", "; @@ -855,7 +878,9 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI // Check the time range. Apply the time window bool valid_time_from_config = true; - unixtime valid_beg_ut, valid_end_ut, obs_time; + unixtime valid_beg_ut; + unixtime valid_end_ut; + unixtime obs_time; valid_time_array.clear(); valid_time = vinfo->valid(); @@ -865,7 +890,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI valid_beg_ut = valid_end_ut = valid_time; if (!is_bad_data(conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; if (!is_bad_data(conf_info.end_ds)) valid_end_ut += conf_info.end_ds; - for(idx=0; idx valid_time) valid_time = obs_time; } @@ -915,7 +940,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI int filtered_by_time = 0; int filtered_by_msg_type = 0; int filtered_by_qc = 0; - for (idx=0; idx < nobs; idx++) { + for (int idx=0; idx < nobs; idx++) { if (var_idx_or_gc == obs_data->obs_ids[idx]) { var_count2++; hdr_idx = obs_data->obs_hids[idx]; @@ -1104,7 +1129,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI log_msg << ", by msg_type: " << filtered_by_msg_type; if (0 < filtered_by_msg_type) { log_msg << " ["; - for(idx=0; idx 0) log_msg << ","; log_msg << conf_info.message_type[idx]; } @@ -1113,7 +1138,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI log_msg << ", by QC: " << filtered_by_qc; if (0 < filtered_by_qc) { log_msg << " ["; - for(idx=0; idx 0) log_msg << ","; log_msg << qc_flags[idx]; } @@ -1179,7 +1204,7 @@ static void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, nc_point_obs.close(); mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; } @@ -1216,7 +1241,7 @@ static void process_point_python(const string python_command, MetConfig &config, met_point_file.close(); mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; return; } @@ -1234,10 +1259,10 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, bool *skip_times = nullptr; double *valid_times = nullptr; int filtered_by_time = 0; + int time_from_size = 1; clock_t start_clock = clock(); bool opt_all_attrs = false; Grid fr_grid = fr_mtddf->grid(); - int from_size = fr_grid.nx() * fr_grid.ny(); static const char *method_name = "process_point_nccf_file() -> "; NcVar var_lat; @@ -1247,10 +1272,10 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, ConcatString lon_vname = conf_info.get_var_name(conf_key_lon_vname); if (lat_vname != conf_key_lat_vname && lon_vname != conf_key_lon_vname) { - if (lat_vname != conf_key_lat_vname && has_var(nc_in, lat_vname.c_str())) { + if (has_var(nc_in, lat_vname.c_str())) { var_lat = get_nc_var(nc_in, lat_vname.c_str()); } - if (lon_vname != conf_key_lon_vname && has_var(nc_in, lon_vname.c_str())) { + if (has_var(nc_in, lon_vname.c_str())) { var_lon = get_nc_var(nc_in, lon_vname.c_str()); } if (IS_INVALID_NC(var_lat)) { @@ -1270,7 +1295,7 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, // Find lat/lon variables from the coordinates attribue if (0 < FieldSA.n() && !user_defined_latlon) { ConcatString coordinates_value; - VarInfoNcCF var_info = VarInfoNcCF(*(VarInfoNcCF *)vinfo); + auto var_info = VarInfoNcCF(*(VarInfoNcCF *)vinfo); // Initialize var_info.clear(); // Populate the VarInfo object using the config string @@ -1322,8 +1347,9 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, if( IS_VALID_NC(time_var) ) { if( 1 < get_dim_count(&time_var) ) { double max_time = bad_data_double; - skip_times = new bool[from_size]; - valid_times = new double[from_size]; + time_from_size = get_data_size(&time_var); + skip_times = new bool[time_from_size]; + valid_times = new double[time_from_size]; if (get_nc_data(&time_var, valid_times)) { int sec_per_unit = 0; bool no_leap_year = false; @@ -1334,7 +1360,7 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, if (!is_bad_data(conf_info.end_ds)) valid_end_ut += conf_info.end_ds; ref_ut = get_reference_unixtime(&time_var, sec_per_unit, no_leap_year); } - for (int i=0; i 0 ) { tmp_time = add_to_unixtime(ref_ut, sec_per_unit, valid_times[i], no_leap_year); @@ -1405,7 +1431,10 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, // List range of data values if(mlog.verbosity_level() >= 2) { - double fr_dmin, fr_dmax, to_dmin, to_dmax; + double fr_dmin; + double fr_dmax; + double to_dmin; + double to_dmax; fr_dp.data_range(fr_dmin, fr_dmax); to_dp.data_range(to_dmin, to_dmax); mlog << Debug(2) << "Range of data (" << FieldSA[i] << ")\n" @@ -1428,7 +1457,8 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, bool has_prob_thresh = !prob_cat_thresh.check(bad_data_double); if (has_prob_thresh || do_gaussian_filter) { - DataPlane prob_dp, prob_mask_dp; + DataPlane prob_dp; + DataPlane prob_mask_dp; ConcatString vname_prob = vname; vname_prob << "_prob_" << prob_cat_thresh.get_abbr_str(); int nx = to_dp.nx(); @@ -1477,12 +1507,12 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, cellMapping = (IntArray *) nullptr; if( 0 < filtered_by_time ) { mlog << Debug(2) << method_name << "Filtered by time: " << filtered_by_time - << " out of " << from_size + << " out of " << time_from_size << " [" << unix_to_yyyymmdd_hhmmss(valid_beg_ut) << " to " << unix_to_yyyymmdd_hhmmss(valid_end_ut) << "]\n"; } mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; return; } @@ -1506,9 +1536,6 @@ static void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, exit(1); } - int from_lat_cnt = fr_grid.ny(); - int from_lon_cnt = fr_grid.nx(); - int from_data_size = from_lat_cnt * from_lon_cnt; if(!fr_mtddf->data_plane(*vinfo, fr_dp)) { mlog << Error << "\n" << method_name << "Trouble reading data \"" @@ -1516,106 +1543,112 @@ static void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, << InputFilename << "\"\n\n"; exit(1); } - else { - bool is_to_north = !fr_grid.get_swap_to_north(); - auto from_data = new float[from_data_size]; - for (int xIdx=0; xIdx= 4) { - if (from_min_value > data_value) from_min_value = data_value; - if (from_max_value < data_value) from_max_value = data_value; - } + int from_index; + int no_map_cnt = 0; + int missing_cnt = 0; + int non_missing_cnt = 0; + double data_value; + IntArray cellArray; + NumArray dataArray; + double from_min_value = 10e10; + double from_max_value = -10e10; + int to_lat_cnt = to_grid.ny(); + int to_lon_cnt = to_grid.nx(); + + missing_cnt = non_missing_cnt = 0; + to_dp.set_constant(bad_data_double); + + for (int xIdx=0; xIdx= 9) { - double to_lat, to_lon; - to_grid.xy_to_latlon(xIdx,yIdx, to_lat, to_lon); - to_lon *= -1; - if (1 == data_cnt) - mlog << Debug(9) << method_name - << "value: " << to_value << " to (" << to_lon << ", " << to_lat - << ") from offset " << from_index << ".\n"; - else - mlog << Debug(9) << method_name - << "value: " << to_value - << ", max: " << dataArray.max() - << ", min: " << dataArray.min() - << ", mean: " << dataArray.sum()/data_cnt - << " from " << data_cnt << " (out of " << cellArray.n() - << ") data values to (" << to_lon << ", " << to_lat << ").\n"; - } + dataArray.add(data_value); + non_missing_cnt++; + if(mlog.verbosity_level() >= 4) { + if (from_min_value > data_value) from_min_value = data_value; + if (from_max_value < data_value) from_max_value = data_value; } } - else { - no_map_cnt++; + + if (0 < dataArray.n()) { + double to_value; + int data_cnt = dataArray.n(); + if (1 == data_cnt) to_value = dataArray[0]; + else if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { + dataArray.sort_array(); + to_value = dataArray[data_cnt/2]; + if (0 == data_cnt % 2) + to_value = (to_value + dataArray[(data_cnt/2)+1])/2; + } + else to_value = dataArray.sum() / data_cnt; // UW_Mean + + to_dp.set(to_value, xIdx, yIdx); + to_cell_cnt++; + if(mlog.verbosity_level() >= 9) { + double to_lat; + double to_lon; + to_grid.xy_to_latlon(xIdx,yIdx, to_lat, to_lon); + to_lon *= -1; + if (1 == data_cnt) + mlog << Debug(9) << method_name + << "value: " << to_value << " to (" << to_lon << ", " << to_lat + << ") from offset " << from_index << ".\n"; + else + mlog << Debug(9) << method_name + << "value: " << to_value + << ", max: " << dataArray.max() + << ", min: " << dataArray.min() + << ", mean: " << dataArray.sum()/data_cnt + << " from " << data_cnt << " (out of " << cellArray.n() + << ") data values to (" << to_lon << ", " << to_lat << ").\n"; + } } } + else { + no_map_cnt++; + } } + } - delete [] from_data; + delete [] from_data; - mlog << Debug(4) << method_name << "[Count] data cells: " << to_cell_cnt - << ", missing: " << missing_cnt << ", non_missing: " << non_missing_cnt - << ", non mapped cells: " << no_map_cnt - << " out of " << (to_lat_cnt*to_lon_cnt) - << "\n\tRange: data: [" << from_min_value << " - " << from_max_value - << "]\n"; - } + mlog << Debug(4) << method_name << "[Count] data cells: " << to_cell_cnt + << ", missing: " << missing_cnt << ", non_missing: " << non_missing_cnt + << ", non mapped cells: " << no_map_cnt + << " out of " << (to_lat_cnt*to_lon_cnt) + << "\n\tRange: data: [" << from_min_value << " - " << from_max_value + << "]\n"; if (to_cell_cnt == 0) { mlog << Warning << "\n" << method_name @@ -1623,7 +1656,7 @@ static void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, } mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; } //////////////////////////////////////////////////////////////////////// @@ -1818,7 +1851,10 @@ static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, // List range of data values if(mlog.verbosity_level() >= 2) { - double fr_dmin, fr_dmax, to_dmin, to_dmax; + double fr_dmin; + double fr_dmax; + double to_dmin; + double to_dmax; fr_dp.data_range(fr_dmin, fr_dmax); to_dp.data_range(to_dmin, to_dmax); mlog << Debug(2) << "Range of data (" << FieldSA[i] << ")\n" @@ -1848,7 +1884,8 @@ static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, bool has_prob_thresh = !prob_cat_thresh.check(bad_data_double); if (has_prob_thresh || do_gaussian_filter) { - DataPlane prob_dp, prob_mask_dp; + DataPlane prob_dp; + DataPlane prob_mask_dp; ConcatString vname_prob = vname; vname_prob << "_prob_" << prob_cat_thresh.get_abbr_str(); int nx = to_dp.nx(); @@ -1901,7 +1938,7 @@ static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, clear_cell_mapping(cellMapping); delete [] cellMapping; cellMapping = (IntArray *) nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; return; } @@ -2018,7 +2055,8 @@ static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, return status; } - double x, y; + double x; + double y; DataPlane to_dp; int to_lat_count = to_grid.ny(); int to_lon_count = to_grid.nx(); @@ -2050,7 +2088,7 @@ static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, << ((obs_count > 0) ? 1.0*count_in_grid/obs_count*100 : 0) << "%)\n"; } mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; return status; } @@ -2061,15 +2099,17 @@ static void get_grid_mapping_latlon( DataPlane from_dp, DataPlane to_dp, Grid to_grid, IntArray *cellMapping, float *latitudes, float *longitudes, int from_lat_count, int from_lon_count, bool *skip_times, bool to_north) { - double x, y; - double to_ll_lat, to_ll_lon; + double x; + double y; + double to_ll_lat; + double to_ll_lon; int count_in_grid = 0; clock_t start_clock = clock(); int to_lat_count = to_grid.ny(); int to_lon_count = to_grid.nx(); int to_size = to_lat_count * to_lon_count; int data_size = from_lat_count * from_lon_count; - static const char *method_name = "get_grid_mapping(lats, lons) -> "; + static const char *method_name = "get_grid_mapping_latlon(lats, lons) -> "; auto to_cell_counts = new int[to_size]; auto mapping_indices = new int[data_size]; @@ -2088,7 +2128,7 @@ static void get_grid_mapping_latlon( float lat = latitudes[coord_offset]; float lon = longitudes[coord_offset]; if( lat < MISSING_LATLON || lon < MISSING_LATLON ) continue; - to_grid.latlon_to_xy(lat, -1.0*lon, x, y); + to_grid.latlon_to_xy(lat, -1.0*rescale_lon(lon), x, y); int idx_x = nint(x); int idx_y = nint(y); if (0 <= idx_x && idx_x < to_lon_count && 0 <= idx_y && idx_y < to_lat_count) { @@ -2097,16 +2137,17 @@ static void get_grid_mapping_latlon( to_cell_counts[to_offset] += 1; count_in_grid++; if(mlog.verbosity_level() >= 15) { - double to_lat, to_lon; + double to_lat; + double to_lon; to_grid.xy_to_latlon(idx_x, idx_y, to_lat, to_lon); - mlog << Debug(15) << method_name << " [" << xIdx << "," << yIdx << "] to " << coord_offset - << " (" << lon << ", " << lat << ") to (" << (to_lon*-1) << ", " << to_lat << ")\n"; + mlog << Debug(15) << method_name << " index: [" << xIdx << "," << yIdx << "] to " << coord_offset + << " (" << lon << ", " << lat << ") to (" << rescale_lon(-1*to_lon) << ", " << to_lat << ")\n"; } } } } mlog << Debug(LEVEL_FOR_PERFORMANCE+2) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds for mapping cells\n"; + << get_exe_duration(start_clock) << " seconds for mapping cells\n"; // Count the mapping cells for each to_cell and prepare IntArray int max_count = 0; @@ -2129,7 +2170,7 @@ static void get_grid_mapping_latlon( } } mlog << Debug(LEVEL_FOR_PERFORMANCE+1) << method_name << "took " - << (clock()-tmp_clock)/double(CLOCKS_PER_SEC) + << get_exe_duration(tmp_clock) << " seconds for extending IntArray (max_cells=" << max_count << ")\n"; // Build cell mapping @@ -2150,7 +2191,7 @@ static void get_grid_mapping_latlon( mlog << Debug(3) << method_name << "within grid: " << count_in_grid << " out of " << data_size << " (" << 1.0*count_in_grid/data_size*100 << "%)\n"; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; } //////////////////////////////////////////////////////////////////////// @@ -2158,7 +2199,8 @@ static void get_grid_mapping_latlon( static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, NcVar var_lat, NcVar var_lon, bool *skip_times) { bool status = false; - DataPlane from_dp, to_dp; + DataPlane from_dp; + DataPlane to_dp; ConcatString cur_coord_name; clock_t start_clock = clock(); static const char *method_name = "get_grid_mapping(var_lat, var_lon) -> "; @@ -2167,7 +2209,14 @@ static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray int to_lon_count = to_grid.nx(); int from_lat_count = fr_grid.ny(); int from_lon_count = fr_grid.nx(); - + if (0 == from_lat_count) { + int dim_offset = get_dim_count(&var_lat) - 1; + if (dim_offset < 0) dim_offset = 0; + from_lat_count = get_dim_size(&var_lat, dim_offset); + dim_offset = get_dim_count(&var_lon) - 2; + if (dim_offset < 0) dim_offset = 0; + from_lon_count = get_dim_size(&var_lon, dim_offset); + } // Override the from nx & ny from NetCDF if exists int data_size = from_lat_count * from_lon_count; mlog << Debug(4) << method_name << "data_size (ny*nx): " << data_size @@ -2212,7 +2261,7 @@ static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray if( longitudes ) delete [] longitudes; } // if data_size > 0 mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; return status; } @@ -2272,7 +2321,8 @@ static ConcatString get_goes_grid_input(MetConfig config, const Grid fr_grid) { static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, const ConcatString &geostationary_file) { static const char *method_name = "get_grid_mapping() -> "; - DataPlane from_dp, to_dp; + DataPlane from_dp; + DataPlane to_dp; ConcatString cur_coord_name; clock_t start_clock = clock(); @@ -2431,7 +2481,7 @@ static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray if(coord_nc_in) delete coord_nc_in; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; } //////////////////////////////////////////////////////////////////////// @@ -2831,7 +2881,7 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, } mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; } //////////////////////////////////////////////////////////////////////// @@ -2900,7 +2950,7 @@ static void save_geostationary_data(const ConcatString geostationary_file, delete nc_file; nc_file = nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " - << (clock()-start_clock)/double(CLOCKS_PER_SEC) << " seconds\n"; + << get_exe_duration(start_clock) << " seconds\n"; } //////////////////////////////////////////////////////////////////////// From f474e8ac74830c218e15fc76cc0438521745db04 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 5 Sep 2024 09:36:52 -0600 Subject: [PATCH 114/114] Bugfix #2958 develop BAGSS SEDI CI (#2959) --- src/libcode/vx_statistics/contable_stats.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcode/vx_statistics/contable_stats.cc b/src/libcode/vx_statistics/contable_stats.cc index 7e7194c11d..7e7b8b4783 100644 --- a/src/libcode/vx_statistics/contable_stats.cc +++ b/src/libcode/vx_statistics/contable_stats.cc @@ -309,8 +309,8 @@ double TTContingencyTable::bagss() const { ha = (double) oy() - (fy_on() / lf) * lw; } - num = ha - (oy() * oy() / n()); - den = 2.0*oy() - ha - (oy() * oy() / n()); + num = ha - ((double) oy() * oy() / n()); + den = 2.0*oy() - ha - ((double) oy() * oy() / n()); if(is_eq(den, 0.0)) v = bad_data_double; else v = num/den; @@ -698,7 +698,7 @@ double TTContingencyTable::sedi_ci(double alpha, double &cl, double &cu) const { double v, h, f, b, se, mf, mh; - v = edi(); + v = sedi(); f = (double) fy_on() / (fy_on() + fn_on()); h = pod_yes(); b = baser();