Skip to content

Commit

Permalink
Per #1971, no real changes here. Just added Dave's name to the mtd re…
Browse files Browse the repository at this point in the history
…vision history and reformatted some of the error messages.
  • Loading branch information
JohnHalleyGotway committed Aug 5, 2022
1 parent b2aede6 commit 62c0a47
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 46 deletions.
73 changes: 37 additions & 36 deletions src/tools/other/mode_time_domain/mtd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
// ---- ---- ---- -----------
// 000 10-15-15 Bullock New
// 001 05-15-17 Prestopnik P. Added regrid shape
// 002 04-18-19 Halley Gotway Add FCST and OBS units.
// 003 04-25-19 Halley Gotway Add percentiles to 2D output.
// 002 04-18-19 Halley Gotway Add FCST and OBS units
// 003 04-25-19 Halley Gotway Add percentiles to 2D output
// 004 08-01-22 Albo MET #1971 Differing time steps
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -445,10 +446,11 @@ for (j=0; j<(fcst_obj.n_objects()); ++j) {
mask_2d = fcst_obj.const_t_mask(t, j + 1); // 1-based

if (t < 0 || t >= (int)valid_times_fcst.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t << " out of forecast valid times range 0 to " << valid_times_fcst.size()-1
<< "\n\n";
exit ( 1 );
mlog << Error
<< "\n " << program_name
<< ": index " << t << " out of forecast valid times range 0 to "
<< valid_times_fcst.size()-1 << "\n\n";
exit ( 1 );
}

fcst_raw.get_data_plane(t, raw_2d);
Expand Down Expand Up @@ -486,10 +488,11 @@ for (j=0; j<(obs_obj.n_objects()); ++j) {
mask_2d = obs_obj.const_t_mask(t, j + 1); // 1-based

if (t < 0 || t >= (int)valid_times_obs.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t << " out of obs valid times range 0 to " << valid_times_obs.size()-1
<< "\n\n";
exit ( 1 );
mlog << Error
<< "\n " << program_name << ": index " << t
<< " out of obs valid times range 0 to "
<< valid_times_obs.size()-1 << "\n\n";
exit ( 1 );
}

obs_raw.get_data_plane(t, raw_2d);
Expand Down Expand Up @@ -702,25 +705,23 @@ if ( have_pairs ) {

for (t=(att_3.tmin()); t<=(att_3.tmax()); ++t) {

// mask_2d = mask.const_t_mask(t, j + 1); // 1-based
mask_2d = mask.const_t_mask(t, 1); // 1-based

// cout << "j = " << j << ", vol = " << mask_2d.object_volume(0) << '\n';
if (t < 0 || t >= (int)valid_times_fcst.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t
<< " out of forecast valid times range 0 to "
<< valid_times_fcst.size()-1 << "\n\n";
exit ( 1 );
}

if (t < 0 || t >= (int)valid_times_fcst.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t << " out of forecast valid times range 0 to " << valid_times_fcst.size()-1
<< "\n\n";
exit ( 1 );
}

fcst_raw.get_data_plane(t, raw_2d);
fcst_raw.get_data_plane(t, raw_2d);

att_2 = calc_2d_single_atts(mask_2d, raw_2d, j + 1, config.inten_perc_value);

att_2.set_fcst();

att_2.set_valid_time(valid_times_fcst[t]);
att_2.set_valid_time(valid_times_fcst[t]);

att_2.set_lead_time(fcst_obj.lead_time(t));

Expand Down Expand Up @@ -752,23 +753,23 @@ if ( have_pairs ) {

for (t=(att_3.tmin()); t<=(att_3.tmax()); ++t) {

// mask_2d = mask.const_t_mask(t, j + 1); // 1-based
mask_2d = mask.const_t_mask(t, 1); // 1-based

if (t < 0 || t >= (int)valid_times_obs.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t << " out of obs valid times range 0 to " << valid_times_obs.size()-1
<< "\n\n";
exit ( 1 );
}
if (t < 0 || t >= (int)valid_times_obs.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t
<< " out of obs valid times range 0 to "
<< valid_times_obs.size()-1 << "\n\n";
exit ( 1 );
}

obs_raw.get_data_plane(t, raw_2d);
obs_raw.get_data_plane(t, raw_2d);

att_2 = calc_2d_single_atts(mask_2d, raw_2d, j + 1, config.inten_perc_value);

att_2.set_obs();

att_2.set_valid_time(valid_times_obs[t]);
att_2.set_valid_time(valid_times_obs[t]);

att_2.set_lead_time(obs_obj.lead_time(t));

Expand Down Expand Up @@ -1199,14 +1200,14 @@ for (j=0; j<(obj.n_objects()); ++j) {
mask_2d = obj.const_t_mask(t, j + 1); // 1-based

if (t < 0 || t >= (int)valid_times.size()) {
mlog << Error
<< "\n " << program_name << ": index " << t << " out of valid times range 0 to " << valid_times.size()-1
<< "\n\n";
exit ( 1 );
}
mlog << Error
<< "\n " << program_name << ": index " << t
<< " out of valid times range 0 to "
<< valid_times.size()-1 << "\n\n";
exit ( 1 );
}

raw.get_data_plane(t, raw_2d);
//raw_2d.set_valid(valid_times[t]);

att_2 = calc_2d_single_atts(mask_2d, raw_2d, j + 1, config.inten_perc_value);

Expand Down
4 changes: 2 additions & 2 deletions src/tools/other/mode_time_domain/mtd_file_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,15 @@ unixtime MtdFileBase::actual_valid_time(int t) const

{

if ( (t < 0) || ( t >= (int)ActualValidTimes.size()) ) {
if ( (t < 0) || ( t >= (int)ActualValidTimes.size()) ) {

mlog << Error << "\n\n MtdFileBase::valid_time(int t) -> range check error\n\n";

exit ( 1 );

}

return ( ActualValidTimes[t] );
return ( ActualValidTimes[t] );

}

Expand Down
14 changes: 7 additions & 7 deletions src/tools/other/mode_time_domain/mtd_read_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace std;


vector<unixtime> mtd_read_data(MtdConfigInfo & config, VarInfo & varinfo,
const StringArray & filenames, MtdFloatFile & raw)
const StringArray & filenames, MtdFloatFile & raw)

{

Expand Down Expand Up @@ -131,23 +131,23 @@ if (variableTimeIncs) {
NumArray na;
for (size_t k=0; k<dtVector.size(); ++k) {
na.add((double)dtVector[k]);
}
}
dt_start = (unixtime)na.mode();

// test if the differences are all months (in seconds)
bool isMonths = true;
int secondsPerDay = 24*3600;
for (size_t k=0; k<dtVector.size(); ++k) {
int days = dtVector[k]/secondsPerDay;
if (days != 28 && days != 29 && days != 30 && days != 31) {
isMonths = false;
break;
if (days != 28 && days != 29 && days != 30 && days != 31) {
isMonths = false;
break;
}
}

if (isMonths) {
mlog << Debug(1) << "File time increments are months (not constant), use MODE of the increments, mode=" << dt_start
<< " seconds = " << dt_start/(24*3600) << " days\n\n";
mlog << Debug(1) << "File time increments are months (not constant), use MODE of the increments, mode="
<< dt_start << " seconds = " << dt_start/(24*3600) << " days\n\n";
} else {
// compute some measures that might be used to exit with an error, for now just show them to the user and go on
double mean, var, svar;
Expand Down
3 changes: 2 additions & 1 deletion src/tools/other/mode_time_domain/mtd_read_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
//

extern vector<unixtime> mtd_read_data(MtdConfigInfo &, VarInfo &,
const StringArray & filenames, MtdFloatFile &);
const StringArray & filenames,
MtdFloatFile &);


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

0 comments on commit 62c0a47

Please sign in to comment.