From 43a11199c88c4ffdf949843a8865ec529f0ad1d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:52:36 -0600 Subject: [PATCH] Update develop-ref after dtcenter/MET#2987 (#2989) 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. * Spelling correction * Feature #2882 seeps qa (#2987) * Update seeps.h Change variable names to reduce ambiguity for interpretation and aid useability. * Update seeps.cc Pull through variable name changes and renaming of functions to aid legibility and clarity. Introduced some additional debug print statements. * Update grid-stat.rst Add documentation about the location of the gridded climatology files for SEEPS and which environment variable to use. * Replace read_seeps_scores() with get_seeps_climo_grid() * Manually merging Rachel's patch-1 changes. * Getting close to getting these seeps changes to compile. But it's failing in pair_data_point.cc * Per #2882, get branch feature_2882_seeps_qa compiling again. Recommend revisiting the volume of SEEPS-related Debug log messages and reducing them once its fully tested. * Per #2882, need to update the handling of the PPT24_seepsweights_grid.nc file name. Rename as _v12.0.nc for the updated version with the new names so that the existing regressions tests and nightly builds for main_v11.1 and develop continue to work. We can remove the _v12.0 once this feature branch is merged into develop but for the time being, we need both versions to exist. * Per #2882, rename the SEEPS columns from S12, S13, S21, S23, S31, S32 to the more descriptive ODFL, ODFH, OLFD, OLFH, OHFD, OHFL names. * Per #2882, update SEEPS details * Per #2882, store and report the weighted mean fcst and mean obs, just like the SEEPS score itself so that they're handled in a consistent manner. Note however that it's hard-coded to NOT write the weighted means/score, only the unweighted ones. * Per #2882, change SEEPS debug log levels and correct the storage of mean_fcst and mean_obs values. * Per #2882, correct SEEPS column name lookups * Per #2882, call is_bad_data() instead of is_eq(..., -9999.0) to get rid of compiler warning message. * Per #2882, add 2 more variations of the is_eq() function with mixed float and double inputs to satisfy compiler pb2nc compiler warnings. * Per #2882, switch from dynamically allocated arrays to std::vector * Per #2882, enhance Stat-Analysis to write the SEEPS line type to an output .stat file. * Per #2882, update the aggregated seeps computation to use better-initialized vectors. * Per #2882, resolve a few more SonarQube code smells. * Per #2882, now that this PR is ready to merge, remove the v12.0 version number from the gridded SEEPS climo file name ci-skip-all --------- Co-authored-by: mpm-meto <64001904+mpm-meto@users.noreply.github.com> * Hotfix to the develop branch for unit_grid_stat.xml to use the updated gridded seeps climo file name. --------- 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: mpm-meto <64001904+mpm-meto@users.noreply.github.com> Co-authored-by: metplus-bot <97135045+metplus-bot@users.noreply.github.com> --- data/table_files/met_header_columns_V12.0.txt | 2 +- docs/Users_Guide/config_options.rst | 2 +- docs/Users_Guide/grid-stat.rst | 2 + docs/Users_Guide/point-stat.rst | 44 +- internal/test_unit/hdr/met_12_0.hdr | 2 +- src/basic/vx_util/stat_column_defs.h | 6 +- src/libcode/vx_analysis_util/stat_job.cc | 2 + src/libcode/vx_seeps/seeps.cc | 443 ++++++++++-------- src/libcode/vx_seeps/seeps.h | 109 ++--- src/libcode/vx_stat_out/stat_columns.cc | 71 +-- src/libcode/vx_statistics/compute_stats.cc | 335 ++++++++----- src/libcode/vx_statistics/pair_data_point.cc | 19 +- .../core/stat_analysis/parse_stat_line.cc | 23 +- 13 files changed, 622 insertions(+), 438 deletions(-) diff --git a/data/table_files/met_header_columns_V12.0.txt b/data/table_files/met_header_columns_V12.0.txt index 5a7f27978e..3f4785edf5 100644 --- a/data/table_files/met_header_columns_V12.0.txt +++ b/data/table_files/met_header_columns_V12.0.txt @@ -6,7 +6,7 @@ V12.0 : STAT : ISC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID V12.0 : STAT : MCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL (N_CAT) F[0-9]*_O[0-9]* EC_VALUE V12.0 : STAT : MCTS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL N_CAT ACC ACC_NCL ACC_NCU ACC_BCL ACC_BCU HK HK_BCL HK_BCU HSS HSS_BCL HSS_BCU GER GER_BCL GER_BCU HSS_EC HSS_EC_BCL HSS_EC_BCU EC_VALUE V12.0 : STAT : MPR : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL INDEX OBS_SID OBS_LAT OBS_LON OBS_LVL OBS_ELV FCST OBS OBS_QC OBS_CLIMO_MEAN OBS_CLIMO_STDEV OBS_CLIMO_CDF FCST_CLIMO_MEAN FCST_CLIMO_STDEV -V12.0 : STAT : SEEPS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL S12 S13 S21 S23 S31 S32 PF1 PF2 PF3 PV1 PV2 PV3 MEAN_FCST MEAN_OBS SEEPS +V12.0 : STAT : SEEPS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL ODFL ODFH OLFD OLFH OHFD OHFL PF1 PF2 PF3 PV1 PV2 PV3 MEAN_FCST MEAN_OBS SEEPS V12.0 : STAT : SEEPS_MPR : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE OBS_SID OBS_LAT OBS_LON FCST OBS OBS_QC FCST_CAT OBS_CAT P1 P2 T1 T2 SEEPS V12.0 : STAT : NBRCNT : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FBS FBS_BCL FBS_BCU FSS FSS_BCL FSS_BCU AFSS AFSS_BCL AFSS_BCU UFSS UFSS_BCL UFSS_BCU F_RATE F_RATE_BCL F_RATE_BCU O_RATE O_RATE_BCL O_RATE_BCU V12.0 : STAT : NBRCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FY_OY FY_ON FN_OY FN_ON diff --git a/docs/Users_Guide/config_options.rst b/docs/Users_Guide/config_options.rst index 49885c3a9d..c9a2ba01f6 100644 --- a/docs/Users_Guide/config_options.rst +++ b/docs/Users_Guide/config_options.rst @@ -660,7 +660,7 @@ used. .. code-block:: none - mesage_type_group_map = [ + message_type_group_map = [ { key = "SURFACE"; val = "ADPSFC,SFCSHP,MSONET"; }, { key = "ANYAIR"; val = "AIRCAR,AIRCFT"; }, { key = "ANYSFC"; val = "ADPSFC,SFCSHP,ADPUPA,PROFLR,MSONET"; }, diff --git a/docs/Users_Guide/grid-stat.rst b/docs/Users_Guide/grid-stat.rst index cac539e497..b10b1b3431 100644 --- a/docs/Users_Guide/grid-stat.rst +++ b/docs/Users_Guide/grid-stat.rst @@ -80,6 +80,8 @@ The Stable Equitable Error in Probability Space (SEEPS) was devised for monitori The capability to calculate the SEEPS has also been added to Grid-Stat. This follows the method described in :ref:`North et al, 2022 `, which uses the TRMM 3B42 v7 gridded satellite product for the climatological values and interpolates the forecast and observed products onto this grid for evaluation. A 24-hour TRMM climatology (valid at 00 UTC) constructed from data over the time period 1998-2015 is supplied with the release. Expansion of the capability to other fields will occur as well vetted examples and funding allow. +The gridded climatology required to compute SEEPS is not distributed as part of the code release and can be downloaded from `Zenodo `. The path to the file needs to be specified using MET_SEEPS_GRID_CLIMO_NAME. + Fourier Decomposition --------------------- diff --git a/docs/Users_Guide/point-stat.rst b/docs/Users_Guide/point-stat.rst index d6de2d32b1..73b7ce9a33 100644 --- a/docs/Users_Guide/point-stat.rst +++ b/docs/Users_Guide/point-stat.rst @@ -1549,10 +1549,10 @@ The first set of header columns are common to all of the output files generated - Quality control flag for observation * - 31 - FCST_CAT - - Forecast category to 3 by 3 matrix + - Forecast category (dry, light, or heavy) * - 32 - OBS_CAT - - Observationtegory to 3 by 3 matrix + - Observation category (dry, light, or heavy) * - 33 - P1 - Climo-derived probability value for this station (dry) @@ -1561,10 +1561,10 @@ The first set of header columns are common to all of the output files generated - Climo-derived probability value for this station (dry + light) * - 35 - T1 - - Threshold 1 for p1 + - Threshold 1 for P1 (dry) * - 36 - T2 - - Threshold 2 for p2 + - Threshold 2 for P2 (dry + light) * - 37 - SEEPS - SEEPS (Stable Equitable Error in Probability Space) score @@ -1589,41 +1589,41 @@ The first set of header columns are common to all of the output files generated - TOTAL - Total number of SEEPS matched pairs * - 26 - - S12 - - Counts multiplied by the weights for FCST_CAT 1 and OBS_CAT 2 + - ODFL + - Counts multiplied by the weights for the observation dry, forecast light category * - 27 - - S13 - - Counts multiplied by the weights for FCST_CAT 1 and OBS_CAT 3 + - ODFH + - Counts multiplied by the weights for the observation dry, forecast heavy category * - 28 - - S21 - - Counts multiplied by the weights for FCST_CAT 2 and OBS_CAT 1 + - OLFD + - Counts multiplied by the weights for the observation light, forecast dry category * - 29 - - S23 - - Counts multiplied by the weights for FCST_CAT 2 and OBS_CAT 3 + - OLFH + - Counts multiplied by the weights for the observation light, forecast heavy category * - 30 - - S31 - - Counts multiplied by the weights for FCST_CAT 3 and OBS_CAT 1 + - OHFD + - Counts multiplied by the weights for the observation heavy, forecast dry category * - 31 - - S32 - - Counts multiplied by the weights for FCST_CAT 3 and OBS_CAT 2 + - OHFL + - Counts multiplied by the weights for the observation heavy, forecast light category * - 32 - PF1 - - marginal probabilities of the forecast values (FCST_CAT 1) + - Marginal probabilities of the forecast dry (FCST_CAT 0) * - 33 - PF2 - - marginal probabilities of the forecast values (FCST_CAT 2) + - Marginal probabilities of the forecast light (FCST_CAT 1) * - 34 - PF3 - - marginal probabilities of the forecast values (FCST_CAT 3) + - Marginal probabilities of the forecast heavy (FCST_CAT 2) * - 35 - PV1 - - marginal probabilities of the observed values (OBS_CAT 1) + - Marginal probabilities of the observed dry (OBS_CAT 0) * - 36 - PV2 - - marginal probabilities of the observed values (OBS_CAT 2) + - Marginal probabilities of the observed light (OBS_CAT 1) * - 37 - PV3 - - marginal probabilities of the observed values (OBS_CAT 3) + - Marginal probabilities of the observed heavy (OBS_CAT 2) * - 38 - SEEPS - Averaged SEEPS (Stable Equitable Error in Probability Space) score diff --git a/internal/test_unit/hdr/met_12_0.hdr b/internal/test_unit/hdr/met_12_0.hdr index f3785b7b48..f8655a4a47 100644 --- a/internal/test_unit/hdr/met_12_0.hdr +++ b/internal/test_unit/hdr/met_12_0.hdr @@ -6,7 +6,7 @@ ISC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_L MCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL N_CAT _VAR_ MCTS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL N_CAT ACC ACC_NCL ACC_NCU ACC_BCL ACC_BCU HK HK_BCL HK_BCU HSS HSS_BCL HSS_BCU GER GER_BCL GER_BCU HSS_EC HSS_EC_BCL HSS_EC_BCU EC_VALUE MPR : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL INDEX OBS_SID OBS_LAT OBS_LON OBS_LVL OBS_ELV FCST OBS OBS_QC OBS_CLIMO_MEAN OBS_CLIMO_STDEV OBS_CLIMO_CDF FCST_CLIMO_MEAN FCST_CLIMO_STDEV -SEEPS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL S12 S13 S21 S23 S31 S32 PF1 PF2 PF3 PV1 PV2 PV3 MEAN_FCST MEAN_OBS SEEPS +SEEPS : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL ODFL ODFH OLFD OLFH OHFD OHFL PF1 PF2 PF3 PV1 PV2 PV3 MEAN_FCST MEAN_OBS SEEPS SEEPS_MPR : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE OBS_SID OBS_LAT OBS_LON FCST OBS OBS_QC FCST_CAT OBS_CAT P1 P2 T1 T2 SEEPS NBRCNT : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FBS FBS_BCL FBS_BCU FSS FSS_BCL FSS_BCU AFSS AFSS_BCL AFSS_BCU UFSS UFSS_BCL UFSS_BCU F_RATE F_RATE_BCL F_RATE_BCU O_RATE O_RATE_BCL O_RATE_BCU NBRCTC : VERSION MODEL DESC FCST_LEAD FCST_VALID_BEG FCST_VALID_END OBS_LEAD OBS_VALID_BEG OBS_VALID_END FCST_VAR FCST_UNITS FCST_LEV OBS_VAR OBS_UNITS OBS_LEV OBTYPE VX_MASK INTERP_MTHD INTERP_PNTS FCST_THRESH OBS_THRESH COV_THRESH ALPHA LINE_TYPE TOTAL FY_OY FY_ON FN_OY FN_ON diff --git a/src/basic/vx_util/stat_column_defs.h b/src/basic/vx_util/stat_column_defs.h index a7b5427143..984ef3c40b 100644 --- a/src/basic/vx_util/stat_column_defs.h +++ b/src/basic/vx_util/stat_column_defs.h @@ -383,9 +383,9 @@ static const char * const seeps_mpr_columns [] = { }; static const char * const seeps_columns [] = { - "TOTAL", "S12", "S13", - "S21", "S23", "S31", - "S32", "PF1", "PF2", + "TOTAL", "ODFL", "ODFH", + "OLFD", "OLFH", "OHFD", + "OHFL", "PF1", "PF2", "PF3", "PV1", "PV2", "PV3", "MEAN_FCST", "MEAN_OBS", "SEEPS" diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 0552bc6d49..c10f392b85 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -1994,6 +1994,7 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { case STATLineType::prc: c = get_n_prc_columns(n); break; case STATLineType::eclv: c = get_n_eclv_columns(n); break; case STATLineType::mpr: c = n_mpr_columns; break; + case STATLineType::seeps: c = n_seeps_columns; break; case STATLineType::nbrctc: c = n_nbrctc_columns; break; case STATLineType::nbrcts: c = n_nbrcts_columns; break; case STATLineType::nbrcnt: c = n_nbrcnt_columns; break; @@ -2065,6 +2066,7 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { case STATLineType::prc: write_prc_header_row (1, n, stat_at, 0, 0); break; case STATLineType::eclv: write_eclv_header_row (1, n, stat_at, 0, 0); break; case STATLineType::mpr: write_header_row (mpr_columns, n_mpr_columns, 1, stat_at, 0, 0); break; + case STATLineType::seeps: write_header_row (seeps_columns, n_seeps_columns, 1, stat_at, 0, 0); break; case STATLineType::nbrctc: write_header_row (nbrctc_columns, n_nbrctc_columns, 1, stat_at, 0, 0); break; case STATLineType::nbrcts: write_header_row (nbrcts_columns, n_nbrcts_columns, 1, stat_at, 0, 0); break; case STATLineType::nbrcnt: write_header_row (nbrcnt_columns, n_nbrcnt_columns, 1, stat_at, 0, 0); break; diff --git a/src/libcode/vx_seeps/seeps.cc b/src/libcode/vx_seeps/seeps.cc index 4204f59370..a2d5184ec6 100644 --- a/src/libcode/vx_seeps/seeps.cc +++ b/src/libcode/vx_seeps/seeps.cc @@ -50,7 +50,7 @@ double weighted_average(double, double, double, double); //////////////////////////////////////////////////////////////////////// -SeepsClimo *get_seeps_climo(ConcatString seeps_point_climo_name) { +SeepsClimo *get_seeps_climo(const ConcatString &seeps_point_climo_name) { if (! seeps_climo) seeps_climo = new SeepsClimo(seeps_point_climo_name); return seeps_climo; } @@ -63,7 +63,7 @@ void release_seeps_climo() { //////////////////////////////////////////////////////////////////////// -SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour) { +SeepsClimoGrid *get_seeps_climo_grid(int month, const ConcatString &seeps_grid_climo_name, int hour) { if (seeps_climo_grid_map_00.count(month) == 0) { seeps_climo_grid_map_00[month] = nullptr; @@ -96,19 +96,25 @@ double weighted_average(double v1, double w1, double v2, double w2) { void SeepsAggScore::clear() { + // Syntax used to define SEEPS obs/fcast categories (s_* or c_*) + // o{d|l|h} : obs in {dry(0)|light(1)|heavy(2)} category + // f{d|l|h} : fcsts in {dry(0)|light(1)|heavy(2)} category + n_obs = 0; - c12 = c13 = c21 = c23 = c31 = c32 = 0; - s12 = s13 = s21 = s23 = s31 = s32 = 0.; - pv1 = pv2 = pv3 = 0.; - pf1 = pf2 = pf3 = 0.; - mean_fcst = mean_obs = bad_data_double; - weighted_score = score = bad_data_double; + c_odfl = c_odfh = c_olfd = c_olfh = c_ohfd = c_ohfl = 0; + s_odfl = s_odfh = s_olfd = s_olfh = s_ohfd = s_ohfl = 0.0; + pv1 = pv2 = pv3 = 0.0; + pf1 = pf2 = pf3 = 0.0; + mean_fcst = mean_fcst_wgt = bad_data_double; + mean_obs = mean_obs_wgt = bad_data_double; + score = score_wgt = bad_data_double; } //////////////////////////////////////////////////////////////////////// SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { + const char *method_name = "SeepsAggScore::operator+=() -> "; // Check for degenerate case if(n_obs == 0 && c.n_obs == 0) return *this; @@ -121,20 +127,23 @@ SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { n_obs += c.n_obs; // Increment counts - c12 += c.c12; - c13 += c.c13; - c21 += c.c21; - c23 += c.c23; - c31 += c.c31; - c32 += c.c32; - + c_odfl += c.c_odfl; + c_odfh += c.c_odfh; + c_olfd += c.c_olfd; + c_olfh += c.c_olfh; + c_ohfd += c.c_ohfd; + c_ohfl += c.c_ohfl; + // Compute weighted averages - s12 = weighted_average(s12, w1, c.s12, w2); - s13 = weighted_average(s13, w1, c.s13, w2); - s21 = weighted_average(s21, w1, c.s21, w2); - s23 = weighted_average(s23, w1, c.s23, w2); - s31 = weighted_average(s31, w1, c.s31, w2); - s32 = weighted_average(s32, w1, c.s32, w2); + s_odfl = weighted_average(s_odfl, w1, c.s_odfl, w2); + s_odfh = weighted_average(s_odfh, w1, c.s_odfh, w2); + s_olfd = weighted_average(s_olfd, w1, c.s_olfd, w2); + s_olfh = weighted_average(s_olfh, w1, c.s_olfh, w2); + s_ohfd = weighted_average(s_ohfd, w1, c.s_ohfd, w2); + s_ohfl = weighted_average(s_ohfl, w1, c.s_ohfl, w2); + mlog << Debug(9) << method_name + << "s_odfl, o_odfh => " + << s_odfl << " " << s_odfh << "\n"; pv1 = weighted_average(pv1, w1, c.pv1, w2); pv2 = weighted_average(pv2, w1, c.pv2, w2); @@ -144,18 +153,21 @@ SeepsAggScore & SeepsAggScore::operator+=(const SeepsAggScore &c) { pf2 = weighted_average(pf2, w1, c.pf2, w2); pf3 = weighted_average(pf3, w1, c.pf3, w2); - mean_fcst = weighted_average(mean_fcst, w1, c.mean_fcst, w2); - mean_obs = weighted_average(mean_obs, w1, c.mean_obs, w2); + mean_fcst = weighted_average(mean_fcst, w1, c.mean_fcst, w2); + mean_fcst_wgt = weighted_average(mean_fcst_wgt, w1, c.mean_fcst_wgt, w2); - score = weighted_average(score, w1, c.score, w2); - weighted_score = weighted_average(weighted_score, w1, c.weighted_score, w2); + mean_obs = weighted_average(mean_obs, w1, c.mean_obs, w2); + mean_obs_wgt = weighted_average(mean_obs_wgt, w1, c.mean_obs_wgt, w2); + + score = weighted_average(score, w1, c.score, w2); + score_wgt = weighted_average(score_wgt, w1, c.score_wgt, w2); return *this; } //////////////////////////////////////////////////////////////////////// -SeepsClimoBase::SeepsClimoBase(ConcatString seeps_climo_name) : climo_file_name{seeps_climo_name} { +SeepsClimoBase::SeepsClimoBase(const ConcatString &seeps_climo_name) : climo_file_name{seeps_climo_name} { clear(); seeps_ready = false; @@ -192,7 +204,8 @@ ConcatString SeepsClimoBase::get_climo_filename() { seeps_ready = file_exists(seeps_filename.c_str()); if (seeps_ready) { - mlog << Debug(7) << method_name << "SEEPS climo name=\"" + mlog << Debug(7) << method_name + << "SEEPS climo name=\"" << seeps_filename.c_str() << "\"\n"; } else { @@ -229,11 +242,11 @@ void SeepsClimoBase::set_p1_thresh(const SingleThresh &p1_thresh) { //////////////////////////////////////////////////////////////////////// -SeepsClimo::SeepsClimo(ConcatString seeps_climo_name) : SeepsClimoBase{seeps_climo_name} { +SeepsClimo::SeepsClimo(const ConcatString &seeps_climo_name) : SeepsClimoBase{seeps_climo_name} { clear(); ConcatString seeps_name = get_climo_filename(); - if (file_exists(seeps_name.c_str())) read_seeps_scores(seeps_name); + if (file_exists(seeps_name.c_str())) read_seeps_climo_grid(seeps_name); } @@ -268,13 +281,17 @@ SeepsClimoRecord *SeepsClimo::create_climo_record( double *p1, double *p2, double *t1, double *t2, double *scores) { int offset; SeepsClimoRecord *record = new SeepsClimoRecord(); + const char *method_name = "SeepsClimo::create_climo_record() -> "; record->sid = sid; record->lat = lat; record->lon = lon; record->elv = elv; if (standalone_debug_seeps && SAMPLE_STATION_ID == sid) { - cout << " sid=" << sid << ", lat=" << lat << ", lon=" << lon << ", elv=" << elv << "\n"; + cout << method_name + << "sid=" << sid << ", lat=" << lat + << ", lon=" << lon << ", elv=" << elv + << "\n"; } for (int idx=0; idxp1[idx] = p1[idx]; @@ -283,7 +300,8 @@ SeepsClimoRecord *SeepsClimo::create_climo_record( record->t2[idx] = t2[idx]; if (standalone_debug_seeps && SAMPLE_STATION_ID == sid) { - cout << str_format("\t%2d: %6.3f %6.3f %6.3f %6.3f ", + cout << method_name + << str_format("\t%2d: %6.3f %6.3f %6.3f %6.3f ", (idx+1), record->p1[idx], record->p2[idx], record->t1[idx], record->t2[idx]); } @@ -291,7 +309,8 @@ SeepsClimoRecord *SeepsClimo::create_climo_record( offset = idx*SEEPS_MATRIX_SIZE + idx_m; record->scores[idx][idx_m] = scores[offset]; if (standalone_debug_seeps && SAMPLE_STATION_ID == sid) { - cout << str_format(" %.3f", record->scores[idx][idx_m]); + cout << method_name + << str_format(" %.3f", record->scores[idx][idx_m]); } } if (standalone_debug_seeps && SAMPLE_STATION_ID == sid) cout << "\n"; @@ -330,14 +349,24 @@ SeepsRecord *SeepsClimo::get_record(int sid, int month, int hour) { record->p2 = climo_record->p2[month-1]; record->t1 = climo_record->t1[month-1]; record->t2 = climo_record->t2[month-1]; + mlog << Debug(9) << method_name + << "record info: sid, lat, lon, month, p1, p2, t1, t2 => " + << record->sid << " " << record->lat << " " + << record->lon << " " << record->month << " " + << record->p1 << " " << record->p2 << " " + << record->t1 << " " << record->t2 << "\n"; for (int idx=0; idxscores[idx] = climo_record->scores[month-1][idx]; + record->scores[idx] = climo_record->scores[month-1][idx]; + mlog << Debug(7) << method_name + << "record info (SEEPS matrix): score => " + << record->scores[idx] << "\n"; } } else if (!is_eq(p1, bad_data_double)) { increase_filtered_count(); - mlog << Debug(7) << method_name << " filtered by threshold p1=" - << climo_record->p1[month-1] <<"\n"; + mlog << Debug(7) << method_name + << "filtered by threshold p1=" + << climo_record->p1[month-1] << "\n"; } } } @@ -349,16 +378,21 @@ SeepsRecord *SeepsClimo::get_record(int sid, int month, int hour) { << "or disable output for SEEPS and SEEPS_MPR.\n\n"; exit(1); } + mlog << Debug(9) << method_name + << "sid = " << sid + << ", month = " << month << ", hour = " << hour + << ", filtered_count = " << get_filtered_count() << "\n"; return record; } //////////////////////////////////////////////////////////////////////// -double SeepsClimo::get_score(int sid, double p_fcst, double p_obs, - int month, int hour) { +double SeepsClimo::get_seeps_category(int sid, double p_fcst, double p_obs, + int month, int hour) { double score = bad_data_double; SeepsRecord *record = get_record(sid, month, hour); + const char *method_name = "SeepsClimo::get_seeps_category() -> "; if (nullptr != record) { // Determine location in contingency table @@ -366,6 +400,10 @@ double SeepsClimo::get_score(int sid, double p_fcst, double p_obs, int jc = (p_fcst>record->t1)+(p_fcst>record->t2); score = record->scores[(jc*3)+ic]; + mlog << Debug(9) << method_name + << "ic, jc, score => " + << ic << " " << jc << " " + << score << "\n"; delete record; } @@ -378,6 +416,7 @@ SeepsScore *SeepsClimo::get_seeps_score(int sid, double p_fcst, double p_obs, int month, int hour) { SeepsScore *score = nullptr; SeepsRecord *record = get_record(sid, month, hour); + const char *method_name = "SeepsClimo::get_seeps_score() -> "; if (nullptr != record) { score = new SeepsScore(); @@ -385,18 +424,27 @@ SeepsScore *SeepsClimo::get_seeps_score(int sid, double p_fcst, double p_obs, score->p2 = record->p2; score->t1 = record->t1; score->t2 = record->t2; - + mlog << Debug(9) << method_name + << "p1, p2, t1, t2 => " + << score->p1 << " " << score->p2 << " " + << score->t1 << " " << score->t2 + << "\n"; + score->obs_cat = (p_obs>record->t1)+(p_obs>record->t2); score->fcst_cat = (p_fcst>record->t1)+(p_fcst>record->t2); score->s_idx = (score->fcst_cat*3)+score->obs_cat; score->score = record->scores[score->s_idx]; + mlog << Debug(9) << method_name + << "obs_cat, fc_cat, s_idx, score => " + << score->obs_cat << " " << score->fcst_cat + << " " << score->s_idx << " " << score->score + << "\n"; delete record; } return score; } - //////////////////////////////////////////////////////////////////////// void SeepsClimo::print_all() { @@ -457,9 +505,9 @@ void SeepsClimo::print_record(SeepsRecord *record, bool with_header) { //////////////////////////////////////////////////////////////////////// -void SeepsClimo::read_seeps_scores(ConcatString filename) { +void SeepsClimo::read_seeps_climo_grid(const ConcatString &filename) { clock_t clock_time = clock(); - const char *method_name = "SeepsClimo::read_records() -> "; + const char *method_name = "SeepsClimo::read_seeps_climo_grid() -> "; try { double p1_00_buf[SEEPS_MONTH]; @@ -478,23 +526,27 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { // dimensions: month = 12 ; nstn = 5293 ; nmatrix = 9 ; get_dim(nc_file, dim_name_nstn, nstn, true); - mlog << Debug(6) << method_name << "dimensions nstn = " << nstn << "\n"; - if (standalone_debug_seeps) cout << "dimensions nstn = " << nstn << "\n"; - - int *sid_array = new int[nstn]; - double *lat_array = new double[nstn]; - double *lon_array = new double[nstn]; - double *elv_array = new double[nstn]; - double *p1_00_array = new double[nstn*SEEPS_MONTH]; - double *p2_00_array = new double[nstn*SEEPS_MONTH]; - double *t1_00_array = new double[nstn*SEEPS_MONTH]; - double *t2_00_array = new double[nstn*SEEPS_MONTH]; - double *p1_12_array = new double[nstn*SEEPS_MONTH]; - double *p2_12_array = new double[nstn*SEEPS_MONTH]; - double *t1_12_array = new double[nstn*SEEPS_MONTH]; - double *t2_12_array = new double[nstn*SEEPS_MONTH]; - double *matrix_00_array = new double[nstn*SEEPS_MONTH*SEEPS_MATRIX_SIZE]; - double *matrix_12_array = new double[nstn*SEEPS_MONTH*SEEPS_MATRIX_SIZE]; + mlog << Debug(6) << method_name + << "dimensions nstn = " << nstn << "\n"; + if (standalone_debug_seeps) { + cout << method_name + << "dimensions nstn = " << nstn << "\n"; + } + + vector sid_array(nstn); + vector lat_array(nstn); + vector lon_array(nstn); + vector elv_array(nstn); + vector p1_00_array(nstn*SEEPS_MONTH); + vector p2_00_array(nstn*SEEPS_MONTH); + vector t1_00_array(nstn*SEEPS_MONTH); + vector t2_00_array(nstn*SEEPS_MONTH); + vector p1_12_array(nstn*SEEPS_MONTH); + vector p2_12_array(nstn*SEEPS_MONTH); + vector t1_12_array(nstn*SEEPS_MONTH); + vector t2_12_array(nstn*SEEPS_MONTH); + vector matrix_00_array(nstn*SEEPS_MONTH*SEEPS_MATRIX_SIZE); + vector matrix_12_array(nstn*SEEPS_MONTH*SEEPS_MATRIX_SIZE); NcVar var_sid = get_nc_var(nc_file, var_name_sid); NcVar var_lat = get_nc_var(nc_file, var_name_lat); @@ -511,72 +563,72 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { NcVar var_matrix_00 = get_nc_var(nc_file, var_name_matrix_00); NcVar var_matrix_12 = get_nc_var(nc_file, var_name_matrix_12); - if (IS_INVALID_NC(var_sid) || !get_nc_data(&var_sid, sid_array)) { + if (IS_INVALID_NC(var_sid) || !get_nc_data(&var_sid, sid_array.data())) { mlog << Error << "\n" << method_name << "Did not get sid\n\n"; exit(1); } - if (IS_INVALID_NC(var_lat) || !get_nc_data(&var_lat, lat_array)) { + if (IS_INVALID_NC(var_lat) || !get_nc_data(&var_lat, lat_array.data())) { mlog << Error << "\n" << method_name << "Did not get lat\n\n"; exit(1); } - if (IS_INVALID_NC(var_lon) || !get_nc_data(&var_lon, lon_array)) { + if (IS_INVALID_NC(var_lon) || !get_nc_data(&var_lon, lon_array.data())) { mlog << Error << "\n" << method_name << "Did not get lon\n\n"; exit(1); } - if (IS_INVALID_NC(var_elv) || !get_nc_data(&var_elv, elv_array)) { + if (IS_INVALID_NC(var_elv) || !get_nc_data(&var_elv, elv_array.data())) { mlog << Error << "\n" << method_name << "Did not get elv\n\n"; exit(1); } - if (IS_INVALID_NC(var_p1_00) || !get_nc_data(&var_p1_00, p1_00_array)) { + if (IS_INVALID_NC(var_p1_00) || !get_nc_data(&var_p1_00, p1_00_array.data())) { mlog << Error << "\n" << method_name << "Did not get p1_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_p2_00) || !get_nc_data(&var_p2_00, p2_00_array)) { + if (IS_INVALID_NC(var_p2_00) || !get_nc_data(&var_p2_00, p2_00_array.data())) { mlog << Error << "\n" << method_name << "Did not get p2_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_t1_00) || !get_nc_data(&var_t1_00, t1_00_array)) { + if (IS_INVALID_NC(var_t1_00) || !get_nc_data(&var_t1_00, t1_00_array.data())) { mlog << Error << "\n" << method_name << "Did not get t1_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_t2_00) || !get_nc_data(&var_t2_00, t2_00_array)) { + if (IS_INVALID_NC(var_t2_00) || !get_nc_data(&var_t2_00, t2_00_array.data())) { mlog << Error << "\n" << method_name << "Did not get t2_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_p1_12) || !get_nc_data(&var_p1_12, p1_12_array)) { + if (IS_INVALID_NC(var_p1_12) || !get_nc_data(&var_p1_12, p1_12_array.data())) { mlog << Error << "\n" << method_name << "Did not get p1_12\n\n"; exit(1); } - if (IS_INVALID_NC(var_p2_12) || !get_nc_data(&var_p2_12, p2_12_array)) { + if (IS_INVALID_NC(var_p2_12) || !get_nc_data(&var_p2_12, p2_12_array.data())) { mlog << Error << "\n" << method_name << "Did not get p2_12\n\n"; exit(1); } - if (IS_INVALID_NC(var_t1_12) || !get_nc_data(&var_t1_12, t1_12_array)) { + if (IS_INVALID_NC(var_t1_12) || !get_nc_data(&var_t1_12, t1_12_array.data())) { mlog << Error << "\n" << method_name << "Did not get t1_12\n\n"; exit(1); } - if (IS_INVALID_NC(var_t2_12) || !get_nc_data(&var_t2_12, t2_12_array)) { + if (IS_INVALID_NC(var_t2_12) || !get_nc_data(&var_t2_12, t2_12_array.data())) { mlog << Error << "\n" << method_name << "Did not get t2_12\n\n"; exit(1); } - if (IS_INVALID_NC(var_matrix_00) || !get_nc_data(&var_matrix_00, matrix_00_array)) { + if (IS_INVALID_NC(var_matrix_00) || !get_nc_data(&var_matrix_00, matrix_00_array.data())) { mlog << Error << "\n" << method_name << "Did not get matrix_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_matrix_12) || !get_nc_data(&var_matrix_12, matrix_12_array)) { + if (IS_INVALID_NC(var_matrix_12) || !get_nc_data(&var_matrix_12, matrix_12_array.data())) { mlog << Error << "\n" << method_name << "Did not get matrix_12\n\n"; exit(1); @@ -611,26 +663,15 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { seeps_score_12_map[sid] = rec_12; } - if (sid_array) delete [] sid_array; - if (lat_array) delete [] lat_array; - if (lon_array) delete [] lon_array; - if (elv_array) delete [] elv_array; - if (p1_00_array) delete [] p1_00_array; - if (p2_00_array) delete [] p2_00_array; - if (t1_00_array) delete [] t1_00_array; - if (t2_00_array) delete [] t2_00_array; - if (p1_12_array) delete [] p1_12_array; - if (p2_12_array) delete [] p2_12_array; - if (t1_12_array) delete [] t1_12_array; - if (t2_12_array) delete [] t2_12_array; - if (matrix_00_array) delete [] matrix_00_array; - if (matrix_12_array) delete [] matrix_12_array; - nc_file->close(); float duration = (float)(clock() - clock_time)/CLOCKS_PER_SEC; - mlog << Debug(6) << method_name << "took " << duration << " seconds\n"; - if (standalone_debug_seeps) cout << method_name << "took " << duration << " seconds\n"; + mlog << Debug(6) << method_name + << "took " << duration << " seconds\n"; + if (standalone_debug_seeps) { + cout << method_name + << "took " << duration << " seconds\n"; + } } catch(int i_err) { @@ -645,12 +686,13 @@ void SeepsClimo::read_seeps_scores(ConcatString filename) { //////////////////////////////////////////////////////////////////////// -SeepsClimoGrid::SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name) +SeepsClimoGrid::SeepsClimoGrid(int month, int hour, const ConcatString &seeps_climo_name) : month{month}, hour{hour}, SeepsClimoBase{seeps_climo_name} { - init_from_scratch(); + clear(); + ConcatString seeps_name = get_climo_filename(); - if (file_exists(seeps_name.c_str())) read_seeps_scores(seeps_name); + if (file_exists(seeps_name.c_str())) read_seeps_climo_grid(seeps_name); } //////////////////////////////////////////////////////////////////////// @@ -662,25 +704,25 @@ SeepsClimoGrid::~SeepsClimoGrid() { //////////////////////////////////////////////////////////////////////// void SeepsClimoGrid::init_from_scratch() { - p1_buf = p2_buf = t1_buf = t2_buf = nullptr; - s12_buf = s13_buf = s21_buf = s23_buf = s31_buf = s32_buf = nullptr; clear(); } //////////////////////////////////////////////////////////////////////// void SeepsClimoGrid::clear() { + SeepsClimoBase::clear(); - if (nullptr != p1_buf) { delete [] p1_buf; p1_buf = nullptr; } - if (nullptr != p2_buf) { delete [] p2_buf; p2_buf = nullptr; } - if (nullptr != t1_buf) { delete [] t1_buf; t1_buf = nullptr; } - if (nullptr != t2_buf) { delete [] t2_buf; t2_buf = nullptr; } - if (nullptr != s12_buf) { delete [] s12_buf; s12_buf = nullptr; } - if (nullptr != s13_buf) { delete [] s13_buf; s13_buf = nullptr; } - if (nullptr != s21_buf) { delete [] s21_buf; s21_buf = nullptr; } - if (nullptr != s23_buf) { delete [] s23_buf; s23_buf = nullptr; } - if (nullptr != s31_buf) { delete [] s31_buf; s31_buf = nullptr; } - if (nullptr != s32_buf) { delete [] s32_buf; s32_buf = nullptr; } + + p1_buf.clear(); + p2_buf.clear(); + t1_buf.clear(); + t2_buf.clear(); + s_odfl_buf.clear(); + s_odfh_buf.clear(); + s_olfd_buf.clear(); + s_olfh_buf.clear(); + s_ohfd_buf.clear(); + s_ohfl_buf.clear(); }; //////////////////////////////////////////////////////////////////////// @@ -689,6 +731,7 @@ SeepsScore *SeepsClimoGrid::get_record(int ix, int iy, double p_fcst, double p_obs) { SeepsScore *seeps_record = nullptr; const char *method_name = "SeepsClimoGrid::get_record() -> "; + if (!is_eq(p_fcst, -9999.0) && !is_eq(p_obs, -9999.0)) { int offset = iy * nx + ix; double p1 = p1_buf[offset]; @@ -697,7 +740,7 @@ SeepsScore *SeepsClimoGrid::get_record(int ix, int iy, // Determine location in contingency table int ic = (p_obs>t1_buf[offset])+(p_obs>t2_buf[offset]); int jc = (p_fcst>t1_buf[offset])+(p_fcst>t2_buf[offset]); - double score = get_score(offset, ic, jc); + double score = get_seeps_score(offset, ic, jc); seeps_record = new SeepsScore(); seeps_record->obs_cat = ic; @@ -711,7 +754,9 @@ SeepsScore *SeepsClimoGrid::get_record(int ix, int iy, } else if (~is_eq(p1, bad_data_double)) { increase_filtered_count(); - mlog << Debug(7) << method_name << " filtered by threshold p1=" << p1_buf[offset] <<"\n"; + mlog << Debug(7) << method_name + << " filtered by threshold p1=" + << p1_buf[offset] << "\n"; } } @@ -720,55 +765,46 @@ SeepsScore *SeepsClimoGrid::get_record(int ix, int iy, //////////////////////////////////////////////////////////////////////// -double SeepsClimoGrid::get_score(int offset, int obs_cat, int fcst_cat) { +double SeepsClimoGrid::get_seeps_score(int offset, int obs_cat, int fcst_cat) { double score = bad_data_double; + const char *method_name = "SeepsClimoGrid::get_seeps_score() -> "; - if (offset >= (nx * ny)) { - mlog << Error << "\nSeepsClimoGrid::get_score() --> offset (" << offset - << " is too big (" << (nx*ny) << ")\n"; + if (offset < 0 || offset >= (nx * ny)) { + mlog << Error << method_name + << "offset (" << offset << ") is too big (" + << (nx*ny) << ")\n"; return score; } + // Place climate score depending on obs and forecast categories if (obs_cat == 0) { - if (fcst_cat == 1) score = s12_buf[offset]; - else if (fcst_cat == 2) score = s13_buf[offset]; + if (fcst_cat == 1) score = s_odfl_buf[offset]; + else if (fcst_cat == 2) score = s_odfh_buf[offset]; else score = 0.; } else if (obs_cat == 1) { - if (fcst_cat == 0) score = s21_buf[offset]; - else if (fcst_cat == 2) score = s23_buf[offset]; + if (fcst_cat == 0) score = s_olfd_buf[offset]; + else if (fcst_cat == 2) score = s_olfh_buf[offset]; else score = 0.; } else { - if (fcst_cat == 0) score = s31_buf[offset]; - else if (fcst_cat == 1) score = s32_buf[offset]; + if (fcst_cat == 0) score = s_ohfd_buf[offset]; + else if (fcst_cat == 1) score = s_ohfl_buf[offset]; else score = 0.; } + mlog << Debug(9) << method_name + << "obs_cat = " << obs_cat + << ", fcst_cat = " << fcst_cat + << ", score = " << score << "\n"; return score; } //////////////////////////////////////////////////////////////////////// -double SeepsClimoGrid::get_score(int ix, int iy, double p_fcst, double p_obs) { - double score = bad_data_double; - - if (!is_eq(p_fcst, -9999.0) && !is_eq(p_obs, -9999.0)) { - int offset = iy * nx + ix; - // Determine location in contingency table - int ic = (p_obs>t1_buf[offset])+(p_obs>t2_buf[offset]); - int jc = (p_fcst>t1_buf[offset])+(p_fcst>t2_buf[offset]); - score = get_score(offset, ic, jc); - } - - return score; -} - -//////////////////////////////////////////////////////////////////////// - -void SeepsClimoGrid::read_seeps_scores(ConcatString filename) { +void SeepsClimoGrid::read_seeps_climo_grid(const ConcatString &filename) { clock_t clock_time = clock(); - const char *method_name = "SeepsClimoGrid::read_seeps_scores() -> "; + const char *method_name = "SeepsClimoGrid::read_seeps_climo_grid() -> "; try { NcFile *nc_file = open_ncfile(filename.c_str()); @@ -777,26 +813,33 @@ void SeepsClimoGrid::read_seeps_scores(ConcatString filename) { if (!has_dim(nc_file, dim_name_lat) || !has_dim(nc_file, dim_name_lon)) { mlog << Error << "\n" << method_name << "\"" << filename << "\" is not valid SEEPS climo file\n\n"; - //exit(1); + exit(1); } get_dim(nc_file, dim_name_lat, ny, true); get_dim(nc_file, dim_name_lon, nx, true); - mlog << Debug(6) << method_name << "dimensions lon = " << nx << " lat = " << ny + mlog << Debug(6) << method_name + << "dimensions lon = " << nx << " lat = " << ny << " month=" << month << "\n"; - if (standalone_debug_seeps) cout << "dimensions lon = " << nx << " lat = " << ny - << " month=" << month << "\n";; - - p1_buf = new double[nx*ny]; - p2_buf = new double[nx*ny]; - t1_buf = new double[nx*ny]; - t2_buf = new double[nx*ny]; - s12_buf = new double[nx*ny]; - s13_buf = new double[nx*ny]; - s21_buf = new double[nx*ny]; - s23_buf = new double[nx*ny]; - s31_buf = new double[nx*ny]; - s32_buf = new double[nx*ny]; + if (standalone_debug_seeps) { + cout << method_name + << "dimensions lon = " << nx << " lat = " << ny + << " month=" << month << "\n"; + } + + // Variables in climo file named as s_odfl, s_odfh etc. These then stored + // into new convention s_odfl, s_odfh etc. + + p1_buf.resize(nx*ny); + p2_buf.resize(nx*ny); + t1_buf.resize(nx*ny); + t2_buf.resize(nx*ny); + s_odfl_buf.resize(nx*ny); + s_odfh_buf.resize(nx*ny); + s_olfd_buf.resize(nx*ny); + s_olfh_buf.resize(nx*ny); + s_ohfd_buf.resize(nx*ny); + s_ohfl_buf.resize(nx*ny); LongArray curs; // = { month-1, 0, 0 }; LongArray dims; // = { 1, ny, nx }; @@ -804,12 +847,12 @@ void SeepsClimoGrid::read_seeps_scores(ConcatString filename) { NcVar var_p2_00 = get_nc_var(nc_file, var_name_p2_00); NcVar var_t1_00 = get_nc_var(nc_file, var_name_t1_00); NcVar var_t2_00 = get_nc_var(nc_file, var_name_t2_00); - NcVar var_s12_00 = get_nc_var(nc_file, var_name_s12_00); - NcVar var_s13_00 = get_nc_var(nc_file, var_name_s13_00); - NcVar var_s21_00 = get_nc_var(nc_file, var_name_s21_00); - NcVar var_s23_00 = get_nc_var(nc_file, var_name_s23_00); - NcVar var_s31_00 = get_nc_var(nc_file, var_name_s31_00); - NcVar var_s32_00 = get_nc_var(nc_file, var_name_s32_00); + NcVar var_odfl_00 = get_nc_var(nc_file, var_name_odfl_00); + NcVar var_odfh_00 = get_nc_var(nc_file, var_name_odfh_00); + NcVar var_olfd_00 = get_nc_var(nc_file, var_name_olfd_00); + NcVar var_olfh_00 = get_nc_var(nc_file, var_name_olfh_00); + NcVar var_ohfd_00 = get_nc_var(nc_file, var_name_ohfd_00); + NcVar var_ohfl_00 = get_nc_var(nc_file, var_name_ohfl_00); curs.add(month-1); curs.add(0); @@ -818,73 +861,86 @@ void SeepsClimoGrid::read_seeps_scores(ConcatString filename) { dims.add(ny); dims.add(nx); - if (IS_INVALID_NC(var_p1_00) || !get_nc_data(&var_p1_00, p1_buf, dims, curs)) { + mlog << Debug(9) << method_name + << "var_odfl_00 = " << &var_odfl_00 << "\n"; + + if (IS_INVALID_NC(var_p1_00) || !get_nc_data(&var_p1_00, p1_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name << "Did not get p1_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_p2_00) || !get_nc_data(&var_p2_00, p2_buf, dims, curs)) { + if (IS_INVALID_NC(var_p2_00) || !get_nc_data(&var_p2_00, p2_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name << "Did not get p2_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_t1_00) || !get_nc_data(&var_t1_00, t1_buf, dims, curs)) { + if (IS_INVALID_NC(var_t1_00) || !get_nc_data(&var_t1_00, t1_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name << "Did not get t1_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_t2_00) || !get_nc_data(&var_t2_00, t2_buf, dims, curs)) { + if (IS_INVALID_NC(var_t2_00) || !get_nc_data(&var_t2_00, t2_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name << "Did not get t2_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_s12_00) || !get_nc_data(&var_s12_00, s12_buf, dims, curs)) { + if (IS_INVALID_NC(var_odfl_00) || !get_nc_data(&var_odfl_00, s_odfl_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name - << "Did not get s12_00\n\n"; + << "Did not get odfl_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_s13_00) || !get_nc_data(&var_s12_00, s13_buf, dims, curs)) { + if (IS_INVALID_NC(var_odfh_00) || !get_nc_data(&var_odfh_00, s_odfh_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name - << "Did not get s13_00\n\n"; + << "Did not get odfh_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_s21_00) || !get_nc_data(&var_s21_00, s21_buf, dims, curs)) { + if (IS_INVALID_NC(var_olfd_00) || !get_nc_data(&var_olfd_00, s_olfd_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name - << "Did not get s21_00\n\n"; + << "Did not get olfd_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_s23_00) || !get_nc_data(&var_s23_00, s23_buf, dims, curs)) { + if (IS_INVALID_NC(var_olfh_00) || !get_nc_data(&var_olfh_00, s_olfh_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name - << "Did not get s23_00\n\n"; + << "Did not get olfh_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_s31_00) || !get_nc_data(&var_s31_00, s31_buf, dims, curs)) { + if (IS_INVALID_NC(var_ohfd_00) || !get_nc_data(&var_ohfd_00, s_ohfd_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name - << "Did not get s31_00\n\n"; + << "Did not get ohfd_00\n\n"; exit(1); } - if (IS_INVALID_NC(var_s32_00) || !get_nc_data(&var_s32_00, s32_buf, dims, curs)) { + if (IS_INVALID_NC(var_ohfl_00) || !get_nc_data(&var_ohfl_00, s_ohfl_buf.data(), dims, curs)) { mlog << Error << "\n" << method_name - << "Did not get s32_00\n\n"; + << "Did not get ohfl_00\n\n"; exit(1); } nc_file->close(); + for(int i = 0; i < ny+3; i++) { + mlog << Debug(9) << method_name + << "s_odfl_buf[" << i << "] = " << s_odfl_buf[i] << "\n"; + } + float duration = (float)(clock() - clock_time)/CLOCKS_PER_SEC; - mlog << Debug(6) << method_name << "took " << duration << " seconds\n"; - if (standalone_debug_seeps) cout << method_name << "took " << duration << " seconds\n"; + mlog << Debug(6) << method_name + << "took " << duration << " seconds\n"; + if (standalone_debug_seeps) { + cout << method_name + << "took " << duration << " seconds\n"; + } } catch(...) { set_seeps_ready(false); mlog << Error << "\n" << method_name << "encountered an error on reading " << filename << ".\n\n"; - exit(-1); + } // end catch block } + //////////////////////////////////////////////////////////////////////// void SeepsClimoGrid::print_all() { @@ -896,36 +952,25 @@ void SeepsClimoGrid::print_all() { cout << method_name << " p2_buf[" << offset << "] = " << p2_buf[offset] << "\n"; cout << method_name << " t1_buf[" << offset << "] = " << t1_buf[offset] << "\n"; cout << method_name << " t2_buf[" << offset << "] = " << t2_buf[offset] << "\n"; - cout << method_name << "s12_buf[" << offset << "] = " << s12_buf[offset] << "\n"; - cout << method_name << "s13_buf[" << offset << "] = " << s13_buf[offset] << "\n"; - cout << method_name << "s21_buf[" << offset << "] = " << s21_buf[offset] << "\n"; - cout << method_name << "s23_buf[" << offset << "] = " << s23_buf[offset] << "\n"; - cout << method_name << "s31_buf[" << offset << "] = " << s31_buf[offset] << "\n"; - cout << method_name << "s32_buf[" << offset << "] = " << s32_buf[offset] << "\n"; - - offset = 400; - cout << method_name << " p1_buf[" << offset << "] = " << p1_buf[offset] << "\n"; - cout << method_name << " p2_buf[" << offset << "] = " << p2_buf[offset] << "\n"; - cout << method_name << " t1_buf[" << offset << "] = " << t1_buf[offset] << "\n"; - cout << method_name << " t2_buf[" << offset << "] = " << t2_buf[offset] << "\n"; - cout << method_name << "s12_buf[" << offset << "] = " << s12_buf[offset] << "\n"; - cout << method_name << "s13_buf[" << offset << "] = " << s13_buf[offset] << "\n"; - cout << method_name << "s21_buf[" << offset << "] = " << s21_buf[offset] << "\n"; - cout << method_name << "s23_buf[" << offset << "] = " << s23_buf[offset] << "\n"; - cout << method_name << "s31_buf[" << offset << "] = " << s31_buf[offset] << "\n"; - cout << method_name << "s32_buf[" << offset << "] = " << s32_buf[offset] << "\n"; - + cout << method_name << "s_odfl_buf[" << offset << "] = " << s_odfl_buf[offset] << "\n"; + cout << method_name << "s_odfh_buf[" << offset << "] = " << s_odfh_buf[offset] << "\n"; + cout << method_name << "s_olfd_buf[" << offset << "] = " << s_olfd_buf[offset] << "\n"; + cout << method_name << "s_olfh_buf[" << offset << "] = " << s_olfh_buf[offset] << "\n"; + cout << method_name << "s_ohfd_buf[" << offset << "] = " << s_ohfd_buf[offset] << "\n"; + cout << method_name << "s_ohfl_buf[" << offset << "] = " << s_ohfl_buf[offset] << "\n"; + offset = (nx*ny) - 1; cout << method_name << " p1_buf[" << offset << "] = " << p1_buf[offset] << "\n"; cout << method_name << " p2_buf[" << offset << "] = " << p2_buf[offset] << "\n"; cout << method_name << " t1_buf[" << offset << "] = " << t1_buf[offset] << "\n"; cout << method_name << " t2_buf[" << offset << "] = " << t2_buf[offset] << "\n"; - cout << method_name << "s12_buf[" << offset << "] = " << s12_buf[offset] << "\n"; - cout << method_name << "s13_buf[" << offset << "] = " << s13_buf[offset] << "\n"; - cout << method_name << "s21_buf[" << offset << "] = " << s21_buf[offset] << "\n"; - cout << method_name << "s23_buf[" << offset << "] = " << s23_buf[offset] << "\n"; - cout << method_name << "s31_buf[" << offset << "] = " << s31_buf[offset] << "\n"; - cout << method_name << "s32_buf[" << offset << "] = " << s32_buf[offset] << "\n"; + cout << method_name << "s_odfl_buf[" << offset << "] = " << s_odfl_buf[offset] << "\n"; + cout << method_name << "s_odfh_buf[" << offset << "] = " << s_odfh_buf[offset] << "\n"; + cout << method_name << "s_olfd_buf[" << offset << "] = " << s_olfd_buf[offset] << "\n"; + cout << method_name << "s_olfh_buf[" << offset << "] = " << s_olfh_buf[offset] << "\n"; + cout << method_name << "s_ohfd_buf[" << offset << "] = " << s_ohfd_buf[offset] << "\n"; + cout << method_name << "s_ohfl_buf[" << offset << "] = " << s_ohfl_buf[offset] << "\n"; + } } diff --git a/src/libcode/vx_seeps/seeps.h b/src/libcode/vx_seeps/seeps.h index 808acefa3e..6f93ddffcb 100644 --- a/src/libcode/vx_seeps/seeps.h +++ b/src/libcode/vx_seeps/seeps.h @@ -39,19 +39,18 @@ constexpr char var_name_t1_12[] = "t1_12"; constexpr char var_name_t2_12[] = "t2_12"; constexpr char var_name_matrix_00[] = "matrix_00"; constexpr char var_name_matrix_12[] = "matrix_12"; -constexpr char var_name_s12_00[] = "s12_00"; -constexpr char var_name_s13_00[] = "s13_00"; -constexpr char var_name_s21_00[] = "s21_00"; -constexpr char var_name_s23_00[] = "s23_00"; -constexpr char var_name_s31_00[] = "s31_00"; -constexpr char var_name_s32_00[] = "s32_00"; -constexpr char var_name_s12_12[] = "s12_12"; -constexpr char var_name_s13_12[] = "s13_12"; -constexpr char var_name_s21_12[] = "s21_12"; -constexpr char var_name_s23_12[] = "s23_12"; -constexpr char var_name_s31_12[] = "s31_12"; -constexpr char var_name_s32_12[] = "s32_12"; - +constexpr char var_name_odfl_00[] = "odfl_00"; +constexpr char var_name_odfh_00[] = "odfh_00"; +constexpr char var_name_olfd_00[] = "olfd_00"; +constexpr char var_name_olfh_00[] = "olfh_00"; +constexpr char var_name_ohfd_00[] = "ohfd_00"; +constexpr char var_name_ohfl_00[] = "ohfl_00"; +constexpr char var_name_odfl_12[] = "odfl_12"; +constexpr char var_name_odfh_12[] = "odfh_12"; +constexpr char var_name_olfd_12[] = "olfd_12"; +constexpr char var_name_olfh_12[] = "olfh_12"; +constexpr char var_name_ohfd_12[] = "ohfd_12"; +constexpr char var_name_ohfl_12[] = "ohfl_12"; constexpr char def_seeps_point_filename[] = "MET_BASE/climo/seeps/PPT24_seepsweights.nc"; constexpr char def_seeps_grid_filename[] = @@ -65,8 +64,8 @@ const double density_radius_rad = density_radius * rad_per_deg; //////////////////////////////////////////////////////////////////////// struct SeepsScore { // For SEEPS_MPR - int obs_cat; // i = obs category 0,1,2 - int fcst_cat; // j = model category 0,1,2 + int obs_cat; // i = obs category 0,1,2 (dry, light, heavy) + int fcst_cat; // j = model category 0,1,2 (dry, light, heavy) int s_idx; // index for 3 by 3 matrix as 1 dimensional (fcst_cat*3)+obs_cat double p1; double p2; @@ -81,19 +80,19 @@ struct SeepsAggScore { // For SEEPS void clear(); SeepsAggScore & operator+=(const SeepsAggScore &); - int n_obs; - int c12; - int c13; - int c21; - int c23; - int c31; - int c32; - double s12; - double s13; - double s21; - double s23; - double s31; - double s32; + int n_obs; + int c_odfl; + int c_odfh; + int c_olfd; + int c_olfh; + int c_ohfd; + int c_ohfl; + double s_odfl; + double s_odfh; + double s_olfd; + double s_olfh; + double s_ohfd; + double s_ohfl; double pv1; // marginal probabilities of the observed values double pv2; double pv3; @@ -101,9 +100,11 @@ struct SeepsAggScore { // For SEEPS double pf2; double pf3; double mean_fcst; + double mean_fcst_wgt; double mean_obs; + double mean_obs_wgt; double score; - double weighted_score; + double score_wgt; }; //////////////////////////////////////////////////////////////////////// @@ -156,12 +157,12 @@ class SeepsClimoBase { virtual void clear(); virtual ConcatString get_env_climo_name() { return "not defined"; }; virtual char *get_def_climo_name() { return nullptr; }; - virtual void read_seeps_scores(ConcatString filename) {}; + virtual void read_seeps_climo_grid(const ConcatString &filename) {}; void set_seeps_ready(bool _seeps_ready) { seeps_ready = _seeps_ready; }; public: - SeepsClimoBase(ConcatString seeps_climo_name); + SeepsClimoBase(const ConcatString &seeps_climo_name); virtual ~SeepsClimoBase(); void set_p1_thresh(const SingleThresh &p1_thresh); int get_filtered_count() const; @@ -182,22 +183,25 @@ class SeepsClimo : public SeepsClimoBase { double *p1, double *p2, double *t1, double *t2, double *scores); void print_record(SeepsClimoRecord *record, bool with_header=false); - void read_records(ConcatString filename); + void read_records(const ConcatString &filename); protected: void clear() override; ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_POINT_CLIMO_NAME; }; char *get_def_climo_name() override { return (char *)def_seeps_point_filename; }; - void read_seeps_scores(ConcatString filename) override; + void read_seeps_climo_grid(const ConcatString &filename) override; public: - SeepsClimo(ConcatString seeps_climo_name); + SeepsClimo(const ConcatString &seeps_climo_name); ~SeepsClimo(); SeepsRecord *get_record(int sid, int month, int hour); - double get_score(int sid, double p_fcst, double p_obs, int month, int hour); - SeepsScore *get_seeps_score(int sid, double p_fcst, double p_obs, int month, int hour); + double get_seeps_category(int sid, double p_fcst, double p_obs, + int month, int hour); + SeepsScore *get_seeps_score(int sid, double p_fcst, double p_obs, + int month, int hour); + void print_all(); void print_record(SeepsRecord *record, bool with_header=false); @@ -205,8 +209,6 @@ class SeepsClimo : public SeepsClimoBase { // // - SeepsRecord get_seeps_record(int sid) const; - }; //////////////////////////////////////////////////////////////////////// @@ -219,16 +221,16 @@ class SeepsClimoGrid : public SeepsClimoBase { int hour; // not implemented int nx; int ny; - double *p1_buf; - double *p2_buf; - double *t1_buf; - double *t2_buf; - double *s12_buf; - double *s13_buf; - double *s21_buf; - double *s23_buf; - double *s31_buf; - double *s32_buf; + std::vector p1_buf; + std::vector p2_buf; + std::vector t1_buf; + std::vector t2_buf; + std::vector s_odfl_buf; + std::vector s_odfh_buf; + std::vector s_olfd_buf; + std::vector s_olfh_buf; + std::vector s_ohfd_buf; + std::vector s_ohfl_buf; void init_from_scratch(); @@ -236,16 +238,15 @@ class SeepsClimoGrid : public SeepsClimoBase { void clear() override; ConcatString get_env_climo_name() override { return MET_ENV_SEEPS_GRID_CLIMO_NAME; }; char *get_def_climo_name() override { return (char *)def_seeps_grid_filename; }; - void read_seeps_scores(ConcatString filename) override; + void read_seeps_climo_grid(const ConcatString &filename) override; public: - SeepsClimoGrid(int month, int hour, ConcatString seeps_climo_name); + SeepsClimoGrid(int month, int hour, const ConcatString &seeps_climo_name); ~SeepsClimoGrid(); SeepsScore *get_record(int ix, int iy, double p_fcst, double p_obs); - double get_score(int offset, int obs_cat, int fcst_cat); - double get_score(int ix, int iy, double p_fcst, double p_obs); + double get_seeps_score(int offset, int obs_cat, int fcst_cat); void print_all(); // @@ -261,8 +262,8 @@ inline int SeepsClimoBase::get_filtered_count() const { return filtered_count; } //////////////////////////////////////////////////////////////////////// -extern SeepsClimo *get_seeps_climo(ConcatString seeps_point_climo_name); -extern SeepsClimoGrid *get_seeps_climo_grid(int month, ConcatString seeps_grid_climo_name, int hour=0); +extern SeepsClimo *get_seeps_climo(const ConcatString &seeps_point_climo_name); +extern SeepsClimoGrid *get_seeps_climo_grid(int month, const ConcatString &seeps_grid_climo_name, int hour=0); extern void release_seeps_climo(); extern void release_seeps_climo_grid(); diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index f4ccb6354b..d971fe2cf7 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -4162,35 +4162,40 @@ void write_seeps_cols(const SeepsAggScore *seeps, // // Stable Equitable Error in Probability Space (SEEPS) // Dump out the SEEPS line: - // TOTAL S12, S13, - // S21, S23, S31, - // S32, PF1, PF2, - // PF3, PV1, PV2, - // PV3, MEAN_FCST, MEAN_OBS, - // SEEPS + // TOTAL, + // ODFL, ODFH, OLFD, + // OLFH, OHFD, OHFL, + // PF1, PF2, PF3, + // PV1, PV2, PV3, + // MEAN_FCST, MEAN_OBS, SEEPS // at.set_entry(r, c+0, seeps->n_obs); // Total Number of Pairs - at.set_entry(r, c+1, seeps->s12); // s12 - at.set_entry(r, c+2, seeps->s13); // s13 - at.set_entry(r, c+3, seeps->s21); // s21 - at.set_entry(r, c+4, seeps->s23); // s23 - at.set_entry(r, c+5, seeps->s31); // s31 - at.set_entry(r, c+6, seeps->s32); // s32 - - at.set_entry(r, c+7, seeps->pf1); // pf1 - at.set_entry(r, c+8, seeps->pf2); // pf2 - at.set_entry(r, c+9, seeps->pf3); // pf3 - - at.set_entry(r, c+10, seeps->pv1); // pv1 - at.set_entry(r, c+11, seeps->pv2); // pv2 - at.set_entry(r, c+12, seeps->pv3); // pv3 - - at.set_entry(r, c+13, seeps->mean_fcst); // mean_fcst - at.set_entry(r, c+14, seeps->mean_obs); // mean_obs - - at.set_entry(r, c+15, (use_weighted_seeps ? seeps->weighted_score : seeps->score)); // SEEPS score/weighted score + at.set_entry(r, c+1, seeps->s_odfl); // ODFL + at.set_entry(r, c+2, seeps->s_odfh); // ODFH + at.set_entry(r, c+3, seeps->s_olfd); // OLFD + at.set_entry(r, c+4, seeps->s_olfh); // OLFH + at.set_entry(r, c+5, seeps->s_ohfd); // OHFD + at.set_entry(r, c+6, seeps->s_ohfl); // OHFL + + at.set_entry(r, c+7, seeps->pf1); // PF1 + at.set_entry(r, c+8, seeps->pf2); // PF2 + at.set_entry(r, c+9, seeps->pf3); // PF3 + + at.set_entry(r, c+10, seeps->pv1); // PV1 + at.set_entry(r, c+11, seeps->pv2); // PV2 + at.set_entry(r, c+12, seeps->pv3); // PV3 + + at.set_entry(r, c+13, (use_weighted_seeps ? + seeps->mean_fcst_wgt : + seeps->mean_fcst)); // MEAN_FCST + at.set_entry(r, c+14, (use_weighted_seeps ? + seeps->mean_obs_wgt : + seeps->mean_obs)); // MEAN_OBS + at.set_entry(r, c+15, (use_weighted_seeps ? + seeps->score_wgt: + seeps->score)); // SEEPS return; } @@ -4219,18 +4224,18 @@ void write_seeps_mpr_cols(const PairDataPoint *pd_ptr, int i, at.set_entry(r, c+4, pd_ptr->o_na[i]); // Observation Value - at.set_entry(r, c+5, (string)pd_ptr->o_qc_sa[i]); // Observation Quality Control + at.set_entry(r, c+5, (string)pd_ptr->o_qc_sa[i]); // Observation Quality Control - at.set_entry(r, c+6, pd_ptr->seeps_mpr[i]->fcst_cat); // model category - at.set_entry(r, c+7, pd_ptr->seeps_mpr[i]->obs_cat); // observation category + at.set_entry(r, c+6, pd_ptr->seeps_mpr[i]->fcst_cat); // FCST_CAT + at.set_entry(r, c+7, pd_ptr->seeps_mpr[i]->obs_cat); // OBS_CAT - at.set_entry(r, c+8, pd_ptr->seeps_mpr[i]->p1); // p1 - at.set_entry(r, c+9, pd_ptr->seeps_mpr[i]->p2); // p2 + at.set_entry(r, c+8, pd_ptr->seeps_mpr[i]->p1); // P1 + at.set_entry(r, c+9, pd_ptr->seeps_mpr[i]->p2); // P2 - at.set_entry(r, c+10, pd_ptr->seeps_mpr[i]->t1); // t1 - at.set_entry(r, c+11, pd_ptr->seeps_mpr[i]->t2); // t2 + at.set_entry(r, c+10, pd_ptr->seeps_mpr[i]->t1); // T1 + at.set_entry(r, c+11, pd_ptr->seeps_mpr[i]->t2); // T2 - at.set_entry(r, c+12, pd_ptr->seeps_mpr[i]->score); // SEEPS score + at.set_entry(r, c+12, pd_ptr->seeps_mpr[i]->score); // SEEPS } diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index 4dc90e4aeb..094587b732 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -1427,13 +1427,21 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps_agg) } SeepsScore *seeps_mpr = nullptr; - int count, count_diagonal; - int c12, c13, c21, c23, c31, c32; - double score_sum, obs_sum, fcst_sum; + int count = 0; + int count_diagonal = 0; + int c_odfl = 0; + int c_odfh = 0; + int c_olfd = 0; + int c_olfh = 0; + int c_ohfd = 0; + int c_ohfl = 0; + double score_sum = 0.0; + double obs_sum_wgt = 0.0; + double fcst_sum_wgt = 0.0; + double obs_sum = 0.0; + double fcst_sum = 0.0; vector seeps_mprs; - score_sum = obs_sum = fcst_sum = 0.0; - count = count_diagonal = c12 = c13 = c21 = c23 = c31 = c32 = 0; for(int i=0; in_obs; i++) { if (i >= pd->seeps_mpr.size()) break; seeps_mpr = pd->seeps_mpr[i]; @@ -1444,49 +1452,64 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps_agg) fcst_sum += pd->f_na[i]; // Forecast Value score_sum += seeps_mpr->score; if (seeps_mpr->fcst_cat == 0) { - if (seeps_mpr->obs_cat == 1) c12++; - else if(seeps_mpr->obs_cat == 2) c13++; + if (seeps_mpr->obs_cat == 1) c_olfd++; + else if(seeps_mpr->obs_cat == 2) c_ohfd++; else count_diagonal++; } else if (seeps_mpr->fcst_cat == 1) { - if (seeps_mpr->obs_cat == 0) c21++; - else if(seeps_mpr->obs_cat == 2) c23++; + if (seeps_mpr->obs_cat == 0) c_odfl++; + else if(seeps_mpr->obs_cat == 2) c_ohfl++; else count_diagonal++; } else if (seeps_mpr->fcst_cat == 2) { - if (seeps_mpr->obs_cat == 0) c31++; - else if (seeps_mpr->obs_cat == 1) c32++; + if (seeps_mpr->obs_cat == 0) c_odfh++; + else if (seeps_mpr->obs_cat == 1) c_olfh++; else count_diagonal++; } seeps_mprs.push_back(seeps_mpr); } if (count > 0) { - vector density_vector; - double pvf[SEEPS_MATRIX_SIZE]; - double weighted_score, weight_sum, weight[count]; + mlog << Debug(9) << method_name + << "Categories c_odfl, c_odfh, c_olfd, c_olfh, c_ohfd, c_ohfl => " + << c_odfl << " " << c_odfh << " " << c_olfd << " " + << c_olfh << " " << c_ohfd << " " << c_ohfl << "\n"; + + // Unweighted means seeps_agg->n_obs = count; seeps_agg->mean_fcst = fcst_sum / count; seeps_agg->mean_obs = obs_sum / count; seeps_agg->score = score_sum / count; - weighted_score = 0.; - for (int i=0; i " + << seeps_agg->mean_fcst << " " + << seeps_agg->mean_obs << " " + << seeps_agg->score << "\n"; + + double score_sum_wgt = 0.0; + vector pvf(SEEPS_MATRIX_SIZE, 0.0); + vector svf(SEEPS_MATRIX_SIZE, 0.0); + vector density_vector; compute_seeps_density_vector(pd, seeps_agg, density_vector); int density_cnt = density_vector.size(); if(density_cnt > count) density_cnt = count; //IDL: w = 1/d - weight_sum = 0.; - for (int i=0; i weight(count, 0.0); for (int i=0; i " + << i << " " << density_vector[i] << " " + << weight[i] << " " << weight_sum << "\n"; } } - if (!is_eq(weight_sum, 0)) { + if (!is_eq(weight_sum, 0.0)) { //IDL: w = w/sum(w) for (int i=0; iscore * weight[i]; + mlog << Debug(9) << method_name + << "i, seeps_mpr, weight(i), s_idx => " + << i << " " << seeps_mpr->score + << " " << weight[i] << " " << seeps_mpr->s_idx << "\n"; + score_sum_wgt += seeps_mpr->score * weight[i]; + obs_sum_wgt += pd->o_na[i] * weight[i]; + fcst_sum_wgt += pd->f_na[i] * weight[i]; + mlog << Debug(9) << method_name + << "score_sum_wgt (seeps_mpr*weight) => " + << score_sum_wgt << "\n"; //IDL: svf(cat{i)) = svf(cat{i)) + c(4+cat(i) * w{i) //IDL: pvf(cat{i)) = pvf(cat{i)) + w{i) pvf[seeps_mpr->s_idx] += weight[i]; + svf[seeps_mpr->s_idx] += seeps_mpr->score * weight[i]; } else { mlog << Debug(1) << method_name @@ -1510,45 +1543,49 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps_agg) } density_vector.clear(); - seeps_mprs.clear(); - // The weight for s12 to s32 should come from climo file, but not available yet + // The weight for odfl to ohfl come from climo file seeps_agg->pv1 = pvf[0] + pvf[3] + pvf[6]; // sum by column for obs seeps_agg->pv2 = pvf[1] + pvf[4] + pvf[7]; // sum by column for obs seeps_agg->pv3 = pvf[2] + pvf[5] + pvf[8]; // sum by column for obs seeps_agg->pf1 = pvf[0] + pvf[1] + pvf[2]; // sum by row for forecast seeps_agg->pf2 = pvf[3] + pvf[4] + pvf[5]; // sum by row for forecast seeps_agg->pf3 = pvf[6] + pvf[7] + pvf[8]; // sum by row for forecast - seeps_agg->s12 = c12 * seeps_agg->pf1 * seeps_agg->pv2; - seeps_agg->s13 = c13 * seeps_agg->pf1 * seeps_agg->pv3; - seeps_agg->s21 = c21 * seeps_agg->pf2 * seeps_agg->pv1; - seeps_agg->s23 = c23 * seeps_agg->pf2 * seeps_agg->pv3; - seeps_agg->s31 = c31 * seeps_agg->pf3 * seeps_agg->pv1; - seeps_agg->s32 = c32 * seeps_agg->pf3 * seeps_agg->pv2; - seeps_agg->weighted_score = weighted_score; + seeps_agg->s_odfl = (is_eq(svf[3], 0.0) ? 0.0 : svf[3]); + seeps_agg->s_odfh = (is_eq(svf[6], 0.0) ? 0.0 : svf[6]); + seeps_agg->s_olfd = (is_eq(svf[1], 0.0) ? 0.0 : svf[1]); + seeps_agg->s_olfh = (is_eq(svf[7], 0.0) ? 0.0 : svf[7]); + seeps_agg->s_ohfd = (is_eq(svf[2], 0.0) ? 0.0 : svf[2]); + seeps_agg->s_ohfl = (is_eq(svf[5], 0.0) ? 0.0 : svf[5]); + seeps_agg->mean_fcst_wgt = fcst_sum_wgt; + seeps_agg->mean_obs_wgt = obs_sum_wgt; + seeps_agg->score_wgt = score_sum_wgt; mlog << Debug(7) << method_name - << "SEEPS score=" << seeps_agg->score << " weighted_score=" << weighted_score + << "SEEPS score=" << seeps_agg->score << " score_wgt=" << seeps_agg->score_wgt << " pv1=" << seeps_agg->pv1 << " pv2=" << seeps_agg->pv2 << " pv3=" << seeps_agg->pv3 - << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 << "\n"; + << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 + << "\n"; } else { mlog << Debug(5) << method_name << "no SEEPS_MPR available\n"; } - seeps_agg->c12 = c12; - seeps_agg->c13 = c13; - seeps_agg->c21 = c21; - seeps_agg->c23 = c23; - seeps_agg->c31 = c31; - seeps_agg->c32 = c32; - - if (count != (c12+c13+c21+c23+c31+c32+count_diagonal)){ + + seeps_agg->c_odfl = c_odfl; + seeps_agg->c_odfh = c_odfh; + seeps_agg->c_olfd = c_olfd; + seeps_agg->c_olfh = c_olfh; + seeps_agg->c_ohfd = c_ohfd; + seeps_agg->c_ohfl = c_ohfl; + + if (count != (c_odfl+c_odfh+c_olfd+c_olfh+c_ohfd+c_ohfl+count_diagonal)){ mlog << Debug(6) << method_name - << "INFO check count: all=" << count << " s12=" << c12<< " s13=" << c13 - << " s21=" << c21 << " s23=" << c23 - << " s31=" << c31 << " s32=" << c32 << "\n"; + << "INFO check count: all=" << count + << " s_odfl=" << c_odfl << " s_odfh=" << c_odfh + << " s_olfd=" << c_olfd << " s_olfh=" << c_olfh + << " s_ohfd=" << c_ohfd << " s_ohfl=" << c_ohfl << "\n"; } return; @@ -1561,31 +1598,44 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob DataPlane &seeps_dp_ocat, SeepsAggScore *seeps_agg, int month, int hour, const SingleThresh &seeps_p1_thresh, const ConcatString &seeps_climo_name) { - int fcst_cat, obs_cat; - int seeps_count, count_diagonal, nan_count, bad_count; int nx = fcst_dp.nx(); int ny = fcst_dp.ny(); int dp_size = (nx * ny); - int pvf_cnt[SEEPS_MATRIX_SIZE]; - double pvf[SEEPS_MATRIX_SIZE]; - int c12, c13, c21, c23, c31, c32; - double obs_sum, fcst_sum; - double seeps_score, seeps_score_sum, seeps_score_partial_sum; static const char *method_name = "compute_aggregated_seeps_grid() -> "; + int fcst_cat = bad_data_int; + int obs_cat = bad_data_int; + int seeps_count = 0; + int count_diagonal = 0; + int nan_count = 0; + int bad_count = 0; + int c_odfl = 0; + int c_odfh = 0; + int c_olfd = 0; + int c_olfh = 0; + int c_ohfd = 0; + int c_ohfl = 0; + double seeps_score = 0.0; + double seeps_score_sum = 0.0; + double seeps_score_partial_sum = 0.0; + double obs_sum = 0.0; + double fcst_sum = 0.0; + seeps_dp.set_size(nx, ny); seeps_dp_fcat.set_size(nx, ny); seeps_dp_ocat.set_size(nx, ny); - obs_sum = fcst_sum = seeps_score_sum = 0.; - seeps_count = count_diagonal = nan_count = bad_count = 0; - c12 = c13 = c21 = c23 = c31 = c32 = 0; + seeps_agg->clear(); + mlog << Debug(9) << method_name + << "month is " << month << "\n"; + SeepsClimoGrid *seeps_climo = get_seeps_climo_grid(month, seeps_climo_name); seeps_climo->set_p1_thresh(seeps_p1_thresh); - for (int i=0; i pvf_cnt(SEEPS_MATRIX_SIZE, 0); + vector pvf(SEEPS_MATRIX_SIZE, 0.0); + vector svf(SEEPS_MATRIX_SIZE, 0.0); + for (int ix=0; ixget_record(ix, iy, fcst_value, obs_value); if (seeps_mpr != nullptr) { fcst_cat = seeps_mpr->fcst_cat; obs_cat = seeps_mpr->obs_cat; if (fcst_cat == 0) { - if (obs_cat == 1) c12++; - else if(obs_cat == 2) c13++; + if (obs_cat == 1) c_olfd++; + else if(obs_cat == 2) c_odfh++; else count_diagonal++; } else if (fcst_cat == 1) { - if (obs_cat == 0) c21++; - else if(obs_cat == 2) c23++; + if (obs_cat == 0) c_odfl++; + else if(obs_cat == 2) c_ohfd++; else count_diagonal++; } else if (fcst_cat == 2) { - if (obs_cat == 0) c31++; - else if (obs_cat == 1) c32++; + if (obs_cat == 0) c_odfh++; + else if (obs_cat == 1) c_olfh++; else count_diagonal++; } seeps_score = seeps_mpr->score; + mlog << Debug(9) << method_name + << "ix, iy, obs_cat, fcst_cat, seeps_score:" + << ix << " " << iy << " " << obs_cat << " " << fcst_cat + << " " << seeps_score << "\n"; + if (std::isnan(seeps_score)) { nan_count++; seeps_score = bad_data_double; @@ -1629,6 +1689,10 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob //IDL: pvf(cat{i)) = pvf(cat{i)) + w{i) //pvf[seeps_mpr->s_idx] += weight; pvf_cnt[seeps_mpr->s_idx] += 1; + mlog << Debug(9) << method_name + << "obs_sum, fcst_sum, seeps_score_partial_sum, category: " + << obs_sum << " " << fcst_sum << " " + << seeps_score_partial_sum << " " << seeps_mpr->s_idx << "\n"; } if(seeps_mpr) { delete seeps_mpr; seeps_mpr = nullptr; } @@ -1640,43 +1704,52 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob } seeps_score_sum += seeps_score_partial_sum; } + mlog << Debug(9) << method_name + << "dp_size, nan_count, bad_count: " + << dp_size << " " << nan_count << " " << bad_count << "\n"; int cell_count = dp_size - nan_count - bad_count; if (cell_count > 0) { - seeps_agg->weighted_score = seeps_score_sum/cell_count; + seeps_agg->score_wgt = seeps_score_sum/cell_count; for (int i=0; in_obs = seeps_count; - seeps_agg->c12 = c12; - seeps_agg->c13 = c13; - seeps_agg->c21 = c21; - seeps_agg->c23 = c23; - seeps_agg->c31 = c31; - seeps_agg->c32 = c32; - if (seeps_count > 0) { - seeps_agg->mean_fcst = fcst_sum / seeps_count; - seeps_agg->mean_obs = obs_sum / seeps_count; + seeps_agg->c_odfl = c_odfl; + seeps_agg->c_odfh = c_odfh; + seeps_agg->c_olfd = c_olfd; + seeps_agg->c_olfh = c_olfh; + seeps_agg->c_ohfd = c_ohfd; + seeps_agg->c_ohfl = c_ohfl; + if (seeps_count > 0) { seeps_agg->pv1 = pvf[0] + pvf[3] + pvf[6]; // sum by column for obs seeps_agg->pv2 = pvf[1] + pvf[4] + pvf[7]; // sum by column for obs seeps_agg->pv3 = pvf[2] + pvf[5] + pvf[8]; // sum by column for obs seeps_agg->pf1 = pvf[0] + pvf[1] + pvf[2]; // sum by row for forecast seeps_agg->pf2 = pvf[3] + pvf[4] + pvf[5]; // sum by row for forecast seeps_agg->pf3 = pvf[6] + pvf[7] + pvf[8]; // sum by row for forecast - seeps_agg->s12 = c12 * seeps_agg->pf1 * seeps_agg->pv2; - seeps_agg->s13 = c13 * seeps_agg->pf1 * seeps_agg->pv3; - seeps_agg->s21 = c21 * seeps_agg->pf2 * seeps_agg->pv1; - seeps_agg->s23 = c23 * seeps_agg->pf2 * seeps_agg->pv3; - seeps_agg->s31 = c31 * seeps_agg->pf3 * seeps_agg->pv1; - seeps_agg->s32 = c32 * seeps_agg->pf3 * seeps_agg->pv2; - seeps_agg->score = seeps_score_sum / seeps_count; + + seeps_agg->s_odfl = (is_eq(svf[3], 0.0) ? 0.0 : svf[3]); + seeps_agg->s_odfh = (is_eq(svf[6], 0.0) ? 0.0 : svf[6]); + seeps_agg->s_olfd = (is_eq(svf[1], 0.0) ? 0.0 : svf[1]); + seeps_agg->s_olfh = (is_eq(svf[7], 0.0) ? 0.0 : svf[7]); + seeps_agg->s_ohfd = (is_eq(svf[2], 0.0) ? 0.0 : svf[2]); + seeps_agg->s_ohfl = (is_eq(svf[5], 0.0) ? 0.0 : svf[5]); + + seeps_agg->mean_fcst = fcst_sum / seeps_count; + seeps_agg->mean_obs = obs_sum / seeps_count; + seeps_agg->score = seeps_score_sum / seeps_count; } + mlog << Debug(6) << method_name - << "SEEPS score=" << seeps_agg->score << " weighted_score=" << seeps_agg->weighted_score + << "SEEPS score=" << seeps_agg->score + << " score_wgt=" << seeps_agg->score_wgt << " pv1=" << seeps_agg->pv1 << " pv2=" << seeps_agg->pv2 << " pv3=" << seeps_agg->pv3 - << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 << "\n"; + << " pf1=" << seeps_agg->pf1 << " pf2=" << seeps_agg->pf2 << " pf3=" << seeps_agg->pf3 + << "\n"; + if(mlog.verbosity_level() >= detailed_debug_level) { char buffer[100]; ConcatString log_message; @@ -1688,8 +1761,9 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob snprintf ( buffer, 100, " nan: %d ", nan_count); log_message.add(buffer); } - mlog << Debug(7) << method_name << "pvf = " << log_message - << " weight=" << (1. / cell_count) << " (1/" << cell_count << ")" << "\n"; + mlog << Debug(7) << method_name + << "pvf = " << log_message << " weight=" << (1. / cell_count) + << " (1/" << cell_count << ")" << "\n"; } } @@ -1725,7 +1799,8 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob // ; PV-WAVE prints: 2.00000 4.00000 //////////////////////////////////////////////////////////////////////// -void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, vector &density_vector) { +void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, + vector &density_vector) { int seeps_idx; SeepsScore *seeps_mpr; int seeps_cnt = seeps->n_obs; @@ -1751,7 +1826,14 @@ void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, for(int i=0; in_obs; i++) { if (i >= pd->seeps_mpr.size()) break; seeps_mpr = pd->seeps_mpr[i]; + mlog << Debug(9) << method_name + << "seeps_idx, seeps_mpr => " + << seeps_idx << " " << seeps_mpr << "\n"; + if (!seeps_mpr || is_eq(seeps_mpr->score, bad_data_double)) continue; + mlog << Debug(4) << method_name + << "lat, long => " << pd->lat_na[i] << " " + << fmod((pd->lon_na[i] + 360.), 360.) << "\n"; rlat[seeps_idx] = pd->lat_na[i] * rad_per_deg; // radian of lat rlon[seeps_idx] = fmod((pd->lon_na[i] + 360.), 360.) * rad_per_deg; // radian of long @@ -1759,15 +1841,22 @@ void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, clon[seeps_idx] = cos(rlon[seeps_idx]); slat[seeps_idx] = sin(rlat[seeps_idx]); slon[seeps_idx] = sin(rlon[seeps_idx]); + mlog << Debug(9) << method_name + << "clat, clon, slat, slon => " + << clat[seeps_idx] << " " << clon[seeps_idx] + << " " << slat[seeps_idx] << " " << slon[seeps_idx] << "\n"; seeps_idx++; } - // prooducs n by n matrix by multipling transposed vector - int v_count; - double density, mask1, mask2, mask3, temp; + // produces n by n matrix by multiplying transposed vector + // Initialize - v_count = 0; + int v_count = 0; + mlog << Debug(9) << method_name + << "seeps_idx, seeps_cnt => " + << seeps_idx << " " << seeps_cnt << "\n"; + if (seeps_idx < seeps_cnt) seeps_cnt = seeps_idx; density_vector.reserve(seeps_cnt); for(int j=0; j " + << j << " " << i << " " << clat_m[i][j] << " " << slat_m[i][j] << " " + << clon_m[i][j] << " " << slon_m[i][j] << "\n"; + //IDL: r=(clat#transpose(clat))*(slon#transpose(slon)) + (clon#transpose(clon))*(slat#transpose(slat)) - density = clat_m[i][j] * slon_m[i][j] + clon_m[i][j] * slat_m[i][j]; + double density = clat_m[i][j] * slon_m[i][j] + clon_m[i][j] * slat_m[i][j]; + double density2 = (clat_m[i][j] * (slon_m[i][j] + clon_m[i][j])) + slat_m[i][j]; + mlog << Debug(9) << method_name + << "density, density2 => " << density << " " << density2 << "\n"; + //IDL: r * ((r lt 1.) and (r gt -1.)) + (r ge 1.) - (r le -1.) - mask1 = (density < 1.0 && density > -1.0) ? 1. : 0.; - mask2 = (density >= 1.0 ) ? 1. : 0.; - mask3 = (density <= -1.0) ? 1. : 0.; + double mask1 = (density < 1.0 && density > -1.0) ? 1. : 0.; + double mask2 = (density >= 1.0 ) ? 1. : 0.; + double mask3 = (density <= -1.0) ? 1. : 0.; + double mask5 = (density2 < 1.0 && density > -1.0) ? 1. : 0.; + double mask6 = (density2 >= 1.0 ) ? 1. : 0.; + double mask7 = (density2 <= -1.0) ? 1. : 0.; density = density * mask1 + mask2 - mask3; + density2 = density2 * mask5 + mask6 - mask7; + mlog << Debug(9) << method_name + << "density, density2 => " << density << " " << density2 << "\n"; + //IDL: r = acos(r) density = acos(density); //IDL: if r0 gt 0.0 then r = exp(-(r/r0)^2) * (r le 4. * r0) else r = (r*0.)+1. - if (density_radius_rad <= 0.) density = 1.0; - else { - mask3 = (density <= 4.0) ? 1. : 0.; - temp = density / density_radius_rad; - density = exp(-(temp * temp)) * mask3 * density_radius_rad; + if (density_radius_rad > 0.) { + if (density < 4.0 * density_radius_rad) { + mask3 = (density <= 4.0) ? 1. : 0.; + double temp = density / density_radius_rad; + density = exp(-(temp * temp)) * mask3 * density_radius_rad; + } + else { + density = 0.; + } + if (density2 < 4.0 * density_radius_rad) { + density2 = exp(-(pow(density2 / density_radius_rad,2))); + } + else { + density2 = 0.; + } + mlog << Debug(4) << method_name + << "final density, density2 => " + << density << " " << density2 << "\n"; + } else { + density = 1.; } - density_vector[j] += density; + mlog << Debug(4) << method_name + << "For Info - Feeding density2 (not density) back as vector " + << "as density all zeros in final output" << "\n"; + density_vector[j] += density2; } if (!is_eq(density_vector[j], 0.)) v_count++; } @@ -1803,8 +1926,8 @@ void compute_seeps_density_vector(const PairDataPoint *pd, SeepsAggScore *seeps, << "no non-zero values at density_vector\n"; } if (seeps_cnt > 0) { - mlog << Debug(10) << method_name - << " non zero count=" << v_count + mlog << Debug(9) << method_name + << " non zero count=" << v_count << " seeps_cnt=" << seeps_cnt << " density_vector[0]=" << density_vector[0] << " density_vector[" << (seeps_cnt-1) << "]=" << density_vector[seeps_cnt-1] << "\n"; } diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 0e7f6203e7..a22194a297 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -223,8 +223,10 @@ void PairDataPoint::set_seeps_score(SeepsScore *seeps, int index) { } } } - else mlog << Warning << "\nPairDataPoint::set_seeps_score(" - << index << ") is out of range " << seeps_count << "\n\n"; + else { + mlog << Warning << "\nPairDataPoint::set_seeps_score(" + << index << ") is out of range " << seeps_count << "\n\n"; + } } } @@ -317,14 +319,17 @@ SeepsScore *PairDataPoint::compute_seeps(const char *sid, double f, int month, day, year, hour, minute, second; int sid_no = atoi(sid); - if (sid_no && nullptr != seeps_climo) { + if (sid_no && seeps_climo) { unix_to_mdyhms(ut, month, day, year, hour, minute, second); seeps = seeps_climo->get_seeps_score(sid_no, f, o, month, hour); - if (mlog.verbosity_level() >= seeps_debug_level - && seeps && !is_eq(seeps->score, bad_data_double) - && !is_eq(seeps->score, 0) && seeps_record_count < 10) { + if (mlog.verbosity_level() >= seeps_debug_level && + seeps && + !is_bad_data(seeps->score) && + !is_eq(seeps->score, 0) && + seeps_record_count < 10) { mlog << Debug(seeps_debug_level) - << "PairDataPoint::compute_seeps() score = " << seeps->score << "\n"; + << "PairDataPoint::compute_seeps() score = " + << seeps->score << "\n"; seeps_record_count++; } } diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index 02283617fe..23cf791f55 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -600,12 +600,12 @@ void parse_seeps_line(STATLine &l, SeepsAggScore &agg_score) { agg_score.n_obs = atoi(l.get_item("TOTAL")); - agg_score.s12 = atoi(l.get_item("S12")); - agg_score.s13 = atoi(l.get_item("S13")); - agg_score.s21 = atof(l.get_item("S21")); - agg_score.s23 = atof(l.get_item("S23")); - agg_score.s31 = atof(l.get_item("S31")); - agg_score.s32 = atof(l.get_item("S32")); + agg_score.s_odfl = atoi(l.get_item("ODFL")); + agg_score.s_odfh = atoi(l.get_item("ODFH")); + agg_score.s_olfd = atof(l.get_item("OLFD")); + agg_score.s_olfh = atof(l.get_item("OLFH")); + agg_score.s_ohfd = atof(l.get_item("OHFD")); + agg_score.s_ohfl = atof(l.get_item("OHFL")); agg_score.pf1 = atof(l.get_item("PF1")); agg_score.pf2 = atof(l.get_item("PF2")); @@ -615,11 +615,12 @@ void parse_seeps_line(STATLine &l, SeepsAggScore &agg_score) { agg_score.pv2 = atof(l.get_item("PV2")); agg_score.pv3 = atof(l.get_item("PV3")); - agg_score.mean_fcst = atof(l.get_item("MEAN_FCST")); - agg_score.mean_obs = atof(l.get_item("MEAN_OBS")); - - agg_score.score = atof(l.get_item("SEEPS")); - agg_score.weighted_score = agg_score.score; + agg_score.mean_fcst = atof(l.get_item("MEAN_FCST")); + agg_score.mean_fcst_wgt = agg_score.mean_fcst; + agg_score.mean_obs = atof(l.get_item("MEAN_OBS")); + agg_score.mean_obs_wgt = agg_score.mean_fcst; + agg_score.score = atof(l.get_item("SEEPS")); + agg_score.score_wgt = agg_score.score; return; }