-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per #1809, define the ProbGenInfo class and update the Makefile to co…
…mpile it. Define ATCF offsets specific to ATCF EDECK GN lines. Update the is_match() logic slightly by moving the checking for consistent valid times from the base class to the ProbRIRWInfo class. That way we can store all probabilities for the same genesis event (across multiple lead times) in the same object.
- Loading branch information
1 parent
4ff28d1
commit 2a159e1
Showing
7 changed files
with
311 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* | ||
// ** Copyright UCAR (c) 1992 - 2021 | ||
// ** 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 <iostream> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <cstdio> | ||
#include <cmath> | ||
|
||
#include "prob_gen_info.h" | ||
#include "atcf_offsets.h" | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
// | ||
// Code for class ProbGenInfo | ||
// | ||
//////////////////////////////////////////////////////////////////////// | ||
|
||
ProbGenInfo::ProbGenInfo() { | ||
|
||
init_from_scratch(); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
ProbGenInfo::~ProbGenInfo() { | ||
|
||
clear(); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
ProbGenInfo::ProbGenInfo(const ProbGenInfo & t) { | ||
|
||
init_from_scratch(); | ||
|
||
assign(t); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
ProbGenInfo & ProbGenInfo::operator=(const ProbGenInfo & t) { | ||
|
||
if(this == &t) return(*this); | ||
|
||
assign(t); | ||
|
||
return(*this); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
void ProbGenInfo::init_from_scratch() { | ||
|
||
clear(); | ||
|
||
return; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
void ProbGenInfo::clear() { | ||
|
||
ProbInfoBase::clear(); | ||
|
||
Initials.clear(); | ||
GenOrDis.clear(); | ||
GenTime = (unixtime) 0; | ||
|
||
return; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
void ProbGenInfo::dump(ostream &out, int indent_depth) const { | ||
Indent prefix(indent_depth); | ||
|
||
ProbInfoBase::dump(out, indent_depth); | ||
|
||
out << prefix << "Initials = \"" << Initials.contents() << "\"\n"; | ||
out << prefix << "GenOrDis = \"" << GenOrDis.contents() << "\"\n"; | ||
out << prefix << "GenTime = " << unix_to_yyyymmdd_hhmmss(GenTime) << "\n"; | ||
|
||
out << flush; | ||
|
||
return; | ||
|
||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
ConcatString ProbGenInfo::serialize() const { | ||
ConcatString s; | ||
|
||
s << ProbInfoBase::serialize() | ||
<< ", ProbGenInfo: " | ||
<< "Initials = \"" << Initials << "\"" | ||
<< ", GenOrDis = \"" << GenOrDis << "\"" | ||
<< ", GenTime = " << unix_to_yyyymmdd_hhmmss(GenTime) << "\n"; | ||
|
||
return(s); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
ConcatString ProbGenInfo::serialize_r(int n, int indent_depth) const { | ||
ConcatString s; | ||
|
||
s << ProbInfoBase::serialize_r(n, indent_depth); | ||
|
||
return(s); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
void ProbGenInfo::assign(const ProbGenInfo &p) { | ||
|
||
clear(); | ||
|
||
ProbInfoBase::assign(p); | ||
|
||
Initials = p.Initials; | ||
GenOrDis = p.GenOrDis; | ||
GenTime = p.GenTime; | ||
|
||
return; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
void ProbGenInfo::initialize(const ATCFProbLine &l) { | ||
|
||
clear(); | ||
|
||
ProbInfoBase::initialize(l); | ||
|
||
Initials = l.get_item(ProbGenInitialsOffset); | ||
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())); | ||
|
||
return; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
bool ProbGenInfo::is_match(const ATCFProbLine &l) const { | ||
|
||
if(!ProbInfoBase::is_match(l)) return(false); | ||
|
||
unixtime gen_ut = (l.get_item(ProbGenTimeOffset).empty() ? | ||
(unixtime) 0 : | ||
parse_time(l.get_item(ProbGenTimeOffset).c_str())); | ||
|
||
return(GenTime == gen_ut); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
bool ProbGenInfo::add(const ATCFProbLine &l, bool check_dup) { | ||
|
||
// Check for duplicates | ||
if(check_dup) { | ||
if(has(l)) { | ||
mlog << Warning | ||
<< "\nProbGenInfo::add(const ATCFProbLine &l, bool check_dup) -> " | ||
<< "skipping duplicate ATCF line:\n" | ||
<< l.get_line() << "\n\n"; | ||
return(false); | ||
} | ||
} | ||
|
||
// Initialize the header information, if necessary | ||
if(Type == NoATCFLineType) initialize(l); | ||
|
||
// Check for matching header information | ||
if(!is_match(l)) return(false); | ||
|
||
// Add probability information | ||
NProb++; | ||
Prob.add(l.prob()); | ||
ProbItem.add(l.prob_item()); | ||
|
||
// Store the ATCFProbLine that was just added | ||
if(check_dup) ProbLines.add(l.get_line()); | ||
|
||
return(true); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* | ||
// ** Copyright UCAR (c) 1992 - 2021 | ||
// ** 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 __VX_PROB_GEN_INFO_H__ | ||
#define __VX_PROB_GEN_INFO_H__ | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
#include <iostream> | ||
|
||
#include "prob_info_base.h" | ||
|
||
#include "vx_util.h" | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
// | ||
// ProbGenInfo class stores probability of rapid intensification. | ||
// | ||
//////////////////////////////////////////////////////////////////////// | ||
|
||
class ProbGenInfo : public ProbInfoBase { | ||
|
||
private: | ||
|
||
void init_from_scratch(); | ||
void assign(const ProbGenInfo &); | ||
|
||
// Probability of Genesis specific values | ||
ConcatString Initials; | ||
ConcatString GenOrDis; | ||
unixtime GenTime; | ||
|
||
public: | ||
|
||
ProbGenInfo(); | ||
~ProbGenInfo(); | ||
ProbGenInfo(const ProbGenInfo &); | ||
ProbGenInfo & operator=(const ProbGenInfo &); | ||
|
||
void clear(); | ||
|
||
void dump(ostream &, int = 0) const; | ||
ConcatString serialize() const; | ||
ConcatString serialize_r(int, int = 0) const; | ||
|
||
// | ||
// set stuff | ||
// | ||
|
||
// | ||
// get stuff | ||
// | ||
|
||
const ConcatString & initials() const; | ||
const ConcatString & gen_or_dis() const; | ||
unixtime gen_time() const; | ||
|
||
// | ||
// do stuff | ||
// | ||
|
||
void initialize(const ATCFProbLine &); | ||
bool is_match (const ATCFProbLine &) const; | ||
bool add (const ATCFProbLine &, bool check_dup = false); | ||
|
||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
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); } | ||
|
||
//////////////////////////////////////////////////////////////////////// | ||
|
||
#endif /* __VX_PROB_GEN_INFO_H__ */ | ||
|
||
//////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters