Skip to content

Commit

Permalink
Per #1809, add GenesisLead to the ProbGenInfo class to track the lead…
Browse files Browse the repository at this point in the history
… time for which genesis is forecast.
  • Loading branch information
JohnHalleyGotway committed Nov 13, 2021
1 parent 17b1323 commit 9f834d1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
42 changes: 27 additions & 15 deletions met/src/libcode/vx_tc_util/prob_gen_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void ProbGenInfo::clear() {

Initials.clear();
GenOrDis.clear();
GenTime = (unixtime) 0;

GenesisTime = (unixtime) 0;
GenesisLead = 0;
BestGen = (const GenesisInfo *) 0;

return;
Expand All @@ -93,7 +93,8 @@ void ProbGenInfo::dump(ostream &out, int indent_depth) const {

out << prefix << "Initials = \"" << Initials.contents() << "\"\n";
out << prefix << "GenOrDis = \"" << GenOrDis.contents() << "\"\n";
out << prefix << "GenTime = " << unix_to_yyyymmdd_hhmmss(GenTime) << "\n";
out << prefix << "GenesisTime = " << unix_to_yyyymmdd_hhmmss(GenesisTime) << "\n";
out << prefix << "GenesisLead = " << sec_to_hhmmss(GenesisLead) << "\n";
out << prefix << "BestGen = " << (BestGen ? "set" : "(nul)") << "\n";

out << flush;
Expand All @@ -111,7 +112,8 @@ ConcatString ProbGenInfo::serialize() const {
<< ", ProbGenInfo: "
<< "Initials = \"" << Initials << "\""
<< ", GenOrDis = \"" << GenOrDis << "\""
<< ", GenTime = " << unix_to_yyyymmdd_hhmmss(GenTime)
<< ", GenesisTime = " << unix_to_yyyymmdd_hhmmss(GenesisTime)
<< ", GenesisLead = " << sec_to_hhmmss(GenesisLead)
<< ", BestGen = " << (BestGen ? "set" : "(nul)") << "\n";

return(s);
Expand All @@ -135,11 +137,11 @@ void ProbGenInfo::assign(const ProbGenInfo &p) {

ProbInfoBase::assign(p);

Initials = p.Initials;
GenOrDis = p.GenOrDis;
GenTime = p.GenTime;

BestGen = p.BestGen;
Initials = p.Initials;
GenOrDis = p.GenOrDis;
GenesisTime = p.GenesisTime;
GenesisLead = p.GenesisLead;
BestGen = p.BestGen;

return;
}
Expand All @@ -155,6 +157,14 @@ void ProbGenInfo::set_best_gen(const GenesisInfo *bg) {

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

int ProbGenInfo::genesis_fhr() const {
return(is_bad_data(GenesisLead) ?
bad_data_int :
nint((double) GenesisLead/sec_per_hour));
}

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

void ProbGenInfo::initialize(const ATCFProbLine &l, double dland) {

clear();
Expand All @@ -165,9 +175,11 @@ void ProbGenInfo::initialize(const ATCFProbLine &l, double dland) {
GenOrDis = l.get_item(ProbGenOrDisOffset);

// Store an empty string as unixtime 0
GenTime = (l.get_item(ProbGenTimeOffset).empty() ?
(unixtime) 0 :
parse_time(l.get_item(ProbGenTimeOffset).c_str()));
GenesisTime = (l.get_item(ProbGenTimeOffset).empty() ?
(unixtime) 0 :
parse_time(l.get_item(ProbGenTimeOffset).c_str()));
GenesisLead = (GenesisTime == 0 ? bad_data_int :
GenesisTime - InitTime);

BestGen = (const GenesisInfo *) 0;

Expand All @@ -184,7 +196,7 @@ bool ProbGenInfo::is_match(const ATCFProbLine &l) const {
(unixtime) 0 :
parse_time(l.get_item(ProbGenTimeOffset).c_str()));

return(GenTime == gen_ut);
return(GenesisTime == gen_ut);
}

////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -225,8 +237,8 @@ bool ProbGenInfo::is_match(const TrackPoint &p, const double rad,
const int beg, const int end) const {

// Check for matching in time and space
return(p.valid() >= (GenTime + beg) &&
p.valid() <= (GenTime + end) &&
return(p.valid() >= (GenesisTime + beg) &&
p.valid() <= (GenesisTime + end) &&
gc_dist(Lat, Lon, p.lat(), p.lon()) <= rad);
}

Expand Down
22 changes: 13 additions & 9 deletions met/src/libcode/vx_tc_util/prob_gen_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ProbGenInfo : public ProbInfoBase {
// Probability of Genesis specific values
ConcatString Initials;
ConcatString GenOrDis;
unixtime GenTime;
unixtime GenesisTime;
int GenesisLead;

// Pointer to the matching BEST genesis event
const GenesisInfo * BestGen;
Expand Down Expand Up @@ -64,10 +65,12 @@ class ProbGenInfo : public ProbInfoBase {
// get stuff
//

const ConcatString & initials() const;
const ConcatString & gen_or_dis() const;
unixtime gen_time() const;
const GenesisInfo * best_gen() const;
const ConcatString & initials() const;
const ConcatString & gen_or_dis() const;
unixtime genesis_time() const;
int genesis_lead() const;
int genesis_fhr() const;
const GenesisInfo * best_gen() const;

//
// do stuff
Expand All @@ -86,10 +89,11 @@ 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::gen_time() const { return(GenTime); }
inline const GenesisInfo * ProbGenInfo::best_gen() const { return(BestGen); }
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 GenesisInfo * ProbGenInfo::best_gen() const { return(BestGen); }

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

Expand Down

0 comments on commit 9f834d1

Please sign in to comment.