Skip to content

Commit

Permalink
Per #2880, update NcPointObsData class to read the obs quality values…
Browse files Browse the repository at this point in the history
… from the input file.
  • Loading branch information
JohnHalleyGotway committed Oct 1, 2024
1 parent baa5af1 commit cbf60bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/libcode/vx_nc_obs/met_point_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ bool MetPointObsData::fill_obs_buf(int buf_size, int offset,
const char *method_name = "fill_obs_data() -> ";

if (obs_cnt < (buf_size + offset)) {
mlog << Error << "\n" << method_name << "obs data is not ready\n\n";
mlog << Error << "\n" << method_name
<< "obs data is not ready\n\n";
}
else {
float *tmp_obs_arr = obs_arr_buf;
Expand Down Expand Up @@ -339,6 +340,22 @@ float MetPointObsData::get_obs_val(int index) {
///////////////////////////////////////////////////////////////////////////////

string MetPointObsData::get_obs_qty(int index) {
const char *method_name = "MetPointObsData::get_obs_qty() -> ";

if(index < 0 || index >= obs_cnt) {
mlog << Error << "\n" << method_name
<< "index value (" << index << ") out of range for "
<< obs_cnt << " observations.\n\n";
exit(1);
}
if(obs_qids[index] < 0 || obs_qids[index] >= qty_names.n()) {
mlog << Error << "\n" << method_name
<< "observation quality index (" << obs_qids[index]
<< ") out of range for " << qty_names.n()
<< " quality strings.\n\n";
exit(1);
}

return qty_names[(obs_qids[index])];
}

Expand Down
12 changes: 11 additions & 1 deletion src/libcode/vx_nc_obs/nc_obs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,17 @@ bool NcPointObsData::read_obs_data_numbers(NetcdfObsVars obs_vars, bool stop) {
}
}
else succeed = false;

if (IS_INVALID_NC(obs_vars.obs_qty_var)) {
succeed = false;
missing_vars.add(nc_var_obs_qty);
}
else {
obs_qids = new int[obs_cnt];
if (!get_nc_data(&obs_vars.obs_qty_var, obs_qids)) {
succeed = false;
failed_vars.add(nc_var_obs_qty);
}
}
}

for (int idx=0; idx<missing_vars.n(); idx++) {
Expand Down

0 comments on commit cbf60bf

Please sign in to comment.