Skip to content

Commit

Permalink
added multiple thresh/radii functionality for the mvmode superobjects…
Browse files Browse the repository at this point in the history
… only situation
  • Loading branch information
davidalbo committed Dec 7, 2024
1 parent e334917 commit 0cc536f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 93 deletions.
139 changes: 72 additions & 67 deletions src/libcode/vx_shapedata/mode_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1831,84 +1831,90 @@ void ModeConfInfo::check_multivar_not_implemented()
}

bool status = false;
// if (quilt) {
// mlog << Error
// << "\nModeConfInfo::check_multivar_not_implemented():\n"
// << " quilting not yet implemented for multivar mode\n\n";
// status = true;
// }

// All inputs must have the same number of convolution radii
// All inputs must have the same number of convolution thresholds
// Without quilting, the radii/thresh array lengths must be the same

int nForFcst = 0;
int nForObs = 0;

int nRForFcst = 0;
int nRForObs = 0;
int nTForFcst = 0;
int nTForObs = 0;
for (int i=0; i<N_fields_f; ++i) {
//if (data_type != ModeDataType::MvMode_Obs) {
if (fcst_array[i].merge_flag == MergeType::Both || fcst_array[i].merge_flag == MergeType::Engine)
{
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " merge_flag ENGINE or BOTH not implemented for multivariate mode\n\n";
status = true;
}
if (i == 0) {
nForFcst = fcst_array[i].conv_thresh_array.n();
}
int nti = fcst_array[i].conv_thresh_array.n();
int nri = fcst_array[i].conv_radius_array.n_elements();
if (nti != nForFcst || nri != nForFcst) {
if (fcst_array[i].merge_flag == MergeType::Both || fcst_array[i].merge_flag == MergeType::Engine)
{
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " merge_flag ENGINE or BOTH not implemented for multivariate mode\n\n";
status = true;
}
if (i == 0) {
nTForFcst = fcst_array[i].conv_thresh_array.n();
nRForFcst = fcst_array[i].conv_radius_array.n_elements();
}
int nti = fcst_array[i].conv_thresh_array.n();
int nri = fcst_array[i].conv_radius_array.n_elements();
if (nti != nTForFcst || nri != nRForFcst) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Unequal array lengths for conv_thresh or conv_radii not allowed in multivariate mode\n\n";
status = true;
}
if (fcst_array[i].merge_flag != MergeType::None) {
int nmi = fcst_array[i].merge_thresh_array.n();
if (nmi != nTForFcst) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Unequal array lengths for conv_thresh or conv_radii not allowed in multivariate mode\n\n";
<< " Unequal array lengths for merge_thresh not allowed in multivariate mode\n\n";
status = true;
}
if (fcst_array[i].merge_flag != MergeType::None) {
int nmi = fcst_array[i].merge_thresh_array.n();
if (nmi != nForFcst) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Unequal array lengths for merge_thresh not allowed in multivariate mode\n\n";
status = true;
}
}
}
}
}
for (int i=0; i<N_fields_o; ++i) {
//if (data_type != ModeDataType::MvMode_Fcst) {
if (obs_array[i].merge_flag == MergeType::Both || obs_array[i].merge_flag == MergeType::Engine) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " merge_flag ENGINE or BOTH not implemented for multivariate mode\n\n";
status = true;
break;
}
if (i == 0) {
nForObs = obs_array[i].conv_thresh_array.n();
}
int nti = obs_array[i].conv_thresh_array.n();
int nri = obs_array[i].conv_radius_array.n_elements();
if (nti != nForObs || nri != nForObs) {
if (obs_array[i].merge_flag == MergeType::Both || obs_array[i].merge_flag == MergeType::Engine) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " merge_flag ENGINE or BOTH not implemented for multivariate mode\n\n";
status = true;
break;
}
if (i == 0) {
nTForObs = obs_array[i].conv_thresh_array.n();
nRForObs = obs_array[i].conv_radius_array.n_elements();
}
int nti = obs_array[i].conv_thresh_array.n();
int nri = obs_array[i].conv_radius_array.n_elements();
if (nti != nTForObs || nri != nRForObs) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Unequal array lengths for conv_thresh or conv_radii not allowed in multivariate mode\n\n";
status = true;
}
if (obs_array[i].merge_flag != MergeType::None) {
int nmi = obs_array[i].merge_thresh_array.n();
if (nmi != nTForObs) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Unequal array lengths for conv_thresh or conv_radii not allowed in multivariate mode\n\n";
<< " Unequal array lengths for merge_thresh not allowed in multivariate mode\n\n";
status = true;
}
if (obs_array[i].merge_flag != MergeType::None) {
int nmi = obs_array[i].merge_thresh_array.n();
if (nmi != nForObs) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Unequal array lengths for merge_thresh not allowed in multivariate mode\n\n";
status = true;
}
}
// if (obs_array[i].conv_thresh_array.n() > 1 || obs_array[i].merge_thresh_array.n() > 1) {
// mlog << Error
// << "\nModeConfInfo::check_multivar_not_implemented():\n"
// << " more than one conv_thresh or merge_thresh per input is not allowed in multivariate mode\n\n";
// status = true;
// }
//}
}
}
}

if (!quilt && (nForObs != nForFcst)) {
if (nTForObs != nTForFcst) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Obs convolution thresh/radius arrays must have the same number of elements as Fcst thresh/radius arrays\n\n";
status = true;
}
if (nRForObs != nRForFcst) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Obs convolution thresh/radius arrays must have the same number of elements as Fcst thresh/radius arrays\n\n";
status = true;
}
if (!quilt && (nTForObs != nRForObs)) {
mlog << Error
<< "\nModeConfInfo::check_multivar_not_implemented():\n"
<< " Obs convolution thresh/radius arrays must have the same number of elements as Fcst thresh/radius arrays unless quilt=true\n\n";
Expand All @@ -1923,7 +1929,6 @@ void ModeConfInfo::check_multivar_not_implemented()
}
}


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

PercThreshType ModeConfInfo::perctype(const Mode_Field_Info &f) const
Expand Down
9 changes: 5 additions & 4 deletions src/tools/core/mode/mode_exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -821,16 +821,17 @@ void ModeExecutive::do_conv_thresh_multivar_super(int rIndexF, int tIndexF,

ModeConfInfo & conf = engine.conf_info;

// R_index = convIndex;
// T_index = convIndex;
R_index = rIndexF;
T_index = tIndexF;

SingleThresh s("ne-9999");
conf.set_fcst_conv_thresh(s);
conf.set_fcst_conv_radius(0.0);
conf.set_fcst_merge_thresh_by_index(tIndexF);
conf.set_fcst_merge_thresh(s);
//conf.set_fcst_merge_thresh_by_index(0);
conf.set_obs_conv_thresh(s);
conf.set_obs_conv_radius(0.0);
conf.set_obs_merge_thresh_by_index(tIndexO);
conf.set_obs_merge_thresh(s);//_by_index(0);

//
// Set up the engine with these raw fields
Expand Down
42 changes: 20 additions & 22 deletions src/tools/core/mode/multivar_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,41 @@ int MultivarFrontEnd::run(const StringArray & Argv)
// Define the verification grid using the 0th fcst and obs inputs
_create_verif_grid();

// in the implementation now, all 4 of these numbers must be the same
// in the implementation now, all 4 of these numbers must be the same without quilting
// and NCTF must equal NCTO, NCRF must equal NCRO with quilting
int NCTF = config.n_conv_threshs_fcst();
int NCRF = config.n_conv_radii_fcst();
int NCTO = config.n_conv_threshs_obs();
int NCRO = config.n_conv_radii_obs();

if ( NCTF != NCRF || NCTO != NCRO) {
if (NCTF != NCTO) {
mlog << Error << "\nMultivarFrontEnd::run() ->"
<< "all convolution radius and threshold arrays must have the same number of elements\n\n";

<< "all convolution threshold arrays must have the same number of elements\n\n";
exit ( 1 );
}
if (NCRO != NCRF) {
if (NCRF != NCRO) {
mlog << Error << "\nMultivarFrontEnd::run() ->"
<< "all convolution radius arrays must have the same number of elements\n\n";
exit ( 1 );
}

if ((!config.quilt) && NCTF != NCRF || NCTO != NCRO) {
mlog << Error << "\nMultivarFrontEnd::run() ->"
<< "Unequal number of forecast and obs convolution radii not yet supported\n\n";
<< "all convolution radius and threshold arrays must have the same number of elements without quilting\n\n";
exit ( 1 );
}

// the single number of convolution parameter choices shared by all inputs
int NCONV = NCRO;
// the numbers to use
int NT = NCTF;
int NR = NCRF;

// containers for information needed to do additional things with simple objects after creation
vector<SimpleObjects> fcstSimple, obsSimple;

// create simple objects for all convolution settings
if (config.quilt) {
for (int ir=0; ir<NCONV; ++ir) {
for (int it=0; it<NCONV; ++it) {
for (int ir=0; ir<NR; ++ir) {
for (int it=0; it<NT; ++it) {
SimpleObjects OF, OO;
_create_simple_objects(ModeDataType::MvMode_Fcst, "forecast", ir, it, n_fcst_files,
fcst_filenames, fcstInput, f_calc, OF);
Expand All @@ -132,7 +139,7 @@ int MultivarFrontEnd::run(const StringArray & Argv)
}
}
else {
for (int ir=0; ir<NCONV; ++ir) {
for (int ir=0; ir<NR; ++ir) {
SimpleObjects OF, OO;
_create_simple_objects(ModeDataType::MvMode_Fcst, "forecast", ir, ir, n_fcst_files,
fcst_filenames, fcstInput, f_calc, OF);
Expand Down Expand Up @@ -522,7 +529,8 @@ void MultivarFrontEnd::_create_simple_objects(ModeDataType dtype, const std::str
for (int j=0; j<n_files; ++j) {
mlog << Debug(2)
<< "\n" << sep << "\ncreating simple " << name << " objects from " << name << " "
<< (j + 1) << " of " << n_files << "\n" << sep << "\n";
<< (j + 1) << " of " << n_files << "\nconv_radius[" << rIndex+1 << "] conv_thresh["
<< tIndex+1 << "]\n" << sep << "\n";
MultiVarData *mvdi = _create_simple_multivar_data(dtype, rIndex, tIndex, j, n_files,
filenames[j], input[j]);
mvdi->print();
Expand Down Expand Up @@ -668,17 +676,7 @@ MultivarFrontEnd::_intensity_compare_mode_algorithm(int rIndexF, int tIndexF,

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

// void MultivarFrontEnd::_process_superobjects(int rIndexF, int tIndexF,
// int rIndexO, int tIndexO,
// ModeSuperObject &fsuper,
// ModeSuperObject &osuper,
// const MultiVarData &mvdf,
// const MultiVarData &mvdo)
void MultivarFrontEnd::_process_superobjects(SimpleObjects &fcsts, SimpleObjects &obs)
// _process_superobjects(fcstSimple[fi]._rIndex, fcstSimple[fi]._tIndex,
// obsSimple[oi]._rIndex, obsSimple[oi]._tIndex,
// fcstSimple[fi]._super, obsSimple[oi]._super,
// *(fcstSimple[fi]._mvd[0]), *(fcstSimple[oi]._mvd[0]));
{
mlog << Debug(1) << "Running superobject mode \n\n";

Expand Down

0 comments on commit 0cc536f

Please sign in to comment.