From c104425f720365d797ab07b97545d1cc09f7a990 Mon Sep 17 00:00:00 2001 From: hsoh-u Date: Wed, 15 Sep 2021 18:17:39 -0600 Subject: [PATCH] Feature 1913 MAX_PBL (#1916) * #1913 Changed MAX_PBL to 10000. Filter out if the PBL input data is invalid * #1912 Replaced is_eq to is_bad_data * #1913 Changed is_eq to is_bad_data Co-authored-by: Howard Soh --- met/src/tools/other/pb2nc/pb2nc.cc | 96 +++++++++++--------- met/src/tools/other/point2grid/point2grid.cc | 22 ++--- 2 files changed, 62 insertions(+), 56 deletions(-) diff --git a/met/src/tools/other/pb2nc/pb2nc.cc b/met/src/tools/other/pb2nc/pb2nc.cc index 2b2c715518..ec8372b0f8 100644 --- a/met/src/tools/other/pb2nc/pb2nc.cc +++ b/met/src/tools/other/pb2nc/pb2nc.cc @@ -166,7 +166,7 @@ static float static_dummy_200[MAX_CAPE_LEVEL]; static float static_dummy_201[MAX_CAPE_LEVEL+1]; #define ROG 287.04 -#define MAX_PBL 5000 +#define MAX_PBL 10000 #define MAX_PBL_LEVEL 256 #define PBL_DEBUG_LEVEL 8 static bool IGNORE_Q_PBL = true; @@ -374,6 +374,7 @@ static void insert_pbl(float *obs_arr, const float pbl_value, const int pbl_co const ConcatString &hdr_typ, const ConcatString &hdr_sid); static int interpolate_by_pressure(int length, float *pres_data, float *var_data); static void interpolate_pqtzuv(float*, float*, float*); +static bool is_valid_pb_data(float pb_value); static void log_merged_tqz_uv(map pqtzuv_map_tq, map pqtzuv_map_uv, map &pqtzuv_map_merged, @@ -1562,35 +1563,36 @@ void process_pbfile(int i_pb) { if (cal_cape) { if (cape_member_cnt >= 3) cape_level++; } - if (do_pbl && !is_eq(pqtzuv[0], bad_data_float)) { - // Allocated memory is deleted after all observations are processed - float *tmp_pqtzuv = new float [mxr8vt]; - - for(kk=0; kk 0) { + bool has_uv = is_valid_pb_data(pqtzuv[4]) && is_valid_pb_data(pqtzuv[5]); + bool has_tq = is_valid_pb_data(pqtzuv[2]) && + (IGNORE_Q_PBL || is_valid_pb_data(pqtzuv[1])) && + (IGNORE_Z_PBL || is_valid_pb_data(pqtzuv[3])); + if (has_tq || has_uv) { + // Allocated memory is deleted after all observations are processed + float *tmp_pqtzuv = new float [mxr8vt]; + + for(kk=0; kk r8bfms) { + if (is_bad_data(quality_code) || quality_mark > r8bfms) { obs_qty.add("NA"); } else { @@ -2833,7 +2835,7 @@ void display_bufr_variables(const StringArray &all_vars, const StringArray &all_ void copy_pqtzuv(float *to_pqtzuv, float *from_pqtzuv, bool copy_all) { int start_idx = (copy_all ? 0 : 1); for (int index = start_idx; index < mxr8vt; index++) { - if (copy_all || !is_eq(from_pqtzuv[index], bad_data_float)) + if (copy_all || !is_bad_data(from_pqtzuv[index])) to_pqtzuv[index] = from_pqtzuv[index]; } } @@ -3007,8 +3009,8 @@ float compute_pbl(map pqtzuv_map_tq, pbl_data_hgt[index] = pqtzuv[3]; pbl_data_ugrd[index] = pqtzuv[4]; pbl_data_vgrd[index] = pqtzuv[5]; - if (!is_eq(pbl_data_spfh[index], bad_data_float)) spfh_cnt++; - if (!is_eq(pbl_data_hgt[index], bad_data_float)) hgt_cnt++; + if (is_valid_pb_data(pbl_data_spfh[index])) spfh_cnt++; + if (is_valid_pb_data(pbl_data_hgt[index])) hgt_cnt++; selected_levels.add(nint(it->first)); } @@ -3028,7 +3030,7 @@ float compute_pbl(map pqtzuv_map_tq, break; } } - if (!is_eq(highest_pressure, bad_data_float)) { + if (!is_bad_data(highest_pressure)) { index = MAX_PBL_LEVEL - 1; for (; it!=pqtzuv_map_tq.end(); ++it) { int pres_level = nint(it->first); @@ -3080,7 +3082,7 @@ float compute_pbl(map pqtzuv_map_tq, //SUBROUTINE CALPBL(T,Q,P,Z,U,V,MZBL,HPBL,jpbl) calpbl_(pbl_data_temp, pbl_data_spfh, pbl_data_pres, pbl_data_hgt, pbl_data_ugrd, pbl_data_vgrd, &mzbl, &hpbl, &jpbl); - if (is_eq(hpbl, bad_data_float)) + if (!is_valid_pb_data(hpbl)) mlog << Debug(5) << method_name << " fail to compute PBL. TQ records: " << tq_count << " UV records: " << uv_count << " merged records: " << pqtzuv_map_merged.size() << "\n"; @@ -3100,8 +3102,8 @@ void insert_pbl(float *obs_arr, const float pbl_value, const int pbl_code, ConcatString hdr_info; hdr_info << unix_to_yyyymmdd_hhmmss(hdr_vld_ut) << " " << hdr_typ << " " << hdr_sid; - if (is_eq(pbl_value, bad_data_float)) { - mlog << Warning << "\nFailed to compute PBL " << hdr_info << "\n\n"; + if (is_bad_data(pbl_value)) { + mlog << Warning << "\nFailed to compute PBL " << pbl_value << " (" << hdr_info << ")\n\n"; } else if (pbl_value < hdr_elv) { mlog << Warning << "\nNot saved because the computed PBL (" << pbl_value @@ -3118,14 +3120,12 @@ void insert_pbl(float *obs_arr, const float pbl_value, const int pbl_code, << " lat: " << hdr_lat << ", lon: " << hdr_lon << ", elv: " << hdr_elv << " " << hdr_info << "\n\n"; if (obs_arr[4] > MAX_PBL) { - mlog << Warning << "\nComputed PBL (" << obs_arr[4] << " from " - << pbl_value << ") is too high, Reset to " << MAX_PBL - << " " << hdr_info<< "\n\n"; - obs_arr[4] = MAX_PBL; + mlog << Warning << "\nNot saved the computed PBL (" << obs_arr[4] << " from " + << pbl_value << ") because of the MAX PBL " << MAX_PBL + << " (" << hdr_info<< ")\n\n"; } - - addObservation(obs_arr, (string)hdr_typ, (string)hdr_sid, hdr_vld_ut, - hdr_lat, hdr_lon, hdr_elv, pbl_qm, OBS_BUFFER_SIZE); + else addObservation(obs_arr, (string)hdr_typ, (string)hdr_sid, hdr_vld_ut, + hdr_lat, hdr_lon, hdr_elv, pbl_qm, OBS_BUFFER_SIZE); } } @@ -3142,7 +3142,7 @@ int interpolate_by_pressure(int length, float *pres_data, float *var_data) { skip_missing = false; count_interpolated = 0; for (idx=0; idx pqtzuv_map_pivot, map pqtzuv_map_aux, map &pqtzuv_map_merged) { diff --git a/met/src/tools/other/point2grid/point2grid.cc b/met/src/tools/other/point2grid/point2grid.cc index 9dd321221d..7b840f08d9 100644 --- a/met/src/tools/other/point2grid/point2grid.cc +++ b/met/src/tools/other/point2grid/point2grid.cc @@ -787,8 +787,8 @@ void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, requested_valid_time = valid_time; if (0 < valid_time) { valid_beg_ut = valid_end_ut = valid_time; - if (!is_eq(bad_data_int, conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; - if (!is_eq(bad_data_int, conf_info.end_ds)) valid_end_ut += conf_info.end_ds; + if (!is_bad_data(conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; + if (!is_bad_data(conf_info.end_ds)) valid_end_ut += conf_info.end_ds; for(idx=0; idx= 4) { if (from_min_value > data_value) from_min_value = data_value; @@ -1134,8 +1134,8 @@ void process_point_nccf_file(NcFile *nc_in, MetConfig &config, unixtime ref_ut = (unixtime) 0; unixtime tmp_time; if( conf_info.valid_time > 0 ) { - if (!is_eq(bad_data_int, conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; - if (!is_eq(bad_data_int, conf_info.end_ds)) valid_end_ut += conf_info.end_ds; + if (!is_bad_data(conf_info.beg_ds)) valid_beg_ut += conf_info.beg_ds; + if (!is_bad_data(conf_info.end_ds)) valid_end_ut += conf_info.end_ds; ref_ut = get_reference_unixtime(&time_var, sec_per_unit, no_leap_year); } for (int i=0; i= to_size ) { mlog << Error << "\n" << method_name << "the mapped cell is out of range: " @@ -1978,7 +1978,7 @@ static unixtime find_valid_time(NcVar time_var) { } } - if (valid_time == bad_data_int) { + if (is_bad_data(valid_time)) { mlog << Error << "\n" << method_name << "trouble finding time variable from \"" << InputFilename << "\"\n\n"; @@ -2401,7 +2401,7 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, for (int dIdx=0; dIdx