From ddf29e0d6872f602afd0552ccb8e0c117d6374d9 Mon Sep 17 00:00:00 2001 From: johnhg Date: Tue, 27 Apr 2021 10:27:19 -0600 Subject: [PATCH] Bugfix 1768 edeck (#1769) * Per #1768, update logic in ATCFProbLine::read_line(). If read_line() from the base class returns bad status, have this one return bad status as well. But do NOT for unsupported line types. Just print a Debug(4) log message instead. * Per #1768, update the probability line types to match those listed in https://www.nrlmry.navy.mil/atcf_web/docs/database/new/edeck.txt. That documentation was last updated in 11/2020, so presumably these reflect NHC's latest changes. * Per #1768, renaming enumerated value from ATCFLineType_ProbRIRW to ATCFLineType_ProbRI since there are now separated ATCF line type for rapid intensitifcation (RI) and weakening (RW). Will work more with this data in future issues to verify more of these probability types. --- met/src/libcode/vx_tc_util/atcf_line_base.cc | 12 ++-- met/src/libcode/vx_tc_util/atcf_line_base.h | 11 +++- met/src/libcode/vx_tc_util/atcf_prob_line.cc | 57 ++++++++++--------- met/src/libcode/vx_tc_util/prob_info_array.cc | 2 +- met/src/libcode/vx_tc_util/prob_info_base.cc | 2 +- met/src/libcode/vx_tc_util/prob_pair_info.cc | 2 +- met/src/tools/tc_utils/tc_pairs/tc_pairs.cc | 2 +- 7 files changed, 51 insertions(+), 37 deletions(-) diff --git a/met/src/libcode/vx_tc_util/atcf_line_base.cc b/met/src/libcode/vx_tc_util/atcf_line_base.cc index bc5474cec4..c4fca4e38e 100644 --- a/met/src/libcode/vx_tc_util/atcf_line_base.cc +++ b/met/src/libcode/vx_tc_util/atcf_line_base.cc @@ -482,11 +482,13 @@ ATCFLineType string_to_atcflinetype(const char *s) { else if(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_ProbRIRW; - else if(strcasecmp(s, "WD") == 0) t = ATCFLineType_ProbWD; + 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; return(t); @@ -502,11 +504,13 @@ ConcatString atcflinetype_to_string(const ATCFLineType t) { case ATCFLineType_GenTrack: s = "GenTrack"; break; case ATCFLineType_ProbTR: s = "ProbTR"; break; case ATCFLineType_ProbIN: s = "ProbIN"; break; - case ATCFLineType_ProbRIRW: s = "ProbRIRW"; break; - case ATCFLineType_ProbWD: s = "ProbWD"; 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; } diff --git a/met/src/libcode/vx_tc_util/atcf_line_base.h b/met/src/libcode/vx_tc_util/atcf_line_base.h index 816ddfeba4..313c294e54 100644 --- a/met/src/libcode/vx_tc_util/atcf_line_base.h +++ b/met/src/libcode/vx_tc_util/atcf_line_base.h @@ -13,9 +13,12 @@ //////////////////////////////////////////////////////////////////////// // -// Based on Best Track file format information at: +// Best Track file format information: // http://www.nrlmry.navy.mil/atcf_web/docs/database/new/abrdeck.html // +// EDeck file format information: +// https://www.nrlmry.navy.mil/atcf_web/docs/database/new/edeck.txt +// //////////////////////////////////////////////////////////////////////// #include @@ -31,11 +34,13 @@ enum ATCFLineType { ATCFLineType_GenTrack, // Genesis Track and intensity line type (numeric) ATCFLineType_ProbTR, // Track probability (TR) ATCFLineType_ProbIN, // Intensity probability (IN) - ATCFLineType_ProbRIRW, // Rapid intensification probability (RI) - ATCFLineType_ProbWD, // Wind radii probability (WD) + 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 }; diff --git a/met/src/libcode/vx_tc_util/atcf_prob_line.cc b/met/src/libcode/vx_tc_util/atcf_prob_line.cc index 2f912e9516..a06ad1c5eb 100644 --- a/met/src/libcode/vx_tc_util/atcf_prob_line.cc +++ b/met/src/libcode/vx_tc_util/atcf_prob_line.cc @@ -98,6 +98,7 @@ void ATCFProbLine::dump(ostream &out, int indent_depth) const { //////////////////////////////////////////////////////////////////////// void ATCFProbLine::clear() { + ATCFLineBase::clear(); return; @@ -106,40 +107,44 @@ void ATCFProbLine::clear() { //////////////////////////////////////////////////////////////////////// int ATCFProbLine::read_line(LineDataFile * ldf) { - int status; + int status = 0; int n_expect; - clear(); + // Read lines until good status is found + while(status == 0) { + + clear(); - status = ATCFLineBase::read_line(ldf); + // Return bad status from the base class + if(!(status = ATCFLineBase::read_line(ldf))) return(0); - // Check for bad return status or blank line - if(!status) return(0); + // Check the line type + switch(Type) { + case ATCFLineType_ProbRI: + n_expect = MinATCFProbRIRWElements; + break; - // Check the line type - switch(Type) { - case ATCFLineType_ProbRIRW: - n_expect = MinATCFProbRIRWElements; - break; + default: + mlog << Debug(4) + << "ATCFProbLine::read_line(LineDataFile * ldf) -> " + << "skipping ATCF line type (" + << atcflinetype_to_string(Type) << ")\n"; + status = 0; + continue; + } - default: + // Check for the minumum number of elements + if(n_items() < n_expect) { mlog << Warning << "\nint ATCFProbLine::read_line(LineDataFile * ldf) -> " - << "unexpected ATCF line type (" - << atcflinetype_to_string(Type) << ")\n\n"; - return(0); - } - - // Check for the minumum number of elements - if(n_items() < n_expect) { - mlog << Warning - << "\nint ATCFProbLine::read_line(LineDataFile * ldf) -> " - << "found fewer than the expected number of elements (" - << n_items() << "<" << n_expect - << ") in ATCF " << atcflinetype_to_string(Type) << " line:\n" - << DataLine::get_line() << "\n\n"; - return(0); - } + << "found fewer than the expected number of elements (" + << n_items() << "<" << n_expect + << ") in ATCF " << atcflinetype_to_string(Type) << " line:\n" + << DataLine::get_line() << "\n\n"; + status = 0; + continue; + } + } return(1); } diff --git a/met/src/libcode/vx_tc_util/prob_info_array.cc b/met/src/libcode/vx_tc_util/prob_info_array.cc index ea8827a682..6197121ff8 100644 --- a/met/src/libcode/vx_tc_util/prob_info_array.cc +++ b/met/src/libcode/vx_tc_util/prob_info_array.cc @@ -184,7 +184,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, bool check_dup) { // Store based on the input line type switch(l.type()) { - case(ATCFLineType_ProbRIRW): + case(ATCFLineType_ProbRI): // Check for no entries or a mismatch with the latest entry if( ProbRIRW.size() == 0 || diff --git a/met/src/libcode/vx_tc_util/prob_info_base.cc b/met/src/libcode/vx_tc_util/prob_info_base.cc index 07de90221a..f8d3bb791e 100644 --- a/met/src/libcode/vx_tc_util/prob_info_base.cc +++ b/met/src/libcode/vx_tc_util/prob_info_base.cc @@ -280,7 +280,7 @@ void ProbInfoBase::set(const TCStatLine &l) { switch(l.type()) { case TCStatLineType_ProbRIRW: - Type = ATCFLineType_ProbRIRW; + Type = ATCFLineType_ProbRI; break; default: diff --git a/met/src/libcode/vx_tc_util/prob_pair_info.cc b/met/src/libcode/vx_tc_util/prob_pair_info.cc index 4f8189d7e0..3415f040d2 100644 --- a/met/src/libcode/vx_tc_util/prob_pair_info.cc +++ b/met/src/libcode/vx_tc_util/prob_pair_info.cc @@ -200,7 +200,7 @@ ProbPairInfoBase * new_prob_pair(const ATCFLineType t) { ProbPairInfoBase *new_pair = (ProbPairInfoBase *) 0; switch(t) { - case ATCFLineType_ProbRIRW: + case ATCFLineType_ProbRI: new_pair = new ProbRIRWPairInfo; break; diff --git a/met/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/met/src/tools/tc_utils/tc_pairs/tc_pairs.cc index dc3792da05..46c3a80b04 100644 --- a/met/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/met/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -949,7 +949,7 @@ void filter_probs(ProbInfoArray &probs) { } // If we've made it here, retain this probability - if(p[i]->type() == ATCFLineType_ProbRIRW) probs.add(p.prob_rirw(i)); + if(p[i]->type() == ATCFLineType_ProbRI) probs.add(p.prob_rirw(i)); } // Print summary filtering info