From cbf60bff11fec31129957fec26a7a0c205de2457 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 1 Oct 2024 14:48:16 +0000 Subject: [PATCH] Per #2880, update NcPointObsData class to read the obs quality values from the input file. --- src/libcode/vx_nc_obs/met_point_data.cc | 19 ++++++++++++++++++- src/libcode/vx_nc_obs/nc_obs_util.cc | 12 +++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/libcode/vx_nc_obs/met_point_data.cc b/src/libcode/vx_nc_obs/met_point_data.cc index bb6bf30e38..2f7f21dfb2 100644 --- a/src/libcode/vx_nc_obs/met_point_data.cc +++ b/src/libcode/vx_nc_obs/met_point_data.cc @@ -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; @@ -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])]; } diff --git a/src/libcode/vx_nc_obs/nc_obs_util.cc b/src/libcode/vx_nc_obs/nc_obs_util.cc index 5380923944..80f217e354 100644 --- a/src/libcode/vx_nc_obs/nc_obs_util.cc +++ b/src/libcode/vx_nc_obs/nc_obs_util.cc @@ -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