Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 2709 mvmode multithreshradii #3034

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions data/table_files/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
tablefilesdir = $(pkgdatadir)/table_files
tablefiles_DATA = \
met_header_columns_V12.1.txt \
met_header_columns_V12.0.txt \
met_header_columns_V11.1.txt \
met_header_columns_V11.0.txt \
Expand Down
6 changes: 5 additions & 1 deletion docs/Users_Guide/mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ When regridding to the FCST or OBS field (e.g. to_grid = FCST), the first field

"file_type" can be set independently for each input in multivariate mode. If not set for an input, MET uses file names and file content to determine the type.

In multivariate mode, with quilt=**FALSE**, for all inputs the number of forecast and observation convolution radii and thresholds must all match. One configuration of MODE will be run for each group of settings in those lists.

In multivariate mode, with quilt=**TRUE**, for all inputs the number of forecast and observation convolution radii must match and the number of forecast and observation convolution thresholds must match. When each input has N radii and M thresholds, NxM configurations of MODE will be run.

When setting a threshold to a percentile, some choices require both an observation input and a forecast input. When this is the case, it's assumed the indices match, so for example if forecast input 1 has such a percentile setting, then observation input 1 will be used to compute the percentile. Percentiles in which this will happen are:

* SFP in an observation input.
Expand Down Expand Up @@ -319,7 +323,7 @@ The **conv_radius** entry defines the radius of the circular convolution applied

The **conv_thresh** entry specifies the threshold values to be applied to the convolved field to define objects. By default, objects are defined using a convolution threshold of 5.0. Multiple convolution thresholds may be specified as an array (e.g. **conv_thresh = [ >=5.0, >=10.0, >=15.0 ];)**.

Multiple convolution radii and thresholds and processed using the logic defined by the **quilt** entry.
Multiple convolution radii and thresholds and processed using the logic defined by the **quilt** entry. The logic specific to multivariate mode is described in the multivariate mode section above.
JohnHalleyGotway marked this conversation as resolved.
Show resolved Hide resolved

The **vld_thresh** entry must be set between 0 and 1. When performing the circular convolution step if the proportion of bad data values in the convolution area is greater than or equal to this threshold, the resulting convolved value will be bad data. If the proportion is less than this threshold, the convolution will be performed on only the valid data. By default, the **vld_thresh** is set to 0.5.

Expand Down
2 changes: 0 additions & 2 deletions src/libcode/vx_shapedata/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ void ModeFuzzyEngine::do_fcst_convolution() {
if(!need_fcst_conv) return;

r = conf_info.Fcst->conv_radius;

*fcst_conv = *fcst_raw;

mlog << Debug(3) << "Applying circular convolution of radius "
Expand Down Expand Up @@ -645,7 +644,6 @@ void ModeFuzzyEngine::do_obs_convolution() {
if(!need_obs_conv) return;

r = conf_info.Obs->conv_radius;

*obs_conv = *obs_raw;

mlog << Debug(3) << "Applying circular convolution of radius "
Expand Down
207 changes: 175 additions & 32 deletions src/libcode/vx_shapedata/mode_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,45 @@ void ModeConfInfo::set_conv_radius_by_index(int k)
}


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

void ModeConfInfo::set_obs_conv_radius_by_index(int k)

{
// if (data_type != ModeDataType::MvMode_Obs) {
// if ( (k < 0) || (k >= Fcst->conv_radius_array.n_elements()) ) {
// mlog << Error
// << "\nModeConfInfo::set_conv_radius_by_index(int) -> "
// << "range check error\n\n";
// exit ( 1 );
// }
// Fcst->conv_radius = Fcst->conv_radius_array[k];
// }
// if (data_type != ModeDataType::MvMode_Fcst) {
if ( (k < 0) || (k >= Obs->conv_radius_array.n_elements()) ) {
mlog << Error
<< "\nModeConfInfo::set_conv_radius_by_index(int) -> "
<< "range check error\n\n";
exit ( 1 );
}
Obs->conv_radius = Obs->conv_radius_array[k];
}


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

void ModeConfInfo::set_fcst_conv_radius_by_index(int k)

{
if ( (k < 0) || (k >= Fcst->conv_radius_array.n_elements()) ) {
mlog << Error
<< "\nModeConfInfo::set_conv_radius_by_index(int) -> "
<< "range check error\n\n";
exit ( 1 );
}
Fcst->conv_radius = Fcst->conv_radius_array[k];
}

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


Expand All @@ -1381,6 +1420,21 @@ void ModeConfInfo::set_conv_thresh(SingleThresh s)

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


void ModeConfInfo::set_fcst_conv_thresh(SingleThresh s)
{
Fcst->conv_thresh = s;
}

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

void ModeConfInfo::set_obs_conv_thresh(SingleThresh s)
{
Obs->conv_thresh = s;
}

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

void ModeConfInfo::set_conv_radius(int r)
{
if (data_type != ModeDataType::MvMode_Obs) {
Expand All @@ -1393,6 +1447,20 @@ void ModeConfInfo::set_conv_radius(int r)

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

void ModeConfInfo::set_fcst_conv_radius(int r)
{
Fcst->conv_radius = r;
}

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

void ModeConfInfo::set_obs_conv_radius(int r)
{
Obs->conv_radius = r;
}

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

void ModeConfInfo::set_conv_thresh_by_index(int k)

{
Expand All @@ -1419,6 +1487,37 @@ void ModeConfInfo::set_conv_thresh_by_index(int k)
}


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

void ModeConfInfo::set_obs_conv_thresh_by_index(int k)

{
if ( (k < 0) || (k >= Obs->conv_thresh_array.n_elements()) ) {
mlog << Error
<< "\nModeConfInfo::set_conv_thresh_by_index(int) -> "
<< "range check error\n\n";
exit ( 1 );
}
Obs->conv_thresh = Obs->conv_thresh_array[k];
}


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

void ModeConfInfo::set_fcst_conv_thresh_by_index(int k)

{
if ( (k < 0) || (k >= Fcst->conv_thresh_array.n_elements()) ) {

mlog << Error
<< "\nModeConfInfo::set_conv_thresh_by_index(int) -> "
<< "range check error\n\n";
exit ( 1 );
}
Fcst->conv_thresh = Fcst->conv_thresh_array[k];
}


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

void ModeConfInfo::set_merge_thresh_by_index(int k)
Expand Down Expand Up @@ -1732,57 +1831,101 @@ 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 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 (fcst_array[i].conv_thresh_array.n() > 1 || fcst_array[i].merge_thresh_array.n() > 1) {
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"
<< " more than one conv_thresh or merge_thresh per input is not allowed in multivariate mode\n\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 (obs_array[i].conv_thresh_array.n() > 1 || obs_array[i].merge_thresh_array.n() > 1) {
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"
<< " more than one conv_thresh or merge_thresh per input is not allowed in multivariate mode\n\n";
<< " Unequal array lengths for merge_thresh not allowed in multivariate mode\n\n";
status = true;
}
}
}
}

if (status) {
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"
<< " Some features not yet implemented in multivar mode\n\n";
<< "\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";
status = true;
}

if (status) {
exit ( 1 );
}
}


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

PercThreshType ModeConfInfo::perctype(const Mode_Field_Info &f) const
Expand Down
39 changes: 37 additions & 2 deletions src/libcode/vx_shapedata/mode_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,30 @@ class ModeConfInfo {

void parse_nc_info ();

// might need addtional methods here for pass2 multivariate, if/when we allow more than 1 radius
void set_conv_radius_by_index (int);
// might need addtional methods here for pass2 multivariate, if/when we allow more than 1 thresh
void set_obs_conv_radius_by_index (int);
void set_fcst_conv_radius_by_index (int);

void set_conv_thresh_by_index (int);
void set_obs_conv_thresh_by_index (int);
void set_fcst_conv_thresh_by_index (int);

void set_conv_thresh(SingleThresh);
void set_fcst_conv_thresh(SingleThresh);
void set_obs_conv_thresh(SingleThresh);
void set_conv_radius(int);
void set_fcst_conv_radius(int);
void set_obs_conv_radius(int);

int n_conv_threshs () const;
int n_conv_radii () const;

int n_conv_threshs_fcst () const;
int n_conv_radii_fcst () const;

int n_conv_threshs_obs () const;
int n_conv_radii_obs () const;

int n_runs() const; // # threshs times # radii

int n_fields_f() const; // should be 1 for traditional mode, >= 1 for muiltivar
Expand Down Expand Up @@ -316,6 +329,7 @@ inline int ModeConfInfo::n_conv_radii() const
{
// this could break down if multivar mode relaxes
// its limitations on number of radii (obs and fcst could be different)
// so far that is not the case.
if (data_type == ModeDataType::MvMode_Obs)
{
return ( Obs->conv_radius_array.n_elements() );
Expand All @@ -324,10 +338,21 @@ inline int ModeConfInfo::n_conv_radii() const
}
}

inline int ModeConfInfo::n_conv_radii_fcst() const
{
return ( Fcst->conv_radius_array.n_elements() );
}

inline int ModeConfInfo::n_conv_radii_obs() const
{
return ( Obs->conv_radius_array.n_elements() );
}

inline int ModeConfInfo::n_conv_threshs() const
{
// this could break down if multivar mode relaxes
// its limitations on number of thresh (obs and fcst could be different)
// so far that is not the case.
if (data_type == ModeDataType::MvMode_Obs)
{
return ( Obs->conv_thresh_array.n_elements() );
Expand All @@ -336,6 +361,16 @@ inline int ModeConfInfo::n_conv_threshs() const
}
}

inline int ModeConfInfo::n_conv_threshs_fcst() const
{
return ( Fcst->conv_thresh_array.n_elements() );
}

inline int ModeConfInfo::n_conv_threshs_obs() const
{
return ( Obs->conv_thresh_array.n_elements() );
}

inline int ModeConfInfo::get_compression_level() { return conf.nc_compression(); }

inline int ModeConfInfo::field_index_f() const { return Field_Index_f; }
Expand Down
1 change: 1 addition & 0 deletions src/tools/core/mode/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mode_SOURCES = mode_usage.cc \
mode_ps_file.cc \
plot_engine.cc \
page_1.cc \
simple_objects.cc \
fcst_enlarge_page.cc \
obs_enlarge_page.cc \
cluster_page.cc \
Expand Down
Loading
Loading