Skip to content

Commit

Permalink
Per #1809, define the ProbGenInfo class and update the Makefile to co…
Browse files Browse the repository at this point in the history
…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
JohnHalleyGotway committed Nov 5, 2021
1 parent 4ff28d1 commit 2a159e1
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 7 deletions.
1 change: 1 addition & 0 deletions met/src/libcode/vx_tc_util/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ libvx_tc_util_a_SOURCES = \
prob_info_base.h prob_info_base.cc \
prob_info_array.h prob_info_array.cc \
prob_rirw_info.h prob_rirw_info.cc \
prob_gen_info.h prob_gen_info.cc \
prob_rirw_pair_info.h prob_rirw_pair_info.cc \
genesis_info.cc genesis_info.h \
pair_data_genesis.cc pair_data_genesis.h \
Expand Down
15 changes: 13 additions & 2 deletions met/src/libcode/vx_tc_util/atcf_offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,35 @@ static const int GenMax700VortOffset = 30;
//

static const int ProbOffset = 8; // probability of event (0-100)
static const int ProbItemOffset = 9; // intensity change for event
static const int ProbItemOffset = 9; // RI: intensity change, GN: time window

//
// Offsets specific to ATCF RIRW line type
// Offsets specific to ATCF EDECK RI line type
//

static const int ProbRIRWValueOffset = 10; // final intensity
static const int ProbRIRWInitialsOffset = 11; // forecaster initials
static const int ProbRIRWBegOffset = 12; // RIRW start time
static const int ProbRIRWEndOffset = 13; // RIRW stop time

//
// Offsets specific to ATCF EDECK GN line type
//

static const int ProbGenInitialsOffset = 10; // forecaster initials
static const int ProbGenOrDisOffset = 11; // genesis or dissipation:
// invest, genFcst, genesis,
// disFcst, dissipate
static const int ProbGenTimeOffset = 12; // forecast genesis time

//
// Minimum number of required elements
//

static const int MinATCFTrackElements = 8;
static const int MinATCFGenTrackElements = 9;
static const int MinATCFProbRIRWElements = 14;
static const int MinATCFProbGNElements = 13;

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

Expand Down
6 changes: 5 additions & 1 deletion met/src/libcode/vx_tc_util/atcf_prob_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ int ATCFProbLine::read_line(LineDataFile * ldf) {
n_expect = MinATCFProbRIRWElements;
break;

case ATCFLineType_ProbGN:
n_expect = MinATCFProbGNElements;
break;

default:
mlog << Debug(4)
mlog << Debug(10)
<< "ATCFProbLine::read_line(LineDataFile * ldf) -> "
<< "skipping ATCF line type ("
<< atcflinetype_to_string(Type) << ")\n";
Expand Down
203 changes: 203 additions & 0 deletions met/src/libcode/vx_tc_util/prob_gen_info.cc
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);
}

////////////////////////////////////////////////////////////////////////
85 changes: 85 additions & 0 deletions met/src/libcode/vx_tc_util/prob_gen_info.h
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__ */

////////////////////////////////////////////////////////////////////////
1 change: 0 additions & 1 deletion met/src/libcode/vx_tc_util/prob_info_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ bool ProbInfoBase::is_match(const ATCFProbLine &l) const {
Cyclone == l.cyclone_number() &&
Technique == l.technique() &&
InitTime == l.warning_time() &&
ValidTime == l.valid() &&
Lat == l.lat() &&
Lon == l.lon());
}
Expand Down
7 changes: 4 additions & 3 deletions met/src/libcode/vx_tc_util/prob_rirw_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ bool ProbRIRWInfo::is_match(const ATCFProbLine &l) const {

if(!ProbInfoBase::is_match(l)) return(false);

return(Value == parse_int(l.get_item(ProbRIRWValueOffset).c_str()) &&
RIRWBeg == parse_int(l.get_item(ProbRIRWBegOffset).c_str()) &&
RIRWEnd == parse_int(l.get_item(ProbRIRWEndOffset).c_str()));
return(ValidTime == l.valid() &&
Value == parse_int(l.get_item(ProbRIRWValueOffset).c_str()) &&
RIRWBeg == parse_int(l.get_item(ProbRIRWBegOffset).c_str()) &&
RIRWEnd == parse_int(l.get_item(ProbRIRWEndOffset).c_str()));
}

////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 2a159e1

Please sign in to comment.