Skip to content

Commit

Permalink
Per #1528, making some progress adding Observation objects and storin…
Browse files Browse the repository at this point in the history
…g the unique locations in a set. Next, I need to parse the options from the config file.
  • Loading branch information
JohnHalleyGotway committed Nov 7, 2020
1 parent e14fc61 commit 55ee7ec
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 9 deletions.
107 changes: 105 additions & 2 deletions met/src/tools/other/plot_point_obs/plot_point_obs_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ using namespace std;
#include "plot_point_obs_conf_info.h"
#include "vx_log.h"

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

bool operator<(const LocationInfo&lhs, const LocationInfo& rhs) {
return(!is_eq(lhs.lat, rhs.lat) ||
!is_eq(lhs.lon, rhs.lon) ||
!is_eq(lhs.val, rhs.val));
}

////////////////////////////////////////////////////////////////////////
//
// Code for class PlotPointObsOpt
Expand Down Expand Up @@ -44,8 +52,42 @@ void PlotPointObsOpt::init_from_scratch() {

void PlotPointObsOpt::clear() {

// Initialize values
// JHG, work here
// Initialize tring filtering options
msg_typ.clear();
sid_inc.clear();
sid_exc.clear();
obs_var.clear();
obs_qty.clear();

// Initialize time filtering options
valid_beg = valid_end = (unixtime) 0;

// Initialize value filtering options
lat_thresh.clear();
lon_thresh.clear();
elv_thresh.clear();
hgt_thresh.clear();
prs_thresh.clear();
obs_thresh.clear();

// Initialize data processing options
convert_fx.clear();
censor_thresh.clear();
censor_val.clear();

// Initialize plotting options
dotsize_fx.clear();
line_color.clear();
line_width = 0.0;
fill_color.clear();
fill_ctable.clear();
fill_ctable_flag = false;
fill_colorbar_flag = false;

// Initialize point location data
n_obs = 0;
locations.clear();

return;
}

Expand All @@ -58,6 +100,55 @@ void PlotPointObsOpt::process_config(Dictionary &dict) {
return;
}

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

bool PlotPointObsOpt::add(const Observation &obs) {

// message type
if(msg_typ.n() > 0 && !msg_typ.has(obs.getHeaderType())) return(false);

// station id
if((sid_inc.n() > 0 && !sid_inc.has(obs.getStationId())) ||
(sid_exc.n() > 0 && sid_exc.has(obs.getStationId()))) return(false);

// observation variable
if(obs_var.n() > 0 && !obs_var.has(obs.getVarName())) return(false);

// quality control string
if(obs_qty.n() > 0 && !obs_qty.has(obs.getQualityFlag())) return(false);

// valid time
unixtime ut = obs.getValidTime();
if((valid_beg > 0 && ut < valid_beg) ||
(valid_end > 0 && ut > valid_end)) return(false);

// lat, lon
if(!lat_thresh.check(obs.getLatitude()) ||
!lon_thresh.check(obs.getLongitude())) return(false);

// elevation, height, pressure
if(!elv_thresh.check(obs.getElevation()) ||
!hgt_thresh.check(obs.getHeight()) ||
!prs_thresh.check(obs.getPressureLevel())) return(false);

// observation value
if(!obs_thresh.check(obs.getValue())) return(false);

// Store this matching point location
LocationInfo loc;
loc.lat = obs.getLatitude();
loc.lon = obs.getLongitude();

// Only store the value if a colortable is defined
loc.val = (fill_ctable_flag ? obs.getValue() : bad_data_double);

// Update the set of locations
n_obs++;
locations.insert(loc);

return(true);
}

////////////////////////////////////////////////////////////////////////
//
// Code for class PlotPointObsConfInfo
Expand Down Expand Up @@ -135,5 +226,17 @@ void PlotPointObsConfInfo::process_config() {

return;
}
////////////////////////////////////////////////////////////////////////

bool PlotPointObsConfInfo::add(const Observation &obs) {
bool match = false;

for(vector<PlotPointObsOpt>::iterator it = plot_opts.begin();
it != plot_opts.end(); it++) {
if((match = it->add(obs))) break;
}

return(match);
}

////////////////////////////////////////////////////////////////////////
20 changes: 13 additions & 7 deletions met/src/tools/other/plot_point_obs/plot_point_obs_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <set>

#include "vx_config.h"
#include "vx_data2d.h"
Expand All @@ -23,6 +24,8 @@
#include "vx_cal.h"
#include "vx_math.h"

#include "observation.h"

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

// Default configuration file name
Expand All @@ -31,12 +34,14 @@ static const char * default_config_filename =

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

struct ObsInfo {
struct LocationInfo {
double lat;
double lon;
double val;
};

extern bool operator<(const LocationInfo&, const LocationInfo&);

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

class PlotPointObsOpt {
Expand Down Expand Up @@ -92,16 +97,17 @@ class PlotPointObsOpt {

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

vector<ObsInfo> point_locations;
// Unique collection of locations
int n_obs;
set<LocationInfo> locations;

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

void clear();

void process_config(Dictionary &);

// JHG add obs record here
bool add();
bool add(const Observation &);
};

////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -138,11 +144,11 @@ class PlotPointObsConfInfo {

void clear();

void read_config (const char *);
void read_config(const char *);

void process_config();

// JHG add obs record here
bool add();
bool add(const Observation &);
};

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

0 comments on commit 55ee7ec

Please sign in to comment.