From 296a5090276e566a8357e15f3665bcdd9a864094 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 16:57:28 -0600 Subject: [PATCH] Update develop-ref after dtcenter/MET#2984 (#2985) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 2673 Moved dvariable declaration after include * #2673 Move down namespace below include * Feature #2395 wdir (#2820) * Per #2395, add new columns to VL1L2, VAL1L2, and VCNT line types for wind direction statistics. Work still in progress. * Per #2395, write the new VCNT columns to the output and document the additions to the VL1L2, VAL1L2, and VCNT columns. * Per #2395, add the definition of new statistics to Appendix G. * Per #2395, update file version history. * Per #2395, tweak warning message about zero wind vectors and update grid-stat and point-stat to log calls to the do_vl1l2() function. * Per #2395, refine the weights for wind direction stats, ignoring the undefined directions. * Update src/tools/core/stat_analysis/aggr_stat_line.cc * Update src/tools/core/stat_analysis/parse_stat_line.cc * Update src/tools/core/stat_analysis/aggr_stat_line.cc * Recent changes to branch protection rules for the develop branch have broken the logic of the update_truth.yml GHA workflow. Instead of submitting a PR to merge develop into develop-ref directly, use an intermediate update_truth_for_develop branch. * Feature #2280 ens_prob (#2823) * Per #2280, update to support probability threshold strings like ==8, where 8 is the number of ensemble members, to create probability bins centered on the n/8 for n = 0 ... 8. * Per #2280, update docs about probability threshold settings. * Per #2280, use a loose tolerance when checking for consistent bin widths. * Per #2280, add a new unit test for grid_stat to demonstrate processing the output from gen_ens_prod. * Per #2280, when verifying NMEP probability forecasts, smooth the obs data first. * Per #2280, only request STAT output for the PCT line type to match unit_grid_stat.xml and minimize the new output files. * Per #2280, update config option docs. * Per #2280, update config option docs. * #2673 Change 0 to nullptr * #2673 Change 0 to nullptr * #2673 Change 0 to nullptr * #2673 Change 0 to nullptr * #2673 Change 0 to nullptr * #2673 Removed the redundant parentheses with return * #2673 Removed the redundant parentheses with return * #2673 Removed the redundant parentheses with return * #2673 Removed the redundant parentheses with return * #2673 Removed the redundant parentheses with return * #2673 restored return statement * #2673 Added std namespace * #2673 Moved down 'using namespace' statement. Removed trailing spaces * #2673 Moved down 'using namespace' statement. * #2673 Moved down 'using namespace' statement. * #2673 Moved down 'using namespace' statement. * #2673 Moved down 'using namespace' statement. * #2673 Added std namespace * #2673 Added std namespace * #2673 Added std namespace * #2673 Changed literal 1 to boolean value, true * Feature #2673 enum_to_string (#2835) * Feature #2583 ecnt (#2825) * Unrelated to #2583, fix typo in code comments. * Per #2583, add hooks write 3 new ECNT columns for observation error data. * Per #2583, make error messages about mis-matched array lengths more informative. * Per #2583, switch to more concise variable naming conventions of ign_oerr_cnv, ign_oerr_cor, and dawid_seb. * Per #2583, fix typo to enable compilation * Per #2583, define the 5 new ECNT column names. * Per #2583, add 5 new columns to the ECNT table in the Ensemble-Stat chapter * Per #2583, update stat_columns.cc to write these 5 new ECNT columns * Per #2583, update ECNTInfo class to compute the 5 new ECNT statistics. * Per #2583, update stat-analysis to parse the 5 new ECNT columns. * Per #2583, update aggregate_stat logic for 5 new ECNT columns. * Per #2583, update PairDataEnsemble logic for 5 new ECNT columns * Per #2583, update vx_statistics library with obs_error handling logic for the 5 new ECNT columns * Per #2583, changes to make it compile * Per #2583, changes to make it compile * Per #2583, switch to a consistent ECNT column naming convention with OERR at the end. Using IGN_CONV_OERR and IGN_CORR_OERR. * Per #2583, define ObsErrorEntry::variance() with a call to the dist_var() utility function. * Per #2583, update PairDataEnsemble::compute_pair_vals() to compute the 5 new stats with the correct inputs. * Per #2583, add DEBUG(10) log messages about computing these new stats. * Per #2583, update Stat-Analysis to compute these 5 new stats from the ORANK line type. * Per #2583, whitespace and comments. * Per #2583, update the User's Guide. * Per #2583, remove the DS_ADD_OERR and DS_MULT_OERR ECNT columns and rename DS_OERR as DSS, since observation error is not actually involved in its computation. * Per #2583, minor update to Appendix C * Per #2583, rename ECNT line type statistic DSS to IDSS. * Per #2583, fix a couple of typos * Per #2583, more error checking. * Per #2583, remove the ECNT IDSS column since its just 2*pi*IGN, the existing ignorance score, and only provides meaningful information when combined with the other Dawid-Sebastiani statistics that have already been removed. * Per #2583, add Eric's documentation of these new stats to Appendix C. Along the way, update the DOI links in the references based on this APA style guide: https://apastyle.apa.org/style-grammar-guidelines/references/dois-urls#:~:text=Include%20a%20DOI%20for%20all,URL%2C%20include%20only%20the%20DOI. * Per #2583, fix new equations with embedded underscores for PDF by defining both html and pdf formatting options. * Per #2583, update the ign_conv_oerr equation to include a 2 *pi multiplier for consistency with the existing ignorance score. Also, fix the documented equations. * Per #2583, remove log file that was inadvertently added on this branch. * Per #2583, simplify ObsErrorEntry::variance() implementation. For the distribution type of NONE, return a variance of 0.0 rather than bad data, as discussed with @michelleharrold and @JeffBeck-NOAA on 3/8/2024. --------- Co-authored-by: MET Tools Test Account * Revert #2825 since more documentation and testing is needed (#2837) This reverts commit 108a8958b206d6712197823a083666ab039bf818. * Feature #2583 ecnt fix IGN_OERR_CORR (#2838) * Unrelated to #2583, fix typo in code comments. * Per #2583, add hooks write 3 new ECNT columns for observation error data. * Per #2583, make error messages about mis-matched array lengths more informative. * Per #2583, switch to more concise variable naming conventions of ign_oerr_cnv, ign_oerr_cor, and dawid_seb. * Per #2583, fix typo to enable compilation * Per #2583, define the 5 new ECNT column names. * Per #2583, add 5 new columns to the ECNT table in the Ensemble-Stat chapter * Per #2583, update stat_columns.cc to write these 5 new ECNT columns * Per #2583, update ECNTInfo class to compute the 5 new ECNT statistics. * Per #2583, update stat-analysis to parse the 5 new ECNT columns. * Per #2583, update aggregate_stat logic for 5 new ECNT columns. * Per #2583, update PairDataEnsemble logic for 5 new ECNT columns * Per #2583, update vx_statistics library with obs_error handling logic for the 5 new ECNT columns * Per #2583, changes to make it compile * Per #2583, changes to make it compile * Per #2583, switch to a consistent ECNT column naming convention with OERR at the end. Using IGN_CONV_OERR and IGN_CORR_OERR. * Per #2583, define ObsErrorEntry::variance() with a call to the dist_var() utility function. * Per #2583, update PairDataEnsemble::compute_pair_vals() to compute the 5 new stats with the correct inputs. * Per #2583, add DEBUG(10) log messages about computing these new stats. * Per #2583, update Stat-Analysis to compute these 5 new stats from the ORANK line type. * Per #2583, whitespace and comments. * Per #2583, update the User's Guide. * Per #2583, remove the DS_ADD_OERR and DS_MULT_OERR ECNT columns and rename DS_OERR as DSS, since observation error is not actually involved in its computation. * Per #2583, minor update to Appendix C * Per #2583, rename ECNT line type statistic DSS to IDSS. * Per #2583, fix a couple of typos * Per #2583, more error checking. * Per #2583, remove the ECNT IDSS column since its just 2*pi*IGN, the existing ignorance score, and only provides meaningful information when combined with the other Dawid-Sebastiani statistics that have already been removed. * Per #2583, add Eric's documentation of these new stats to Appendix C. Along the way, update the DOI links in the references based on this APA style guide: https://apastyle.apa.org/style-grammar-guidelines/references/dois-urls#:~:text=Include%20a%20DOI%20for%20all,URL%2C%20include%20only%20the%20DOI. * Per #2583, fix new equations with embedded underscores for PDF by defining both html and pdf formatting options. * Per #2583, update the ign_conv_oerr equation to include a 2 *pi multiplier for consistency with the existing ignorance score. Also, fix the documented equations. * Per #2583, remove log file that was inadvertently added on this branch. * Per #2583, simplify ObsErrorEntry::variance() implementation. For the distribution type of NONE, return a variance of 0.0 rather than bad data, as discussed with @michelleharrold and @JeffBeck-NOAA on 3/8/2024. * Per #2583, updates to ensemble-stat.rst recommended by @michelleharrold and @JeffBeck-NOAA. * Per #2583, implement changes to the IGN_CORR_OERR corrected as directed by @ericgilleland. --------- Co-authored-by: MET Tools Test Account * Update the pull request template to include a question about expected impacts to existing METplus Use Cases. * #2830 Changed enum Builtin to enum class * #2830 Converted enum to enum class at config_constants.h * Feature #2830 bootstrap enum (#2843) * Bugfix #2833 develop azimuth (#2840) * Per #2833, fix n-1 bug when defining the azimuth delta for range/azimuth grids. * Per #2833, when definng TcrmwData:range_max_km, divide by n_range - 1 since the range values start at 0. * Per #2833, remove max_range_km from the TC-RMW config file. Set the default rmw_scale to NA so that its not used by default. And update the documentation. Still actually need to make the logic of the code work as it should. * Per #2833, update tc_rmw to define the range as either a function of rmw or using explicit spacing in km. * Per #2833, update the TCRMW Config files to remove the max_range_km entry, and update the unit test for one call to use RMW ranges and the other to use ranges defined in kilometers. * Per #2833, just correct code comments. * Per #2833, divide by n - 1 when computing the range delta, rather than n. * Per #2833, correct the handling of the maximum range in the tc-rmw tool. For fixed delta km, need to define the max range when setting up the grid at the beginning. --------- Co-authored-by: MET Tools Test Account * #2830 Changed enum PadSize to enum class * #2830 Removed redundant parantheses * #2830 Removed commenyted out code * #2830 Use auto * #2830 Changed enum to enum class for DistType, InterpMthd, GridTemplates, and NormalizeType * #2830 Moved enum_class_as_integer from header file to cc files * #2830 Added enum_as_int.hpp * #2830 Added enum_as_int.hpp * Deleted enum_class_as_integer and renamed it to enum_class_as_int * Removed redundant paranthese * #2830 Changed enum to enumclass * #2830 Changed enum_class_as_integer to enum_class_as_int * Feature #2379 sonarqube gha (#2847) * Per #2379, testing initial GHA SonarQube setup. * Per #2379, switch to only analyzing the src directory. * Per #2379, move more config logic from sonar-project.properties into the workflow. #ci-skip-all * Per #2379, try removing + symbols * Per #2379, move projectKey into xml workflow and remove sonar-project.properties. * Per #2379, try following the instructions at https://github.com/sonarsource-cfamily-examples/linux-autotools-gh-actions-sq/blob/main/.github/workflows/build.yml ci-skip-all * Per #2379, see details of progress described in this issue comment: https://github.com/dtcenter/MET/issues/2379#issuecomment-2000242425 * Unrelated to #2379, just removing spurious space that gets flagged as a diff when re-running enum_to_string on seneca. * Per #2379, try running SonarQube through GitHub. * Per #2379, remove empty env section and also disable the testing workflow temporarily during sonarqube development. * Per #2379, fix docker image name. * Per #2379, delete unneeded script. * Per #2379, update GHA to scan Python code and push to the correct SonarQube projects. * Per #2379, update GHA SonarQube project names * Per #2379, update the build job name * Per #2379, update the comile step name * Per #2379, switch to consistent SONAR variable names. * Per #2379, fix type in sed expressions. * Per #2379, just rename the log artifact * Per #2379, use time_command wrapper instead of run_command. * Per #2379, fix bad env var name * Per #2379, switch from egrep to grep. * Per #2379, just try cat-ting the logfile * Per #2379, test whether cat-ting the log file actually works. * Per #2379, revert back * Per #2379, mention SonarQube in the PR template. Make workflow name more succinct. * Per #2379, add SONAR_REFERENCE_BRANCH setting to define the sonar.newCode.referenceBranch property. The goal is to define the comparison reference branch for each SonarQube scan. * Per #2379, have the sonarqube.yml job print the reference branch it's using * Per #2379, intentionally introduce a new code smell to see if SonarQube correctly flag it as appearing in new code. * Per #2379, trying adding the SonarQube quality gate check. * Per #2379, add logic for using the report-task.txt output files to check the quality gate status for both the python and cxx scans. * Per #2379 must use unique GHA id's * Per #2379, working on syntax for quality gate checks * Per #2379, try again. * Per #2379, try again * Per #2379, try again * Per #2379, try again * Per #2379, try again * Per #2379, try again * Per #2379, try yet again * Per #2379 * Per #2379, add more debug * Per #2379, remove -it option from docker run commands * Per #2379, again * Per #2379, now that the scan works as expected, remove the intentional SonarQube code smell as well as debug logging. * Hotfix related to #2379. The sonar.newCode.referenceBranch and sonar.branch.name cannot be set to the same string! Only add the newCode definition when they differ. * #2830 Changed enum STATJobType to enum class * #2830 Changed STATLineType to enum class * #2830 Changed Action to enum class * #2830 Changed ModeDataType to enum class * #2830 Changed StepCase to enum class * #2830 Changed enum to enum class * #2830 Changed GenesisPairCategory to enum class * #2830 Removed rediundabt parenrthese * #2830 Reduced same if checking * #2830 Cleanup * #2830 USe empty() instead of lebgth checking * #2830 Adjusted indentations * Feature #2379 develop sonarqube updates (#2850) * Per #2379, move rgb2ctable.py into the python utility scripts directory for better organization and to enable convenient SonarQube scanning. * Per #2379, remove point.py from the vx_python3_utils directory which cleary was inadvertenlty added during development 4 years ago. As far as I can tell it isn't being called by any other code and doesn't belong in the repository. Note that scripts/python/met/point.py has the same name but is entirely different. * Per #2379, update the GHA SonarQube scan to do a single one with Python and C++ combined. The nightly build script is still doing 2 separate scans for now. If this all works well, they could also be combined into a single one. * Per #2379, eliminate MET_CONFIG_OPTIONS from the SonarQube workflow since it doesn't need to be and probably shouldn't be configurable. * Per #2379, trying to copy report-task.txt out of the image * Per #2379, update build_met_sonarqube.sh to check the scan return status * Per #2379, fix bash assignment syntax * Per #2379, remove unused SCRIPT_DIR envvar * Per #2379, switch to a single SonarQube scan for MET's nightly build as well * Feature 2654 ascii2nc polar buoy support (#2846) * Added iabp data type, and modified file_handler to filter based on time range, which was added as a command line option * handle time using input year, hour, min, and doy * cleanup and switch to position day of year for time computations * Added an ascii2nc unit test for iabp data * Added utility scripts to pull iabp data from the web and find files in a time range * Modified iabp_handler to always output a placeholder 'location' observation with value 1 * added description of IABP data python utility scripts * Fixed syntax error * Fixed Another syntax error. * Slight reformat of documentation * Per #2654, update the Makefiles in scripts/python/utility to include all the python scripts that should be installed. * Per #2654, remove unused code from get_iabp_from_web.py that is getting flagged as a bug by SonarQube. * Per #2654, fix typo in docs --------- Co-authored-by: John Halley Gotway Co-authored-by: MET Tools Test Account * Feature #2786 rpss_from_prob (#2861) * Per #2786, small change to a an error message unrelated to this development. * Per #2786, add RPSInfo::set_climo_prob() function to derive the RPS line type from climatology probability bins. And update Ensemble-Stat to call it. * Per #2786, minor change to clarify error log message. * Per #2786, for is_prob = TRUE input, the RPS line type is the only output option. Still need to update docs! * Per #2786, add new call to Ensemble-Stat to test computing RPS from climo probabilities * Per #2786, use name rps_climo_bin_prob to be very explicit. * Per #2786, redefine logic of RPSInfo::set_climo_bin_prob() to match the CPC definition. Note that reliability, resolution, uncertainty, and RPSS based on the sample climatology are all set to bad data. Need to investigate whether they can be computed using these inputs. * Per #2786, remove the requirement that any fcst.prob_cat_thresh thresholds must be defined. If they are defined, pass them through to the FCST_THRESH output column. If not, write NA. Add check to make sure the event occurs in exactly 1 category. * Per #2786, don't enforce fcst.prob_cat_thresh == obs.prob_cat_thresh for probabilistic inputs. And add more is_prob checks so that only the RPS line type can be written when given probabilistic inputs. * updated documentation * Per #2786, call rescale_probability() function to convert from 0-100 probs to 0-1 probs. --------- Co-authored-by: j-opatz * Feature #2862 v12.0.0-beta4 (#2864) * Feature #2379 develop single_sq_project (#2865) * Hotfix to the documentation in the develop branch. Issue #2858 was closed as a duplicate of #2857. I had included it in the MET-12.0.0-beta4 release notes, but the work is not yet actually complete. * Feature 2842 ugrid config (#2852) * #2842 Removed UGrid related setting * #2842 Corrected vertical level for data_plane_array * #2842 Do not allow the time range * #2842 The UGridConfig file can be passed as ugrid_dataset * #2842 Changed -config option to -ugrid_config * #2842 Deleted UGrid configurations * 2842 Fix a compile error when UGrid is disabled * #2842 Cleanup * #2842 Added an unittest point_stat_ugrid_mpas_config * #2842 Added a PointStatConfig without UGrid dataset. * #2842 Corrected ty[po at the variable name * Switched from time_centered to time_instant. I think time_centered is the center of the forecast lead window and time_instant is the time the forecast is valid (end of forecast window). * #2842 Removed ugrid_max_distance_km and unused metadata names * #2842 Restored time variable time_instant for LFric * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjusted lon to between -180 to 180 * #2842 Changed variable names * Per #2842, switch from degrees east to west right when the longitudes are read. * #2842, switch from degrees east to west right when the longitudes are read * #2842 Cleanup debug messages --------- Co-authored-by: Howard Soh Co-authored-by: Daniel Adriaansen Co-authored-by: John Halley Gotway * Feature 2753 comp script config (#2868) * set dynamic library file extension to .dylib if running on MacOS and .so otherwise * Added disabling of jasper documentation for compiliation on Hera * Updated * remove extra export of compiler env vars * include full path to log file so it is easier to file the log file to examine when a command fails * send cmake output to a log file * remove redundant semi-colon * use full path to log file so it is easier to examine on failure * use run_cmd to catch if rm command fails * Modifications for compilation on hera, gaea, and orion * Updating * fixed variable name * clean up if/else statements * set TIFF_LIBRARY_RELEASE argument to use full path to dynamic library file to prevent failure installing proj library * set LDFLAGS so that LDFLAGS value set in the user's environment will also be used * Updated based on gaea, orion, and hera installs * Updated * change extension of dynamic library files only if architecture is arm64 because older Macs still use .so * added netcdf library to args to prevent error installing NetCDF-CXX when PROJ has been installed in the same run of the script -- PATH is set in the COMPILE_PROJ if block that causes this flag from being added automatically * clean up how rpath and -L are added to LDFLAGS so that each entry is separate -- prevents errors installing on Mac arm64 because multiple rpath values aren't read using :. Also use MET_PROJLIB * Updated * removed -ltiff from MET libs * only add path to rpath and -L arguments if they are not already included in LDFLAGS * changed from using LIB_TIFF (full path to tiff lib file) to use TIFF_LIB_DIR (dir containing tiff lib file). Added TIFF_INCLUDE_DIR to proj compilation and -DJAS_ENABLE_DOC to jasper compliation taken from @jprestop branch * update comments * ensure all MET_* and MET_*LIB variables are added to the rpath for consistency * remove unnecessary if block and only export LDFLAGS at the end of setting locally * Updated * Added section for adding /lib64 and rearranged placement of ADDTL_DIR * Commenting out the running of the Jasper lib tests * Updating and/or removing files * Updating and/or removing files * Latest udpates which include the addition of the tiff library for proj * Remove commented out line. Co-authored-by: John Halley Gotway * Make indentation consistent. Co-authored-by: John Halley Gotway * Make indentation consistent. Co-authored-by: John Halley Gotway * Make indentation consistent. Co-authored-by: John Halley Gotway * Per 2753, added -lm to configure_lib_args for NetCDF-CXX * Per #2753 updating acorn files * Per #2753, update wcoss2 files * Per #2753, updating acorn file to include MET_PYTHON_EXE * Per #2753, updated files for 12.0.0 for derecho * Per #2753, updated derecho file adding MET_PYTHON_EXE and made corrections * Updating config files * Updating orion files * Updates for gaea's files * Updating gaea modulefile * Removing modulefile for cheyenne * Added MET_PYTHON_EXE * Added MET_PYTHON_EXE to hera too * Adding file for hercules * Removing equals sign from setenv * Adding file for hercules * Updated script to add libjpeg installation for grib2c * Per #2753, Adding file for casper --------- Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> Co-authored-by: John Halley Gotway * Feature #2795 level_mismatch_warning (#2873) * Per #2795, move the warning message about level mismatch from the config validation step to when the forecast files are being processed. Only check this when the number of forecast fields is greater than 1, but no longer limit the check to pressure levels only. * Per #2795, add comments * Whitespace * Per #2795, port level mismatch fix over to Ensemble-Stat. Check it for each verification task, but only print it once for each task, rather than once for each task * ensemble member. * Feature #2870 removing_MISSING_warning (#2872) * Per #2870, define utility functions for parsing the file type from a file list and for logging missing files, checking for the MISSING keyword. Also, update Ensemble-Stat and Gen-Ens-Prod to call these functions. * Per #2870, update the gen_ens_prod tests to demonstrate the use of the MISSING keyword for missing files. METplus uses this keyword for Ensemble-Stat and Gen-Ens-Prod. * Feature 2842 ugrid config (#2875) * #2842 Removed UGrid related setting * #2842 Corrected vertical level for data_plane_array * #2842 Do not allow the time range * #2842 The UGridConfig file can be passed as ugrid_dataset * #2842 Changed -config option to -ugrid_config * #2842 Deleted UGrid configurations * 2842 Fix a compile error when UGrid is disabled * #2842 Cleanup * #2842 Added an unittest point_stat_ugrid_mpas_config * #2842 Added a PointStatConfig without UGrid dataset. * #2842 Corrected ty[po at the variable name * Switched from time_centered to time_instant. I think time_centered is the center of the forecast lead window and time_instant is the time the forecast is valid (end of forecast window). * #2842 Removed ugrid_max_distance_km and unused metadata names * #2842 Restored time variable time_instant for LFric * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjust lon between -180 and 180 * #2842 Adjusted lon to between -180 to 180 * #2842 Changed variable names * Per #2842, switch from degrees east to west right when the longitudes are read. * #2842, switch from degrees east to west right when the longitudes are read * #2842 Cleanup debug messages * #2842 Disabled output types except STAT for sl1l2 * #2842 Disabled output types except STAT for sl1l2 and MPR * #2842 Reduced output files for UGrid --------- Co-authored-by: Howard Soh Co-authored-by: Daniel Adriaansen Co-authored-by: John Halley Gotway * Hotfix to develop branch to remove duplicate test named 'point_stat_ugrid_mpas_config'. That was causing unit_ugrid.xml to fail because it was still looking for .txt output files that are no longer being generated. * Feature 2748 document ugrid (#2869) * Initial documentation of the UGRID capability. * Fixes error in references, adds appendix to index, and adds sub-section for configuration entries and a table for metadata map items. * Corrects LFRic, rewords section on UGRID conventions, updates description of using GridStat, and removes mention of nodes. * Forgot one more mention of UGRID conventions. * Incorporates more suggestions from @willmayfield. * Switches to numerical table reference. * Feature #2781 Convert MET NetCDF point obs to Pandas DataFrame (#2877) * Per #2781, added function to convert MET NetCDF point observation data to pandas so it can be read and modified in a python embedding script. Added example python embedding script * ignore python cache files * fixed function call * reduce cognitive complexity to satisfy SonarQube and add boolean return value to catch if function fails to read data * clean up script and add comments * replace call to object function that doesn't exist, handle exception when file passed to script cannot be read by the NetCDF library * rename example script * add new example script to makefiles * fix logic to build pandas DataFrame to properly get header information from observation header IDs * Per #2781, add unit test to demonstrate python embedding script that reads MET NetCDF point observation file and converts it to a pandas DataFrame * Per #2781, added init function for nc_point_obs to take an input filename. Also raise TypeError exception from nc_point_obs.read_data() if input file cannot be read * call parent class init function to properly initialize nc_point_obs * Feature #2833 pcp_combine_missing (#2886) * Per #2883, add -input_thresh command line option to configure allowable missing input files. * Per #2883, update pcp_combine usage statement. * Per #2883, update existing pcp_combine -derive unit test example by adding 3 new missing file inputs at the beginning, middle, and end of the file list. The first two are ignored since they include the MISSING keyword, but the third without that keyword triggers a warning message as desired. The -input_thresh option is added to only require 70% of the input files be present. This should produce the exact same output data. * Per #2883, update the pcp_combine logic for the sum command to allow missing data files based on the -input_thresh threshold. Add a test in unit_pcp_combine.xml to demonstrate. * Update docs/Users_Guide/reformat_grid.rst Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> * Per #2883, update pcp_combine usage statement in the code to be more simliar to the User's Guide. * Per #2883, switch to using derive_file_list_missing as the one containing missing files and recreate derive_file_list as it had existed for the test named pcp_combine_derive_VLD_THRESH. * Per #2883, move initialization inside the same loop to resolve SonarQube issues. * Per #2883, update sum_data_files() to switch from allocating memory to using STL vectors to satisfy SonarQube. * Per #2883, changes to declarations of variables to satisfy SonarQube. * Per #2883, address more SonarQube issues * Per #2883, backing out an unintended change I made to tcrmw_grid.cc. This change belongs on a different branch. * Per #2883, update logic of parse_file_list_type() function to handle python input strings. Also update pcp_combine to parse the type of input files being read and log non-missing python input files expected. --------- Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> * Per #2888, update STATAnalysisJob::dump_stat_line() to support dumping stat line types VCNT, RPS, DMAP, and SSIDX. (#2891) * Per #2659, making updates as proposed at the 20240516 MET Eng. Mtg. (#2895) * Feature #2395 TOTAL_DIR (#2892) * Per #2395, remove the n_dir_undef and n_dira_undef variables that are superceded by the new dcount and dacount VL1L2Info members to keep track of the number of valid wind direction vectors. * Per #2395, add TOTAL_DIR columns to the VL1L2, VAL1L2, and VCNT line types and update the header column tables. * Per #2395, update the User's Guide to list the new TOTAL_DIR columns in the VL1L2, VAL1L2, and VCNT line types. * Per #2395, update stat_analysis to parse the new TOTAL_DIR columns and use the values to aggregate results when needed. * Per #2395, for SonarQube change 'const char *' to 'const char * const' to satisfy the finding that 'Global variables should be const.' Should probably switch from 'char char *' to strings eventually. But for now, I'm just making up for some SonarQube technical debt. * Per #2395, fix typo in placement of the DIR_ME column name in the met_header_columns_V12.0.txt file * Per #2395, add 2 new Stat-Analysis jobs to demonstrate the processing of VL1L2 lines. * Per #2395, update logic of is_vector_dir_stat(). Instead of just checking 'DIR_', check 'DIR_ME', 'DIR_MAE', and 'DIR_MSE' to avoid an false positive match for the 'DIR_ERR' column which is computed from the vector partial sums rather than the individual direction differences. * Bugfix #2897 develop python_valid_time (#2899) * Per #2897, fix typos in 2 log messages. Also fix the bug in storing the valid time strings. The time string in vld_array should exactly correspond to the numeric unixtime values in vld_num_array. Therefore they need to be updated inside the same if block. The bug is that we were storing only the unique unixtime values but storing ALL of the valid time string, not just the unique ones. * Per #2897, minor change to formatting of log message * MET #2897, don’t waste time searching, just set the index to n - 1 * Per #2897, remove unused add_prec_point_obs(...) function * Per #2897, update add_point_obs(...) logic for DEBUG(9) to print very detailed log messages about what obs are being rejected and which are being used for each verification task. * Per #2897, refine the 'using' log message to make the wording consistent with the summary rejection reason counts log message * Per #2897, update the User's Guide about -v 9 for Point-Stat --------- Co-authored-by: j-opatz Co-authored-by: MET Tools Test Account * Bugfix 2867 point2grid qc flag (#2890) * #2867 Added compute_adp_qc_flag and adjusted ADP QC flags * #2867 Added point2grid_GOES_16_ADP_Enterprise_high. Changed AOD QC flags to 0,1,2 (was 1,2,3) * #2867 Added get_nc_att_values_ * #2867 Added get_nc_att_values. Added the argument allow_conversion to get_nc_data(netCDF::NcVar *, uchar *data) * #2867 Read the ADP QC flag values and meanings attributes from DQF variable and set the QC high, meduium, low values to support Enterprise algorithm. Adjusted the ADP QC values by using AOD qc values * #2867 Cleanup * #2867 Corrected indent * #2867 Changed log message * #2867 Removed unused argument * #2867 Removed unused argument * Cleanup * #2867 Fix SonarQube findings * #2867 Deleted protected section with no members * #2867 Cleanup * #2867 FIxed SonarQube findings; unused local variables, decalare as const, etc * #2867 MOved include directives to top * #2867 Changed some argumenmt with references to avoid copying objects * #2867 Do not filter by QC flag if -qc is not given * #2867 Use enumj class for GOES QC: HIGH, MEDIUM, and LOW * #2867 Added log message back which were deleted accidently * #2867 Chaned statci const to constexpr * #2867 Initial release. Separated from nc_utils.h * @2867 Added nc_utils_core.h * #2867 Moved some blocks to nc_utils_core.h * #2867 Include nc_utils_core.h * #2867 Added const references * Per #2867, fixing typo in comments. --------- Co-authored-by: Howard Soh Co-authored-by: j-opatz * Hotfix to develop to fix the update_truth.yml workflow logic. This testing workflow run failed (https://github.com/dtcenter/MET/actions/runs/9209471209). Here we switch to a unique update truth branch name to avoid conflicts. * Avoid pushing directly to the develop or main_vX.Y branches since that is not necessary for the automation logic in MET. * #2904 Changed R path to R-4.4.0 (#2905) Co-authored-by: Howard Soh * Feature #2912 pb2nc error (#2914) * Feature 2717 convert unit.pl to unit.py (#2871) * created unit.py module in new internal/test_unit/python directory * added xml parsing to unit.py * added repl_env function * added reading of the remaining xml tags in build_tests function * progress on main function (putting together test commands) * a few more lines in the main function * minor updates * fixed how the test command was being run * added if name/main and command line parsing * fixed handling of no 'env' in cmd_only mode * handle params from xml that have \ after filename without space in between * added logging * added some more pieces to unit * more updates to unit.py, including running checks on output files * bug fixes, improved handling of output file names, improved handling of env vars, improved logging output * fixed how shell commands are run, and other minor fixes * added last bits from the perl script, fixed some bugs * created unit.py module in new internal/test_unit/python directory * added xml parsing to unit.py * added repl_env function * added reading of the remaining xml tags in build_tests function * progress on main function (putting together test commands) * a few more lines in the main function * minor updates * update scripts to call python unit test script instead of the old perl script * fix she-bang line to allow script to be run without python3 before it * add missing test_dir and exit_on_fail tags that are found in the rest of the unit test xml files * fix call to logger.warning * change tags named 'exists' to 'exist' to match the rest of the xml files * added logger to function * removed tab at end of line that was causing output file path to be excluded from the command * fix broken checks for output files * incorporated george's recommended changes * changed default to overwrite logs; allow for more than one xml file to be passed in command --------- Co-authored-by: Natalie babij Co-authored-by: Natalie babij Co-authored-by: Natalie babij Co-authored-by: Natalie Babij Co-authored-by: John Halley Gotway Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> Co-authored-by: j-opatz * Bugfix 2867 point2grid qc unittest (#2913) * #2867 Added compute_adp_qc_flag and adjusted ADP QC flags * #2867 Added point2grid_GOES_16_ADP_Enterprise_high. Changed AOD QC flags to 0,1,2 (was 1,2,3) * #2867 Added get_nc_att_values_ * #2867 Added get_nc_att_values. Added the argument allow_conversion to get_nc_data(netCDF::NcVar *, uchar *data) * #2867 Read the ADP QC flag values and meanings attributes from DQF variable and set the QC high, meduium, low values to support Enterprise algorithm. Adjusted the ADP QC values by using AOD qc values * #2867 Cleanup * #2867 Corrected indent * #2867 Changed log message * #2867 Removed unused argument * #2867 Removed unused argument * Cleanup * #2867 Fix SonarQube findings * #2867 Deleted protected section with no members * #2867 Cleanup * #2867 FIxed SonarQube findings; unused local variables, decalare as const, etc * #2867 MOved include directives to top * #2867 Changed some argumenmt with references to avoid copying objects * #2867 Do not filter by QC flag if -qc is not given * #2867 Use enumj class for GOES QC: HIGH, MEDIUM, and LOW * #2867 Added log message back which were deleted accidently * #2867 Chaned statci const to constexpr * #2867 Initial release. Separated from nc_utils.h * @2867 Added nc_utils_core.h * #2867 Moved some blocks to nc_utils_core.h * #2867 Include nc_utils_core.h * #2867 Added const references * #2867 Some 'static const' were chnaged to constexpr * #2867 Changed -qc options (1,2,3 to 0,1 - high & medium) for AOD * #2867 Merged develop branch * #2867 Corrected the unit test name --------- Co-authored-by: Howard Soh * Feature #2911 tc_stat_set_hdr (#2916) * Per #2911, no real changes for Stat-Analysis. Just changing order of variables for consistency. * Per #2911, add StatHdrColumns::apply_set_hdr_opts(...) function to be used by TC-Stat. * Per #2911, move ByColumn to the TCStatJob base class and add HdrName and HdrValue to support the -set_hdr job command. * Per #2911, update GSI tools to call the newly added StatHdrColumns::apply_set_hdr_opts(...) function. * Per #2911, update logic of Stat-Analysis for consistency to make use of common apply_set_hdr_opts() function. * Per #2911, add DataLine::set_item() function to support -set_hdr options. * Per #2911, just update contents of error message * Per #2911, add TCStatLine member functions for has() and get_offset(). * Per #2911, update tc_stat to support applying -set_hdr to TC-Stat filter jobs. * Per #2911, revise TC-Stat config files to exercise the -set_hdr job command option * Per #2911, update TC-Stat documentation to mention the -set_hdr job command option * Per #2911, add note * Per #2911, as recommended by SonarQube, make some of these member functions const. * Bugfix #2856 develop ens_climo (#2918) * Per #2856, port over fixes from main_v11.1 to develop. * Per #2856, correct conditionals in set_job_controls.sh and tweak existing Ensemble-Stat configuration file to exercise the logic that's being impacted here. * Bugfix #2841 develop tang_rad_winds (#2921) * Per #2841, port over fixes from bugfix_2841_main_v11.1_tang_rad_winds for the develop branch * Per #2841, clarify in the docs that azimuths are defined in degrees counter-clockwise from due east. * Per #2841, just updating with output from enum_to_string. * Per #2841, tweak the documentation. * Per #2841, correct the location of using namespace lines. * Per #2841, update compute_tc_diag.py to no longer skip writing the radial and tangential wind diagnostics. * Per #2841, update compute_tc_diag.py to no longer skip writing radial and tangential wind diagnostics. * Revert "Per #2841, update compute_tc_diag.py to no longer skip writing radial and tangential wind diagnostics." This reverts commit f097345bedcfcca663e8fb4322eed5b5e00e19fd. * Revert "Per #2841, update compute_tc_diag.py to no longer skip writing the radial and tangential wind diagnostics." This reverts commit c0402151b038c59efab99c060cc5c390edf002f6. * Per #2841, update comp_dir.sh logic to include .dat in the files that are diffed * Replace tab with spaces * Per #2841, correct the units for the azimuth netcdf output variable * Per #2841, reverse the x dimension of the rotated latlon grid to effectively switch from counterclockwise rotation to clockwise. --------- Co-authored-by: MET Tools Test Account * Feature #2601 seeps climo config (#2927) * #2601 Added seeps_grid_climo_name and seeps_point_climo_name * #2601 Added seeps_grid_climo_name * #2601 Removed SEEPS settings * #2601 Initial release * #2601 Changed to set the SEEPS climo by using the configuration * #2601 Removed SEESP settings at PointStatConfig_APCP and use PointStatConfig_SEEPS for SEEPSm testing * #2601 Updated descryption for seeps_grid_climo_name * #2601 Added a argument for the SEEPS clomo file * #2601 Added conf_key_seeps_grid_climo_name and conf_key_seeps_point_climo_name * #2601 Support the climo filename from the configuration * #2601 Corrected key for climo name * Removing duplicate word --------- Co-authored-by: Howard Soh Co-authored-by: Julie Prestopnik * Feature 2673 sonarqube beta5 redundant parentheses (#2930) * #2673 Removed redundant_parentheses * #2673 Removed redundant_parentheses * #2673 Removed redundant parentheses * #2673 Removed redundant parentheses --------- Co-authored-by: Howard Soh * Fix release checksum action (#2929) * Feature 2857 tripolar coordinates (#2928) * #2857 Added MetNcCFDataFile::build_grid_from_lat_lon_vars * #2857 Added NcCfFile::build_grid_from_lat_lon_vars * #2857 Check the coordinates attribute to find latitude, longitude, and time variables * #2857 Get the lat/lon variables from coordinates attribute if exists * #2857 Added two constants * #2857 Deleted debug messages * #2857 Added lat_vname and lon_vname for var_name_map * #2857 Added two unit tests: point2grid_sea_ice_tripolar and point2grid_sea_ice_tripolar_config * #2857 Initial release * #2857 Correct dictinary to get file_type * #2857 DO not check the time variable for point2grid * #2857 Added point2grid_tripolar_rtofs --------- Co-authored-by: Howard Soh * Feature 2932 v12.0.0-beta5 (#2933) * Per #2932, updating version and release notes * Per #2932, updating date on release notes * Per #2932, fixed formatting and links * Update release-notes.rst * Update release-notes.rst Removing inline backticks since they do not format the way I expected, especially when put inside bolded release notes. --------- Co-authored-by: John Halley Gotway * Feature fix release notes (#2934) * Fixing up release notes * Update release-notes.rst --------- Co-authored-by: John Halley Gotway * Per dtcenter/METplus#2643 discussion, add more detail about the budget interpolation method. * Feature #2924 fcst climo, PR 1 of 2 (#2939) * Per #2924, Update the MPR and ORANK output line types to just write duplicate existing climo values, update the header tables and MPR/ORANK documentation tables. * Per #2924, update get_n_orank_columns() logic * Per #2924, update the Stat-Analysis parsing logic to parse the new MPR and ORANK climatology columns. * Per #2924, making some changes to the vx_statistics library to store climo data... but more work to come. Committing this first set of changes that are incomplete but do compile. * Per #2924, this big set of changes does compile but make test produces a segfault for ensemble-stat * Per #2924, fix return value for is_keeper_obs() * Per #2924, move fcst_info/obs_info into the VxPairBase pointer. * Per #2924, update Ensemble-Stat to set the VxPairBase::fcst_info pointer * Per #2924 udpate handling of fcst_info and obs_info pointers in Ensemble-Stat * Per #2924, update the GSI tools to handle the new fcst climo columns. * Per #2924, add backward compatibility logic so that when old climo column names are requested, the new ones are used. * Per #2924, print a DEBUG(2) log message if old column names are used. * Per #2924, switch the unit tests to reference the updated MPR column names rather than the old ones. * Per #2924, working progress. Not fully compiling yet * Per #2924, another round of changes. Removing MPR:FCST_CLIMO_CDF output column. This compiles but not sure if it actually runs yet * Per #2924, work in progress * Per #2924, work in progress. Almost compiling again. * Per #2924, get it compiling * Per #2924, add back in support for SCP and CDP which are interpreted as SOCP and OCDP, resp * Per #2924, update docs about SCP and CDP threshold types * Per #2924, minor whitespace changes * Per #2924, fix an uninitialized pointer bug by defining/calling SeepsClimoGrid::init_from_scratch() member function. The constructor had been calling clear() to delete pointers that weren't properly initialized to nullptr. Also, simplify some map processing logic. * Per #2924, rename SeepsAggScore from seeps to seeps_agg for clarity and to avoid conflicts in member function implementations. * Per #2924, fix seeps compilation error in Point-Stat * Per #2924, fix bug in the boolean logic for handling the do_climo_cdp NetCDF output option. * Per #2924, add missing exit statement. * Per #2924, tweak threshold.h * Per #2924, define one perc_thresh_info entry for each enumerated PercThreshType value * Per #2924, simplify the logic for handling percentile threshold types and print a log message once when the old versions are still used. * Per #2924, update the string comparison return value logic * Per #2924, fix the perc thresh string parsing logic by calling ConcatString::startswith() * Per #2924, switch all instances of CDP to OCDP. Gen-Ens-Prod was writing NetCDF files with OCDP in the output variable names, but Grid-Stat was requesting that the wrong variable name be read. So the unit tests failed. * Per #2924, add more doc details * Per #2924, update default config file to indicate when climo_mean and climo_stdev can be set seperately in the fcst and obs dictionaries. * Per #2924, update the MET tools to parse climo_mean and climo_stdev separately from the fcst and obs dictionaries. * Per #2924, backing out new/modified columns to minimize reg test diffs * Per #2924, one more section to be commented out later. * Per #2924, replace several calls to strncmp() with ConcatString::startswith() to simplify the code * Per #2924, strip out some more references to OBS_CLIMO_... in the unit tests. * Per #2924, delete accidental file * Per #2924 fix broken XML comments * Per #2924, fix comments * Per #2924, address SonarQube findings * Per #2924, tweak a Point-Stat and Grid-Stat unit test config file to make the output more comparable to develop. * Per #2924, fix bug in the logic of PairDataPoint and PairDataEnsemble, when looping over the 3-dim array do not return when checking the climo and fcst values. Instead we need to continue to the next loop iteration. * Per #2924, address more SonarQube code smells to reduce the overall number in MET for this PR. * Per #2924, correct the logic for parsing climo data from MPR lines. * Per #2924, cleanup grid_stat.cc source code by making calls to DataPlane::is_empty() and Grid::nxy(). * Per #2924, remove unneeded ==0 * Hotfix to the develop branch for a copy/paste bug introduced by PR #2939 * Feature #2924 sal1l2_mae, PR 3 of 3 (#2943) * Per #2924, track SL1L2 and SAL1L2 MAE scores with separate variables since they are no longer the same value. I renamed the existing 'mae' as 'smae' and added a new 'samae' variable. Renaming the existing lets me use the compiler help find all references to it throughout the code. * Per #2924, update the User's Guide climatology details and equations. * Per #2924, some changes to aggr_stat_line.cc and series_analysis.cc to satisfy some SonarQube code smells. * Update develop to clarify masking poly options based on METplus Discussion dtcenter/METplus#2650 * Remove two semi-colons that are not actually necessary to avoid confusion. * Per dtcenter/METplus#2653 discussion, update the MTD usage statement to clarify that data specified in the fcst dictionary is read from the -single input files. * Feature #2924 fcst climo, PR 2 of 3 (#2942) * Per #2924, Update the MPR and ORANK output line types to just write duplicate existing climo values, update the header tables and MPR/ORANK documentation tables. * Per #2924, update get_n_orank_columns() logic * Per #2924, update the Stat-Analysis parsing logic to parse the new MPR and ORANK climatology columns. * Per #2924, making some changes to the vx_statistics library to store climo data... but more work to come. Committing this first set of changes that are incomplete but do compile. * Per #2924, this big set of changes does compile but make test produces a segfault for ensemble-stat * Per #2924, fix return value for is_keeper_obs() * Per #2924, move fcst_info/obs_info into the VxPairBase pointer. * Per #2924, update Ensemble-Stat to set the VxPairBase::fcst_info pointer * Per #2924 udpate handling of fcst_info and obs_info pointers in Ensemble-Stat * Per #2924, update the GSI tools to handle the new fcst climo columns. * Per #2924, add backward compatibility logic so that when old climo column names are requested, the new ones are used. * Per #2924, print a DEBUG(2) log message if old column names are used. * Per #2924, switch the unit tests to reference the updated MPR column names rather than the old ones. * Per #2924, working progress. Not fully compiling yet * Per #2924, another round of changes. Removing MPR:FCST_CLIMO_CDF output column. This compiles but not sure if it actually runs yet * Per #2924, work in progress * Per #2924, work in progress. Almost compiling again. * Per #2924, get it compiling * Per #2924, add back in support for SCP and CDP which are interpreted as SOCP and OCDP, resp * Per #2924, update docs about SCP and CDP threshold types * Per #2924, minor whitespace changes * Per #2924, fix an uninitialized pointer bug by defining/calling SeepsClimoGrid::init_from_scratch() member function. The constructor had been calling clear() to delete pointers that weren't properly initialized to nullptr. Also, simplify some map processing logic. * Per #2924, rename SeepsAggScore from seeps to seeps_agg for clarity and to avoid conflicts in member function implementations. * Per #2924, fix seeps compilation error in Point-Stat * Per #2924, fix bug in the boolean logic for handling the do_climo_cdp NetCDF output option. * Per #2924, add missing exit statement. * Per #2924, tweak threshold.h * Per #2924, define one perc_thresh_info entry for each enumerated PercThreshType value * Per #2924, simplify the logic for handling percentile threshold types and print a log message once when the old versions are still used. * Per #2924, update the string comparison return value logic * Per #2924, fix the perc thresh string parsing logic by calling ConcatString::startswith() * Per #2924, switch all instances of CDP to OCDP. Gen-Ens-Prod was writing NetCDF files with OCDP in the output variable names, but Grid-Stat was requesting that the wrong variable name be read. So the unit tests failed. * Per #2924, add more doc details * Per #2924, update default config file to indicate when climo_mean and climo_stdev can be set seperately in the fcst and obs dictionaries. * Per #2924, update the MET tools to parse climo_mean and climo_stdev separately from the fcst and obs dictionaries. * Per #2924, backing out new/modified columns to minimize reg test diffs * Per #2924, one more section to be commented out later. * Per #2924, replace several calls to strncmp() with ConcatString::startswith() to simplify the code * Per #2924, strip out some more references to OBS_CLIMO_... in the unit tests. * Per #2924, delete accidental file * Per #2924 fix broken XML comments * Per #2924, fix comments * Per #2924, address SonarQube findings * Per #2924, tweak a Point-Stat and Grid-Stat unit test config file to make the output more comparable to develop. * Per #2924, fix bug in the logic of PairDataPoint and PairDataEnsemble, when looping over the 3-dim array do not return when checking the climo and fcst values. Instead we need to continue to the next loop iteration. * Per #2924, address more SonarQube code smells to reduce the overall number in MET for this PR. * Per #2924, correct the logic for parsing climo data from MPR lines. * Per #2924, update MPR and ORANK line types to update/add FCST/OBS_CLIMO_MEAN/STDEV/CDF columns. * Per #2924, cleanup grid_stat.cc source code by making calls to DataPlane::is_empty() and Grid::nxy(). * Per #2924, remove unneeded ==0 * Per #2924, working on PR2. * Per #2924, update User's Guide with notional example of specifying climo_mean and climo_stdev separately in the fcst and obs dicts. * Per #2924, adding a new unit test. It does NOT yet run as expected. Will debug on seneca * Per #2924, pass the description string to the read_climo_data_plane*() function to provide better log messages * Per #2924, more work on consistent log messages * Per #2924, tweak the configuration to define both field, climo_mean, and climo_stdev in both the fcst and obs dictionaries * Per #2924, tweak the unit_climatology_mixed.xml test * Per #2924, only whitespace changes. * Per #2924, missed swapping MET #2924 changes in 3 test files * Per #2924, delete accidentally committed file * Per #2924, delete accidentally committed files * Per #2924, add support for GRIB1 time range indicator value of 123 used for the corresponding METplus Use Case. Note that there are 22 other TRI values not currently supported. * Adds caveat regarding longitudes appearing in DEBUG statements with a… (#2947) * Adds caveat regarding longitudes appearing in DEBUG statements with a different sign to the FAQ. * Update appendixA.rst Missing paren * Create install_met_env.cactus * Adding special script for installing beta5 on wcoss2 * Modifying script, including updates to eckit and atlas * Corrected version of bufr being used * Feature #2938 pb2nc_center_time (#2954) * Per #2938, define CRC_Array::add_uniq(...) member function which is now used in PB2NC * Per #2938, replace n_elements() with n() to make the code more concise. Refine log/warning message when multiple message center times are encountered. * Feature #1371 series_analysis (#2951) * Per #1371, add -input command line argument and add support for ALL for the CTC, MCTC, SL1L2, and PCT line types. * Per #1371, rename the -input command line option as -aggregate instead * Per #1371, work in progress * Per #1371, just comments * Per #1371, working on aggregating CTC counts * Per #1371, work in progress * Per #1371, update timing info using time stamps in the aggr file * Per #1371, close the aggregate data file * Per #1371, define set_event() and set_nonevent() member functions * Per #1371, add logic to aggregate MCTC and PCT counts * Merging changes from develop * Per #1371, work in progress aggregating all the line statistics types. Still have several issues to address * Per #1371, switch to using get_stat() functions * Per #1371, work in progress. More consolidation * Per #1371, correct expected output file name * Per #1371, consistent regridding log messages and fix the Series-Analysis PairDataPoint object handling logic. * Per #1371, check the return status when opening the aggregate file. * Per #1371, fix prc/pjc typo * Per #1371, fix the series_analysis PCT aggregation logic and add a test to unit_series_analysis.xml to demonstrate. * Per #1371, resolve a few SonarQube findings * Per #1371, make use of range-based for loop, as recommeded by SonarQube * Per #1371, update series-analysis to apply the valid data threshold properly using the old aggregate data and the new pair data. * Per #1371, update series_analysis to buffer data and write it all at once instead of storing data value by value for each point. * Per #1371, add useful error message when required aggregation variables are not present in the input -aggr file. * Per #1371, print a Debug(2) message listing the aggregation fields being read. * Per #1371, correct operator+= logic in met_stats.cc for SL1L2Info, VL1L2Info, and NBRCNTInfo. The metadata settings, like fthresh and othresh, were not being passed to the output. * Per #1371, the DataPlane for the computed statistics should be initialized to a field of bad data values rather than the default value of 0. Otherwise, 0's are reported for stats a grid points with no data when they should really be reported as bad data! * Per #1371, update logic of the compute_cntinfo() function so that CNT statistics can be derived from a single SL1L2Info object containing both scalar and scalar anomaly partial sums. These changes enable CNT:ANOM_CORR to be aggregated in the Series-Analysis tool. * Per #1371, fix logic of climo log message. * Per #1371, this is actually related to MET #2924. In compute_pctinfo() used obs climo data first, if provided. And if not, use fcst climo data. * Per #1371, fix indexing bug (+i instead of +1) when check the valid data count. Also update the logic of read_aggr_total() to return a count of 0 for bad data. * Per #1371, add logic to aggregate the PSTD BRIERCL and BSS statistics in the do_climo_brier() function. Tested manually to confirm that it works. * Per #1371, switch to using string literals to satisfy SonarQube * Per #1371, update series_analysis tests in unit_climatology_1.0deg.xml to demonstrate aggregating climo-based stats. * Per #1371, remove extra comment * Per #1371, skip writing the PCT THRESH_i columns to the Series-Analysis output since they are not used * Per #1371, fix the R string literals to remove \t and \n escape sequences. * Per #1371, update the read_aggr_data_plane() suggestion strings. * Per #1371, ignore unneeded PCT 'THRESH_' variables both when reading and writing ALL PCT columns. * Per #1371, update the test named series_analysis_AGGR_CMD_LINE to include data for the F42 lead time that had previously been included for the same run in the develop branch. Note however that the timestamps in the output file for the develop branch (2012040900_to_2012041100) were wrong and have been corrected here (2012040900_to_2012041018) to match the actual data. * Per #1371, update the -aggr note to warn users about slow runtimes * Feature 2948 cxx17 (#2953) * Per #2948, updating versions of ecbuild, eckit, and atlas * Per #2948, Adding MET_CXX_STANDARD * Per #2948, updated wording for MET_CXX_STANDARD description * Per #2948, updating script to work with two versions of ecbuild, eckit, and atlas * Per #2948, without this change, there are compilation problems if the user wants to compile wihtout python * Per #2948, fixing logic for MET_CXX_STANDARD * Per #2928, adding missing end bracket * Per #2948, fixed the logic for compiling versions of ecbuild, eckit, and atlas * Per 948, fixed syntax for setting CXXFLAGS * Per #2948, adding new Makefile.in files and configure and changing METbaseimage 3.2 to 3.3. * Per #2948, updating version of met base tag from 3.2 to 3.3 * Per #2948, adding --enable-all MET_CXX_STANDARD=11 job * Update compilation_options.yml * Per #2948, added a job10 for MET_CXX_STANDARD=14 * Per #2948, added brief documentation for the MET_CXX_STANDARD option --------- Co-authored-by: Julie Prestopnik Co-authored-by: John Halley Gotway * Feature 1729 set attr grid (#2955) * #1729 Allow to change to differnt grid size if the raw size is 0 * Added build_grid_by_grid_string and build_grid_by_grid_string * #1729 Calls build_grid_by_grid_string * #1729 Added set_attr_grid at the -field option * #1729 Set obs_type to TYPE_NCCF if the file_type is given at the config file * #1729 Support set_sttr_grid and changed Error messages to Warning * #1729 FIxed SonmarQube findings * #1729 Initial release for unit test * #1729 Added update_missing_values * #1729 Deleted a shadowed local variable * #2673 Added more is_eq * #2673 Added get_exe_duration * 2673 Reducded nested statements * 2673 Fixed SonarGube findings * 2673 Fixed SonarQube findings * 2673 Fixed SonarQube findings * #1729 Added aan unittest plot_data_plane_set_attr_grid * #1729 Added aan unittest point2grid_cice_set_attr_grid * #1729 Added changed back the verbose level * #1729 Corrected typo --------- Co-authored-by: Howard Soh * Bugfix #2958 develop BAGSS SEDI CI (#2959) * Bugfix 2936 point2grid gfs (#2964) * #2936 Support 1D lat/lon values * #2936 Initial release * #2936 Cast the data type to avoid a compile warning * #2936 Added an unittest point2grid_gfs_1D_lat_lon --------- Co-authored-by: Howard Soh * Bugfix 2968 point2grid set attr grid (#2969) * #2968 Corrected set_attr_grid for point2grid_cice_set_attr_grid * #2968 Compare the DataPlane size and the variable data size * #2968 nx and ny are not ignored with set_attr_grid * #2968 Compare the DataPlane size and the variable data size --------- Co-authored-by: Howard Soh * Feature 2937 update unit (#2944) * added single quotes around env var/val pairs in export statements in cmd only mode * updated logic in unit() to check exec return value against expected return value; created TEST xml file to test this feature * deleted TEST_ xml, added test with retval 1 to unit_ascii2nc --------- Co-authored-by: Natalie Babij * Feature #2887 categorical weights PR 1 of 2 (#2967) * Per #2887, update NumArray::vals() to return a reference to the vector rather a pointer to doubles. * Per #2887, switch over the whole ContingencyTable class heirarchy from storing integer counts to storing double-precision weights. * Add ContingencyTable::is_integer() member function to check whether the table contains all integers * Per #2887, update parse_stat_line.cc to get it to compile after changing PCT to store thresholds in a std::vector. * Per #2887, update PCTInfo::clear() logic. * Per #2887, update ctc_by_row() logic to create reproducible results with the develop branch. * Per #2887, update logic of define_prob_bins() to add a final >=1.0 threshold if needed. While ==0.1 works fine, I found that ==0.05 did not because the last >=1.0 threshold was missing likely do to floating point precision issues. This change should fix that problem. * Per #2887, update roc_auc() function to match the develop branch * Per #2887, fix bug if computation of far() * Per #2887, replaced all ==0 integer equality checks with calls to is_eq() instead and fix a couple of equations to snuff out diffs in some CTS statistics. * Per #2887, address some of the 34 SonarQube code smells flagged for this PR. Note that the compute_ci.h/.cc changes are necessary and good since we should be computing CI's using doubles instead of integer counts. * Per #2887, update run_sonarqube.sh to specify the target CXX standard as 11. The hope is that that will limit the findings to only those features available in the C++11 standard. * Per #2887, update to SonarQube version 6.1.0.4477 released on 6/27/2024. * Per #2887, updating build_met_sonarqube.sh to specify --std=c++11 since c++17 is used by default * Hotfix to develop to fix a bug introduced for MET #2887. Refine the define_prob_bins() utility function so that ==n probability thresholds result in the correct number of probability thresholds. We were adding an unncessary 10-th bin (from 1.07143 to 1.0) for the ==7 probability threshold type. * Fix typo in tc-pairs.rst * Update build_docker_and_trigger_metplus.yml The docs directory was moved up to the top-level of the repository but this workflow was not updated. Changing the ignore setting so that doc-only updates do not trigger the full METplus testing workflow. * Feature 2023 remove double quotes around keywords (#2974) * testing AREA and AUTO changes * Keywords B thru L * thru R * adding quotes back in for lower case items * S thru the end of the document * Removing double quotes around 3 key words * Per #2023, adding a label name for the Attributes section * Per #2023, adding an internal link for the MODE tool Attributes section. * Adding quotes around Valid basins entries * more double quote updates * more complex updates with Julie P help * removing double quotes * fixing typos * removing double quotes * unbolding SURFACE and putting it in double quotes * fixing grammar * grammar * fixing typo * fixing typo --------- Co-authored-by: Julie Prestopnik * Feature #2924 parse_config (#2963) * Per #2924, remove GenEnsProd config file comment about parsing desc separately from each obs.field entry because the obs dictionary does not exist in the GenEnsProd config file. * Per #2924, update list of needed config entry names * Per #2924, remove const from the parent() member function so that we can perform lookups for the parent. * Per #2924, update the signature for and logic of the utility functions that retrieve the climatology data. Rather than requiring all the climo_mean and climo_stdev dictionary entries to be defined at the same config file context level, parse each one individually. This enables the METplus wrappers to only partially override this dictionary and still rely on the default values provided in MET's default configuration files. * Per #2924, update all calls to the climatology utility functions based on the new function signature. Also update the tools to check the number of climo fields separately for the forecast and observation climos. * Per #2924, update the parsing logic for the climatology regrid dictionary. Use config.fcst.climo_mean.regrid first, config.fcst.regrid second, and config.climo_mean.regrid third. Notably, DO NOT use config.regrid. This is definitely the problem with having regrid specified at mutliple config file context levels. It makes the logic for which to use when very messy. * Per #2924, forgot to add an else to print an error * Per #2924, remove extraneous semicolon * Per #2924, move 'fcst.regrid' into 'fcst.climo_mean.regrid'. Defining the climatology regridding logic inside fcst is problematic because it applies to the forecast data as well and you end up with the verification grid being undefined. So the climo regridding logic must be defined in 'climo_mean.regrid' either within the 'fcst' and 'obs' dictionaries or at the top-level config context. * Per #2924, based on PR feedback from @georgemccabe, add the Upper_Left, Upper_Right, Lower_Right, and Lower_Left interpolation methods to the list of valid options for regridding, as already indicated in the MET User's Guide. * Per #2924, update the logic of parse_conf_regrid() to (hopefully) make it work the way @georgemccabe expects it to. It now uses pointers to both the primary and default dictionaries and parses each entry individually. * Per #2924, need to check for non-null pointer before using it * Per #2924, revise the climo_name dictionary lookup logic when parsing the regrid dictionary. * Per #2924, update logic for handling RegridInfo * Per #2924, remove the default regridding information from the 'Searching' log message to avoid confusion. --------- Co-authored-by: MET Tools Test Account * Feature #2924 parse_config PR 2 (#2975) * Per #2924, remove GenEnsProd config file comment about parsing desc separately from each obs.field entry because the obs dictionary does not exist in the GenEnsProd config file. * Per #2924, update list of needed config entry names * Per #2924, remove const from the parent() member function so that we can perform lookups for the parent. * Per #2924, update the signature for and logic of the utility functions that retrieve the climatology data. Rather than requiring all the climo_mean and climo_stdev dictionary entries to be defined at the same config file context level, parse each one individually. This enables the METplus wrappers to only partially override this dictionary and still rely on the default values provided in MET's default configuration files. * Per #2924, update all calls to the climatology utility functions based on the new function signature. Also update the tools to check the number of climo fields separately for the forecast and observation climos. * Per #2924, update the parsing logic for the climatology regrid dictionary. Use config.fcst.climo_mean.regrid first, config.fcst.regrid second, and config.climo_mean.regrid third. Notably, DO NOT use config.regrid. This is definitely the problem with having regrid specified at mutliple config file context levels. It makes the logic for which to use when very messy. * Per #2924, forgot to add an else to print an error * Per #2924, remove extraneous semicolon * Per #2924, move 'fcst.regrid' into 'fcst.climo_mean.regrid'. Defining the climatology regridding logic inside fcst is problematic because it applies to the forecast data as well and you end up with the verification grid being undefined. So the climo regridding logic must be defined in 'climo_mean.regrid' either within the 'fcst' and 'obs' dictionaries or at the top-level config context. * Per #2924, based on PR feedback from @georgemccabe, add the Upper_Left, Upper_Right, Lower_Right, and Lower_Left interpolation methods to the list of valid options for regridding, as already indicated in the MET User's Guide. * Per #2924, update the logic of parse_conf_regrid() to (hopefully) make it work the way @georgemccabe expects it to. It now uses pointers to both the primary and default dictionaries and parses each entry individually. * Per #2924, need to check for non-null pointer before using it * Per #2924, revise the climo_name dictionary lookup logic when parsing the regrid dictionary. * Per #2924, update logic for handling RegridInfo * Per #2924, remove the default regridding information from the 'Searching' log message to avoid confusion. * Per #2924, escape sequences, like \n, cannot be used inside R-string literals. * Per #2924, update the logic of check_climo_n_vx() * Per #2924, revise logic in read_climo_data_plane_array(). Check the number of climo fields provided. If there's 0, just return since no data has been requested. If there's 1, use it regardless of the number of input fields. If there's more than 1, just use the requested i_vx index value. * Per #2924, update Series-Analysis to set both i_fcst and i_obs when looping over the series entries. * Per #2924, no real change. Just whitespace. * Unrelated to #2924, superficial changes to formatting of method_name strings for consistency. * Per #2924, add a new series_analysis test that ERRORS OUT prior to this PR but works after the changes in this PR. --------- Co-authored-by: MET Tools Test Account * Feature 2949 cxx11 doc (#2973) * Per #2949, updating installation instructions * Per #2949, adding missing colon from note directive * Per #2949, third attempt to get the new note to show up * Per #2949, modifying text and format * Per #2949, removing images in favor of code blocks for easier modification * Per #2949, modified wording for clarity * Per #2929, corrected typo * Update installation.rst No changes to content, only whitespace for consistency, mostly removing tabs. * Update docs/Users_Guide/installation.rst Co-authored-by: John Halley Gotway * Per #2949, testing variable replacement, expect failures * Per #2949, reverting to orignal state after testing --------- Co-authored-by: John Halley Gotway * Bugfix #2979 develop MTD Grid (#2981) * Per #2979, remove nc_grid.h/.cc and replace it with calls to the read_netcdf_grid(...) and write_netcdf_proj(...) library utility functions. Note that these changes do compile but I haven't tested whether they actually fix the underlying problem. Also note that nc_utils_local.h/.cc can also likely be replaced with calls to common library functions. * Per #2979, remove references to nc_grid.o from the MTD test code. * Per #2979, insert a newline in unit.py output between the env vars and the command. * Per #2979, insert a newline in unit.py output between the env vars and the command. * Per #2979, the write_netcdf_proj(...) utility function adds the lat and lon dimensions. Update mtd to NOT define those dimensions prior to calling write_netcdf_proj(...). * Per #2979, minor changes to is_eq() calls to fix compiler warning messages * Per #2979, for the develop branch, also replace nc_utils_local.h/.cc with calls to common library code. Also remove commented out code. * Per #2979, delete commented out code and make error/warning message formatting consistent. * Fixes for SonarQube --------- Co-authored-by: MET Tools Test Account * Feature #2880 point2grid qc (#2984) * Per #2880, remove Point2Grid quality_mark_thresh config option and add obs_quality_inc and obs_quality_exc from the config file. * Per #2880, update point2grid docs and reformat whitespace throughout. * Per #2880, remove quality_mark_thresh and add obs_quality_inc and obs_quality_exc. * Unrelated to #2880, fix formatting of this R-string which cannot include any special formatting, such as \n. * Per #2880, not working quite right yet but this is progress * Per #2880, add a write_css(IntArray) utility function. * Per #2880, update NcPointObsData class to read the obs quality values from the input file. * Per #2880, update the log message about the quality control filter options applied. * Per #2880, tweak log messages. * Per #2880, tweak log messages. * Per #2880, add a Point2Grid unit test to demonstrate using the obs_quality_inc and obs_quality_exc options. * Per #2880, declare these get accessor functions as const to avoid SonarQube code smell. * Per #2880, many changes to the vx_nc_obs library and point2grid application to replace dynamically allocated memory with STL vectors to satisfy SonarQube code smells. * Per #2880, fix compilation error. * Per #2880, fix compilation error * Per #2880, revert skip_times back to vector since I wasn't postive the casting (int *) to (bool *) would actually work in the way I expect. This is safer. * Per #2880, rename the -qc command line option as -goes_qc, but still quietly support -qc * Per #2880, based on guidance from @hsoh, reset the var_cell_mapping vector for each loop iteration. --------- Co-authored-by: Howard Soh Co-authored-by: John Halley Gotway Co-authored-by: Howard Soh Co-authored-by: MET Tools Test Account Co-authored-by: davidalbo Co-authored-by: j-opatz Co-authored-by: Daniel Adriaansen Co-authored-by: Julie Prestopnik Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com> Co-authored-by: natalieb-noaa <146213121+natalieb-noaa@users.noreply.github.com> Co-authored-by: Natalie babij Co-authored-by: Natalie babij Co-authored-by: Natalie babij Co-authored-by: Natalie Babij Co-authored-by: Julie Prestopnik Co-authored-by: lisagoodrich <33230218+lisagoodrich@users.noreply.github.com> Co-authored-by: metplus-bot <97135045+metplus-bot@users.noreply.github.com> --- data/config/Point2GridConfig_default | 11 +- docs/Users_Guide/reformat_point.rst | 431 +++++++----------- .../test_unit/config/Point2GridConfig_WINDS | 2 + .../config/Point2GridConfig_valid_time | 11 +- internal/test_unit/xml/unit_point2grid.xml | 28 +- src/basic/vx_util/crc_array.h | 1 - src/basic/vx_util/int_array.h | 8 +- src/basic/vx_util/num_array.cc | 20 + src/libcode/vx_nc_obs/met_point_data.cc | 146 +++--- src/libcode/vx_nc_obs/met_point_data.h | 18 +- src/libcode/vx_nc_obs/nc_obs_util.cc | 40 +- .../vx_pointdata_python/python_pointdata.cc | 12 +- src/libcode/vx_statistics/apply_mask.cc | 8 +- src/tools/other/point2grid/point2grid.cc | 296 ++++++------ .../other/point2grid/point2grid_conf_info.cc | 18 +- .../other/point2grid/point2grid_conf_info.h | 3 +- 16 files changed, 467 insertions(+), 586 deletions(-) create mode 100644 internal/test_unit/config/Point2GridConfig_WINDS diff --git a/data/config/Point2GridConfig_default b/data/config/Point2GridConfig_default index 8361e871c9..3b8625023d 100644 --- a/data/config/Point2GridConfig_default +++ b/data/config/Point2GridConfig_default @@ -22,11 +22,12 @@ obs_window = { //////////////////////////////////////////////////////////////////////////////// - // -// Observation message type +// Point observation filtering options // -message_type = []; +message_type = []; +obs_quality_inc = []; +obs_quality_exc = []; //////////////////////////////////////////////////////////////////////////////// @@ -72,10 +73,6 @@ var_name_map = [ //////////////////////////////////////////////////////////////////////////////// -quality_mark_thresh = 2; - -//////////////////////////////////////////////////////////////////////////////// - tmp_dir = "/tmp"; version = "V12.0.0"; diff --git a/docs/Users_Guide/reformat_point.rst b/docs/Users_Guide/reformat_point.rst index d9ad8695c1..9be547fad1 100644 --- a/docs/Users_Guide/reformat_point.rst +++ b/docs/Users_Guide/reformat_point.rst @@ -41,51 +41,39 @@ pb2nc has both required and optional arguments. Required Arguments for pb2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1. -The **prepbufr_file** argument is the input PrepBUFR file to be processed. +1. The **prepbufr_file** argument is the input PrepBUFR file to be processed. -2. -The **netcdf_file** argument is the output NetCDF file to be written. +2. The **netcdf_file** argument is the output NetCDF file to be written. -3. -The **config_file** argument is the configuration file to be used. The contents of the configuration file are discussed below. +3. The **config_file** argument is the configuration file to be used. The contents of the configuration file are discussed below. Optional Arguments for pb2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1. -The **-pbfile prepbufr_file** option is used to pass additional input PrepBUFR files. +1. The **-pbfile prepbufr_file** option is used to pass additional input PrepBUFR files. -2. -The **-valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the retention time window. +2. The **-valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the retention time window. -3. -The **-valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the retention time window. +3. The **-valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the retention time window. -4. -The **-nmsg num_messages** option may be used for testing purposes. This argument indicates that only the first "num_messages" PrepBUFR messages should be processed rather than the whole file. This option is provided to speed up testing because running the PB2NC tool can take a few minutes for each file. Most users will not need this option. +4. The **-nmsg num_messages** option may be used for testing purposes. This argument indicates that only the first "num_messages" PrepBUFR messages should be processed rather than the whole file. This option is provided to speed up testing because running the PB2NC tool can take a few minutes for each file. Most users will not need this option. -5. -The **-dump path** option may be used to dump the entire contents of the PrepBUFR file to several ASCII files written to the directory specified by "path". The user may use this option to view a human-readable version of the input PrepBUFR file, although writing the contents to ASCII files can be slow. +5. The **-dump path** option may be used to dump the entire contents of the PrepBUFR file to several ASCII files written to the directory specified by "path". The user may use this option to view a human-readable version of the input PrepBUFR file, although writing the contents to ASCII files can be slow. -6. -The **-index** option shows the available variables with valid data from the BUFR input. It collects the available variable list from BUFR input and checks the existence of valid data and directs the variable names with valid data to the screen. The NetCDF output won't be generated. +6. The **-index** option shows the available variables with valid data from the BUFR input. It collects the available variable list from BUFR input and checks the existence of valid data and directs the variable names with valid data to the screen. The NetCDF output won't be generated. -7. -The **-log** file option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. +7. The **-log** file option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. -8. -The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. +8. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. -9. -The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. +9. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. An example of the pb2nc calling sequence is shown below: .. code-block:: none - - pb2nc sample_pb.blk \ - sample_pb.nc \ - PB2NCConfig + + pb2nc sample_pb.blk \ + sample_pb.nc \ + PB2NCConfig In this example, the PB2NC tool will process the input **sample_pb.blk** file applying the configuration specified in the **PB2NCConfig** file and write the output to a file named **sample_pb.nc**. @@ -101,11 +89,11 @@ Note that environment variables may be used when editing configuration files, as ____________________ .. code-block:: none - - obs_window = { beg = -5400; end = 5400; } - mask = { grid = ""; poly = ""; } - tmp_dir = "/tmp"; - version = "VN.N"; + + obs_window = { beg = -5400; end = 5400; } + mask = { grid = ""; poly = ""; } + tmp_dir = "/tmp"; + version = "VN.N"; The configuration options listed above are common to many MET tools and are described in :numref:`config_options`. The use of temporary files in PB2NC is described in :numref:`Contributor's Guide Section %s `. @@ -113,47 +101,45 @@ The use of temporary files in PB2NC is described in :numref:`Contributor's Guide _____________________ .. code-block:: none - - message_type = []; + + message_type = []; Each PrepBUFR message is tagged with one of eighteen message types as listed in the :numref:`config_options` file. The **message_type** refers to the type of observation from which the observation value (or 'report') was derived. The user may specify a comma-separated list of message types to be retained. Providing an empty list indicates that all message types should be retained. _____________________ -.. code-block:: none +.. code-block:: none - message_type_map = [ { key = "AIRCAR"; val = "AIRCAR_PROFILES"; } ]; + message_type_map = [ { key = "AIRCAR"; val = "AIRCAR_PROFILES"; } ]; The **message_type_map** entry is an array of dictionaries, each containing a **key** string and **val** string. This defines a mapping of input PrepBUFR message types to output message types. This provides a method for renaming input PrepBUFR message types. _____________________ .. code-block:: none - - message_type_group_map = [ - { key = "SURFACE"; val = "ADPSFC,SFCSHP,MSONET"; }, - { key = "ANYAIR"; val = "AIRCAR,AIRCFT"; }, - { key = "ANYSFC"; val = "ADPSFC,SFCSHP,ADPUPA,PROFLR,MSONET"; }, - { key = "ONLYSF"; val = "ADPSFC,SFCSHP"; } - ]; + message_type_group_map = [ + { key = "SURFACE"; val = "ADPSFC,SFCSHP,MSONET"; }, + { key = "ANYAIR"; val = "AIRCAR,AIRCFT"; }, + { key = "ANYSFC"; val = "ADPSFC,SFCSHP,ADPUPA,PROFLR,MSONET"; }, + { key = "ONLYSF"; val = "ADPSFC,SFCSHP"; } + ]; The **message_type_group_map** entry is an array of dictionaries, each containing a **key** string and **val** string. This defines a mapping of message type group names to a comma-separated list of values. This map is defined in the config files for PB2NC, Point-Stat, or Ensemble-Stat. Modify this map to define sets of message types that should be processed together as a group. The **SURFACE** entry must be present to define message types for which surface verification logic should be applied. _____________________ .. code-block:: none - - station_id = []; + + station_id = []; Each PrepBUFR message has a station identification string associated with it. The user may specify a comma-separated list of station IDs to be retained. Providing an empty list indicates that messages from all station IDs will be retained. It can be a file name containing a list of stations. _____________________ .. code-block:: none - - elevation_range = { beg = -1000; end = 100000; } + elevation_range = { beg = -1000; end = 100000; } The **beg** and **end** variables are used to stratify the elevation (in meters) of the observations to be retained. The range shown above is set to -1000 to 100000 meters, which essentially retains every observation. @@ -161,11 +147,10 @@ _____________________ .. code-block:: none - pb_report_type = []; - in_report_type = []; - instrument_type = []; + pb_report_type = []; + in_report_type = []; + instrument_type = []; - The **pb_report_type, in_report_type**, and **instrument_type** variables are used to specify comma-separated lists of PrepBUFR report types, input report types, and instrument types to be retained, respectively. If left empty, all PrepBUFR report types, input report types, and instrument types will be retained. See the following for more details: `Code table for PrepBUFR report types used by Regional NAM GSI analyses. `_ @@ -175,19 +160,16 @@ The **pb_report_type, in_report_type**, and **instrument_type** variables are us _____________________ .. code-block:: none - - level_range = { beg = 1; end = 255; } - level_category = []; + level_range = { beg = 1; end = 255; } + level_category = []; The **beg** and **end** variables are used to stratify the model level of observations to be retained. The range shown above is 1 to 255. - The **level_category** variable is used to specify a comma-separated list of PrepBUFR data level categories to retain. An empty string indicates that all level categories should be retained. Accepted values and their meanings are described in :numref:`table_reformat-point_pb2nc_level_category`. See the following for more details: `PrepBUFR mnemonic table. `_ - .. _table_reformat-point_pb2nc_level_category: .. list-table:: Values for the level_category option. @@ -212,17 +194,15 @@ The **level_category** variable is used to specify a comma-separated list of Pre - Reports on a single level * - 7 - Auxiliary levels generated via interpolation from spanning levels - + _____________________ .. code-block:: none - - obs_bufr_var = [ 'QOB', 'TOB', 'ZOB', 'UOB', 'VOB' ]; + obs_bufr_var = [ 'QOB', 'TOB', 'ZOB', 'UOB', 'VOB' ]; Each PrepBUFR message will likely contain multiple observation variables. The **obs_bufr_var** variable is used to specify which observation variables should be retained or derived. The observation variable names are retrieved from the BUFR table embedded within the file. Users can run PB2NC with the **-index** command line argument to list out the variable names present in the file, and those names can be listed in this setting. If the list is empty, all BUFR variables present in the file are retained. This setting replaces the deprecated **obs_grib_code**. - The example **obs_bufr_var** setting above retains observations of QOB, TOB, ZOB, UOB, and VOB for specific humidity, temperature, height, and the u and v components of winds. Observations of those types are reported at the corresponding POB pressure level. In addition, PB2NC can derive several other variables from these observations. By convention, all observations that are derivable are named with a **D_** prefix: • **D_DPT** for dew point (from POB and QOB) @@ -243,39 +223,37 @@ The example **obs_bufr_var** setting above retains observations of QOB, TOB, ZOB • **D_MLCAPE** for mixed layer convective available potential energy (from POB, QOB, and TOB) - In BUFR, lower quality mark values indicate higher quality observations. The quality marks for derived observations are computed as the maximum of the quality marks for its components. For example, **D_DPT** derived from **POB** with quality mark 1 and **QOB** with quality mark 2 is assigned a quality mark value of 2. **D_PBL**, **D_CAPE**, and **D_MLCAPE** are derived using data from multiple vertical levels. Their quality marks are computed as the maximum of their components over all vertical levels. _____________________ .. code-block:: none - - obs_bufr_map = [ - { key = 'POB'; val = 'PRES'; }, - { key = 'QOB'; val = 'SPFH'; }, - { key = 'TOB'; val = 'TMP'; }, - { key = 'ZOB'; val = 'HGT'; }, - { key = 'UOB'; val = 'UGRD'; }, - { key = 'VOB'; val = 'VGRD'; }, - { key = 'D_DPT'; val = 'DPT'; }, - { key = 'D_WDIR'; val = 'WDIR'; }, - { key = 'D_WIND'; val = 'WIND'; }, - { key = 'D_RH'; val = 'RH'; }, - { key = 'D_MIXR'; val = 'MIXR'; }, - { key = 'D_PRMSL'; val = 'PRMSL'; }, - { key = 'D_PBL'; val = 'PBL'; }, - { key = 'D_CAPE'; val = 'CAPE'; } - { key = 'D_MLCAPE'; val = 'MLCAPE'; } - ]; + obs_bufr_map = [ + { key = 'POB'; val = 'PRES'; }, + { key = 'QOB'; val = 'SPFH'; }, + { key = 'TOB'; val = 'TMP'; }, + { key = 'ZOB'; val = 'HGT'; }, + { key = 'UOB'; val = 'UGRD'; }, + { key = 'VOB'; val = 'VGRD'; }, + { key = 'D_DPT'; val = 'DPT'; }, + { key = 'D_WDIR'; val = 'WDIR'; }, + { key = 'D_WIND'; val = 'WIND'; }, + { key = 'D_RH'; val = 'RH'; }, + { key = 'D_MIXR'; val = 'MIXR'; }, + { key = 'D_PRMSL'; val = 'PRMSL'; }, + { key = 'D_PBL'; val = 'PBL'; }, + { key = 'D_CAPE'; val = 'CAPE'; } + { key = 'D_MLCAPE'; val = 'MLCAPE'; } + ]; The BUFR variable names are not shared with other forecast data. This map is used to convert the BUFR name to the common name, like GRIB2. It allows to share the configuration for forecast data with PB2NC observation data. If there is no mapping, the BUFR variable name will be saved to output NetCDF file. _____________________ .. code-block:: none - - quality_mark_thresh = 2; + + quality_mark_thresh = 2; Each observation has a quality mark value associated with it. The **quality_mark_thresh** is used to stratify out which quality marks will be retained. The value shown above indicates that only observations with quality marks less than or equal to 2 will be retained. @@ -283,51 +261,45 @@ Each observation has a quality mark value associated with it. The **quality_mark _____________________ .. code-block:: none - - event_stack_flag = TOP; + event_stack_flag = TOP; A PrepBUFR message may contain duplicate observations with different quality mark values. The **event_stack_flag** indicates whether to use the observations at the top of the event stack (observation values have had more quality control processing applied) or the bottom of the event stack (observation values have had no quality control processing applied). The flag value of **TOP** listed above indicates the observations with the most amount of quality control processing should be used, the **BOTTOM** option uses the data closest to raw values. _____________________ .. code-block:: none - - time_summary = { - flag = FALSE; - raw_data = FALSE; - beg = "000000"; - end = "235959"; - step = 300; - width = 600; - // width = { beg = -300; end = 300; } - grib_code = []; - obs_var = [ "TMP", "WDIR", "RH" ]; - type = [ "min", "max", "range", "mean", "stdev", "median", "p80" ]; - vld_freq = 0; - vld_thresh = 0.0; - } + time_summary = { + flag = FALSE; + raw_data = FALSE; + beg = "000000"; + end = "235959"; + step = 300; + width = 600; + // width = { beg = -300; end = 300; } + grib_code = []; + obs_var = [ "TMP", "WDIR", "RH" ]; + type = [ "min", "max", "range", "mean", "stdev", "median", "p80" ]; + vld_freq = 0; + vld_thresh = 0.0; + } The **time_summary** dictionary enables additional processing for observations with high temporal resolution. The **flag** entry toggles the **time_summary** on (**TRUE**) and off (**FALSE**). If the **raw_data** flag is set to TRUE, then both the individual observation values and the derived time summary value will be written to the output. If FALSE, only the summary values are written. Observations may be summarized across the user specified time period defined by the **beg** and **end** entries in HHMMSS format. The **step** entry defines the time between intervals in seconds. The **width** entry specifies the summary interval in seconds. It may either be set as an integer number of seconds for a centered time interval or a dictionary with beginning and ending time offsets in seconds. - This example listed above does a 10-minute time summary (width = 600;) every 5 minutes (step = 300;) throughout the day (beg = "000000"; end = 235959";). The first interval will be from 23:55:00 the previous day through 00:04:59 of the current day. The second interval will be from 0:00:00 through 00:09:59. And so on. - The two **width** settings listed above are equivalent. Both define a centered 10-minute time interval. Use the **beg** and **end** entries to define uncentered time intervals. The following example requests observations for one hour prior: .. code-block:: none - - width = { beg = -3600; end = 0; } + width = { beg = -3600; end = 0; } -The summaries will only be calculated for the observations specified in the **grib_code** or **obs_var** entries. The **grib_code** entry is an array of integers while the **obs_var** entries is an array of strings. The supported summaries are **min** (minimum), **max** (maximum), **range, mean, stdev** (standard deviation), **median** and **p##** (percentile, with the desired percentile value specified in place of ##). If multiple summaries are selected in a single run, a string indicating the summary method applied will be appended to the output message type. +The summaries will only be calculated for the observations specified in the **grib_code** or **obs_var** entries. The **grib_code** entry is an array of integers while the **obs_var** entries is an array of strings. The supported summaries are **min** (minimum), **max** (maximum), **range, mean, stdev** (standard deviation), **median** and **p##** (percentile, with the desired percentile value specified in place of ##). If multiple summaries are selected in a single run, a string indicating the summary method applied will be appended to the output message type. The **vld_freq** and **vld_thresh** entries specify the required ratio of valid data for an output time summary value to be computed. This option is only applied when these entries are set to non-zero values. The **vld_freq** entry specifies the expected frequency of observations in seconds. The width of the time window is divided by this frequency to compute the expected number of observations for the time window. The actual number of valid observations is divided by the expected number to compute the ratio of valid data. An output time summary value will only be written if that ratio is greater than or equal to the **vld_thresh** entry. Detailed information about which observations are excluded is provided at debug level 4. - The quality mark for time summaries is always reported by PB2NC as bad data. Time summaries are computed by several MET point pre-processing tools using common library code. While BUFR quality marks are integers, the quality flags for other point data formats (MADIS NetCDF, for example) are stored as strings. MET does not currently contain logic to determine which quality flag strings are better or worse. Note however that any point observation whose quality mark does not meet the **quality_mark_thresh** criteria is not used in the computation of time summaries. .. _pb2nc output: @@ -358,14 +330,14 @@ Each NetCDF file generated by the PB2NC tool contains the dimensions and variabl * - nobs_qty - Number of unique quality control strings (variable) * - obs_var_num - - Number of unique observation variable types (variable) + - Number of unique observation variable types (variable) .. _table_reformat-point_pb2nc_output_vars: .. list-table:: NetCDF variables in pb2nc output :widths: auto :header-rows: 2 - + * - pb2nc NetCDF VARIABLES - - @@ -436,7 +408,6 @@ Each NetCDF file generated by the PB2NC tool contains the dimensions and variabl - obs_var_num, mxstr3 - Lookup table containing a description string for the unique observation variable names in obs_var. - ASCII2NC Tool ============= @@ -518,7 +489,7 @@ ascii2nc Usage Once the ASCII point observations have been formatted as expected, the ASCII file is ready to be processed by the ASCII2NC tool. The usage statement for ASCII2NC tool is shown below: .. code-block:: none - + Usage: ascii2nc ascii_file1 [ascii_file2 ... ascii_filen] netcdf_file @@ -568,9 +539,9 @@ Optional Arguments for ascii2nc An example of the ascii2nc calling sequence is shown below: .. code-block:: none - - ascii2nc sample_ascii_obs.txt \ - sample_ascii_obs.nc + + ascii2nc sample_ascii_obs.txt \ + sample_ascii_obs.nc In this example, the ASCII2NC tool will reformat the input **sample_ascii_obs.txt file** into NetCDF format and write the output to a file named **sample_ascii_obs.nc**. @@ -587,7 +558,7 @@ _____________________ .. code-block:: none - version = "VN.N"; + version = "VN.N"; The configuration options listed above are common to many MET tools and are described in :numref:`config_options`. @@ -595,31 +566,28 @@ _____________________ .. code-block:: none - time_summary = { ... } - + time_summary = { ... } The **time_summary** feature was implemented to allow additional processing of observations with high temporal resolution, such as SURFRAD data every 5 minutes. This option is described in :numref:`pb2nc configuration file`. _____________________ .. code-block:: none - - message_type_map = [ - { key = "FM-12 SYNOP"; val = "ADPSFC"; }, - { key = "FM-13 SHIP"; val = "SFCSHP"; }, - { key = "FM-15 METAR"; val = "ADPSFC"; }, - { key = "FM-18 BUOY"; val = "SFCSHP"; }, - { key = "FM-281 QSCAT"; val = "ASCATW"; }, - { key = "FM-32 PILOT"; val = "ADPUPA"; }, - { key = "FM-35 TEMP"; val = "ADPUPA"; }, - { key = "FM-88 SATOB"; val = "SATWND"; }, - { key = "FM-97 ACARS"; val = "AIRCFT"; } - ]; + message_type_map = [ + { key = "FM-12 SYNOP"; val = "ADPSFC"; }, + { key = "FM-13 SHIP"; val = "SFCSHP"; }, + { key = "FM-15 METAR"; val = "ADPSFC"; }, + { key = "FM-18 BUOY"; val = "SFCSHP"; }, + { key = "FM-281 QSCAT"; val = "ASCATW"; }, + { key = "FM-32 PILOT"; val = "ADPUPA"; }, + { key = "FM-35 TEMP"; val = "ADPUPA"; }, + { key = "FM-88 SATOB"; val = "SATWND"; }, + { key = "FM-97 ACARS"; val = "AIRCFT"; } + ]; This entry is an array of dictionaries, each containing a **key** string and **val** string which define a mapping of input strings to output message types. This mapping is currently only applied when converting input little_r report types to output message types. - ascii2nc Output --------------- @@ -627,21 +595,18 @@ The NetCDF output of the ASCII2NC tool is structured in the same way as the outp "obs_vid" variable is replaced with "obs_gc" when the GRIB code is given instead of the variable names. In this case, the global variable "use_var_id" does not exist or set to false (use_var_id = "false" ;). Three variables (obs_var, obs_units, and obs_desc) related with variable names are not added. - MADIS2NC Tool ============= - This section describes how to run the MADIS2NC tool. The MADIS2NC tool is used to reformat `Meteorological Assimilation Data Ingest System (MADIS) `_ point observations into the NetCDF format expected by the MET statistics tools. An optional configuration file controls the processing of the point observations. The MADIS2NC tool supports many of the MADIS data types, as listed in the usage statement below. Support for additional MADIS data types may be added in the future based on user feedback. - madis2nc Usage -------------- The usage statement for the MADIS2NC tool is shown below: .. code-block:: none - + Usage: madis2nc madis_file [madis_file2 ... madis_filen] out_file @@ -658,81 +623,61 @@ The usage statement for the MADIS2NC tool is shown below: [-v level] [-compress level] - madis2nc has required arguments and can also take optional ones. - Required Arguments for madis2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1. The **madis_file** argument is one or more input MADIS point observation files to be processed. - 2. The **out_file** argument is the NetCDF output file to be written. - 3. The argument **-type str** is a type of MADIS observations (metar, raob, profiler, maritime, mesonet or acarsProfiles). - Optional Arguments for madis2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4. The **-config file** option specifies the configuration file to generate summaries of the fields in the ASCII files. - 5. The **-qc_dd list** option specifies a comma-separated list of QC flag values to be accepted(Z,C,S,V,X,Q,K,G,B). - 6. The **-lvl_dim list** option specifies a comma-separated list of vertical level dimensions to be processed. - 7. To specify the exact records to be processed, the **-rec_beg n** specifies the index of the first MADIS record to process and **-rec_end n** specifies the index of the last MADIS record to process. Both are zero-based. - 8. The **-mask_grid string** option specifies a named grid or a gridded data file for filtering the point observations spatially. - 9. The **-mask_poly file** option defines a polyline masking file for filtering the point observations spatially. - 10. The **-mask_sid file|list** option is a station ID masking file or a comma-separated list of station ID's for filtering the point observations spatially. See the description of the "sid" entry in :numref:`config_options`. - 11. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. - 12. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity will increase the amount of logging. - 13. The **-compress level** option specifies the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. - An example of the madis2nc calling sequence is shown below: .. code-block:: none - - madis2nc sample_madis_obs.nc \ - sample_madis_obs_met.nc -log madis.log -v 3 + madis2nc sample_madis_obs.nc \ + sample_madis_obs_met.nc -log madis.log -v 3 In this example, the MADIS2NC tool will reformat the input sample_madis_obs.nc file into NetCDF format and write the output to a file named sample_madis_obs_met.nc. Warnings and error messages will be written to the madis.log file, and the verbosity level of logging is three. - madis2nc Configuration File --------------------------- - The default configuration file for the MADIS2NC tool named **Madis2NcConfig_default** can be found in the installed *share/met/config* directory. It is recommended that users make a copy of this file prior to modifying its contents. - The MADIS2NC configuration file is optional and only necessary when defining time summaries. The contents of the default MADIS2NC configuration file are described below. _____________________ .. code-block:: none - version = "VN.N"; - + version = "VN.N"; The configuration options listed above are common to many MET tools and are described in :numref:`config_options`. @@ -740,12 +685,10 @@ _____________________ .. code-block:: none - time_summary = { ... } - + time_summary = { ... } The **time_summary** dictionary is described in :numref:`pb2nc configuration file`. - madis2nc Output --------------- @@ -753,14 +696,11 @@ The NetCDF output of the MADIS2NC tool is structured in the same way as the outp "obs_vid" variable is replaced with "obs_gc" when the GRIB code is given instead of the variable names. In this case, the global variable "use_var_id" does not exist or set to false (use_var_id = "false" ;). Three variables (obs_var, obs_units, and obs_desc) related with variable names are not added. - LIDAR2NC Tool ============= - The LIDAR2NC tool creates a NetCDF point observation file from a CALIPSO HDF data file. Not all of the data present in the CALIPSO file is reproduced in the output, however. Instead, the output focuses mostly on information about clouds (as opposed to aerosols) as seen by the satellite along its ground track. - lidar2nc Usage -------------- @@ -775,19 +715,16 @@ The usage statement for LIDAR2NC tool is shown below: [-v level] [-compress level] - -Unlike most of the MET tools, lidar2nc does not use a config file. Currently, the options needed to run lidar2nc are not complex enough to require one. +Unlike most of the MET tools, lidar2nc does not use a config file. Currently, the options needed to run lidar2nc are not complex enough to require one. Required Arguments for lidar2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1. The **lidar_file** argument is the input HDF lidar data file to be processed. Currently, CALIPSO files are supported but support for additional file types will be added in future releases. - 2. The **out_file** argument is the NetCDF output file to be written. - Optional Arguments for lidar2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -802,13 +739,10 @@ lidar2nc Output Each observation type in the lidar2nc output is assigned a GRIB code. These are outlined in :numref:`lidar2nc_grib_code_table`. GRIB codes were assigned to these fields arbitrarily, with GRIB codes in the 600s denoting individual bit fields taken from the feature classification flag field in the CALIPSO file. - We will not give a detailed description of each CALIPSO data product that lidar2nc reads. Users should refer to existing CALIPSO documentation for this information. We will, however, give some explanation of how the cloud layer base and top information is encoded in the lidar2nc NetCDF output file. - **Layer_Base** gives the elevation in meters above ground level of the cloud base for each cloud level at each observation location. Similarly, **Layer_Top** gives the elevation of the top of each cloud layer. Note that if there are multiple cloud layers at a particular location, then there will be more than one base (or top) given for that location. For convenience, **Min_Base** and **Max_Top** give, respectively, the base elevation for the bottom cloud layer, and the top elevation for the top cloud layer. For these data types, there will be only one value per observation location regardless of how many cloud layers there are at that location. - .. _lidar2nc_grib_code_table: .. list-table:: lidar2nc GRIB codes and their meaning, units, and abbreviations @@ -868,21 +802,18 @@ We will not give a detailed description of each CALIPSO data product that lidar2 - NA - Horizontal_Averaging - IODA2NC Tool ============ - This section describes the IODA2NC tool which is used to reformat IODA (Interface for Observation Data Access) point observations from the `Joint Center for Satellite Data Assimilation (JCSDA) `_ into the NetCDF format expected by the MET statistics tools. An optional configuration file controls the processing of the point observations. The IODA2NC tool reads NetCDF point observation files created by the `IODA Converters `_. Support for interfacing with data from IODA may be added in the future based on user feedback. - ioda2nc Usage ------------- The usage statement for the IODA2NC tool is shown below: .. code-block:: none - + Usage: ioda2nc ioda_file netcdf_file @@ -928,12 +859,11 @@ An example of the ioda2nc calling sequence is shown below: .. code-block:: none - ioda2nc \ - ioda.NC001007.2020031012.nc ioda2nc.2020031012.nc \ - -config IODA2NCConfig -v 3 -lg run_ioda2nc.log - -In this example, the IODA2NC tool will reformat the data in the input ioda.NC001007.2020031012.nc file and write the output to a file named ioda2nc.2020031012.nc. The data to be processed is specified by IODA2NCConfig, log messages will be written to the ioda2nc.log file, and the verbosity level is three. + ioda2nc \ + ioda.NC001007.2020031012.nc ioda2nc.2020031012.nc \ + -config IODA2NCConfig -v 3 -lg run_ioda2nc.log +In this example, the IODA2NC tool will reformat the data in the input ioda.NC001007.2020031012.nc file and write the output to a file named ioda2nc.2020031012.nc. The data to be processed is specified by IODA2NCConfig, log messages will be written to the ioda2nc.log file, and the verbosity level is three. ioda2nc Configuration File -------------------------- @@ -946,10 +876,10 @@ _____________________ .. code-block:: none - obs_window = { beg = -5400; end = 5400; } - mask = { grid = ""; poly = ""; } - tmp_dir = "/tmp"; - version = "VN.N"; + obs_window = { beg = -5400; end = 5400; } + mask = { grid = ""; poly = ""; } + tmp_dir = "/tmp"; + version = "VN.N"; The configuration options listed above are common to many MET tools and are described in :numref:`config_options`. @@ -957,15 +887,15 @@ _____________________ .. code-block:: none - message_type = []; - message_type_group_map = []; - message_type_map = []; - station_id = []; - elevation_range = { ... }; - level_range = { ... }; - obs_var = []; - quality_mark_thresh = 0; - time_summary = { ... } + message_type = []; + message_type_group_map = []; + message_type_map = []; + station_id = []; + elevation_range = { ... }; + level_range = { ... }; + obs_var = []; + quality_mark_thresh = 0; + time_summary = { ... } The configuration options listed above are supported by other point observation pre-processing tools and are described in :numref:`pb2nc configuration file`. @@ -973,22 +903,22 @@ _____________________ .. code-block:: none - obs_name_map = []; + obs_name_map = []; This entry is an array of dictionaries, each containing a **key** string and **val** string which define a mapping of input IODA variable names to output variable names. The default IODA map, obs_var_map, is appended to this map. _____________________ .. code-block:: none - - metadata_map = [ - { 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 = "elevation,station_elevation"; }, - { key = "nlocs"; val = "Location"; } - ]; + + metadata_map = [ + { 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 = "elevation,station_elevation"; }, + { key = "nlocs"; val = "Location"; } + ]; This entry is an array of dictionaries, each containing a **key** string and **val** string which define a mapping of metadata for IODA data files. The "nlocs" is for the dimension name of the locations. The following key can be added: "nstring", "latitude" and "longitude". @@ -996,11 +926,11 @@ The "nlocs" is for the dimension name of the locations. The following key can be _____________________ .. code-block:: none - - obs_to_qc_map = [ - { key = "wind_from_direction"; val = "eastward_wind,northward_wind"; }, - { key = "wind_speed"; val = "eastward_wind,northward_wind"; } - ]; + + obs_to_qc_map = [ + { key = "wind_from_direction"; val = "eastward_wind,northward_wind"; }, + { key = "wind_speed"; val = "eastward_wind,northward_wind"; } + ]; This entry is an array of dictionaries, each containing a **key** string and **val** string which define a mapping of QC variable name for IODA data files. @@ -1008,17 +938,15 @@ _____________________ .. code-block:: none - missing_thresh = [ <=-1e9, >=1e9, ==-9999 ]; + missing_thresh = [ <=-1e9, >=1e9, ==-9999 ]; The **missing_thresh** option is an array of thresholds. Any data values which meet any of these thresholds are interpreted as being bad, or missing, data. - ioda2nc Output -------------- The NetCDF output of the IODA2NC tool is structured in the same way as the output of the PB2NC tool described in :numref:`pb2nc output`. - Point2Grid Tool =============== @@ -1030,15 +958,15 @@ point2grid Usage The usage statement for the Point2Grid tool is shown below: .. code-block:: none - + Usage: point2grid input_filename to_grid output_filename -field string [-config file] - [-qc flags] - [-adp adp_file_name] + [-goes_qc flags] + [-adp adp_filename] [-method type] [-gaussian_dx n] [-gaussian_radius n] @@ -1049,7 +977,6 @@ The usage statement for the Point2Grid tool is shown below: [-v level] [-compress level] - Required Arguments for point2grid ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1063,21 +990,20 @@ The MET point observation NetCDF file name as **input_filename** argument is equ 4. The **-field** string argument is a string that defines the data to be regridded. It may be used multiple times. If **-adp** option is given (for AOD data from GOES16/17), the name consists with the variable name from the input data file and the variable name from ADP data file (for example, "AOD_Smoke" or "AOD_Dust": getting AOD variable from the input data and applying smoke or dust variable from ADP data file). - Optional Arguments for point2grid ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5. The **-config** file option is the configuration file to be used. -6. The **-qc** flags option specifies a comma-separated list of quality control (QC) flags, for example "0,1". This should only be applied if grid_mapping is set to "goes_imager_projection" and the QC variable exists. +6. The **-goes_qc** flags option specifies a comma-separated list of quality control (QC) flags, for example "0,1". Only used if grid_mapping is set to "goes_imager_projection" and the QC variable exists. Note that the older **-qc** option name is also supported. -7. The **-adp adp_file_name** option provides an additional Aerosol Detection Product (ADP) information on aerosols, dust, and smoke. This option is ignored if the requested variable is not AOD ("AOD_Dust" or "AOD_Smoke") from GOES16/17. The gridded data is filtered by the presence of dust/smoke. If -qc options are given, it's applied to QC of dust/smoke, too (First filtering with AOD QC values and the second filtering with dust/smoke QC values). +7. The **-adp adp_filename** option provides an additional Aerosol Detection Product (ADP) information on aerosols, dust, and smoke. This option is ignored if the requested variable is not AOD ("AOD_Dust" or "AOD_Smoke") from GOES16/17. The gridded data is filtered by the presence of dust/smoke. If -goes_qc options are given, it's applied to QC of dust/smoke, too (First filtering with AOD QC values and the second filtering with dust/smoke QC values). 8. The **-method type** option specifies the regridding method. The default method is UW_MEAN. -9. The **-gaussian_dx n** option defines the distance interval for Gaussian smoothing. The default is 81.271 km. Ignored if the method is not GAUSSIAN or MAXGAUSS. +9. The **-gaussian_dx n** option specifies the distance interval for Gaussian smoothing. The default is 81.271 km. Only used if the method is GAUSSIAN or MAXGAUSS. -10. The **-gaussian_radius** n option defines the radius of influence for Gaussian interpolation. The default is 120. Ignored if the method is not GAUSSIAN or MAXGAUSS. +10. The **-gaussian_radius** n option specifies the radius of influence for Gaussian interpolation. The default is 120. Only used if the method is GAUSSIAN or MAXGAUSS. 11. The **-prob_cat_thresh string** option sets the threshold to compute the probability of occurrence. The default is set to disabled. This option is relevant when calculating practically perfect forecasts. @@ -1109,26 +1035,26 @@ The grid name or the grid definition can be given with the -field option when th -v 1 .. code-block:: none - - point2grid \ - OR_ABI-L2-AODC-M3_G16_s20181341702215_e20181341704588_c20181341711418.nc \ - G212 \ - regrid_data_plane_GOES-16_AOD_TO_G212.nc \ - -field 'name="AOD"; level="(*,*)";' \ - -qc 0,1,2 - -method MAX -v 1 + + point2grid \ + OR_ABI-L2-AODC-M3_G16_s20181341702215_e20181341704588_c20181341711418.nc \ + G212 \ + regrid_data_plane_GOES-16_AOD_TO_G212.nc \ + -field 'name="AOD"; level="(*,*)";' \ + -goes_qc 0,1,2 + -method MAX -v 1 -When processing GOES-16 data, the **-qc** option may also be used to specify the acceptable quality control flag values. The example above regrids the GOES-16 AOD values to NCEP Grid number 212 (which QC flags are high, medium, and low), writing to the output the maximum AOD value falling inside each grid box. +When processing GOES-16 data, the **-goes_qc** option may also be used to specify the acceptable quality control flag values. The example above regrids the GOES-16 AOD values to NCEP Grid number 212 (which QC flags are high, medium, and low), writing to the output the maximum AOD value falling inside each grid box. Listed below is an example of processing the same set of observations but using Python embedding instead: .. code-block:: none - - point2grid \ - 'PYTHON_NUMPY=MET_BASE/python/examples/read_met_point_obs.py ascii2nc_edr_hourly.20130827.nc' \ - G212 python_gridded_ascii_python.nc -config Point2GridConfig_edr \ - -field 'name="200"; level="*"; valid_time="20130827_205959";' -method MAX -v 1 + + point2grid \ + 'PYTHON_NUMPY=MET_BASE/python/examples/read_met_point_obs.py ascii2nc_edr_hourly.20130827.nc' \ + G212 python_gridded_ascii_python.nc -config Point2GridConfig_edr \ + -field 'name="200"; level="*"; valid_time="20130827_205959";' -method MAX -v 1 Please refer to :numref:`Appendix F, Section %s ` for more details about Python embedding in MET. @@ -1137,25 +1063,18 @@ point2grid Output The point2grid tool will output a gridded NetCDF file containing the following: - 1. Latitude - 2. Longitude - 3. The variable specified in the -field string regridded to the grid defined in the **to_grid** argument. - 4. The count field which represents the number of point observations that were included calculating the value of the variable at that grid cell. - 5. The mask field which is a binary field representing the presence or lack thereof of point observations at that grid cell. A value of "1" indicates that there was at least one point observation within the bounds of that grid cell and a value of "0" indicates the lack of point observations at that grid cell. - 6. The probability field which is the probability of the event defined by the **-prob_cat_thresh** command line option. The output variable name includes the threshold used to define the probability. Ranges from 0 to 1. - 7. The probability mask field which is a binary field that represents whether or not there is probability data at that grid point. Can be either "0" or "1" with "0" meaning the probability value does not exist and a value of "1" meaning that the probability value does exist. For MET observation input and CF complaint NetCDF input with 2D time variable: The latest observation time within the target grid is saved as the observation time. If the "valid_time" is configured at the configuration file, the valid_time from the configuration file is saved into the output file. @@ -1163,7 +1082,6 @@ For MET observation input and CF complaint NetCDF input with 2D time variable: T point2grid Configuration File ----------------------------- - The default configuration file for the point2grid tool named **Point2GridConfig_default** can be found in the installed *share/met/config* directory. It is recommended that users make a copy of this file prior to modifying its contents. The point2grid configuration file is optional and only necessary when defining the variable name instead of GRIB code or filtering by time. The contents of the default point2grid configuration file are described below. @@ -1172,27 +1090,23 @@ _____________________ .. code-block:: none - version = "VN.N"; - + obs_window = { beg = -5400; end = 5400; } + message_type = []; + obs_quality_inc = []; + obs_quality_exc = []; + version = "VN.N"; The configuration options listed above are common to many MET tools and are described in :numref:`config_options`. _____________________ .. code-block:: none - - valid_time = "YYYYMMDD_HHMMSS"; -This entry is a string to override the obseration time into the output and to filter observation data by time. + valid_time = "YYYYMMDD_HHMMSS"; -.. code-block:: none - - obs_window = { - beg = -5400; - end = 5400; - } +This entry is a string to override the observation time into the output and to filter observation data by time. -The configuration option listed above is common to many MET tools and are described in :numref:`config_options`. +_____________________ .. code-block:: none @@ -1202,21 +1116,14 @@ The configuration option listed above is common to many MET tools and are descri { key = "7"; val = "HGT"; }, // GRIB: Geopotential height { key = "11"; val = "TMP"; }, // GRIB: Temperature { key = "15"; val = "TMAX"; }, // GRIB: Max Temperature - ... - ] - -This entry is an array of dictionaries, each containing a **GRIB code** string and mathcing **variable name** string which define a mapping of GRIB code to the output variable names. - -.. code-block:: none - - var_name_map = [ ... - { key = "lat_vname"; val = "NLAT"; }, - { key = "lon_vname"; val = "NLON"; } + { key = "lat_vname"; val = "NLAT"; }, // NetCDF latitude variable name + { key = "lon_vname"; val = "NLON"; }, // NetCDF longitude varialbe name ... ] -The latitude and longitude variables for NetCDF input can be overridden by the configurations. There are two special keys, **lat_vname** and **lon_vname** which are applied to the NetCDF input, not for GRIB code. +This entry is an array of dictionaries, each containing a **GRIB code** string and matching **variable name** string which define a mapping of GRIB code to the output variable names. +The latitude and longitude variables for NetCDF input can be overridden by the configurations. There are two special keys, **lat_vname** and **lon_vname**, are applied to the NetCDF input, not for a GRIB code. Point NetCDF to ASCII Python Utility ==================================== diff --git a/internal/test_unit/config/Point2GridConfig_WINDS b/internal/test_unit/config/Point2GridConfig_WINDS new file mode 100644 index 0000000000..d39221adbe --- /dev/null +++ b/internal/test_unit/config/Point2GridConfig_WINDS @@ -0,0 +1,2 @@ +obs_quality_inc = [ "2" ]; +obs_quality_exc = [ "1" ]; diff --git a/internal/test_unit/config/Point2GridConfig_valid_time b/internal/test_unit/config/Point2GridConfig_valid_time index 748da58b4f..a2a1a69a0a 100644 --- a/internal/test_unit/config/Point2GridConfig_valid_time +++ b/internal/test_unit/config/Point2GridConfig_valid_time @@ -22,11 +22,12 @@ valid_time = "20201022_173000"; //////////////////////////////////////////////////////////////////////////////// - // -// Observation message type +// Point observation filtering options // -//message_type = []; +message_type = []; +obs_quality_inc = []; +obs_quality_exc = []; //////////////////////////////////////////////////////////////////////////////// @@ -72,10 +73,6 @@ valid_time = "20201022_173000"; //////////////////////////////////////////////////////////////////////////////// -//quality_mark_thresh = 2; - -//////////////////////////////////////////////////////////////////////////////// - tmp_dir = "/tmp"; version = "V12.0.0"; diff --git a/internal/test_unit/xml/unit_point2grid.xml b/internal/test_unit/xml/unit_point2grid.xml index ac94683703..c198834114 100644 --- a/internal/test_unit/xml/unit_point2grid.xml +++ b/internal/test_unit/xml/unit_point2grid.xml @@ -46,6 +46,23 @@ + + &MET_BIN;/point2grid + \ + &OUTPUT_DIR;/pb2nc/ndas.20120409.t12z.prepbufr.tm00.nc \ + G212 \ + &OUTPUT_DIR;/point2grid/pb2nc_WINDS.nc \ + -field 'name="UGRD"; level="*";' \ + -field 'name="VGRD"; level="*";' \ + -name UWIND,VWIND \ + -config &CONFIG_DIR;/Point2GridConfig_WINDS \ + -v 3 + + + &OUTPUT_DIR;/point2grid/pb2nc_WINDS.nc + + + &MET_BIN;/point2grid \ @@ -130,7 +147,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_compute.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 0,1 -method MAX \ + -goes_qc 0,1 -method MAX \ -v 1 @@ -167,7 +184,7 @@ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_ADP.nc \ -field 'name="AOD_Smoke"; level="(*,*)";' \ -adp &DATA_DIR_MODEL;/goes_16/OR_ABI-L2-ADPC-M6_G16_s20192662141196_e20192662143569_c20192662144526.nc \ - -qc 0,1 -method MAX \ + -goes_qc 0,1 -method MAX \ -v 1 @@ -185,7 +202,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212_grid_map.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 0,1,2 -method MAX \ + -goes_qc 0,1,2 -method MAX \ -v 1 @@ -205,7 +222,7 @@ G212 \ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_AOD_TO_G212.nc \ -field 'name="AOD"; level="(*,*)";' \ - -qc 0,1,2 -method MAX \ + -goes_qc 0,1,2 -method MAX \ -v 1 @@ -224,7 +241,7 @@ &OUTPUT_DIR;/point2grid/point2grid_GOES_16_ADP_Enterprise_high.nc \ -field 'name="AOD_Smoke"; level="(*,*)";' \ -adp &DATA_DIR_MODEL;/goes_16/OR_ABI-L2-ADPC-M6_G16_s20241100001171_e20241100003544_c20241100006361.nc \ - -qc 0,1 -method MAX \ + -goes_qc 0,1 -method MAX \ -v 1 @@ -319,6 +336,7 @@ + &MET_BIN;/point2grid diff --git a/src/basic/vx_util/crc_array.h b/src/basic/vx_util/crc_array.h index 6a8841afce..0eea7d529c 100644 --- a/src/basic/vx_util/crc_array.h +++ b/src/basic/vx_util/crc_array.h @@ -22,7 +22,6 @@ #include #include "num_array.h" -#include "int_array.h" #include "is_bad_data.h" #include "nint.h" #include "vx_cal.h" diff --git a/src/basic/vx_util/int_array.h b/src/basic/vx_util/int_array.h index c435c4aba7..608f6f2dfa 100644 --- a/src/basic/vx_util/int_array.h +++ b/src/basic/vx_util/int_array.h @@ -20,8 +20,6 @@ #include -#include "num_array.h" - #include "crc_array.h" @@ -34,6 +32,12 @@ typedef CRC_Array IntArray; //////////////////////////////////////////////////////////////////////// +extern ConcatString write_css(const IntArray &); + + +//////////////////////////////////////////////////////////////////////// + + #endif /* __INT_ARRAY_H__ */ diff --git a/src/basic/vx_util/num_array.cc b/src/basic/vx_util/num_array.cc index e2a8c79ff0..cb5046c8a6 100644 --- a/src/basic/vx_util/num_array.cc +++ b/src/basic/vx_util/num_array.cc @@ -19,6 +19,7 @@ #include "num_array.h" +#include "int_array.h" #include "is_bad_data.h" #include "ptile.h" #include "nint.h" @@ -1382,3 +1383,22 @@ ConcatString write_css_hhmmss(const NumArray &na) //////////////////////////////////////////////////////////////////////// + + +ConcatString write_css(const IntArray &ia) + +{ + + ConcatString css; + + for ( int i=0; iobs_cnt = obs_cnt; } - - - //////////////////////////////////////////////////////////////////////// - - - // - // Code for class MetPointDataPython - // - - +// +// Code for class MetPointDataPython +// //////////////////////////////////////////////////////////////////////// MetPointDataPython::MetPointDataPython() { @@ -178,14 +169,12 @@ MetPointDataPython::MetPointDataPython(MetPointDataPython &d) { header_data.assign(*d.get_header_data()); } - //////////////////////////////////////////////////////////////////////// MetPointDataPython::~MetPointDataPython() { clear(); } - //////////////////////////////////////////////////////////////////////// void MetPointDataPython::allocate(int obs_cnt) { @@ -193,63 +182,47 @@ void MetPointDataPython::allocate(int obs_cnt) { obs_data->allocate(); } -//////////////////////////////////////////////////////////////////////// - - - /////////////////////////////////////////////////////////////////////////////// -// struct MetPointObsData - -MetPointObsData::MetPointObsData(): - obs_cnt(0), - obs_ids((int *)0), - obs_hids((int *)0), - obs_qids((int *)0), - obs_lvls((float *)0), - obs_hgts((float *)0), - obs_vals((float *)0), - obs_arr((float *)0), - is_obs_array(false) -{ -} +// +// Code for struct MetPointObsData +// +/////////////////////////////////////////////////////////////////////////////// +MetPointObsData::MetPointObsData() { + clear(); +} /////////////////////////////////////////////////////////////////////////////// void MetPointObsData::allocate() { - if (is_obs_array) obs_arr = new float[obs_cnt*OBS_ARRAY_LEN]; // nobs * 5 + if (is_obs_array) { + obs_arr.resize(obs_cnt*OBS_ARRAY_LEN, bad_data_float); // nobs * 5 + } else { - obs_ids = new int[obs_cnt]; // grib_code or var_id - obs_hids = new int[obs_cnt]; - obs_qids = new int[obs_cnt]; - obs_lvls = new float[obs_cnt]; - obs_hgts = new float[obs_cnt]; - obs_vals = new float[obs_cnt]; + obs_ids.resize(obs_cnt, bad_data_int); // grib_code or var_id + obs_hids.resize(obs_cnt, bad_data_int); + obs_qids.resize(obs_cnt, bad_data_int); + obs_lvls.resize(obs_cnt, bad_data_float); + obs_hgts.resize(obs_cnt, bad_data_float); + obs_vals.resize(obs_cnt, bad_data_float); } } /////////////////////////////////////////////////////////////////////////////// void MetPointObsData::assign(MetPointObsData &o) { + clear(); obs_cnt = o.obs_cnt; is_obs_array = o.is_obs_array; - - clear(); - allocate(); - if (is_obs_array) - for (int idx=0; idx= 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])]; +} + +/////////////////////////////////////////////////////////////////////////////// + // struct MetPointHeader MetPointHeader::MetPointHeader() diff --git a/src/libcode/vx_nc_obs/met_point_data.h b/src/libcode/vx_nc_obs/met_point_data.h index 939c63ba35..83ba31e729 100644 --- a/src/libcode/vx_nc_obs/met_point_data.h +++ b/src/libcode/vx_nc_obs/met_point_data.h @@ -18,6 +18,7 @@ #include +#include #include "nc_utils.h" @@ -61,13 +62,13 @@ struct MetPointObsData { int obs_cnt; bool is_obs_array; - int *obs_ids; // grib_code or var_id - int *obs_hids; - int *obs_qids; - float *obs_lvls; - float *obs_hgts; - float *obs_vals; - float *obs_arr; // nobs * 5 + std::vector obs_ids; // grib_code or var_id + std::vector obs_hids; + std::vector obs_qids; + std::vector obs_lvls; + std::vector obs_hgts; + std::vector obs_vals; + std::vector obs_arr; // nobs * 5 StringArray var_names; StringArray qty_names; @@ -78,7 +79,8 @@ struct MetPointObsData { void clear_numbers(); void clear_strings(); bool fill_obs_buf(int buf_size, int offset, float *obs_arr, int *qty_idx_arr); - float get_obs_val(int index); + float get_obs_val(int index) const; + std::string get_obs_qty(int index) const; }; diff --git a/src/libcode/vx_nc_obs/nc_obs_util.cc b/src/libcode/vx_nc_obs/nc_obs_util.cc index 5380923944..d78d281549 100644 --- a/src/libcode/vx_nc_obs/nc_obs_util.cc +++ b/src/libcode/vx_nc_obs/nc_obs_util.cc @@ -87,12 +87,15 @@ bool NcPointObsData::read_obs_data_numbers(NetcdfObsVars obs_vars, bool stop) { clear_numbers(); obs_cnt = obs_vars.obs_cnt; + if (!IS_INVALID_NC(obs_vars.obs_arr_var)) is_obs_array = true; + + // Resize arrays for input data + allocate(); + StringArray missing_vars; StringArray failed_vars; - if (!IS_INVALID_NC(obs_vars.obs_arr_var)) { - is_obs_array = true; - obs_arr = new float[obs_cnt*OBS_ARRAY_LEN]; - if (!get_nc_data(&obs_vars.obs_arr_var, obs_arr)) { + if(is_obs_array) { + if (!get_nc_data(&obs_vars.obs_arr_var, obs_arr.data())) { succeed = false; failed_vars.add(nc_var_obs_arr); } @@ -103,8 +106,7 @@ bool NcPointObsData::read_obs_data_numbers(NetcdfObsVars obs_vars, bool stop) { missing_vars.add(nc_var_obs_hid); } else { - obs_hids = new int[obs_cnt]; - if (!get_nc_data(&obs_vars.obs_hid_var, obs_hids)) { + if (!get_nc_data(&obs_vars.obs_hid_var, obs_hids.data())) { succeed = false; failed_vars.add(nc_var_obs_hid); } @@ -114,8 +116,7 @@ bool NcPointObsData::read_obs_data_numbers(NetcdfObsVars obs_vars, bool stop) { missing_vars.add(nc_var_obs_lvl); } else { - obs_lvls = new float[obs_cnt]; - if (!get_nc_data(&obs_vars.obs_lvl_var, obs_lvls)) { + if (!get_nc_data(&obs_vars.obs_lvl_var, obs_lvls.data())) { succeed = false; failed_vars.add(nc_var_obs_lvl); } @@ -125,8 +126,7 @@ bool NcPointObsData::read_obs_data_numbers(NetcdfObsVars obs_vars, bool stop) { missing_vars.add(nc_var_obs_hgt); } else { - obs_hgts = new float[obs_cnt]; - if (!get_nc_data(&obs_vars.obs_hgt_var, obs_hgts)) { + if (!get_nc_data(&obs_vars.obs_hgt_var, obs_hgts.data())) { succeed = false; failed_vars.add(nc_var_obs_hgt); } @@ -136,28 +136,34 @@ bool NcPointObsData::read_obs_data_numbers(NetcdfObsVars obs_vars, bool stop) { missing_vars.add(nc_var_obs_val); } else { - obs_vals = new float[obs_cnt]; - if (!get_nc_data(&obs_vars.obs_val_var, obs_vals)) { + if (!get_nc_data(&obs_vars.obs_val_var, obs_vals.data())) { succeed = false; failed_vars.add(nc_var_obs_val); } } if (IS_VALID_NC(obs_vars.obs_gc_var)) { - obs_ids = new int[obs_cnt]; - if (!get_nc_data(&obs_vars.obs_gc_var, obs_ids)) { + if (!get_nc_data(&obs_vars.obs_gc_var, obs_ids.data())) { succeed = false; failed_vars.add(nc_var_obs_gc); } } else if (IS_VALID_NC(obs_vars.obs_vid_var)) { - obs_ids = new int[obs_cnt]; - if (!get_nc_data(&obs_vars.obs_vid_var, obs_ids)) { + if (!get_nc_data(&obs_vars.obs_vid_var, obs_ids.data())) { succeed = false; failed_vars.add(nc_var_obs_vid); } } else succeed = false; - + if (IS_INVALID_NC(obs_vars.obs_qty_var)) { + succeed = false; + missing_vars.add(nc_var_obs_qty); + } + else { + if (!get_nc_data(&obs_vars.obs_qty_var, obs_qids.data())) { + succeed = false; + failed_vars.add(nc_var_obs_qty); + } + } } for (int idx=0; idxobs_qids); - set_array_from_python(python_met_point_data, numpy_array_obs_hid, obs_data->obs_hids); - set_array_from_python(python_met_point_data, numpy_array_obs_vid, obs_data->obs_ids); - set_array_from_python(python_met_point_data, numpy_array_obs_lvl, obs_data->obs_lvls); - set_array_from_python(python_met_point_data, numpy_array_obs_hgt, obs_data->obs_hgts); - set_array_from_python(python_met_point_data, numpy_array_obs_val, obs_data->obs_vals); + set_array_from_python(python_met_point_data, numpy_array_obs_qty, obs_data->obs_qids.data()); + set_array_from_python(python_met_point_data, numpy_array_obs_hid, obs_data->obs_hids.data()); + set_array_from_python(python_met_point_data, numpy_array_obs_vid, obs_data->obs_ids.data()); + set_array_from_python(python_met_point_data, numpy_array_obs_lvl, obs_data->obs_lvls.data()); + set_array_from_python(python_met_point_data, numpy_array_obs_hgt, obs_data->obs_hgts.data()); + set_array_from_python(python_met_point_data, numpy_array_obs_val, obs_data->obs_vals.data()); set_str_array_from_python(python_met_point_data, numpy_array_obs_qty_table, &obs_data->qty_names); set_str_array_from_python(python_met_point_data, numpy_array_obs_var_table, &obs_data->var_names); diff --git a/src/libcode/vx_statistics/apply_mask.cc b/src/libcode/vx_statistics/apply_mask.cc index 01c696243c..c299d8d3d0 100644 --- a/src/libcode/vx_statistics/apply_mask.cc +++ b/src/libcode/vx_statistics/apply_mask.cc @@ -60,19 +60,19 @@ Grid parse_vx_grid(const RegridInfo info, const Grid *fgrid, const Grid *ogrid) // Verify on the forecast grid if(info.field == FieldType::Fcst) { - mlog << Debug(2) << "Using the forecast grid as the verification grid\n"; + mlog << Debug(2) << "Using the forecast grid as the verification grid.\n"; vx_grid = *fgrid; } // Verify on the observation grid else if(info.field == FieldType::Obs) { - mlog << Debug(2) << "Using the observation grid as the verification grid\n"; + mlog << Debug(2) << "Using the observation grid as the verification grid.\n"; vx_grid = *ogrid; } // Parse a named grid, grid specification string, // or gridded data file else { - mlog << Debug(2) << "Using named grid as the verification grid. " - << "Name=" << info.name << "\n"; + mlog << Debug(2) << "Using named grid (" << info.name + << ") as the verification grid.\n"; parse_grid_mask(info.name, vx_grid); } } diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index c243b226bc..e159649266 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -22,10 +22,10 @@ // 002 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // 003 10-03-23 Prestopnik MET #2227 Remove namespace std and netCDF from header files // 004 05-20-24 Howard Soh MET #2867 Fix -qc ADP bug. +// 004 06-24-24 Halley Gotway MET #2880 Filter obs_quality. // //////////////////////////////////////////////////////////////////////// - #include #include #include @@ -55,7 +55,6 @@ using namespace std; using namespace netCDF; - //////////////////////////////////////////////////////////////////////// static ConcatString program_name; @@ -171,9 +170,8 @@ static void set_gaussian_dx(const StringArray &); static void set_gaussian_radius(const StringArray &); static unixtime compute_unixtime(NcVar *time_var, unixtime var_value); -void clear_cell_mapping(IntArray *cell_mapping); static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, - NcVar var_lat, NcVar var_lon, bool *skip_times); + NcVar var_lat, NcVar var_lon, vector skip_times); static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, const IntArray obs_index_array, const int *obs_hids, const float *hdr_lats, const float *hdr_lons); @@ -219,7 +217,7 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, static void save_geostationary_data(const ConcatString geostationary_file, const float *latitudes, const float *longitudes, const GoesImagerData &grid_data); -static void set_qc_flags(const StringArray &); +static void set_goes_qc_flags(const StringArray &); //////////////////////////////////////////////////////////////////////// @@ -274,7 +272,9 @@ static void process_command_line(int argc, char **argv) { cline.add(set_vld_thresh, "-vld_thresh", 1); cline.add(set_name, "-name", 1); cline.add(set_compress, "-compress", 1); - cline.add(set_qc_flags, "-qc", 1); + cline.add(set_goes_qc_flags, "-goes_qc", 1); + // Also support old -qc option + cline.add(set_goes_qc_flags, "-qc", 1); cline.add(set_adp, "-adp", 1); cline.add(set_config, "-config", 1); cline.add(set_prob_cat_thresh, "-prob_cat_thresh", 1); @@ -743,8 +743,8 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI bool empty_input = (nhdr == 0 && nobs == 0); bool use_var_id = met_point_obs->is_using_var_id(); - auto hdr_lats = new float[nhdr]; - auto hdr_lons = new float[nhdr]; + vector hdr_lats(nhdr, bad_data_float); + vector hdr_lons(nhdr, bad_data_float); IntArray var_index_array; IntArray valid_time_array; StringArray qc_tables = met_point_obs->get_qty_data(); @@ -752,8 +752,8 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI StringArray hdr_valid_times = header_data->vld_array; hdr_valid_times.sort(); - met_point_obs->get_lats(hdr_lats); - met_point_obs->get_lons(hdr_lons); + met_point_obs->get_lats(hdr_lats.data()); + met_point_obs->get_lons(hdr_lons.data()); // Check the message types prepare_message_types(header_data->typ_array); @@ -784,7 +784,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI int obs_count_zero_from = 0; int obs_count_non_zero_to = 0; int obs_count_non_zero_from = 0; - auto cellMapping = (IntArray *) nullptr; + vector cellMapping; for(int i=0; iobs_qids[idx])) { filtered_by_qc++; continue; } + // Filter by QC inclusion/exclusion lists (obs_quality_inc/exc config option) + if ((conf_info.obs_qty_inc.n() > 0 && + !conf_info.obs_qty_inc.has(obs_data->get_obs_qty(idx))) || + (conf_info.obs_qty_exc.n() > 0 && + conf_info.obs_qty_exc.has(obs_data->get_obs_qty(idx)))) { + filtered_by_qc++; + continue; + } + var_index_array.add(idx); var_count++; if (is_eq(obs_data->obs_vals[idx], (float)0.)) obs_count_zero_from++; @@ -968,14 +977,11 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI } } - if (cellMapping) { - clear_cell_mapping(cellMapping); - delete [] cellMapping; - cellMapping = (IntArray *) nullptr; - } - cellMapping = new IntArray[nx * ny]; - if( get_grid_mapping(to_grid, cellMapping, var_index_array, - obs_data->obs_hids, hdr_lats, hdr_lons) ) { + cellMapping.clear(); + cellMapping.resize(nx * ny); + if( get_grid_mapping(to_grid, cellMapping.data(), var_index_array, + obs_data->obs_hids.data(), + hdr_lats.data(), hdr_lons.data()) ) { int from_index; IntArray cellArray; NumArray dataArray; @@ -1122,30 +1128,35 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI << ", obs_count_non_zero_to: " << obs_count_non_zero_to << "\n"; ConcatString log_msg; - log_msg << "Filtered by time: " << filtered_by_time; + int filtered_count = filtered_by_msg_type + filtered_by_qc + filtered_by_time; + log_msg << "Filtered " << filtered_count << " of " << var_count2 + << " observations by time: " << filtered_by_time; if (0 < requested_valid_time) { log_msg << " [" << unix_to_yyyymmdd_hhmmss(requested_valid_time) << "]"; } - log_msg << ", by msg_type: " << filtered_by_msg_type; + log_msg << ", by message type: " << filtered_by_msg_type; if (0 < filtered_by_msg_type) { - log_msg << " ["; - for(int idx=0; idx 0) log_msg << ","; - log_msg << conf_info.message_type[idx]; - } - log_msg << "]"; + log_msg << " [" << write_css(conf_info.message_type) << "]"; } - log_msg << ", by QC: " << filtered_by_qc; + log_msg << ", and by QC: " << filtered_by_qc; if (0 < filtered_by_qc) { - log_msg << " ["; - for(int idx=0; idx 0) log_msg << ","; - log_msg << qc_flags[idx]; + if (0 < qc_flags.n()) { + log_msg << " [-qc " + << write_css(qc_flags) + << "]"; + } + if (0 < conf_info.obs_qty_inc.n()) { + log_msg << " [obs_quality_inc = " + << write_css(conf_info.obs_qty_inc) + << "]"; + } + if (0 < conf_info.obs_qty_exc.n()) { + log_msg << " [obs_quality_exc = " + << write_css(conf_info.obs_qty_exc) + << "]"; } - log_msg << "]"; } - log_msg << ", out of " << var_count2; - int filtered_count = filtered_by_msg_type + filtered_by_qc + (int)requested_valid_time; + log_msg << "."; if (0 == var_count) { if (0 == filtered_count) { mlog << Warning << "\n" << method_name @@ -1155,24 +1166,17 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI else { mlog << Warning << "\n" << method_name << "No valid data after filtering.\n\t" - << log_msg << ".\n\n"; + << log_msg << "\n\n"; } } else { - mlog << Debug(2) << method_name << "var_count=" << var_count - << ", grid: " << to_count << " out of " << (nx * ny) << " " - << (0 < filtered_count ? log_msg.c_str() : " ") << "\n"; + mlog << Debug(3) << "Using " << var_count << " " + << vinfo->name() << " observations to populate " << to_count + << " of " << to_grid.nxy() << " grid points.\n"; + if (0 < filtered_count ) mlog << log_msg << "\n"; } } // end for i - if (cellMapping) { - clear_cell_mapping(cellMapping); - delete [] cellMapping; cellMapping = (IntArray *) nullptr; - } - - delete [] hdr_lats; - delete [] hdr_lons; - return; } @@ -1256,8 +1260,7 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, DataPlane fr_dp, to_dp; DataPlane cnt_dp, mask_dp; unixtime valid_beg_ut, valid_end_ut; - bool *skip_times = nullptr; - double *valid_times = nullptr; + vector skip_times; int filtered_by_time = 0; int time_from_size = 1; clock_t start_clock = clock(); @@ -1348,9 +1351,9 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, if( 1 < get_dim_count(&time_var) ) { double max_time = bad_data_double; time_from_size = get_data_size(&time_var); - skip_times = new bool[time_from_size]; - valid_times = new double[time_from_size]; - if (get_nc_data(&time_var, valid_times)) { + skip_times.resize(time_from_size, false); + vector valid_times(time_from_size, bad_data_double); + if (get_nc_data(&time_var, valid_times.data())) { int sec_per_unit = 0; bool no_leap_year = false; auto ref_ut = (unixtime) 0; @@ -1365,7 +1368,7 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, tmp_time = add_to_unixtime(ref_ut, sec_per_unit, valid_times[i], no_leap_year); skip_times[i] = (valid_beg_ut > tmp_time || tmp_time > valid_end_ut); - if( skip_times[i]) filtered_by_time++; + if( skip_times[i] ) filtered_by_time++; } else skip_times[i] = false; if (max_time < valid_times[i]) max_time = valid_times[i]; @@ -1376,17 +1379,16 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, else valid_time = find_valid_time(time_var); } to_dp.set_size(to_grid.nx(), to_grid.ny()); - IntArray *var_cell_mapping = nullptr; - auto cellMapping = new IntArray[to_grid.nx() * to_grid.ny()]; - get_grid_mapping(fr_grid, to_grid, cellMapping, var_lat, var_lon, skip_times); - if( skip_times ) delete [] skip_times; - if( valid_times ) delete [] valid_times; + vector var_cell_mapping; + vector cellMapping(to_grid.nx() * to_grid.ny()); + get_grid_mapping(fr_grid, to_grid, cellMapping.data(), var_lat, var_lon, skip_times); // Loop through the requested fields for(int i=0; iclear(); + var_cell_mapping.clear(); // Populate the VarInfo object using the config string config.read_string(FieldSA[i].c_str()); @@ -1415,8 +1417,8 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, else if (is_nc_unit_longitude(units.c_str())) v_lon = nc_var; } } - var_cell_mapping = new IntArray[to_grid.nx() * to_grid.ny()]; - get_grid_mapping(fr_grid, to_grid, var_cell_mapping, v_lat, v_lon, skip_times); + var_cell_mapping.resize(to_grid.nx() * to_grid.ny()); + get_grid_mapping(fr_grid, to_grid, var_cell_mapping.data(), v_lat, v_lon, skip_times); mlog << Debug(4) << method_name << "Override cell mapping from " << GET_NC_NAME(v_lat) << " and " << GET_NC_NAME(v_lon) << "\n"; } @@ -1427,7 +1429,9 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, to_dp.set_init(valid_time); to_dp.set_valid(valid_time); regrid_nc_variable(nc_in, fr_mtddf, vinfo, fr_dp, to_dp, to_grid, - (nullptr != var_cell_mapping ? var_cell_mapping: cellMapping)); + (var_cell_mapping.size() > 0 ? + var_cell_mapping.data() : + cellMapping.data())); // List range of data values if(mlog.verbosity_level() >= 2) { @@ -1494,19 +1498,10 @@ static void process_point_nccf_file(NcFile *nc_in, MetConfig &config, } } - if (nullptr != var_cell_mapping) { - clear_cell_mapping(var_cell_mapping); - delete [] var_cell_mapping; - var_cell_mapping = nullptr; - } - } // end for i - clear_cell_mapping(cellMapping); - delete [] cellMapping; - cellMapping = (IntArray *) nullptr; if( 0 < filtered_by_time ) { - mlog << Debug(2) << method_name << "Filtered by time: " << filtered_by_time + mlog << Debug(3) << method_name << "Filtered by time: " << filtered_by_time << " out of " << time_from_size << " [" << unix_to_yyyymmdd_hhmmss(valid_beg_ut) << " to " << unix_to_yyyymmdd_hhmmss(valid_end_ut) << "]\n"; @@ -1551,7 +1546,7 @@ static void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, int from_data_size = from_lat_count * from_lon_count; bool is_to_north = !fr_grid.get_swap_to_north(); - auto from_data = new float[from_data_size]; + vector from_data(from_data_size, bad_data_float); for (int xIdx=0; xIdx data(grid.nx()*grid.ny(), bad_data_float); // Store the data int grid_nx = grid.nx(); @@ -1706,15 +1699,12 @@ void write_nc_data(const DataPlane &dp, const Grid &grid, NcVar *data_var) { } // end for x // Write out the data - if(!put_nc_data_with_dims(data_var, &data[0], grid.ny(), grid.nx())) { + if(!put_nc_data_with_dims(data_var, &data.data()[0], grid.ny(), grid.nx())) { mlog << Error << "\nwrite_nc_data() -> " << "error writing data to the output file.\n\n"; exit(1); } - // Clean up - if(data) { delete [] data; data = (float *) nullptr; } - return; } @@ -1723,7 +1713,7 @@ void write_nc_data(const DataPlane &dp, const Grid &grid, NcVar *data_var) { void write_nc_data_int(const DataPlane &dp, const Grid &grid, NcVar *data_var) { // Allocate memory to store data values for each grid point - auto data = new int [grid.nx()*grid.ny()]; + vector data(grid.nx()*grid.ny(), bad_data_int); // Store the data int grid_nx = grid.nx(); @@ -1736,15 +1726,12 @@ void write_nc_data_int(const DataPlane &dp, const Grid &grid, NcVar *data_var) { } // end for x // Write out the data - if(!put_nc_data_with_dims(data_var, &data[0], grid.ny(), grid.nx())) { + if(!put_nc_data_with_dims(data_var, &data.data()[0], grid.ny(), grid.nx())) { mlog << Error << "\nwrite_nc_data_int() -> " << "error writing data to the output file.\n\n"; exit(1); } - // Clean up - if(data) { delete [] data; data = (int *) nullptr; } - return; } @@ -1792,11 +1779,10 @@ static void write_nc_int(const DataPlane &dp, const Grid &grid, return; } -// //////////////////////////////////////////////////////////////////////// +// // GOES related modules // - //////////////////////////////////////////////////////////////////////// static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, @@ -1830,8 +1816,8 @@ static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, NcVar time_var = get_nc_var_time(nc_in); unixtime valid_time = find_valid_time(time_var); to_dp.set_size(to_grid.nx(), to_grid.ny()); - auto cellMapping = new IntArray[to_grid.nx() * to_grid.ny()]; - get_grid_mapping(fr_grid, to_grid, cellMapping, geostationary_file); + vector cellMapping(to_grid.nx() * to_grid.ny()); + get_grid_mapping(fr_grid, to_grid, cellMapping.data(), geostationary_file); // Loop through the requested fields for(int i=0; i= 2) { @@ -1935,8 +1921,6 @@ static void process_goes_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo, } delete nc_adp; nc_adp = nullptr; - clear_cell_mapping(cellMapping); - delete [] cellMapping; cellMapping = (IntArray *) nullptr; mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " << get_exe_duration(start_clock) << " seconds\n"; @@ -2000,15 +1984,6 @@ GOES_QC compute_adp_qc_flag(int adp_qc, int shift_bits) { return adp_qc_flag; } - -//////////////////////////////////////////////////////////////////////// - -void clear_cell_mapping(IntArray *cell_mapping) { - if (nullptr != cell_mapping) { - for (int idx=0; idxn(); idx++) cell_mapping[idx].clear(); - } -} - //////////////////////////////////////////////////////////////////////// static unixtime compute_unixtime(NcVar *time_var, unixtime var_value) { @@ -2098,7 +2073,7 @@ static bool get_grid_mapping(const Grid &to_grid, IntArray *cellMapping, static void get_grid_mapping_latlon( DataPlane from_dp, DataPlane to_dp, Grid to_grid, IntArray *cellMapping, float *latitudes, float *longitudes, - int from_lat_count, int from_lon_count, bool *skip_times, bool to_north, bool is_2d) { + int from_lat_count, int from_lon_count, vector skip_times, bool to_north, bool is_2d) { double x; double y; double to_ll_lat; @@ -2111,10 +2086,8 @@ static void get_grid_mapping_latlon( int data_size = from_lat_count * from_lon_count; static const char *method_name = "get_grid_mapping_latlon(lats, lons) -> "; - auto to_cell_counts = new int[to_size]; - auto mapping_indices = new int[data_size]; - for (int xIdx=0; xIdx to_cell_counts(to_size, 0); + vector mapping_indices(data_size, bad_data_int); to_grid.xy_to_latlon(0, 0, to_ll_lat, to_ll_lon); mlog << Debug(5) << method_name << " to_grid ll corner: (" << to_ll_lon << ", " << to_ll_lat << ")\n"; @@ -2128,7 +2101,7 @@ static void get_grid_mapping_latlon( int coord_offset = from_dp.two_to_one(xIdx, yIdx, to_north); if (is_2d) { lon_offset = lat_offset = coord_offset; - if( skip_times != 0 && skip_times[coord_offset] ) continue; + if( skip_times.size() > 0 && skip_times[coord_offset] ) continue; } float lat = latitudes[lat_offset]; float lon = longitudes[lon_offset]; @@ -2190,8 +2163,6 @@ static void get_grid_mapping_latlon( } else cellMapping[to_offset].add(xIdx); } - delete [] to_cell_counts; - delete [] mapping_indices; mlog << Debug(3) << method_name << "within grid: " << count_in_grid << " out of " << data_size << " (" << 1.0*count_in_grid/data_size*100 << "%)\n"; @@ -2202,7 +2173,7 @@ static void get_grid_mapping_latlon( //////////////////////////////////////////////////////////////////////// static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray *cellMapping, - NcVar var_lat, NcVar var_lon, bool *skip_times) { + NcVar var_lat, NcVar var_lon, vector skip_times) { bool status = false; DataPlane from_dp; DataPlane to_dp; @@ -2246,14 +2217,14 @@ static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray int last_idx = data_size - 1; int lat_count = get_data_size(&var_lat); int lon_count = get_data_size(&var_lon); - auto latitudes = new float[lat_count]; - auto longitudes = new float[lon_count]; - status = get_nc_data(&var_lat, latitudes); - if( status ) status = get_nc_data(&var_lon, longitudes); + vector latitudes(lat_count, bad_data_float); + vector longitudes(lon_count, bad_data_float); + status = get_nc_data(&var_lat, latitudes.data()); + if( status ) status = get_nc_data(&var_lon, longitudes.data()); if( status ) { get_grid_mapping_latlon(from_dp, to_dp, to_grid, cellMapping, - latitudes, longitudes, from_lat_count, - from_lon_count, skip_times, + latitudes.data(), longitudes.data(), + from_lat_count, from_lon_count, skip_times, !fr_grid.get_swap_to_north(), (lon_count==data_size)); if (is_eq(latitudes[0], latitudes[last_idx]) || @@ -2264,8 +2235,6 @@ static bool get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray << longitudes[last_idx] << "\n\n"; } } - if( latitudes ) delete [] latitudes; - if( longitudes ) delete [] longitudes; } // if data_size > 0 mlog << Debug(LEVEL_FOR_PERFORMANCE) << method_name << "took " << get_exe_duration(start_clock) << " seconds\n"; @@ -2376,22 +2345,14 @@ static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray if (data_size > 0) { int lat_count = data_size; int lon_count = data_size; - auto latitudes = (float *)nullptr; - auto longitudes = (float *)nullptr; - auto latitudes_buf = (float *)nullptr; - auto longitudes_buf = (float *)nullptr; - int buff_size = data_size*sizeof(float); + float *latitudes = nullptr; + float *longitudes = nullptr; + vector latitudes_buf(data_size, bad_data_float); + vector longitudes_buf(data_size, bad_data_float); GoesImagerData grid_data; grid_data.reset(); if (has_coord_input) { - latitudes_buf = new float[data_size]; - longitudes_buf = new float[data_size]; - - latitudes = latitudes_buf; - longitudes = longitudes_buf; - memset(latitudes, 0, buff_size); - memset(longitudes, 0, buff_size); if (IS_VALID_NC_P(coord_nc_in)) { NcVar var_lat = get_nc_var(coord_nc_in, var_name_lat); @@ -2399,12 +2360,16 @@ static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray if (IS_VALID_NC(var_lat) && IS_VALID_NC(var_lon)) { lat_count = get_data_size(&var_lat); lon_count = get_data_size(&var_lon); + latitudes = latitudes_buf.data(); + longitudes = longitudes_buf.data(); get_nc_data(&var_lat, latitudes); get_nc_data(&var_lon, longitudes); } } else { FILE *pFile = met_fopen ( cur_coord_name.c_str(), "rb" ); + latitudes = latitudes_buf.data(); + longitudes = longitudes_buf.data(); (void) fread (latitudes,sizeof(latitudes[0]),data_size,pFile); (void) fread (longitudes,sizeof(longitudes[0]),data_size,pFile); fclose (pFile); @@ -2465,24 +2430,23 @@ static void get_grid_mapping(const Grid &fr_grid, const Grid &to_grid, IntArray latitudes, longitudes, grid_data); } } - if (nullptr == latitudes) { + if (latitudes == nullptr) { mlog << Error << "\n" << method_name << "Fail to get latitudes!\n\n"; } - else if (nullptr == longitudes) { + else if (longitudes == nullptr) { mlog << Error << "\n" << method_name << "Fail to get longitudes!\n\n"; } else { check_lat_lon(data_size, latitudes, longitudes); - get_grid_mapping_latlon(from_dp, to_dp, to_grid, cellMapping, latitudes, - longitudes, from_lat_count, from_lon_count, nullptr, + vector skip_times; + get_grid_mapping_latlon(from_dp, to_dp, to_grid, cellMapping, + latitudes, longitudes, + from_lat_count, from_lon_count, skip_times, !fr_grid.get_swap_to_north(), (lon_count==data_size)); } - if (latitudes_buf) delete [] latitudes_buf; - if (longitudes_buf) delete [] longitudes_buf; - grid_data.release(); } // if data_size > 0 @@ -2614,15 +2578,12 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, ConcatString goes_var_sub_name; ConcatString qc_var_name; uchar qc_value; - auto qc_data = new uchar[from_data_size]; - auto adp_data = new uchar[from_data_size]; - auto from_data = new float[from_data_size]; - auto adp_qc_data = new unsigned short[from_data_size]; + vector qc_data(from_data_size, -99); + vector adp_data(from_data_size, 1); + vector from_data(from_data_size, bad_data_float); + vector adp_qc_data(from_data_size, 255); static const char *method_name = "regrid_goes_variable() -> "; - // -99 is arbitrary number as invalid QC value - memset(qc_data, -99, from_data_size*sizeof(uchar)); - adp_qc_high = 3; /* 3 as baseline algorithm, 0 for enterprise algorithm */ adp_qc_medium = 1; /* 1 as baseline algorithm, 1 for enterprise algorithm */ adp_qc_low = 0; /* 0 as baseline algorithm, 2 for enterprise algorithm */ @@ -2637,8 +2598,6 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, auto actual_var_len = actual_var_name.length(); bool is_adp_variable = (0 != actual_var_name.compare(vinfo->name().c_str())); - memset(adp_data, 1, from_data_size*sizeof(uchar)); // Default: 1 = data present - memset(adp_qc_data, 255, from_data_size*sizeof(unsigned short)); if (is_adp_variable && IS_VALID_NC_P(nc_adp)) { is_dust_only = (0 == vinfo->name().comparecase((actual_var_len + 1), vname_dust.length(), vname_dust.c_str())); @@ -2649,13 +2608,13 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, else if (is_smoke_only) var_adp = get_goes_nc_var(nc_adp, vname_smoke); if (IS_VALID_NC(var_adp)) { - get_nc_data(&var_adp, adp_data, true); + get_nc_data(&var_adp, adp_data.data(), true); //ADP Smoke:ancillary_variables: ubyte DQF(y, x) if (get_att_value_string(&var_adp, (string)"ancillary_variables", qc_var_name)) { var_adp_qc = get_nc_var(nc_adp, qc_var_name.c_str()); if (IS_VALID_NC(var_adp_qc)) { - get_nc_data(&var_adp_qc, adp_qc_data); + get_nc_data(&var_adp_qc, adp_qc_data.data()); set_adp_gc_values(var_adp_qc); has_adp_qc_var = true; mlog << Debug(5) << method_name << "found QC var: " << qc_var_name @@ -2677,7 +2636,7 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, if (get_att_value_string(&var_data, (string)"ancillary_variables", qc_var_name)) { var_qc = get_nc_var(nc_in, qc_var_name.c_str()); if (IS_VALID_NC(var_qc)) { - get_nc_data(&var_qc, qc_data); + get_nc_data(&var_qc, qc_data.data()); has_qc_var = true; mlog << Debug(3) << method_name << "found QC var: " << qc_var_name << ".\n"; } @@ -2688,7 +2647,7 @@ static void regrid_goes_variable(NcFile *nc_in, const VarInfo *vinfo, } } - get_nc_data(&var_data, from_data); + get_nc_data(&var_data, from_data.data()); fr_dp.set_size(from_lon_count, from_lat_count); for (int xIdx=0; xIdx 15) { - mlog << Warning << "\nPointToGridConfInfo::process_config() -> " - << "the \"" << conf_key_quality_mark_thresh - << "\" entry (" << quality_mark_thresh - << ") should be set between 0 and 15.\n\n"; - } + // Conf: obs_quality_exc + obs_qty_exc = parse_conf_obs_qty_exc(&conf); return; } diff --git a/src/tools/other/point2grid/point2grid_conf_info.h b/src/tools/other/point2grid/point2grid_conf_info.h index 5b12b6166e..725099b89c 100644 --- a/src/tools/other/point2grid/point2grid_conf_info.h +++ b/src/tools/other/point2grid/point2grid_conf_info.h @@ -42,7 +42,8 @@ class PointToGridConfInfo { unixtime valid_time; // valid time int beg_ds; // Time range of observations to be retained, int end_ds; // Defined relative to the PrepBufr center time (seconds) - int quality_mark_thresh; // Quality marks to be retained + StringArray obs_qty_inc; // Quality mark strings to be included + StringArray obs_qty_exc; // Quality mark strings to be excluded ConcatString version; // Config file version PointToGridConfInfo();