Skip to content

Commit

Permalink
Per #392, update TrackInfo to store the DiagType source.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Oct 26, 2022
1 parent b618f92 commit 10cc706
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/libcode/vx_tc_util/diag_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class DiagFile : public LineDataFile {
double lat(int) const;
double lon(int) const;

DiagType source() const;
int n_diag() const;
const StringArray & diag_name() const;
bool has_diag(const std::string &) const;
Expand Down Expand Up @@ -132,6 +133,7 @@ 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::source() const { return(SourceType); }
inline int DiagFile::n_diag() const { return(DiagName.n()); }
inline const StringArray & DiagFile::diag_name() const { return(DiagName); }

Expand Down
7 changes: 7 additions & 0 deletions src/libcode/vx_tc_util/track_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void TrackInfo::clear() {
MaxValidTime = (unixtime) 0;
MinWarmCore = (unixtime) 0;
MaxWarmCore = (unixtime) 0;
DiagSource = DiagType_None;
DiagName.clear();
TrackLines.clear();

Expand Down Expand Up @@ -131,6 +132,7 @@ void TrackInfo::dump(ostream &out, int indent_depth) const {
out << prefix << "MaxValidTime = \"" << (MaxValidTime > 0 ? unix_to_yyyymmdd_hhmmss(MaxValidTime).text() : na_str) << "\n";
out << prefix << "MinWarmCore = \"" << (MinWarmCore > 0 ? unix_to_yyyymmdd_hhmmss(MinWarmCore).text() : na_str) << "\n";
out << prefix << "MaxWarmCore = \"" << (MaxWarmCore > 0 ? unix_to_yyyymmdd_hhmmss(MaxWarmCore).text() : na_str) << "\n";
out << prefix << "DiagSource = " << diagtype_to_string(DiagSource) << "\n";
out << prefix << "NDiag = " << DiagName.n() << "\n";
out << prefix << "NPoints = " << NPoints << "\n";
out << prefix << "NAlloc = " << NAlloc << "\n";
Expand Down Expand Up @@ -169,6 +171,7 @@ ConcatString TrackInfo::serialize() const {
<< ", MaxValidTime = " << (MaxValidTime > 0 ? unix_to_yyyymmdd_hhmmss(MaxValidTime).text() : na_str)
<< ", MinWarmCore = " << (MinWarmCore > 0 ? unix_to_yyyymmdd_hhmmss(MinWarmCore).text() : na_str)
<< ", MaxWarmCore = " << (MaxWarmCore > 0 ? unix_to_yyyymmdd_hhmmss(MaxWarmCore).text() : na_str)
<< ", DiagSource = " << diagtype_to_string(DiagSource)
<< ", NDiag = " << DiagName.n()
<< ", NPoints = " << NPoints
<< ", NAlloc = " << NAlloc
Expand Down Expand Up @@ -219,6 +222,7 @@ void TrackInfo::assign(const TrackInfo &t) {
MaxValidTime = t.MaxValidTime;
MinWarmCore = t.MinWarmCore;
MaxWarmCore = t.MaxWarmCore;
DiagSource = t.DiagSource;
DiagName = t.DiagName;
TrackLines = t.TrackLines;

Expand Down Expand Up @@ -530,6 +534,9 @@ bool TrackInfo::add_diag_data(DiagFile &diag_file, const StringArray &diag_name)
InitTime != diag_file.init() ||
!diag_file.technique().has(Technique)) return(false);

// Store the diagnostic source
DiagSource = diag_file.source();

// If empty, store all diagnostics
if(diag_name.n() > 0) DiagName = diag_name;
else DiagName = diag_file.diag_name();
Expand Down
16 changes: 12 additions & 4 deletions src/libcode/vx_tc_util/track_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class TrackInfo {
unixtime MinWarmCore;
unixtime MaxWarmCore;

// Diagnostic names
// Diagnostic source and names
DiagType DiagSource;
StringArray DiagName;

// TrackPoints
Expand Down Expand Up @@ -113,6 +114,7 @@ class TrackInfo {
void set_valid_min(const unixtime);
void set_valid_max(const unixtime);
void set_point(int, const TrackPoint &);
void set_diag_source(DiagType);
void set_diag_name(const StringArray &);

//
Expand Down Expand Up @@ -144,6 +146,8 @@ class TrackInfo {
int warm_core_dur() const;
int valid_inc() const;
int n_points() const;

DiagType diag_source() const;
int n_diag() const;
const StringArray & diag_name() const;
const char * diag_name(int) const;
Expand Down Expand Up @@ -184,6 +188,7 @@ inline void TrackInfo::set_initials(const char *s) { Initials = s;
inline void TrackInfo::set_init(const unixtime u) { InitTime = u; }
inline void TrackInfo::set_valid_min(const unixtime u) { MinValidTime = u; }
inline void TrackInfo::set_valid_max(const unixtime u) { MaxValidTime = u; }
inline void TrackInfo::set_diag_source(DiagType t) { DiagSource = t; }
inline void TrackInfo::set_diag_name(const StringArray &s) { DiagName = s; }

inline const ConcatString & TrackInfo::storm_id() const { return(StormId); }
Expand All @@ -200,9 +205,12 @@ inline unixtime TrackInfo::valid_max() const { return(MaxVali
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 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 DiagType TrackInfo::diag_source() const { return(DiagSource); }
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); }

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

0 comments on commit 10cc706

Please sign in to comment.