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 2215 ioda2nc message type #2217

Merged
merged 4 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/config/IODA2NCConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ obs_name_map = [];
// Default mapping for Metadata.
//
metadata_map = [
{ key = "message_type"; val = "msg_type"; },
{ key = "station_id"; val = "report_identifier"; },
{ key = "message_type"; val = "msg_type,station_ob"; },
{ key = "station_id"; val = "station_id,report_identifier"; },
{ key = "pressure"; val = "air_pressure,pressure"; },
{ key = "height"; val = "height,height_above_mean_sea_level"; },
{ key = "elevation"; val = ""; }
Expand Down
4 changes: 2 additions & 2 deletions docs/Users_Guide/reformat_point.rst
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,8 @@ _____________________
.. code-block:: none

metadata_map = [
{ key = "message_type"; val = "msg_type"; },
{ key = "station_id"; val = "report_identifier"; },
{ key = "message_type"; val = "msg_type,station_ob"; },
{ key = "station_id"; val = "station_id,report_identifier"; },
{ key = "pressure"; val = "air_pressure,pressure"; },
{ key = "height"; val = "height,height_above_mean_sea_level"; },
{ key = "elevation"; val = ""; }
Expand Down
46 changes: 25 additions & 21 deletions src/tools/other/ioda2nc/ioda2nc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ static int compress_level = -1;
////////////////////////////////////////////////////////////////////////

static IntArray filtered_times;
//static map<ConcatString, StringArray> variableTypeMap;

static bool do_summary;
static bool save_summary_only = false;
Expand Down Expand Up @@ -412,10 +411,10 @@ void process_ioda_file(int i_pb) {
get_var_names(f_in, &var_names);
get_dim_names(f_in, &dim_names);
for(idx=0; idx<var_names.n(); idx++) {
if(has_postfix(var_names[idx], "MetaData")) {
if(has_postfix(var_names[idx], "@MetaData")) {
metadata_vars.add(var_names[idx].substr(0, var_names[idx].find('@')));
}
if(has_postfix(var_names[idx], "ObsValue")) {
if(has_postfix(var_names[idx], "@ObsValue")) {
obs_value_vars.add(var_names[idx].substr(0, var_names[idx].find('@')));
}
}
Expand Down Expand Up @@ -505,11 +504,19 @@ void process_ioda_file(int i_pb) {
hdr_msg_types = new char[nlocs*nstring];
get_meta_data_strings(f_in, msg_type_name, hdr_msg_types);
}
else {
mlog << Debug(1) << method_name
<< "The metadata variable for message type does not exist!\n";
}

if(has_station_id) {
hdr_station_ids = new char[nlocs*nstring];
get_meta_data_strings(f_in, station_id_name, hdr_station_ids);
}
else {
mlog << Debug(1) << method_name
<< "The metadata variable for station ID does not exist!\n";
}

if(!get_nc_data(&in_hdr_lat_var, hdr_lat_arr, nlocs)) {
mlog << Error << "\n" << method_name
Expand Down Expand Up @@ -576,9 +583,9 @@ void process_ioda_file(int i_pb) {
start_t = clock();
}

log_message.add(" IODA messages");
log_message = " IODA messages";
if(npbmsg != npbmsg_total) {
log_message << " (out of " << unixtime_to_string(npbmsg_total) << ")";
log_message << " (out of " << npbmsg_total << ")";
}
mlog << Debug(2) << "Processing " << npbmsg << log_message << "...\n";

Expand Down Expand Up @@ -658,7 +665,6 @@ void process_ioda_file(int i_pb) {
}

if(has_msg_type) {
int buf_len = sizeof(modified_hdr_typ);
m_strncpy(hdr_typ, hdr_msg_types+(i_read*nstring), nstring, method_name_s, "hdr_typ");
m_rstrip(hdr_typ, nstring);

Expand All @@ -669,20 +675,18 @@ void process_ioda_file(int i_pb) {
rej_typ++;
continue;
}

if(0 < message_type_map.count((string)hdr_typ)) {
ConcatString mappedMessageType = message_type_map[(string)hdr_typ];
mlog << Debug(6) << "\n" << method_name
<< "Switching report type \"" << hdr_typ
<< "\" to message type \"" << mappedMessageType << "\".\n";
if(mappedMessageType.length() < HEADER_STR_LEN) buf_len = HEADER_STR_LEN;
m_strncpy(modified_hdr_typ, mappedMessageType.c_str(), buf_len,
method_name_s, "modified_hdr_typ");
}
else {
m_strncpy(modified_hdr_typ, hdr_typ, buf_len, method_name_s, "modified_hdr_typ2");
}
modified_hdr_typ[buf_len-1] = 0;
}
else m_strncpy(hdr_typ, "NA", HEADER_STR_LEN,
method_name_s, "missing_hdr_typ");
if(0 < message_type_map.count((string)hdr_typ)) {
int buf_len = sizeof(modified_hdr_typ);
ConcatString mappedMessageType = message_type_map[(string)hdr_typ];
mlog << Debug(6) << "\n" << method_name
<< "Switching report type \"" << hdr_typ
<< "\" to message type \"" << mappedMessageType << "\".\n";
if(mappedMessageType.length() < HEADER_STR_LEN) buf_len = HEADER_STR_LEN;
m_strncpy(modified_hdr_typ, mappedMessageType.c_str(), buf_len,
method_name_s, "modified_hdr_typ");
}

if(has_station_id) {
Expand Down Expand Up @@ -768,7 +772,7 @@ void process_ioda_file(int i_pb) {
}

// Store the index to the header data
obs_arr[0] = (float) nc_point_obs.get_hdr_index();
obs_arr[0] = (float)nc_point_obs.get_hdr_index();

n_hdr_obs = 0;
for(idx=0; idx<v_obs_data.size(); idx++ ) {
Expand Down