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 2044 pb2nc config #2050

Merged
merged 10 commits into from
Feb 17, 2022
2 changes: 2 additions & 0 deletions .github/dummy_for_action
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#update me to add action comment

2 changes: 1 addition & 1 deletion met/data/config/PB2NCConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ obs_bufr_map = [];
// abbreviations in the output. This default map is appended to obs_bufr_map.
// This should not typically be overridden.
//
obs_prefbufr_map = [
obs_prepbufr_map = [
{ key = "POB"; val = "PRES"; },
{ key = "QOB"; val = "SPFH"; },
{ key = "TOB"; val = "TMP"; },
Expand Down
4 changes: 2 additions & 2 deletions met/docs/Users_Guide/config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,7 @@ of the forecast the observation is used to verify.

obs_bufr_map = [];

obs_prefbufr_map
obs_prepbufr_map
""""""""""""""""

Default mapping for PREPBUFR. Replace input BUFR variable names with GRIB
Expand All @@ -3478,7 +3478,7 @@ abbreviations to the output.

.. code-block:: none

obs_prefbufr_map = [
obs_prepbufr_map = [
{ key = "POB"; val = "PRES"; },
{ key = "QOB"; val = "SPFH"; },
{ key = "TOB"; val = "TMP"; },
Expand Down
2 changes: 1 addition & 1 deletion met/scripts/config/PB2NCConfig_G212
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ obs_bufr_var = [ "QOB", "TOB", "ZOB", "UOB", "VOB",
// Mapping of BUFR variable name to GRIB name. The default map is defined at
// obs_prepbufr_map. This replaces/expends the default map.
//
//obs_bufr_var = [];
obs_bufr_map = [];

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

Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static const char conf_key_message_type_group_map[] = "message_type_group_map";
static const char conf_key_obs_bufr_map[] = "obs_bufr_map";
static const char conf_key_obs_bufr_var[] = "obs_bufr_var";
static const char conf_key_obs_name_map[] = "obs_name_map";
static const char conf_key_obs_prefbufr_map[] = "obs_prefbufr_map";
static const char conf_key_obs_prepbufr_map[] = "obs_prepbufr_map";
static const char conf_key_key[] = "key";
static const char conf_key_val[] = "val";
static const char conf_key_boot_interval[] = "boot.interval";
Expand Down
9 changes: 1 addition & 8 deletions met/src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using namespace std;
///////////////////////////////////////////////////////////////////////////////

static const double default_vld_thresh = 1.0;
static const char conf_key_prepbufr_map_bad[] = "obs_prefbufr_map"; // for backward compatibility

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

Expand Down Expand Up @@ -1088,14 +1089,6 @@ map<ConcatString,StringArray> parse_conf_metadata_map(Dictionary *dict) {

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

map<ConcatString,ConcatString> parse_conf_obs_bufr_map(Dictionary *dict) {
map<ConcatString,ConcatString> m = parse_conf_key_value_map(dict, conf_key_obs_prefbufr_map);
parse_add_conf_key_value_map(dict, conf_key_obs_bufr_map, &m);
return m;
}

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

map<ConcatString,ConcatString> parse_conf_obs_name_map(Dictionary *dict) {
const char *method_name = "parse_conf_obs_name_map() -> ";
return parse_conf_key_value_map(dict, conf_key_obs_name_map);
Expand Down
8 changes: 6 additions & 2 deletions met/src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

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

static const char conf_key_old_prepbufr_map[] = "obs_prefbufr_map"; // for backward compatibility

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

extern ConcatString parse_conf_version(Dictionary *dict);
extern ConcatString parse_conf_string(Dictionary *dict, const char *, bool check_empty = true);
extern GrdFileType parse_conf_file_type(Dictionary *dict);
Expand All @@ -48,13 +52,13 @@ extern ClimoCDFInfo parse_conf_climo_cdf(Dictionary *dict);
extern TimeSummaryInfo parse_conf_time_summary(Dictionary *dict);
extern map<ConcatString,ConcatString> parse_conf_key_value_map(
Dictionary *dict, const char *conf_key_map_name, const char *caller=0);
extern void parse_add_conf_key_value_map(
Dictionary *dict, const char *conf_key_map_name, map<ConcatString,ConcatString> *m);
extern map<ConcatString,ConcatString>
parse_conf_message_type_map(Dictionary *dict);
extern map<ConcatString,StringArray>
parse_conf_message_type_group_map(Dictionary *dict);
extern map<ConcatString,StringArray> parse_conf_metadata_map(Dictionary *dict);
extern map<ConcatString,ConcatString>
parse_conf_obs_bufr_map(Dictionary *dict);
extern map<ConcatString,ConcatString>
parse_conf_obs_name_map(Dictionary *dict);
extern BootInfo parse_conf_boot(Dictionary *dict);
Expand Down
2 changes: 1 addition & 1 deletion met/src/libcode/vx_nc_obs/nc_obs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct NetcdfObsVars {
NcDim obs_arr_dim ; // Observation array width (V1.0, not used from V1.2)
NcDim obs_dim ; // Observation array length (V1.0)
NcDim hdr_dim ; // Header array length (V1.0)
NcDim pb_hdr_dim ; // PrefBufr Header array length (V1.2)
NcDim pb_hdr_dim ; // PrepfBufr Header array length (V1.2)

NcVar hdr_typ_tbl_var ; // Message type (string) (V1.1)
NcVar hdr_sid_tbl_var ; // Station ID (string) (V1.1)
Expand Down
3 changes: 2 additions & 1 deletion met/src/tools/core/series_analysis/series_analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,10 @@ void process_scores() {
// Number of points skipped due to valid data threshold
int n_skip_zero = 0;
int n_skip_pos = 0;

// Loop over the data reads
for(i_read=0; i_read<n_reads; i_read++) {
i_point = 0;

// Loop over the series variable
for(i_series=0; i_series<n_series; i_series++) {
Expand Down
6 changes: 3 additions & 3 deletions met/src/tools/other/pb2nc/pb2nc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3057,7 +3057,7 @@ float compute_pbl(map<float, float*> pqtzuv_map_tq,
pbl_data_hgt[index] = pqtzuv[3];
pbl_data_ugrd[index] = pqtzuv[4];
pbl_data_vgrd[index] = pqtzuv[5];
mlog << Debug(5) << method_name << "Force to add "
mlog << Debug(6) << method_name << "Force to add "
<< pres_level << " into " << index << "\n";
index--;
}
Expand All @@ -3077,11 +3077,11 @@ float compute_pbl(map<float, float*> pqtzuv_map_tq,

if (hgt_cnt < pbl_level) {
hgt_cnt += interpolate_by_pressure(pbl_level, pbl_data_pres, pbl_data_hgt);
mlog << Debug(4) << method_name << "interpolate Z (HGT)\n";
mlog << Debug(6) << method_name << "interpolate Z (HGT)\n";
}
if (spfh_cnt < pbl_level) {
spfh_cnt += interpolate_by_pressure(pbl_level, pbl_data_pres, pbl_data_spfh);
mlog << Debug(4) << method_name << "interpolate Q (SPFH)\n";
mlog << Debug(6) << method_name << "interpolate Q (SPFH)\n";
}

if ((spfh_cnt>0) && (pbl_level>0)) {
Expand Down
40 changes: 40 additions & 0 deletions met/src/tools/other/pb2nc/pb2nc_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ using namespace std;
#include "grib_strings.h"
#include "vx_log.h"


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

map<ConcatString,ConcatString> parse_conf_obs_bufr_map(Dictionary *dict) {

const char *key_name = (0 != dict->lookup_array(conf_key_obs_prepbufr_map, false, false))
? conf_key_obs_prepbufr_map : conf_key_old_prepbufr_map;
map<ConcatString,ConcatString> m = parse_conf_key_value_map(dict, (const char *)key_name);
parse_add_conf_key_value_map(dict, conf_key_obs_bufr_map, &m);
return m;
}

////////////////////////////////////////////////////////////////////////
//
// Code for class PB2NCConfInfo
Expand Down Expand Up @@ -85,14 +97,42 @@ void PB2NCConfInfo::clear() {
void PB2NCConfInfo::read_config(const char *default_file_name,
const char *user_file_name) {

int warning_code = 0;
bool use_bad_one = true;
string bad_file_names;

// Read the config file constants
conf.read(replace_path(config_const_filename).c_str());

// Read the default config file
conf.read(default_file_name);
if (0 != conf.lookup_array(conf_key_old_prepbufr_map, false, false)) {
warning_code = 1;
bad_file_names = default_file_name;
if (0 != conf.lookup_array(conf_key_obs_prepbufr_map, false, false)) use_bad_one = false;
}

// Read the user-specified config file
conf.read(user_file_name);
if (0 != conf.lookup_array(conf_key_old_prepbufr_map, false, false)) {
warning_code = 2;
if (0 < bad_file_names.length()) bad_file_names += " and ";
bad_file_names += user_file_name;
if (0 != conf.lookup_array(conf_key_obs_prepbufr_map, false, false)) use_bad_one = false;
}

if (0 < warning_code) {
string ignored_message = " ";

if (!use_bad_one) {
ignored_message = " (Ignored \"";
ignored_message += conf_key_old_prepbufr_map;
ignored_message += "\" key)";
}
mlog << Warning << "\nPlease rename the configuration key \""
<< conf_key_old_prepbufr_map << "\" to \"" << conf_key_obs_prepbufr_map
<< "\" at " << bad_file_names << ignored_message << "\n\n";
}

return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/config/PB2NCConfig_airnow
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ obs_bufr_map = [];
// This map is for PREPBUFR. It will be added into obs_bufr_map.
// Please do not override this map.
//
obs_prefbufr_map = [
obs_prepbufr_map = [
{ key = "POB"; val = "PRES"; },
{ key = "QOB"; val = "SPFH"; },
{ key = "TOB"; val = "TMP"; },
Expand Down
2 changes: 1 addition & 1 deletion test/config/PB2NCConfig_pbl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ obs_bufr_map = [];
// abbreviations in the output. This default map is appended to obs_bufr_map.
// This should not typically be overridden.
//
obs_prefbufr_map = [
obs_prepbufr_map = [
{ key = "POB"; val = "PRES"; },
{ key = "QOB"; val = "SPFH"; },
{ key = "TOB"; val = "TMP"; },
Expand Down