diff --git a/src/libcode/vx_seeps/seeps.cc b/src/libcode/vx_seeps/seeps.cc index 7da1ac48f9..a2d5184ec6 100644 --- a/src/libcode/vx_seeps/seeps.cc +++ b/src/libcode/vx_seeps/seeps.cc @@ -50,7 +50,7 @@ double weighted_average(double, double, double, double); //////////////////////////////////////////////////////////////////////// -SeepsClimo *get_seeps_climo(ConcatString seeps_point_climo_name) { +SeepsClimo *get_seeps_climo(const ConcatString &seeps_point_climo_name) { if (! seeps_climo) seeps_climo = new SeepsClimo(seeps_point_climo_name); return seeps_climo; } @@ -63,7 +63,7 @@ void release_seeps_climo() { //////////////////////////////////////////////////////////////////////// -SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour) { +SeepsClimoGrid *get_seeps_climo_grid(int month, const ConcatString &seeps_grid_climo_name, int hour) { if (seeps_climo_grid_map_00.count(month) == 0) { seeps_climo_grid_map_00[month] = nullptr; @@ -167,7 +167,7 @@ SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { //////////////////////////////////////////////////////////////////////// -SeepsClimoBase::SeepsClimoBase(ConcatString seeps_climo_name) : climo_file_name{seeps_climo_name} { +SeepsClimoBase::SeepsClimoBase(const ConcatString &seeps_climo_name) : climo_file_name{seeps_climo_name} { clear(); seeps_ready = false; @@ -242,7 +242,7 @@ void SeepsClimoBase::set_p1_thresh(const SingleThresh &p1_thresh) { //////////////////////////////////////////////////////////////////////// -SeepsClimo::SeepsClimo(ConcatString seeps_climo_name) : SeepsClimoBase{seeps_climo_name} { +SeepsClimo::SeepsClimo(const ConcatString &seeps_climo_name) : SeepsClimoBase{seeps_climo_name} { clear(); ConcatString seeps_name = get_climo_filename(); @@ -505,7 +505,7 @@ void SeepsClimo::print_record(SeepsRecord *record, bool with_header) { //////////////////////////////////////////////////////////////////////// -void SeepsClimo::read_seeps_climo_grid(ConcatString filename) { +void SeepsClimo::read_seeps_climo_grid(const ConcatString &filename) { clock_t clock_time = clock(); const char *method_name = "SeepsClimo::read_seeps_climo_grid() -> "; @@ -686,7 +686,7 @@ void SeepsClimo::read_seeps_climo_grid(ConcatString filename) { //////////////////////////////////////////////////////////////////////// -SeepsClimoGrid::SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name) +SeepsClimoGrid::SeepsClimoGrid(int month, int hour, const ConcatString &seeps_climo_name) : month{month}, hour{hour}, SeepsClimoBase{seeps_climo_name} { clear(); @@ -802,7 +802,7 @@ double SeepsClimoGrid::get_seeps_score(int offset, int obs_cat, int fcst_cat) { //////////////////////////////////////////////////////////////////////// -void SeepsClimoGrid::read_seeps_climo_grid(ConcatString filename) { +void SeepsClimoGrid::read_seeps_climo_grid(const ConcatString &filename) { clock_t clock_time = clock(); const char *method_name = "SeepsClimoGrid::read_seeps_climo_grid() -> "; diff --git a/src/libcode/vx_seeps/seeps.h b/src/libcode/vx_seeps/seeps.h index 3cf25e2e1c..9f8b6e063e 100644 --- a/src/libcode/vx_seeps/seeps.h +++ b/src/libcode/vx_seeps/seeps.h @@ -157,12 +157,12 @@ class SeepsClimoBase { virtual void clear(); virtual ConcatString get_env_climo_name() { return "not defined"; }; virtual char *get_def_climo_name() { return nullptr; }; - virtual void read_seeps_climo_grid(ConcatString filename) {}; + virtual void read_seeps_climo_grid(const ConcatString &filename) {}; void set_seeps_ready(bool _seeps_ready) { seeps_ready = _seeps_ready; }; public: - SeepsClimoBase(ConcatString seeps_climo_name); + SeepsClimoBase(const ConcatString &seeps_climo_name); virtual ~SeepsClimoBase(); void set_p1_thresh(const SingleThresh &p1_thresh); int get_filtered_count() const; @@ -183,17 +183,17 @@ class SeepsClimo : public SeepsClimoBase { double *p1, double *p2, double *t1, double *t2, double *scores); void print_record(SeepsClimoRecord *record, bool with_header=false); - void read_records(ConcatString filename); + void read_records(const ConcatString &filename); protected: void clear() override; ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_POINT_CLIMO_NAME; }; char *get_def_climo_name() override { return (char *)def_seeps_point_filename; }; - void read_seeps_climo_grid(ConcatString filename) override; + void read_seeps_climo_grid(const ConcatString &filename) override; public: - SeepsClimo(ConcatString seeps_climo_name); + SeepsClimo(const ConcatString &seeps_climo_name); ~SeepsClimo(); SeepsRecord *get_record(int sid, int month, int hour); @@ -238,11 +238,11 @@ class SeepsClimoGrid : public SeepsClimoBase { void clear() override; ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_GRID_CLIMO_NAME; }; char *get_def_climo_name() override { return (char *)def_seeps_grid_filename; }; - void read_seeps_climo_grid(ConcatString filename) override; + void read_seeps_climo_grid(const ConcatString &filename) override; public: - SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name); + SeepsClimoGrid(int month, int hour, const ConcatString &seeps_climo_name); ~SeepsClimoGrid(); SeepsScore *get_record(int ix, int iy, double p_fcst, double p_obs); @@ -262,8 +262,8 @@ inline int SeepsClimoBase::get_filtered_count() const { return filtered_count; } //////////////////////////////////////////////////////////////////////// -extern SeepsClimo *get_seeps_climo(ConcatString seeps_point_climo_name); -extern SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour=0); +extern SeepsClimo *get_seeps_climo(const ConcatString &seeps_point_climo_name); +extern SeepsClimoGrid *get_seeps_climo_grid(int month, const ConcatString &seeps_grid_climo_name, int hour=0); extern void release_seeps_climo(); extern void release_seeps_climo_grid(); diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index 99b02d7d56..094587b732 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -1427,13 +1427,21 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps_agg) } SeepsScore *seeps_mpr = nullptr; - int count, count_diagonal; - int c_odfl, c_odfh, c_olfd, c_olfh, c_ohfd, c_ohfl; - double score_sum, obs_sum_wgt, fcst_sum_wgt, obs_sum, fcst_sum; + int count = 0; + int count_diagonal = 0; + int c_odfl = 0; + int c_odfh = 0; + int c_olfd = 0; + int c_olfh = 0; + int c_ohfd = 0; + int c_ohfl = 0; + double score_sum = 0.0; + double obs_sum_wgt = 0.0; + double fcst_sum_wgt = 0.0; + double obs_sum = 0.0; + double fcst_sum = 0.0; vector seeps_mprs; - score_sum = obs_sum = obs_sum_wgt = fcst_sum = fcst_sum_wgt = 0.; - count = count_diagonal = c_odfl = c_odfh = c_olfd = c_olfh = c_ohfd = c_ohfl = 0; for(int i=0; in_obs; i++) { if (i >= pd->seeps_mpr.size()) break; seeps_mpr = pd->seeps_mpr[i]; @@ -1590,25 +1598,32 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob DataPlane &seeps_dp_ocat, SeepsAggScore *seeps_agg, int month, int hour, const SingleThresh &seeps_p1_thresh, const ConcatString &seeps_climo_name) { - int fcst_cat, obs_cat; - int seeps_count, count_diagonal, nan_count, bad_count; int nx = fcst_dp.nx(); int ny = fcst_dp.ny(); int dp_size = (nx * ny); - int pvf_cnt[SEEPS_MATRIX_SIZE]; - double pvf[SEEPS_MATRIX_SIZE]; - double svf[SEEPS_MATRIX_SIZE]; - int c_odfl, c_odfh, c_olfd, c_olfh, c_ohfd, c_ohfl; - double obs_sum, fcst_sum; - double seeps_score, seeps_score_sum, seeps_score_partial_sum; static const char *method_name = "compute_aggregated_seeps_grid() -> "; + int fcst_cat = bad_data_int; + int obs_cat = bad_data_int; + int seeps_count = 0; + int count_diagonal = 0; + int nan_count = 0; + int bad_count = 0; + int c_odfl = 0; + int c_odfh = 0; + int c_olfd = 0; + int c_olfh = 0; + int c_ohfd = 0; + int c_ohfl = 0; + double seeps_score = 0.0; + double seeps_score_sum = 0.0; + double seeps_score_partial_sum = 0.0; + double obs_sum = 0.0; + double fcst_sum = 0.0; + seeps_dp.set_size(nx, ny); seeps_dp_fcat.set_size(nx, ny); seeps_dp_ocat.set_size(nx, ny); - obs_sum = fcst_sum = seeps_score_sum = 0.; - seeps_count = count_diagonal = nan_count = bad_count = 0; - c_odfl = c_odfh = c_olfd = c_olfh = c_ohfd = c_ohfl = 0; seeps_agg->clear(); mlog << Debug(9) << method_name @@ -1616,10 +1631,11 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob SeepsClimoGrid *seeps_climo = get_seeps_climo_grid(month, seeps_climo_name); seeps_climo->set_p1_thresh(seeps_p1_thresh); - for (int i=0; i pvf_cnt(SEEPS_MATRIX_SIZE, 0); + vector pvf(SEEPS_MATRIX_SIZE, 0.0); + vector svf(SEEPS_MATRIX_SIZE, 0.0); + for (int ix=0; ixmean_obs = obs_sum / seeps_count; seeps_agg->score = seeps_score_sum / seeps_count; } + mlog << Debug(6) << method_name << "SEEPS score=" << seeps_agg->score << " score_wgt=" << seeps_agg->score_wgt << " pv1=" << seeps_agg->pv1 << " pv2=" << seeps_agg->pv2 << " pv3=" << seeps_agg->pv3 << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 << "\n"; + if(mlog.verbosity_level() >= detailed_debug_level) { char buffer[100]; ConcatString log_message; @@ -1832,10 +1850,9 @@ void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, } // produces n by n matrix by multiplying transposed vector - int v_count; - double density, density2, mask1, mask2, mask3, mask4, mask5, mask6, mask7, temp; + // Initialize - v_count = 0; + int v_count = 0; mlog << Debug(9) << method_name << "seeps_idx, seeps_cnt => " << seeps_idx << " " << seeps_cnt << "\n"; @@ -1856,18 +1873,18 @@ void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, << clon_m[i][j] << " " << slon_m[i][j] << "\n"; //IDL: r=(clat#transpose(clat))*(slon#transpose(slon)) + (clon#transpose(clon))*(slat#transpose(slat)) - density = clat_m[i][j] * slon_m[i][j] + clon_m[i][j] * slat_m[i][j]; - density2 = (clat_m[i][j] * (slon_m[i][j] + clon_m[i][j])) + slat_m[i][j]; + double density = clat_m[i][j] * slon_m[i][j] + clon_m[i][j] * slat_m[i][j]; + double density2 = (clat_m[i][j] * (slon_m[i][j] + clon_m[i][j])) + slat_m[i][j]; mlog << Debug(9) << method_name << "density, density2 => " << density << " " << density2 << "\n"; //IDL: r * ((r lt 1.) and (r gt -1.)) + (r ge 1.) - (r le -1.) - mask1 = (density < 1.0 && density > -1.0) ? 1. : 0.; - mask2 = (density >= 1.0 ) ? 1. : 0.; - mask3 = (density <= -1.0) ? 1. : 0.; - mask5 = (density2 < 1.0 && density > -1.0) ? 1. : 0.; - mask6 = (density2 >= 1.0 ) ? 1. : 0.; - mask7 = (density2 <= -1.0) ? 1. : 0.; + double mask1 = (density < 1.0 && density > -1.0) ? 1. : 0.; + double mask2 = (density >= 1.0 ) ? 1. : 0.; + double mask3 = (density <= -1.0) ? 1. : 0.; + double mask5 = (density2 < 1.0 && density > -1.0) ? 1. : 0.; + double mask6 = (density2 >= 1.0 ) ? 1. : 0.; + double mask7 = (density2 <= -1.0) ? 1. : 0.; density = density * mask1 + mask2 - mask3; density2 = density2 * mask5 + mask6 - mask7; mlog << Debug(9) << method_name @@ -1878,22 +1895,19 @@ void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, //IDL: if r0 gt 0.0 then r = exp(-(r/r0)^2) * (r le 4. * r0) else r = (r*0.)+1. if (density_radius_rad > 0.) { if (density < 4.0 * density_radius_rad) { - //temp = density / density_radius_rad; mask3 = (density <= 4.0) ? 1. : 0.; - temp = density / density_radius_rad; + double temp = density / density_radius_rad; density = exp(-(temp * temp)) * mask3 * density_radius_rad; } else { density = 0.; } if (density2 < 4.0 * density_radius_rad) { - //temp = density / density_radius_rad; density2 = exp(-(pow(density2 / density_radius_rad,2))); } else { density2 = 0.; } - //double dens = exp(-(pow(2,2))); mlog << Debug(4) << method_name << "final density, density2 => " << density << " " << density2 << "\n";